Script to reboot the dreambox every night
I picked up a script from the internet that rebooted the dreambox every night.
I was looking for something like this after experiencing hangs of cccam due to enigma running out of memory due to a massive memory leak triggered by crossepg.
It would fill up the swap area and caused cccam to fail.
I've modified the script for enigma2. The only bit I have not find a solution for is the check if the box is in recording mode.
Save the script in /usr/script, set the execute permissions with chmod +x restart_check.sh
and add something like this in root's contab entry,
*/5 3-5 * * * /usr/script/restart_check.sh
Here is the script:
# reboot dreambox when up for more than 24 hours and go to standby
# reboots only if the box isn't doing anything like:
# - recording
# - watching
# - serving an active CCcam client
# you can run this script from cron with a line like this:
#*/5 3-5 * * * /usr/script/restart_check.sh
# so it tries to reboot every 5 minutes between 3 and 6 a.m.
date >> $LOGFILE
# create a script in /etc/rc2.d to put enigma to sleep after the reboot
sleep 120 && wget -q http://127.0.0.1/cgi-bin/admin?command=standby
-O - &
date >> $LOGFILE
echo 'box rebooted' >> $LOGFILE
rm -f $RCFILE > $RCFILE
chmod 777 $RCFILE
# log this restart
echo "Restart box" >> $LOGFILE
# now we reboot, finally
# powerstate 0: Standby
# 1: Deep standby
# 2: Reboot Dreambox
# 3: Restart Enigma2
# 116: Wakeup from Standby
wget -q http://127.0.0.1/web/powerstate?newstate=2
# we restart only if the box has been up for over a day
uptime | fgrep day || exit
echo "Passed uptime check" >> $LOGFILE
# No option found yet to do this in enigma2!
# wget -q http://127.0.0.1/cgi-bin/status
-O - | fgrep -i recording | fgrep -i off || exit
# echo "Passed Recording check" >> $LOGFILE
wget -q http://127.0.0.1/web/powerstate
-O - | fgrep -i true || exit
echo "Passed Standby check" >> $LOGFILE
# CCcam running?
ps | fgrep -i cccam | fgrep -i camd || restart_box
echo "Passed CCcam active check" >> $LOGFILE
# no active CCcam clients?
wget -q http://web:[email protected]:16001/activeclients
-O - | fgrep "0 ACTIVE CLI" || exit
echo "Passed CCcam active clients check" >> $LOGFILE