From 0b16092ebf0e9fb5cd1c6ddf4b2c99d53f286cee Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Thu, 30 Apr 2020 17:31:30 +0200 Subject: [PATCH] Added hostname --- README.md | 12 ++++++------ sd_setup.sh | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1368a15..7576bff 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,9 @@ This repository contains some shell scripts to install Arch Linux for the Raspbe ## Todo - Implement hostname setting -- Implement password change - Implement ssh configuration - Implement wifi automation - +- Hostname ## Setup ### SD-Card #### Guided @@ -21,13 +20,14 @@ To pase the configuration to the program use this syntax: ( echo "$USER" # | The username echo "mmcblk1" # | The device - echo "4" # | The raspberry pi number - echo "retropie" # | The operation system + echo "3" # | The raspberry pi number + echo "arch" # | The operation system echo "n" # | Force image download echo "n" # | Transfer image #echo "n" # ├── Overwrite device before copying - echo "test12345" # | The user password - echo "test12345" # | The root password + echo "test12345" # | The user password + echo "test12345" # | The root password + echo "example-host" # | The hostname echo "y" # | Copy wifi configurations to target system )| sudo bash ./sd_setup.sh ``` diff --git a/sd_setup.sh b/sd_setup.sh index 2d83bf8..aadd3fb 100644 --- a/sd_setup.sh +++ b/sd_setup.sh @@ -37,7 +37,7 @@ success(){ destructor(){ 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_mount_path" || warning "Umounting $chroot_dev_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 /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." info "Changing passwords on target system..." @@ -355,13 +355,16 @@ if [ "$password_1" == "$password_2" ] error "Passwords didn't match." fi -question "Do you want to copy all Wifi passwords to the device?(y/n)" && read -r copy_wifi -if [ "$copy_wifi" = "y" ] - then - 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 +question "Type in the hostname:" && read -r hostname; +echo "$hostname" > "$root_mount_path""etc/hostname" | error "Changing hostname failed." + +# question "Do you want to copy all Wifi passwords to the device?(y/n)" && read -r copy_wifi +# if [ "$copy_wifi" = "y" ] +# then +# 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 $boot_mount_path is:" && tree -laL 1 "$boot_mount_path"