Jul 26, 2025 - 09:43 PMDeutsch | English
Hello unlogged user [ Register | Log in ]

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
jokobau
Post subject: script zum herunterladen von acritox nightlies und schreiben  PostPosted: Jan 15, 2014 - 08:34 PM



Joined: Jul 08, 2006
Posts: 976
Location: Sömmerda / Thüringen
Code:

#! /bin/bash
# script zum herunterladen von acritox nightlies und schreiben auf Stick
# Version 15. Januar 2014
red="\033[31m"
red_bg="\033[41m"   
green="\033[32m"
green_bg="\033[42m"   
yellow="\033[33m"
yellow_bg="\033[43m"
blue="\033[34m"
blue_bg="\033[44m"
magenta="\033[35m"
magenta_bg="\033[45m"
ende="\033[0m\n"
ende1="\033[0m"
GESCHRIEBEN="NEIN"
THEMPO=4000k
NUTZER=$(users |awk '{print $1}')
TARGET="keiner"
AUSWAHL1="x"
AUSWAHL2="x"
AUSW="x"
ISO="x"

for LAUFWERKBUCHSTABE in b c d e f g h i "kein" ; do
  TARGET=/dev/sd$LAUFWERKBUCHSTABE
  [ -e $TARGET ] || continue
  REM=$(cat /sys/block/${TARGET#/dev/}/removable 2>/dev/null)
  [ $REM = 1 ] && break
done

if [[ $TARGET == *kein* ]] ; then
STICK="kein USB-Stick gesteckt ggf. später einstecken"
else
STICK="Nightly herunterladen und auf USB-Stick $TARGET schreiben. Sollten mehrere Stick beschrieben werden bitte weitere Auswahl wählen"
fi

AUSWAHL1=`dialog --radiolist "$STICK" 0 0 0 \
 "64-KDE_schreiben        " "" off\
 "32-KDE_schreiben        " "" off\
 "64-KDE-spezial_schreiben" "" off\
 "32-KDE-spezial_schreiben" "" off\
 "64-lxde_schreiben       " "" off\
 "32-lxde_schreiben       " "" off\
 "oder weitere Auswahl" " " on 3>&1 1>&2 2>&3`

if [[ $AUSWAHL1 ==  *oder* ]] ; then
AUSWAHL2=`dialog --checklist "Welche/s nightly soll heruntergeladen werden" 0 0 0 \
 "64-KDE        " "     " off\
 "32-KDE        " "     " off\
 "64-KDE-spezial" "     " off\
 "32-KDE-spezial" "     " off\
 "64-lxde       " "     " off\
 "32-lxde       " "     " off\
 "löschen" "alle nyghtlyes löschen?" off\
 "2000k       " "Tempobegrenzung" off\
 "1200k       " "Tempobegrenzung" off\
 "600k       " "Tempobegrenzung" off\
 "300k       " "Tempobegrenzung" off\
 "Stick/s beschreiben" "In Laufwerk $TARGET" off\
 "herunterfahren am Ende" "nur als root" off\
 3>&1 1>&2 2>&3`
 fi
 
AUSW="$AUSWAHL2 $AUSWAHL1 Ende"
 echo Ausgewählt wurde: $AUSW
#read

clear

cd  /home/$NUTZER/

[[ "$AUSW" == *schen* ]] && rm /home/$NUTZER/Downloads/nightly -rf
case $AUSW in
  *2000k*) THEMPO=2000k ;;
  *1200k*) THEMPO=1200k ;;
  *600k*) THEMPO=600k ;;
  *300k*) THEMPO=300k ;;
esac

mkdir /home/$NUTZER/Downloads
mkdir /home/$NUTZER/Downloads/nightly
mkdir /home/$NUTZER/Downloads/nightly/$(date +%F)
chown $NUTZER:$NUTZER /home/$NUTZER/Downloads -R
chmod +rw+rw+rw /home/$NUTZER/Downloads -R
cd /home/$NUTZER/Downloads/nightly/$(date +%F)

for TODO in $AUSW ; do

case  $TODO in
 *64-KDE* ) ISO=kanotix64-acritox-nightly-KDE.iso ;;
 *32-KDE* ) ISO=kanotix32-acritox-nightly-KDE.iso ;;
 *64-KDE-special* ) ISO=kanotix64-acritox-nightly-KDE-special.iso ;;
 *32-KDE-special* ) ISO=kanotix32-acritox-nightly-KDE-special.iso ;;
 *64-lxde* ) ISO=kanotix64-acritox-nightly-LXDE.iso ;;
 *32-lxde* ) ISO=kanotix32-acritox-nightly-LXDE.iso ;;
 *Ende*) break ;;
 *) continue ;;
