Adapted variables

This commit is contained in:
Kevin Veen-Birkenbach 2020-04-29 16:56:31 +02:00
parent 54a3d292a6
commit e365b75fc2

View File

@ -24,6 +24,8 @@ fi
echo "Please type in a valid username from which the SSH-Key should be copied:" echo "Please type in a valid username from which the SSH-Key should be copied:"
read -r username; read -r username;
image_folder="/home/$username/Images/"; image_folder="/home/$username/Images/";
ssh_key_source="/home/$username/.ssh/id_rsa.pub"
echo "The images will be stored in \"$image_folder\"." echo "The images will be stored in \"$image_folder\"."
if [ ! -d "$DIR" ]; then if [ ! -d "$DIR" ]; then
echo "Folder \"$image_folder\" doesn't exist. It will be created now." echo "Folder \"$image_folder\" doesn't exist. It will be created now."
@ -38,7 +40,7 @@ while [ \! -b "$of_device" ]
echo "Please select the correct SD-Card." echo "Please select the correct SD-Card."
echo "/dev/:" echo "/dev/:"
read -r device read -r device
$of_device="/dev/$device" of_device="/dev/$device"
done done
echo "Which Raspberry Pi version do you want to use?" echo "Which Raspberry Pi version do you want to use?"
read -r version read -r version
@ -96,11 +98,13 @@ case "$os" in
;; ;;
esac esac
download_url="$base_download_url$imagename" download_url="$base_download_url$imagename"
$imagepath="$image_folder$imagename" image_path="$image_folder$image_path"
if [ \! -f "$imagepath" ] root_mount_path="$working_folder""root"
ssh_key_target="$root_mount_path/home/$os_username/.ssh/authorized_keys"
if [ \! -f "$image_path" ]
then then
echo "The selected image \"$imagename\" doesn't exist under local path \"$imagepath\"." echo "The selected image \"$imagename\" doesn't exist under local path \"$image_path\"."
if [ \! -f "$imagepath" ] if [ \! -f "$image_path" ]
then then
echo "Image \"$imagename\" gets downloaded from \"$download_url\"" echo "Image \"$imagename\" gets downloaded from \"$download_url\""
wget "$download_url" wget "$download_url"
@ -108,11 +112,7 @@ if [ \! -f "$imagepath" ]
fi fi
case "$os" in case "$os" in
"arch") "arch")
bootpath="$workingpath""boot" boot_path="$workingpath""boot"
rootpath="$workingpath""root"
ssh_key_source="/home/$username/.ssh/id_rsa.pub"
ssh_key_target="$rootpath/home/$username/.ssh/authorized_keys"
if [ "${of_device:5:1}" != "s" ] if [ "${of_device:5:1}" != "s" ]
then then
partion="p" partion="p"
@ -142,39 +142,39 @@ case "$os" in
#Bootpartion formatieren und mounten #Bootpartion formatieren und mounten
echo "Generate and mount boot-partition..." echo "Generate and mount boot-partition..."
mkfs.vfat "$ofiboot" mkfs.vfat "$ofiboot"
mkdir -v "$bootpath" mkdir -v "$boot_path"
mount "$ofiboot" "$bootpath" mount "$ofiboot" "$boot_path"
#Rootpartition formatieren und mounten #Rootpartition formatieren und mounten
echo "Generate and mount root-partition..." echo "Generate and mount root-partition..."
mkfs.ext4 "$ofiroot" mkfs.ext4 "$ofiroot"
mkdir -v "$rootpath" mkdir -v "$root_path"
mount "$ofiroot" "$rootpath" mount "$ofiroot" "$root_path"
echo "Die Root-Dateien werden auf die SD-Karte aufgespielt..." echo "Die Root-Dateien werden auf die SD-Karte aufgespielt..."
bsdtar -xpf "$imagepath" -C "$rootpath" bsdtar -xpf "$image_path" -C "$root_path"
sync sync
echo "Die Boot-Dateien werden auf die SD-Karte aufgespielt..." echo "Die Boot-Dateien werden auf die SD-Karte aufgespielt..."
mv -v "$rootpath/boot/"* "$bootpath" mv -v "$root_path/boot/"* "$boot_path"
if [ "$username" != "" ] && [ -f "$ssh_key_source" ] if [ "$username" != "" ] && [ -f "$ssh_key_source" ]
then then
echo "SSH key will be copied to Raspberry Pi.." echo "SSH key will be copied to Raspberry Pi.."
mkdir -v "$rootpath/home/$os_username/.ssh" mkdir -v "$root_path/home/$os_username/.ssh"
cat "$ssh_key_source" > "$ssh_key_target" cat "$ssh_key_source" > "$ssh_key_target"
chown -R 1000 "$rootpath/home/$os_username/.ssh" chown -R 1000 "$root_path/home/$os_username/.ssh"
chmod -R 400 "$rootpath/home/$os_username/.ssh" chmod -R 400 "$root_path/home/$os_username/.ssh"
fi fi
echo "Unmount partitions..." echo "Unmount partitions..."
umount -v "$rootpath" "$bootpath" umount -v "$root_path" "$boot_path"
;; ;;
"moode") "moode")
unzip -p "$imagepath" | sudo dd of="$of_device" bs=4M conv=fsync unzip -p "$image_path" | sudo dd of="$of_device" bs=4M conv=fsync
;; ;;
"retropie") "retropie")
gunzip -c "$imagepath" | sudo dd of="$of_device" bs=4M conv=fsync gunzip -c "$image_path" | sudo dd of="$of_device" bs=4M conv=fsync
;; ;;
*) *)
echo "The operation system \"$os\" is not supported yet!" && exit 1; echo "The operation system \"$os\" is not supported yet!" && exit 1;