Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: no shutdown while encoding



Gernot A. Weber wrote:

Hi,

some time ago I read a posting which included a shutdownscript that checks whetther there is an encoding process running or not and cancels shutdown if it found. Could someone mail this script, please.

Thanks,

Gernot



Hi,
it looks pretty ugly, but it has "grown" with my vdr project and its easy to understand. BTW "cchannel" is a script to set the channel of the next recording as "CurrentChannel" in the setup.conf for the next time vdr starts. So if vdr ist started by nvram-wakeup it starts with the channel of the upcoming recording because I had sometimes problems with switching the channels.

Greets Helge.

-------------------------------- vdrshutdown.scr -----------------------

#!/bin/bash
TIME_UTC=$1 # Time of the next timer, 0 if no timer
TIME_TO_NEXT_TIMER=$2 # Second to the next timer, 0 if no timer, <0 if recording
CHANNEL_NEXT_TIMER=$3 # Channel of the next timer, 0 if no timer
NAME_NEXT_TIMER=$4 # Name of the next timer, "" if no timer
SHUTDOWN_REASON=$5 # 0 for automatic shutdown, 1 for user shutdown
NVWKUP=/usr/local/bin/nvram-wakeup
TIMEOUT=600
TOSVCD=`/sbin/pidof tosvcd`
TRANSCODE=`/sbin/pidof transcode`
VDRLOG=`cat /etc/vdr/VDRLOG`
SMBLOCK=`/usr/bin/smbstatus -L | /bin/awk 'BEGIN{i=99999999}{if($0~/-----------/)i=NR;if(NR>i)print $0}' | /usr/bin/wc -l | /bin/awk '{printf "%i",$0}'`
echo $SMBLOCK

echo "------------------- " `/bin/date` " -----------------------" >>$VDRLOG
echo "TIME UTC: "$TIME_UTC >>$VDRLOG # Time of the next timer, 0 if no timer
echo "TIME TO NEXT TIMER: " $TIME_TO_NEXT_TIMER >>$VDRLOG # Second to the next timer, 0 if no timer, <0 if recording
echo "CHANNEL NEXT TIMER: " $CHANNEL_NEXT_TIMER >>$VDRLOG # Channel of the next timer, 0 if no timer
echo "NAME NEXT TIMER: " $NAME_NEXT_TIMER >>$VDRLOG # Name of the next timer, "" if no timer
echo "SHUTDOWN REASON: " $SHUTDOWN_REASON >>$VDRLOG # 0 for automatic shutdown, 1 for user shutdown


function exit_call () {
echo "Exit Call" $1 >>$VDRLOG
case $1 in
E)
exit
;;
H)
/usr/local/bin/cchannel $CHANNEL_NEXT_TIMER
shutdown -h now
;;
R)
/usr/local/bin/cchannel $CHANNEL_NEXT_TIMER
shutdown -r now
;;
*)
exit
;;
esac exit
}

if [ "$TRANSCODE" != "" ]
then
echo "transcode is still working..."$MENCVCD >> $VDRLOG
exit_call E
fi

if [ "$TOSVCD" != "" ]
then
echo "tosvcd is still working..."$TOSVCD >> $VDRLOG
exit_call E
fi

if [ $SMBLOCK -gt 0 ]
then
echo "SMBLock still active..."$SMBLOCK >> $VDRLOG
exit_call E
fi

if [ $TIME_TO_NEXT_TIMER -lt 0 ]
then
echo "VDR is recording! Exit shutdown" >> $VDRLOG
exit_call E
fi

if [ $TIME_TO_NEXT_TIMER -eq 0 ] && [ $SHUTDOWN_REASON -eq 1 ]
then
if [ -e /tmp/nvshutdowntime ]
then
echo "VDR unprogram nvwakeup and reboot" >> $VDRLOG
$NVWKUP -d
touch /tmp/nvshutdown
rm -f /tmp/nvshutdowntime
exit_call R
else
echo "VDR no unprogram needed" >> $VDRLOG
exit_call H
fi
fi

if [ $TIME_TO_NEXT_TIMER -eq 0 ] && [ $SHUTDOWN_REASON -eq 0 ]
then
if [ -e /tmp/nvshutdowntime ]
then
"VDR unprogram an reboot 2" >> $VDRLOG
$NVWKUP -d
touch /tmp/nvshutdown
rm -f /tmp/nvshutdowntime
exit_call R
else
"VDR no unprogram needed 2" >> $VDRLOG
exit_call H
fi
fi

if [ $TIME_TO_NEXT_TIMER -gt $TIMEOUT ] && [ $SHUTDOWN_REASON -eq 0 ]
then
if [ -e /tmp/nvshutdowntime ] && [ $TIME_UTC -eq `cat /tmp/nvshutdowntime` ]
then
echo "VDR no reprogram needed 3" >> $VDRLOG
shutdown -h now
exit_call H
else echo "VDR reprogram an reboot 3" >> $VDRLOG
$NVWKUP -s $TIME_UTC
touch /tmp/nvshutdown
echo $TIME_UTC > /tmp/nvshutdowntime
exit_call R
fi
elif [ $TIME_TO_NEXT_TIMER -le $TIMEOUT ] && [ $SHUTDOWN_REASON -eq 0 ]
then
echo "Aufnahme startet in wenigen Minuten..."
exit_call E
fi

if [ $TIME_TO_NEXT_TIMER -gt $TIMEOUT ] && [ $SHUTDOWN_REASON -eq 1 ]
then
if [ -e /tmp/nvshutdowntime ] && [ $TIME_UTC -eq `cat /tmp/nvshutdowntime` ]
then
echo "VDR no reprogram needed 4" >> $VDRLOG
exit_call H
else echo "VDR reprogram an reboot 4" >> $VDRLOG
$NVWKUP -s $TIME_UTC
touch /tmp/nvshutdown
echo $TIME_UTC > /tmp/nvshutdowntime
exit_call R
fi
elif [ $TIME_TO_NEXT_TIMER -le $TIMEOUT ] && [ $SHUTDOWN_REASON -eq 1 ]
then
echo "Aufnahme startet in wenigen Minuten..." >> $VDRLOG
exit_call E
fi





--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index