HD-PVR Power Cycle by Module Reload
Author | Steve Adeff |
Description | A method to power cycle the HD-PVR by reloading the driver module |
Supports |
Contents
multi HD-PVR safe module reload script
This is another method of "power-cycling" the HD-PVR for when it fails to properly record. Much like the actions taken by "HD-PVR Killer Device", this attempts to leverage the idea that just reloading the driver modules will achieve the same result.
It is intended that this script be run via the /etc/cron.hourly directory. As such a control allowing you to limit the hours between which the script will run are in place.
This script has some variables at the beginning that the user must set, this includes user and password for your mythweb installation if you have them set.
The other is the above mentioned hour control, MINHR and MAXHR, which are to be set in 24h format (ie 1pm = 13). If you wish to allow it to run at any time setting the values to MINHR=0 and MAXHR=25 should work.
You can also have it log the output to a log file, which is what the first few lines accomplish, which can be commented out for testing on the command line.
The actual module commands are in a second script, to allow for easier testing, but can easily be rolled into the main script. That script is below the script to check the HD-PVR status.
Final word of note, this is set up for an English system so if you are running in another language you will have to modify the commands to account for the language difference.
The Code
hdpvr_check.sh
#!/bin/bash #export PATH=/usr/bin logfile=/var/log/mythtv/hdpvr_powercycle.log exec >> $logfile 2>&1 echo "Checking PVR status at " `date` ## mythweb url, should work as long as the script is being run on the same ## system as mythweb and apache MYTHWEBURL=http://localhost/mythweb/status ## if your mythweb is password protected enter your username and password here MYTHWEBUSER=mythweb MYTHWEBPASSWORD=c00ldvr ## to limit the time the script will run, place your hour limits here ## in 24h format (ie 1pm=13) MINHR=2 MAXHR=6 ## don't touch these! STATUS=1 TIME=`date +%H` TODAY=`date +%F` ## Let's start! echo "Hour: " $TIME if [ "$TIME" -ge "$MINHR" -a "$TIME" -lt "$MAXHR" ] then echo "Clear to run at this time!" wget -O - --quiet --user=$MYTHWEBUSER --password=$MYTHWEBPASSWORD $MYTHWEBURL | grep HDPVR | \ while read line do device=`echo $line | sed -e 's/.*Encoder \([0-9]\).*/\1/'` if `echo $line | grep --quiet 'and is not'` then echo "HDPVR ${device} is not being used" else echo "however, HDPVR ${device} is busy, we will wait" exit 2 fi done STATUS=$? if [ "$STATUS" -eq "1" ] then echo "no devices are in use!" echo "reloading driver for HDPVR devices..." /usr/local/bin/hdpvr_powercycle.sh else echo "an HDPVR is in use, we won't reload at this time" fi else echo "Wrong time! We won't run now..." fi
this is the code to actually unload and load the driver module