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:
```bash
(
echo "$USER" #The username
echo "mmcblk1" #The device
echo "3" #The raspberry pi number
echo "arch" #The operation system
echo "user_password" #The user password
echo "root_password" #The root password
echo "y" #Copy wifi configurations to target system
echo "$USER" # The username
echo "mmcblk1" # The device
echo "3" # The raspberry pi number
echo "arch" # The operation system
echo "y" # Transfer image
echo "user_password" # The user password
echo "root_password" # The root password
echo "y" # Copy wifi configurations to target system
)| sudo bash ./sd_setup.sh
```

View File

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