esac
[[ $ISO == *iso* ]] || continue
echo -e " \n\n \t\t $yellow_bg $ISO wird heruntergeladen $ende $ende1 "
wget -Nc --limit-rate=$THEMPO http://nightly.kanotix.acritox.com/latest/$ISO
  if [[ "$AUSW" == *schreiben* ]] ; then
      while [[ $TARGET == *ein* ]] ; do
      [[ $TARGET == *kein* ]] && MELDUNG=" \n\t $red_bg $ISO soll geschrieben werden.\n\tAber es wurde kein USB-Drive gefunden\n\tbitte einstecken und kurz warten\n\t\t\tweiter mit Enter\n\t\t\t\toder Abbruch mit ctrl c $ende $ende1"
      [[ $TARGET == *einer* ]] && MELDUNG=" \n\n \t$red_bg $ISO soll jetzt geschrieben werden \n\n \t\t USB-Stick wechseln, kurz warten \n\t\t\t weiter mit Enter \n\t\t\t\t oder Abbruch mit ctrl c $ende1 $ende"
   for LAUFWERKBUCHSTABE in b c d e f g h i kein; do
   TARGET="/dev/sd$LAUFWERKBUCHSTABE"
   [ -e $TARGET ] || continue
   REM=$(cat /sys/block/${TARGET#/dev/}/removable 2>/dev/null)
   [ $REM = 1 ] && break
   done
   echo -e "$MELDUNG"
   read
   clear
      done
      echo -e " \n\n \t\t $yellow_bg $ISO wird auf $TARGET geschrieben $ende $ende1 $red"
  cp $ISO $TARGET
   echo -e " $ende $ende1 "
  TARGET="einer"
  fi
done
chmod 666 *.iso

if [[ $AUSW ==  *herunter* ]] ; then
  if [ "$(id -u)" = "0" ] ; then
  shutdown -t 1035  -h now Rechner wird heruntergefahren
  fi
echo -e "$red_bg \a\a\a Zum herunterfahren bitte als root anmelden $ende $ende1"
fi



Last edited by jokobau on Jan 18, 2014 - 07:20 AM; edited 1 time in total
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
totschka
Post subject: script zum herunterladen von acritox nightlies und schreiben  PostPosted: Jan 15, 2014 - 09:20 PM



Joined: Jun 27, 2007
Posts: 409

Habs mal mit 64bit-LXDE probiert, und es hat funktioniert. Prima!
Mir fehlt dabei aber die Überprüfung des Downloads. Bevor ich ein Iso verwende, prüfe ich das. Also müsste noch die dazugehörige .md5-Datei heruntergeladen werden.
Die Prüfung selbst dürfte dann nicht wirklich ein Problem sein.
 
 View user's profile Send private message  
Reply with quote Back to top
jokobau
Post subject: script zum herunterladen von acritox nightlies und schreiben  PostPosted: Jan 15, 2014 - 09:24 PM



Joined: Jul 08, 2006
Posts: 976
Location: Sömmerda / Thüringen
Hab ich auch schon dran gedacht. Vielleicht komme ich nächste Woche dazu.
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
totschka
Post subject:   PostPosted: Jan 15, 2014 - 09:43 PM



Joined: Jun 27, 2007
Posts: 409

Ja, ist auch keine große Sache. Zum Beispiel so:
Code:
a=$(md5sum $ISO | awk '{print $1}')

schreibt die md5-Summe des ISOs in a.
Dasselbe mit dem entsprechenden $ISO.md5-file nach b (um den Download habe ich mich hier nicht gekümmert, ist ja auch nur eine Zeile)
Code:
b=$(cat $ISO.md5 | awk '{print $1}')

Nur noch beide Variablen vergleichen und die entsprechende Fehlerbehandlung:
Code:
if [ $a = $b ];then echo Download passt\!;else echo Download fehlerhaft\!;fi

Natürlich müsste dann an der Stelle der Ausgabe des Fehlers die passende Behandlung eingefügt werden,
also z.B. der Abbruch des Skriptes. Hab die Prüfung nur als Einzeiler geschrieben,
quasi als Anregung. In einem Skript schreibt man das natürlich schicker. Winken
 
 View user's profile Send private message  
Reply with quote Back to top
Kano
Post subject:   PostPosted: Jan 16, 2014 - 02:06 PM



Joined: Dec 17, 2003
Posts: 16809

Sowas in effizientes... Hast schon mal von zsync gehört?
 
 View user's profile Send private message  
Reply with quote Back to top
jokobau
Post subject:   PostPosted: Jan 18, 2014 - 07:21 AM



Joined: Jul 08, 2006
Posts: 976
Location: Sömmerda / Thüringen
Nö - zsync war mir neu. Da mach ich dann was.
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
 
Deutsch | English
Logos and trademarks are the property of their respective owners, comments are property of their posters, the rest is © 2004 - 2006 by Jörg Schirottke (Kano).
Consult Impressum and Legal Terms for details. Kanotix is Free Software released under the GNU/GPL license.
This CMS is powered by PostNuke, all themes used at this site are released under the GNU/GPL license. designed and hosted by w3you. Our web server is running on Kanotix64-2006.