Added hostname

This commit is contained in:
Kevin Veen-Birkenbach 2020-04-30 17:31:30 +02:00
parent 2faf488d58
commit 0b16092ebf
2 changed files with 18 additions and 15 deletions

View File

@ -3,10 +3,9 @@ This repository contains some shell scripts to install Arch Linux for the Raspbe
## Todo ## Todo
- Implement hostname setting - Implement hostname setting
- Implement password change
- Implement ssh configuration - Implement ssh configuration
- Implement wifi automation - Implement wifi automation
- Hostname
## Setup ## Setup
### SD-Card ### SD-Card
#### Guided #### Guided
@ -21,13 +20,14 @@ To pase the configuration to the program use this syntax:
( (
echo "$USER" # | The username echo "$USER" # | The username
echo "mmcblk1" # | The device echo "mmcblk1" # | The device
echo "4" # | The raspberry pi number echo "3" # | The raspberry pi number
echo "retropie" # | The operation system echo "arch" # | The operation system
echo "n" # | Force image download echo "n" # | Force image download
echo "n" # | Transfer image echo "n" # | Transfer image
#echo "n" # ├── Overwrite device before copying #echo "n" # ├── Overwrite device before copying
echo "test12345" # | The user password echo "test12345" # | The user password
echo "test12345" # | The root password echo "test12345" # | The root password
echo "example-host" # | The hostname
echo "y" # | Copy wifi configurations to target system echo "y" # | Copy wifi configurations to target system
)| sudo bash ./sd_setup.sh )| sudo bash ./sd_setup.sh
``` ```

View File

@ -37,7 +37,7 @@ success(){
destructor(){ destructor(){
info "Cleaning up..." info "Cleaning up..."
sed -i 's/^#CHROOT //g' "$root_mount_path/etc/ld.so.preload" sed -i 's/^#CHROOT //g' "$root_mount_path""etc/ld.so.preload"
umount -v "$chroot_dev_pts_mount_path" || warning "Umounting $chroot_dev_pts_mount_path failed!" umount -v "$chroot_dev_pts_mount_path" || warning "Umounting $chroot_dev_pts_mount_path failed!"
umount -v "$chroot_dev_mount_path" || warning "Umounting $chroot_dev_mount_path failed!" umount -v "$chroot_dev_mount_path" || warning "Umounting $chroot_dev_mount_path failed!"
umount -v "$chroot_proc_mount_path" || warning "Umounting $chroot_proc_mount_path failed!" umount -v "$chroot_proc_mount_path" || warning "Umounting $chroot_proc_mount_path failed!"
@ -333,7 +333,7 @@ mount --bind /sys "$chroot_sys_mount_path" || error "Mounting $chroot_sys_mount_
mount --bind /proc "$chroot_proc_mount_path" || error "Mounting $chroot_proc_mount_path failed." mount --bind /proc "$chroot_proc_mount_path" || error "Mounting $chroot_proc_mount_path failed."
mount --bind /dev/pts "$chroot_dev_pts_mount_path" || error "Mounting $chroot_dev_pts_mount_path failed." mount --bind /dev/pts "$chroot_dev_pts_mount_path" || error "Mounting $chroot_dev_pts_mount_path failed."
sed -i 's/^/#CHROOT /g' /mnt/raspbian/etc/ld.so.preload sed -i 's/^/#CHROOT /g' "$root_mount_path""etc/ld.so.preload"
cp -v /usr/bin/qemu-arm-static "$root_mount_path""/usr/bin/" || error "Copy qemu-arm-static failed. The following packages are neccessary: qemu qemu-user-static binfmt-support." cp -v /usr/bin/qemu-arm-static "$root_mount_path""/usr/bin/" || error "Copy qemu-arm-static failed. The following packages are neccessary: qemu qemu-user-static binfmt-support."
info "Changing passwords on target system..." info "Changing passwords on target system..."
@ -355,13 +355,16 @@ if [ "$password_1" == "$password_2" ]
error "Passwords didn't match." error "Passwords didn't match."
fi fi
question "Do you want to copy all Wifi passwords to the device?(y/n)" && read -r copy_wifi question "Type in the hostname:" && read -r hostname;
if [ "$copy_wifi" = "y" ] echo "$hostname" > "$root_mount_path""etc/hostname" | error "Changing hostname failed."
then
origin_wifi_config_path="/etc/NetworkManager/system-connections/" # question "Do you want to copy all Wifi passwords to the device?(y/n)" && read -r copy_wifi
target_wifi_config_path="$root_mount_path$origin_wifi_config_path" # if [ "$copy_wifi" = "y" ]
rsync -av "$origin_wifi_config_path" "$target_wifi_config_path" # then
fi # origin_wifi_config_path="/etc/NetworkManager/system-connections/"
# target_wifi_config_path="$root_mount_path$origin_wifi_config_path"
# rsync -av "$origin_wifi_config_path" "$target_wifi_config_path"
# fi
info "The first level folder structure on $root_mount_path is:" && tree -laL 1 "$root_mount_path" info "The first level folder structure on $root_mount_path is:" && tree -laL 1 "$root_mount_path"
info "The first level folder structure on $boot_mount_path is:" && tree -laL 1 "$boot_mount_path" info "The first level folder structure on $boot_mount_path is:" && tree -laL 1 "$boot_mount_path"