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

@ -23,6 +23,7 @@ To pase the configuration to the program use this syntax:
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

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,8 +177,11 @@ mount_partitions(){
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
if [ "$transfer_image" = "y" ]
then
echo "Starting image transfer..."
case "$os" in
"arch")
echo "Execute fdisk..."
@ -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
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/";