Added optional copying to sd_card

This commit is contained in:
Kevin Veen-Birkenbach 2020-04-30 09:29:57 +02:00
parent 7a4f700f0f
commit 30f1d3e021
2 changed files with 66 additions and 54 deletions

View File

@ -19,13 +19,14 @@ To install a Linux distribution manually on a SD card type in:
To pase the configuration to the program use this syntax: To pase the configuration to the program use this syntax:
```bash ```bash
( (
echo "$USER" #The username echo "$USER" # The username
echo "mmcblk1" #The device echo "mmcblk1" # The device
echo "3" #The raspberry pi number echo "3" # The raspberry pi number
echo "arch" #The operation system echo "arch" # The operation system
echo "user_password" #The user password echo "y" # Transfer image
echo "root_password" #The root password echo "user_password" # The user password
echo "y" #Copy wifi configurations to target system echo "root_password" # The root password
echo "y" # Copy wifi configurations to target system
)| sudo bash ./sd_setup.sh )| sudo bash ./sd_setup.sh
``` ```

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
# shellcheck disable=SC2010 # ls | grep allowed # shellcheck disable=SC2010 # ls | grep allowed
# shellcheck disable=SC2143 # Suppress wrong grep -q warning
echo "Setupscript for Raspberry Pi SD's" echo "Setupscript for Raspberry Pi SD's"
echo echo
@ -176,9 +177,12 @@ mount_partitions(){
echo "The following mounts refering this setup exist:" && mount | grep "$working_folder" echo "The following mounts refering this setup exist:" && mount | grep "$working_folder"
} }
echo "Copy data to $sd_card_path..." echo "Should the image be transfered to $sd_card_path?(y/n)"
read -r transfer_image
case "$os" in if [ "$transfer_image" = "y" ]
then
echo "Starting image transfer..."
case "$os" in
"arch") "arch")
echo "Execute fdisk..." echo "Execute fdisk..."
( echo "o" #Type o. This will clear out any partitions on the drive. ( echo "o" #Type o. This will clear out any partitions on the drive.
@ -217,19 +221,26 @@ case "$os" in
"moode") "moode")
unzip -p "$image_path" | sudo dd of="$sd_card_path" bs=1M conv=fsync || error "DD to $sd_card_path failed." unzip -p "$image_path" | sudo dd of="$sd_card_path" bs=1M conv=fsync || error "DD to $sd_card_path failed."
sync sync
mount_partitions;
;; ;;
"retropie") "retropie")
gunzip -c "$image_path" | sudo dd of="$sd_card_path" bs=1M conv=fsync gunzip -c "$image_path" | sudo dd of="$sd_card_path" bs=1M conv=fsync
sync sync
mount_partitions;
;; ;;
*) *)
error "Image transfer for operation system \"$os\" is not supported yet!"; error "Image transfer for operation system \"$os\" is not supported yet!";
;; ;;
esac esac
else
echo "Skipping image transfer..."
fi
echo "Start regular mounting procedure..."
if [ "$(mount | grep -q "$boot_mount_path")" ] && [ "$(mount | grep -q "$root_mount_path")" ]
then
echo "Everything allready mounted. Skipping..."
else
mount_partitions
fi
echo "Define target paths..." echo "Define target paths..."
target_home_path="$root_mount_path/home/"; target_home_path="$root_mount_path/home/";