diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fdc4761..1db445a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,6 @@ jobs: name: Shellcheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Run ShellCheck uses: ludeeus/action-shellcheck@master diff --git a/README.md b/README.md index 4ad011f..2b56898 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,17 @@ -# Raspi-auto-downloader - -. -05.05.2022 Diese Version kann jetzt Images die mit xz gepackt wurden. - - -.[![Trigger: Push action](https://github.com/dewomser/Raspi-auto-downloader/actions/workflows/main.yml/badge.svg)](https://github.com/dewomser/Raspi-auto-downloader/actions/workflows/main.yml) Shellchecked +# Raspi-auto-downloader +[![Trigger: Push action](https://github.com/dewomser/Raspi-auto-downloader/actions/workflows/main.yml/badge.svg)](https://github.com/dewomser/Raspi-auto-downloader/actions/workflows/main.yml) Shellchecked Load fresh images for the Raspberry Pi, check SHA256, and copy to SD-Card, a Bashscript. -Jetzt auch mit den 64er Images +## Hilfe raspi-install -h -## Hilfe raspi-install.sh -h - -![alt text](./bilder/help.png "help") +![alt text](https://github.com/dewomser/Raspi-auto-downloader/blob/main/bilder/help.png "help") ## Copy and check SD-Image -![alt text](./bilder/copy.png "copy and check") +![alt text](https://github.com/dewomser/Raspi-auto-downloader/blob/main/bilder/copy.png "copy and check") ## Fork, Issue, Pull request, Clone -Be carefull, this script is in status Beta 0.2. ! - -## Bei fehlenden Rootrechten zum Schreiben auf SD-Karte - -Wenn die Karte nur als Root gemountet werden kann, muss dd durch sudo dd ersetzt werden. umount -> sudo umount. Gilt ab Zeile 105 - -### Alternative für Ubuntu: - -echo 'KERNEL=="sd*", SUBSYSTEMS=="usb", MODE="0666"' | sudo tee /etc/udev/rules.d/99-usb-storage.rules - -Quelle : https://askubuntu.com/questions/828545/using-dd-without-sudo - +Be carefull, this script is in status Alpha 0.2. ! diff --git a/bilder/help.png b/bilder/help.png index 765ba88..fd4eef8 100644 Binary files a/bilder/help.png and b/bilder/help.png differ diff --git a/dietpi-install.sh b/dietpi-install.sh deleted file mode 100755 index f346d83..0000000 --- a/dietpi-install.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -# gemacht von Stefan Höhn -#https://github.com/dewomser/Raspi-auto-downloader -#ACHTUNG : Zeile 106-112 Beachten ! -attribut=$1 -# datum="[0-9]{4}-[0-9]{2}-[0-9]{2}" -url="https://dietpi.com/downloads/images/" -if [[ "$attribut" = "-h" ]] -then -echo " -Aufruf dietpi-install.sh [OPTION] - -Option Bedeutung --1 dietpi für Raspberry v1 ARMv6 --2 dietpi für Raspberry v2 ARNv7 --234 dietpi für Raspberry v2-4 ARMv8 --h Diese Hilfe --5 dietpi für Raspberrx v5 ARMv8 - -" && exit -elif [[ "$attribut" = "-1" ]] -then -rimage="DietPi_RPi1-ARMv6-Trixie" -elif [[ "$attribut" = "-2" ]] -then -rimage="DietPi_RPi2-ARMv7-Trixie" - -elif [[ "$attribut" = "-234" ]] -then -rimage="DietPi_RPi234-ARM8-Trixie" - -elif [[ "$attribut" = "-5" ]] -then -rimage="DietPi_RPi5-ARMv8-Trixie" - -else -echo "Kein Pi-Image ausgewählt. \"raspi-install.sh -h \" für Hilfe!" && exit -fi - - -cd "$HOME/Downloads" || echo"Downloads Ordner nicht vorhanden" - -#https://dietpi.com/downloads/images/DietPi_RPi2-ARMv7-Trixie.img.xz - -pathr="$url$rimage.img.xz" -pathrs="$pathr.sha256" - -# -c -wget -c "$pathr" -O "$rimage.img.xz" -wget "$pathrs" -O "$rimage.img.xz.sha256" -echo "Bitte ein paar Sekunden warten. Der Hash wird erzeugt." -sha1=$(shasum -a 256 "$rimage.img.xz") -sha2=$(cat "$rimage.img.xz.sha256") -sleep 1 -echo Prüfsumme aus Download "$sha1" -echo Prüfsumme von Webseite "$sha2" - -if [ "$sha1" == "$sha2" ]; then -echo "Prüfsumme stimmt." -echo "-----------------" -echo "SD-Karte auf die geschrieben werden soll ENTFERNEN !" \"y\" -read -r input -if [ "$input" == "y" ]; then -mapfile -t laufwerke < <(lsblk -l -o Name | grep -E "^sd[a-z]*$") -laufwerke[0]="lolo" -laufwerke1[0]="lolo" -else -exit -fi - -echo Es gibt diese seriellen Blockdevices "${laufwerke[*]}" -echo "SD-Karte auf die geschrieben werden soll EINSCHIEBEN !" \"y\" -read -r input -if [ "$input" == "y" ]; then -mapfile -t laufwerke1 < <(lsblk -l -o Name |grep -E "^sd[a-z]*$") -echo "${laufwerke1[0]}" -mapfile -t laufwerke2 < <({ printf "%s\n" "${laufwerke[@]}" | sort -u; printf "%s\n" "${laufwerke1[@]}" "${laufwerke[@]}"; } | sort | uniq -u) -zahl_laufwerke="${#laufwerke2[@]}" - - -echo neu erkannte Es gibt jetzt dieses neue serielle Blockdevice: "${laufwerke2[@]}" -echo Laufwerke ${#laufwerke2[@]} - -echo lwo:"${laufwerke2[0]}" -echo lw1:"${laufwerke2[1]}" - - -if [ "$zahl_laufwerke" -eq 1 ]; then -echo Es gibt jetzt dieses neue serielle Blockdevice: "${laufwerke2[0]}" -else -echo "Es kann nicht geschrieben werden. Es wurden mehr oder weniger als 1 SD-Karte erkannt" ; exit -fi -else -exit -fi - -echo Ich bin mir SICHER und will auf SD-Karte schreiben : /dev/"${laufwerke2[0]}" \"y\" oder \"n\" - -read -r endgueltigja -if [ "$endgueltigja" == "y" ]; then - -# Wenn die Karte nur als root gemountet werden kann, muss dd durch sudo dd ersetzt werden. umount -> sudo umount -## sudo ddd – is now on -# Alternative für Ubuntu: -# echo 'KERNEL=="sd*", SUBSYSTEMS=="usb", MODE="0666"' | sudo tee /etc/udev/rules.d/99-usb-storage.rules -# Quelle : https://askubuntu.com/questions/828545/using-dd-without-sudo - -# Wenn die nächsten 3 Zeilen aktiviert sind: "don't blame me!" -#umount /dev/"${laufwerke2[0]}"[0-9] > /dev/null 2>&1 -xz --keep --decompress dietpi"$attribut".xz -sudo dd if=raspi"$attribut" of=/dev/"${laufwerke2[0]}" bs=4M conv=fsync status=progress || echo "Es gibt Probleme mit Schreibrechten.Ab Zeile 105 gibts Hilfe" -echo "Tatatatah ! fertig" -#umount /dev/"${laufwerke2[0]}"[0-9] > /dev/null 2>&1 -else -exit -fi -else -echo "Achtung,Prüfsumme stimmt nicht überein !" -fi diff --git a/raspi-install.sh b/raspi-install.sh index 0c5f946..e6ff515 100755 --- a/raspi-install.sh +++ b/raspi-install.sh @@ -1,10 +1,11 @@ #!/bin/bash # gemacht von Stefan Höhn #https://github.com/dewomser/Raspi-auto-downloader -#ACHTUNG : Zeile 106-112 Beachten ! + attribut=$1 datum="[0-9]{4}-[0-9]{2}-[0-9]{2}" + if [[ "$attribut" = "-h" ]] then echo " @@ -15,55 +16,32 @@ Option Bedeutung -l raspios_lite_armhf Raspberry Pi OS Lite -d raspios_armhf Raspberry Pi OS with desktop -h Diese Hilfe --f64 raspios_full_arm64 --l64 raspios_lite_arm64 --d64 raspios_arm64 " && exit -elif [[ "$attribut" = "-f" ]] -then -rimage="raspios_full_armhf" elif [[ "$attribut" = "-l" ]] then rimage="raspios_lite_armhf" - elif [[ "$attribut" = "-d" ]] then rimage="raspios_armhf" - -elif [[ "$attribut" = "-f64" ]] -then -rimage="raspios_full_arm64" - -elif [[ "$attribut" = "-l64" ]] -then -rimage="raspios_lite_arm64" - -elif [[ "$attribut" = "-d64" ]] -then -rimage="raspios_arm64" - else -echo "Kein Pi-Image ausgewählt. \"raspi-install.sh -h \" für Hilfe!" && exit +rimage="raspios_full_armhf" +attribut="-f" fi #rimage ="raspios_lite_armhf" #rimage="raspios_full_armhf" -cd "$HOME/Downloads" || echo"Downloads Ordner nicht vorhanden" +cd "$HOME/Downloads" || exit - -dirr=$(curl --silent "https://downloads.raspberrypi.org/$rimage/images/" | grep -o -E "$rimage-$datum" | tail -1 ) +dirr=$(curl --silent https://downloads.raspberrypi.org/$rimage/images/ | grep -o -E "$rimage-$datum" | tail -1 ) pathr="https://downloads.raspberrypi.org/$rimage/images/$dirr/" -#rname=$(curl --silent "$pathr" | grep -o -E -w "$datum-[[:lower:]-]*\.zip" | head -1) -#rname=$(curl --silent "$pathr" | grep -o -E "$datum-[[:alnum:]-]*\.xz" | head -1) -rname=$(curl --silent "$pathr" | grep -o -E "$datum-[[:alnum:]-]*\.img\.xz"|tail -1) - -wget -c "$pathr""$rname" -O "raspi$attribut".xz +rname=$(curl --silent "$pathr" | grep -o -E -w "$datum-[[:lower:]-]*\.zip" | head -1) +wget -c "$pathr""$rname" -O "raspi$attribut".zip #echo Test kompletter Pfad :: "$pathr""$rname" -shaname=$(curl --silent "$pathr" | grep -o -E -w "$datum-[[:alnum:]-]*\.img.\xz\.sha256" | tail -1) +shaname=$(curl --silent "$pathr" | grep -o -E -w "$datum-[[:lower:]-]*\.zip\.sha256" | head -1) #echo Test kompletter sha256-Pfad :: $pathr$shaname wget "$pathr""$shaname" -O raspi"$attribut".sha256 echo "Bitte ein paar Sekunden warten. Der Hash wird erzeugt." -sha1=$(shasum -a 256 raspi"$attribut".xz | grep -o -P "[0-9a-z]{40,}") +sha1=$(shasum -a 256 raspi"$attribut".zip | grep -o -P "[0-9a-z]{40,}") sha2=$( grep -o -P "[0-9a-z]{40,}" < raspi"$attribut".sha256 ) sleep 1 echo Prüfsumme aus Download "$sha1" @@ -75,9 +53,7 @@ echo "-----------------" echo "SD-Karte auf die geschrieben werden soll ENTFERNEN !" \"y\" read -r input if [ "$input" == "y" ]; then -mapfile -t laufwerke < <(lsblk -l -o Name | grep -E "^sd[a-z]*$") -laufwerke[0]="lolo" -laufwerke1[0]="lolo" +mapfile -t laufwerke < <(lsblk -l -o Name | grep -E -v "[0-9]" | grep -E "sd[a-z]") else exit fi @@ -86,19 +62,11 @@ echo Es gibt diese seriellen Blockdevices "${laufwerke[*]}" echo "SD-Karte auf die geschrieben werden soll EINSCHIEBEN !" \"y\" read -r input if [ "$input" == "y" ]; then -mapfile -t laufwerke1 < <(lsblk -l -o Name |grep -E "^sd[a-z]*$") -echo "${laufwerke1[0]}" +mapfile -t laufwerke1 < <(lsblk -l -o Name | grep -E -v "[0-9]" | grep -E "sd[a-z]") + mapfile -t laufwerke2 < <({ printf "%s\n" "${laufwerke[@]}" | sort -u; printf "%s\n" "${laufwerke1[@]}" "${laufwerke[@]}"; } | sort | uniq -u) zahl_laufwerke="${#laufwerke2[@]}" - - -echo neu erkannte Es gibt jetzt dieses neue serielle Blockdevice: "${laufwerke2[@]}" -echo Laufwerke ${#laufwerke2[@]} - -echo lwo:"${laufwerke2[0]}" -echo lw1:"${laufwerke2[1]}" - - +echo neu erkannte Laufwerke "$zahl_laufwerke" if [ "$zahl_laufwerke" -eq 1 ]; then echo Es gibt jetzt dieses neue serielle Blockdevice: "${laufwerke2[0]}" else @@ -112,22 +80,14 @@ echo Ich bin mir SICHER und will auf SD-Karte schreiben : /dev/"${laufwerke2[0]} read -r endgueltigja if [ "$endgueltigja" == "y" ]; then - -# Wenn die Karte nur als root gemountet werden kann, muss dd durch sudo dd ersetzt werden. umount -> sudo umount -## sudo ddd – is now on -# Alternative für Ubuntu: -# echo 'KERNEL=="sd*", SUBSYSTEMS=="usb", MODE="0666"' | sudo tee /etc/udev/rules.d/99-usb-storage.rules -# Quelle : https://askubuntu.com/questions/828545/using-dd-without-sudo - -# Wenn die nächsten 3 Zeilen aktiviert sind: "don't blame me!" -#umount /dev/"${laufwerke2[0]}"[0-9] > /dev/null 2>&1 -xz --keep --decompress raspi"$attribut".xz -sudo dd if=raspi"$attribut" of=/dev/"${laufwerke2[0]}" bs=4M conv=fsync status=progress || echo "Es gibt Probleme mit Schreibrechten.Ab Zeile 105 gibts Hilfe" +# das hier aktivieren --TOTENKOPF--- zum Schreiben +#unzip -p raspi"attribut".zip | dd of=/dev/${laufwerke2[0]} bs=4M conv=fsync status=progress echo "Tatatatah ! fertig" -#umount /dev/"${laufwerke2[0]}"[0-9] > /dev/null 2>&1 else exit fi else echo "Achtung,Prüfsumme stimmt nicht überein !" fi + +#http://downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2021-05-28/2021-05-07-raspios-buster-armhf-full.zip