SkyMaster
schläft auf dem Boardsofa
Hallo ich habe hier ein Scribt, was sich alle 10 Min (600 Sec) widerholt.
das sollte so aber nicht sein, das Scribt sollte nur EINMAL durchlaufen und dann ENDE
Doch ich habe so wenig Ahnung von Scripten, das ich nicht weis was alles raus muss. wer kann mir erfolgreich den Loop aus folgenden Script entfernen ?
das sollte so aber nicht sein, das Scribt sollte nur EINMAL durchlaufen und dann ENDE
Doch ich habe so wenig Ahnung von Scripten, das ich nicht weis was alles raus muss. wer kann mir erfolgreich den Loop aus folgenden Script entfernen ?
#!/bin/sh
URL="http://meinedomain.de/ancs/"
FILESonServer="/tmp/files_on_server"
shDIR="script/"
FILESonDream="/var/""$shDIR""ancs_update.txt"
LOOPDELAY=600
TEST=0
hex_to_dec () {
HexStrLen=`expr length $HexSTR`
HexStrPos=1
DEC=0
while [ "$HexStrLen" -ge "$HexStrPos" ]
do
DEC=$((DEC*16)) X0="0"
Hex1=`expr substr "$HexSTR" "$HexStrPos" 1`
case "$Hex1" in
[0-9]) X0="$Hex1";;
A|a) X0="10";;
B|b) X0="11";;
C|c) X0="12";;
D|d) X0="13";;
E|e) X0="14";;
F|f) X0="15";;
esac
DEC=$((DEC+X0*16))
HexStrPos=$((HexStrPos+1))
done
DEC=$((DEC/16))
}
UPDATE=0
LOOPCOUNT=0
case $TEST in
0) TESTSTR="" LOOPLIMIT=0
sleep 0;;
*) TESTSTR=".test" LOOPDELAY=35 LOOPLIMIT=5;;
esac
while echo;
do
LOOPCOUNT=$(($LOOPCOUNT + 1))
echo "##" `date +%Y.%m.%d.\ %H:%M:%S` "-> Start ($LOOPCOUNT)checking for ancs updates ##"
rm -f $FILESonServer$TESTSTR
srvMD5OK=0
wget -q $URL"files_md5.php" -O $FILESonServer$TESTSTR
if [ "$?" = "0" ]; then
if [ -s $FILESonServer$TESTSTR ]; then
srvMD5OK=1
else
echo Zero len $FILESonServer$TESTSTR
fi
else
echo !!! Download $URL"files_md5.php" failed !!!
fi
# for FNR in "0" "1" "2" "3" "4" "5" "6" "7"
for FNR in "3" "4" "5" "6" "7"
do
ADDSTR=""
case $FNR in
0|1|3) FDEST="$shDIR";;
2) FDEST="bin/";;
4|5|6|7) FDEST="keys/";;
esac
case $FNR in
0) FILENAME="ancs_cam.sh";;
1) FILENAME="ancs_update.sh";;
2) FILENAME="ancs";;
3) FILENAME="reload_emu_names.sh";;
4) FILENAME="Soft.pic";;
5) FILENAME="Auto.pic";;
6) FILENAME="ancs.igno";;
7) FILENAME="ancs.cw";;
esac
##
##
echo "## $FDEST$FILENAME$TESTSTR ##"
DoDOWNLOAD=0
MD5_NEW=""
if [ ! -f /var/$FDEST$FILENAME$TESTSTR ]; then
DoDOWNLOAD=1
else
MD5_OLD=`grep " $FILENAME " $FILESonDream$TESTSTR | awk {'print $1'}`
if [ ! $MD5_OLD ]; then
MD5_OLD=`md5sum /var/$FDEST$FILENAME$TESTSTR | awk {'print $1'}`
echo "$MD5_OLD $FILENAME "`date +%Y.%m.%d.\ %H:%M:%S`>>$FILESonDream$TESTSTR
fi
echo MD5_OLD: $MD5_OLD
fi
if [ $srvMD5OK = "1" ]; then
MD5_NEW=`grep "$FILENAME$ADDSTR " $FILESonServer$TESTSTR | awk {'print $2'}`
fi
if [ $DoDOWNLOAD = "0" ] && [ "$MD5_OLD" = "$MD5_NEW" ]; then
echo MD5_NEW: $MD5_NEW
echo File isnt changed
else
echo $URL$FILENAME
wget -q $URL$FILENAME$ADDSTR -O /tmp/$FILENAME$TESTSTR
if [ "$?" = "0" ]; then
if [ -s /tmp/$FILENAME$TESTSTR ]; then
MD5_NEWtmp=`md5sum /tmp/$FILENAME$TESTSTR | awk {'print $1'}`
if [ ! $DoDOWNLOAD = "0" ] || [ "$MD5_NEWtmp" = "$MD5_NEW" ]; then
echo MD5_NEW: $MD5_NEWtmp
if [ "$MD5_OLD" = "$MD5_NEWtmp" ]; then
echo File isnt changed
else
echo "## update /var/$FDEST$FILENAME$TESTSTR ##"
rm -f /var/$FDEST$FILENAME$TESTSTR
mv /tmp/$FILENAME$TESTSTR /var/$FDEST$FILENAME$TESTSTR
MD5_NEW=`md5sum /var/$FDEST$FILENAME$TESTSTR | awk {'print $1'}`
if [ "$MD5_NEWtmp" = "$MD5_NEW" ]; then
case $FNR in
0|1|2)
chmod 755 /var/$FDEST$FILENAME$TESTSTR
UPDATE=1
;;
3)
chmod 755 /var/$FDEST$FILENAME$TESTSTR
if [ $FNR = 9 -a $TEST = 0 ]; then
/var/$FDEST$FILENAME$TESTSTR &
fi
;;
esac
current=`grep " $FILENAME " $FILESonDream$TESTSTR | tail -1`
if [ ! $current ]; then
echo "$MD5_NEW $FILENAME "`date +%Y.%m.%d.\ %H:%M:%S`
echo "$MD5_NEW $FILENAME "`date +%Y.%m.%d.\ %H:%M:%S`>>$FILESonDream$TESTSTR
else
rm -f /tmp/ancs_update.tmp
sed s/"$current"// $FILESonDream$TESTSTR | sed '/^$/d'>/tmp/ancs_update.tmp
echo "$MD5_NEW $FILENAME "`date +%Y.%m.%d.\ %H:%M:%S`>>/tmp/ancs_update.tmp
mv /tmp/ancs_update.tmp $FILESonDream$TESTSTR
fi
else
echo "!! File isn't copyed correctly - maybe no space available under /var/$FDEST"
fi
fi
else
echo "!! Downloaded file has different md5sum:$MD5_NEWtmp but on Server:$MD5_NEW"
fi
else
echo Zero len /tmp/$FILENAME$TESTSTR
fi
else
echo !!! Download $URL$FILENAME$ADDSTR failed !!!
fi
rm -f /tmp/$FILENAME$TESTSTR
fi
done
#
##
##
case $UPDATE in
1)
if [ $UPDATE = 1 ]; then
/var/script/reload_emu_names.sh
sleep 3
fi
echo DOing RESTART ancs because of files change
if [ $TEST = 0 ]; then
PortHex=`grep 'webifport=' /var/tuxbox/config/enigma/config| sed -e 's/.*webifport=//'`
HexSTR="$PortHex"
hex_to_dec
PortDec="$DEC"
wget -O /tmp/webcommands.tmp -q http://localhost:"$PortDec"/cgi-bin/StartCam?300
rm -f /tmp/webcommands.tmp
fi
exit
;;
esac
if [ $LOOPCOUNT = $LOOPLIMIT ]; then
exit
else
echo "## ancs_update.sh going to sleep for $LOOPDELAY sec ##"
fi
UPDATE=0
sleep $LOOPDELAY
done