Hello, all:
I am hoping someone can help me sort out a problem.
I recently started using a script called "AutoZap" which scrolls through the channels in a user bouquet to try to give CCcaminfoPHP a bit more information with which to work, particularly for those channels and bouquets I do not watch very frequently.
Unfortunately, for reasons which are not at all clear to me, this script runs as expected for 15 to 20 minutes and then freezes. Once locked it cannot be stopped except by reboot. It also seems to cause problems for connected clients.
I am presently using the script below in a slightly modified form to be compatible with an EDG-Nemesis 4.2 image running in flash on a Technomate 9100 with no swap file and no hard drive. The script is started using the manage user scripts menu in the EDG-Nemesis image. I've also used a variation of the script in a heavily modified form to bypass the problems and restrictions the author mentions of the script only working on the current user bouquet and not handling the presence of identical channels in multiple bouquets. I still have the same problems with freezing.
I have not tried this on a PC nor on any STB other than the Technomate.
Would someone take a look at this script to see if there are any obvious issues that would cause a STB to hang so predictably?
Any comments are very much appreciated.
Thanks again!
Code:
#!/bin/sh
#------------------------------------------------------------------------------------
#
# autozap.sh
#
# V1.0
#
# Auto Zap Skript
#
# Zappt durch die Kanaele eines Bouquets
# Zur Ermittlung des Bouqets wird der aktuell eingestellte Kanal verwendet
# Die Verweildauer beim zappen kann als Parameter in Sekunden
# ( hier im Bspl. 10 sek. ) angegeben werden.
# Werte kleiner 5 sek. machen dabei wenig Sinn :-)
#
# Einschraenkung:
# Das Skript funktioniert z.Zt. nur mit Userbouquets
# Sind Kanaele in mehreren Bouquets vorhanden wird immer das erste gefundene
# Bouquet verwendet
#
# Aufruf übers Flexmenu:
#
# DEPENDOFF=Auto ZAP An, ( /var/script/autozap.sh 10 & ) ,/tmp/autozap.flag
# DEPENDON=Auto ZAP Aus, ( kill -15 `cat /tmp/autozap.flag` ; rm /tmp/autozap.flag ),/tmp/autozap.flag
#
#
# Author: barabas
#
#------------------------------------------------------------------------------------
# set -x
# Falls vorzeitig gekillt wurden noch aufraeumen :-)
trap 'rm -f /tmp/autozap_* ; exit 0' 15
#-------------------------------------------------------------------------------------
# Bspl. Service IDs aus userbouquet
# ( Spalten Nr. fuer awk )
# 1 2 3 4 5 6 7 8 9 10
# 1:0:1:6dca:44d:1:c00000:0:0:0:
#
# umwandeln fuer /cgi-bin/switchService <ServiceId>:<DVB Namespace>:<TSID>:<NID>:<ServiceType>(1=TV,2=Radio)
#
# 4 7 5 6 3
# 6dca:00c00000:044d:0001:1
#-------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------
# Dreambox HTTP User Authentifizierung User Passwort hier aendern
# oder in der Datei pass.txt im Skriptverzeichnis hinterlegen
#-------------------------------------------------------------------------------------
scriptname=`basename $0`
passfile=`echo $0 | sed "s:$scriptname:pass.txt:"`
if [ -f $passfile ] ; then
read auth <$passfile
else
auth="root:dreambox"
fi
# Bouquet Files werden nicht immer in unixkonformen Textformat erzeugt, z.B. mit Dreamboxedit !
# deshalb CRLF erzeugen
CRLF=`echo -e "\r"`;
# Verweildauer Parameteruebergabe
time=$1
# Prozessnummer in Flag Datei ablegen
echo $$ >/tmp/autozap.flag
# TV und Radio UserBouquets inkl. Kanaele ausgeben
wget -O- "http://$auth@localhost/cgi-bin/getServices?ref=4097:7:0:6:0:0:0:0:0:0:&listContent=true" >/tmp/autozap_bouquets.txt
# Radio
wget -O- "http://$auth@localhost/cgi-bin/getServices?ref=4097:7:0:4:0:0:0:0:0:0:&listContent=true" >>/tmp/autozap_bouquets.txt
# Aus den ServiceIds des aktuellen Kanals das zugehoerige Bouquet ermitteln
# mir ist leider kein Request bekannt der das automatisch liefert....
#
# Bspl. Eintrag fuers Bouquet in /tmp/autozap_tv_bouqets.txt:
# 4097:7:0:dbe03:0:0:0:0:0:0:/var/tuxbox/config/enigma/userbouquet.dbe03.tv;Sport
aktsid=`wget -O- http://$auth@localhost/cgi-bin/currentService`
aktbouquet=`awk -v aktsid=$aktsid 'BEGIN {
FS=":"
}
$0 ~/^4097/ {
# Bouquet-Filename ermitteln
split($11,bouquet,";")
bouquetfile=bouquet[1]
}
$0 ~/^1:/ {
# aktuellen Kanal gefunden , Bouquetfilename ausgeben
if(match($0,aktsid)>0)
exit
}
END {
print bouquetfile
}' /tmp/autozap_bouquets.txt`
# aktuellen Kanal speichern und SIDs umwandeln fuer /cgi-bin/switchService
aktchan=`wget -O- http://$auth@localhost/cgi-bin/currentService | awk 'BEGIN {FS=":"} { printf("%s:%s:%s:%s:%s\n",$4,"00"$7,$5,$6,$3)}'`
# aus dem aktuellen Userbouquet alle SIDs umwandeln fuer /cgi-bin/switchService
# vorher ggfs. unixkonform machen
sed "s/$CRLF//g" $aktbouquet | awk 'BEGIN {FS=":"} $0 ~/^#SERVICE: / { printf("%s:%s:%s:%s:%s\n",$5,$8,$6,$7,$4)}' >/tmp/autozap_zapkanaele.txt
# nur fuers debuggen
echo "$time $aktsid $aktchan $aktbouquet" >/tmp/autozap_debug.txt
# durchzappen der Kanaele innerhalb des aktiven UserBouquets
for service in `cat /tmp/autozap_zapkanaele.txt`
do
wget -q -O- "http://$auth@localhost/cgi-bin/switchService?$service"
sleep $time
done
# zurueck zum gespeicherten Kanal zappen
wget -q -O- "http://$auth@localhost/cgi-bin/switchService?$aktchan"
# aufraeumen
rm /tmp/autozap_*
