In between commit

This commit is contained in:
Kevin Veen-Birkenbach 2020-04-29 10:32:18 +02:00
parent 8ec630053d
commit ca9c62fe7d

View File

@ -5,13 +5,13 @@ echo "@author Kevin Veen-Birkenbach [kevin@veen.world]"
echo "@since 2017-03-12" echo "@since 2017-03-12"
echo echo
echo "The images will be stored in /home/\$username/images/." echo "The images will be stored in /home/\$username/images/."
tmp_folder="/tmp/raspberry-pi-tools-$(date +%s)"; working_folder="/tmp/raspberry-pi-tools-$(date +%s)";
echo "Create temporary working folder in $tmp_folder"; echo "Create temporary working folder in $working_folder";
if [ $(id -u) != 0 ];then if [ $(id -u) != 0 ];then
echo "This script must be executed as root!" && exit 1 echo "This script must be executed as root!" && exit 1
fi fi
echo "Please type in the username from which the SSH-Key should be copied:" echo "Please type in the username from which the SSH-Key should be copied:"
read username; read -r username;
image_folder="/home/$username/images/"; image_folder="/home/$username/images/";
echo "List of actual mounted devices:" echo "List of actual mounted devices:"
echo echo
@ -21,39 +21,18 @@ while [ \! -b "$ofi" ]
do do
echo "Please select the correct SD-Card." echo "Please select the correct SD-Card."
echo "/dev/:" echo "/dev/:"
read device read -r device
ofi="/dev/$device" ofi="/dev/$device"
done done
while [ "$workingpath" == "" ]
do
echo "Bitte waehlen Sie den Arbeitspfad zu $(pwd) aus:"
read workingpath
if [ "${workingpath:0:1}" != "/" ]
then
workingpath=$(pwd)"/"$workingpath
fi
if [ -d "$workingpath" ]
then
i=$((${#workingpath}-1)) #Letzte Zeichenstelle ermitteln
if [ "${workingpath:$i:1}" != "/" ]
then
workingpath=$workingpath"/"
fi
else
echo "Der ausgewaehlte Arbeitspfad existiert nicht."
workingpath=""
fi
done
echo "Which raspberry pi version do you want to use?" echo "Which raspberry pi version do you want to use?"
read version read -r version
echo "Image for RaspberryPi $version will be used..." echo "Image for RaspberryPi $version will be used..."
echo "Which OS do you want to use?" echo "Which OS do you want to use?"
echo "1) arch" echo "1) arch"
echo "2) moode" echo "2) moode"
echo "3) retropie" echo "3) retropie"
echo "Please type in the os:" echo "Please type in the os:"
read os read -r os
case "$os" in case "$os" in
"arch") "arch")
base_download_url="http://os.archlinuxarm.org/os/"; base_download_url="http://os.archlinuxarm.org/os/";
@ -71,11 +50,10 @@ case "$os" in
echo "ArchLinux for RaspberryPi Version $version is not supported!" && exit 1; echo "ArchLinux for RaspberryPi Version $version is not supported!" && exit 1;
;; ;;
esac esac
downloadurl="http://os.archlinuxarm.org/os/$imagename"
;; ;;
"moode") "moode")
base_download_url="https://github.com/moode-player/moode/releases/download/r651prod/"
imagename="moode-r651-iso.zip"; imagename="moode-r651-iso.zip";
downloadurl="https://github.com/moode-player/moode/releases/download/r651prod/moode-r651-iso.zip";
;; ;;
"retropie") "retropie")
base_download_url="https://github.com/RetroPie/RetroPie-Setup/releases/download/4.6/"; base_download_url="https://github.com/RetroPie/RetroPie-Setup/releases/download/4.6/";
@ -95,40 +73,27 @@ case "$os" in
echo "RetroPie for RaspberryPi Version $version is not supported!" && exit 1; echo "RetroPie for RaspberryPi Version $version is not supported!" && exit 1;
;; ;;
esac esac
downloadurl="$base_download_url$imagename"
;; ;;
*) *)
echo "The operation system \"$os\" is not supported yet!" && exit 1; echo "The operation system \"$os\" is not supported yet!" && exit 1;
;; ;;
esac esac
while [ "$imagepath" == "" ] download_url="$base_download_url$imagename"
do $imagepath="$image_folder"
echo "Setzen Sie den Imagenamen(Standart:$workingpath$imagename)" if [ \! -f "$imagepath" ]
read image then
if [ "$image" == "" ] echo "The selected image doesn't exist yet local."
then
imagepath=$workingpath$imagename
else
imagepath=$workingpath$image
fi
if [ \! -f "$imagepath" ] if [ \! -f "$imagepath" ]
then then
echo "Das ausgewaehlte Image existiert nicht!" echo "Image gets downloaded..."
#Image ggf. downloaden wget $download_url
if [ \! -f "$imagepath" ]
then
echo "Image wird gedownloadet..."
wget $downloadurl
fi
fi fi
fi
done
echo "Die Arbeitsvariablen werden gesetzt..." echo "Die Arbeitsvariablen werden gesetzt..."
bootpath=$workingpath"boot" bootpath=$workingpath"boot"
rootpath=$workingpath"root" rootpath=$workingpath"root"
ssh_key_source="/home/$user/.ssh/id_rsa.pub" ssh_key_source="/home/$username/.ssh/id_rsa.pub"
ssh_key_target="$rootpath/home/alarm/.ssh/authorized_keys" ssh_key_target="$rootpath/home/alarm/.ssh/authorized_keys"
if [ "${ofi:5:1}" != "s" ] if [ "${ofi:5:1}" != "s" ]
@ -149,7 +114,7 @@ echo "SD-Karte-Partition 2(root): $ofiroot"
echo "SSH-Source-Path: $ssh_key_source" echo "SSH-Source-Path: $ssh_key_source"
echo "SSH-Target-Path: $ssh_key_target" echo "SSH-Target-Path: $ssh_key_target"
echo "Bestaetigen Sie mit der Enter-Taste. Zum Abbruch Ctrl + Alt + C druecken" echo "Bestaetigen Sie mit der Enter-Taste. Zum Abbruch Ctrl + Alt + C druecken"
read bestaetigung read -r bestaetigung
echo "fdisk wird ausgefuehrt..." echo "fdisk wird ausgefuehrt..."
( 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.
echo "p" #Type p to list partitions. There should be no partitions left echo "p" #Type p to list partitions. There should be no partitions left
@ -187,7 +152,7 @@ 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 $rootpath"/boot/"* "$bootpath"
if [ "$user" != "" ] && [ -f "$ssh_key_source" ] if [ "$username" != "" ] && [ -f "$ssh_key_source" ]
then then
echo "Der SSH-Key wird auf den Raspberry kopiert..." echo "Der SSH-Key wird auf den Raspberry kopiert..."
mkdir -v "$rootpath/home/alarm/.ssh" mkdir -v "$rootpath/home/alarm/.ssh"