EPG-Backup
Guude @all,
das Skript ist ansich selbsterklärend...
Ich nutze das PlugIn "EPGRefresh", was mir den EPG täglich zwischen 5.30 - 6.30 Uhr autom. aktualisiert. Danach kopiere ich die EPG-Datei auf ein NFS-Share und hole die Datei dann wiederum von anderen Receivern ab.
Verbesserungen oder Verbesserungsvorschläge sind wie immer sehr erwünscht
"Skript"
Alles anzeigen
Guude @all,
das Skript ist ansich selbsterklärend...
Ich nutze das PlugIn "EPGRefresh", was mir den EPG täglich zwischen 5.30 - 6.30 Uhr autom. aktualisiert. Danach kopiere ich die EPG-Datei auf ein NFS-Share und hole die Datei dann wiederum von anderen Receivern ab.
Verbesserungen oder Verbesserungsvorschläge sind wie immer sehr erwünscht
HTML-Quellcode
- #!/bin/sh
- # Schorschis EPG Backup: V1.0 / 2015/12/13
- #
- # USAGE:
- # epg_backup.sh OR epg_backup s --> SAVE EPG
- # epg_backup.sh g --> GET (overwrite) EPG
- #
- # CRON EXAMPLE SAVE EPG:
- # min hour day month dow command
- # 0 7 * * * /usr/script/epg_backup.sh > /tmp/epg_backup_save.log 2>&1
- #
- # CRON EXAMPLE GET EPG:
- # min hour day month dow command
- # 30 7 * * * /usr/script/epg_backup.sh g > /tmp/epg_backup_get.log 2>&1
- #
- # USER SETUP ***********************************************
- # epg filename:
- epgFilename='epg.dat'
- # target directory (without a trailing slash!)
- epgTgtDir='/media/autofs/timeshift'
- # END USER SETUP *******************************************
- # FUNCTIONS ************************************************
- # set PATH
- requiredPaths='/usr/bin /bin /sbin'
- function setPath() {
- for p in $1; do
- case ":$PATH:" in
- *":$p:"*)
- # dir already exist in PATH variable, do nothing
- ;;
- *)
- # add required dir to the PATH variable
- [ -d "$p" ] && PATH="$PATH:$p"
- ;;
- esac
- done
- }
- [ ! -z "$requiredPaths" ] && setPath "$requiredPaths"
- printOut() {
- echo $(date "+%d.%m.%Y %H:%M:%S")" - $1"
- }
- standBy() {
- if [ $standBy -eq 1 ]; then
- printOut "Switching receiver into standby mode..."
- WEBIF=0
- cnt=0
- until [ $WEBIF -eq 1 ]; do
- if [ $cnt -gt 12 ]; then
- # slept 2 minutes, break out...
- printOut "WARNING: WebIF is not started"
- break
- fi
- cnt=`expr $cnt + 1`
- # Web-Interface reachable?
- if [ $(wget -q -O - 'http://127.0.0.1' | grep -cim 1 "<html") = "0" ]; then
- printOut "WebIF is not reachable: Sleeping $cnt..."
- sleep 10
- else
- printOut "OK: WebIF is reachable, switching receiver into standby mode..."
- # PowerState: 0 = Toggle Standby; 1 = Deepstandby; 2 = Reboot; 3 = Restart Enigma2; 4 = Wakeup form Standby; 5 = Standby
- tmpV=`wget -O - -q http://127.0.0.1/web/powerstate?newstate=5 | grep "\(<\|</\)e2instandby" | tr -d '\n' | sed "s/.*<e2instandby>\(.*\)<\/e2instandby.*/\\1\n/"`
- WEBIF=1
- break
- fi
- done
- fi
- }
- # POWERSTATE?
- tmpV=`wget -O - -q http://127.0.0.1/web/powerstate | grep "\(<\|</\)e2instandby" | tr -d '\n' | sed "s/.*<e2instandby>\(.*\)<\/e2instandby.*/\\1\n/g" | sed "s/\s*//g"`
- if [ "$tmpV" = "false" ]; then
- standBy=0
- else
- standBy=1
- fi
- # EPG source directory
- epgSrcDir=`grep -m 1 "^config.misc.epgcachepath" /etc/enigma2/settings | cut -d "=" -f2 | sed "s/\s*//g" | sed "s/\/$//g"`
- # VALIDATION ***********************************************
- if [ ! -d "$epgTgtDir" ]; then
- printOut "ERROR: Target directory "$epgTgtDir" not found!"
- exit 1
- fi
- if [ ! -d "$epgSrcDir" ]; then
- printOut "ERROR: Source directory "$epgSrcDir" not found!"
- exit 1
- fi
- #if [ ! -s "$epgSrcDir/$epgFilename" ]; then
- # printOut "ERROR: EPG file "$epgSrcDir/$epgFilename" not found or file is empty!"
- # exit 1
- #fi
- # END VALIDATION *******************************************
- # SAVE EPG *************************************************
- if [ -z "$1" -o "$1" = "s" ]; then
- printOut "Saving EPG to $epgSrcDir/$epgFilename"
- # shutdown enigma2
- printOut "Shutdown Enigma2..."
- init 4
- # wait...
- sleep 3
- # check...
- if [ -s "$epgSrcDir/$epgFilename" ]; then
- cp -f "$epgSrcDir/$epgFilename" "$epgTgtDir/$epgFilename"
- fi
- tmpV=`find "$epgTgtDir/" -mmin -5 -type f -name "$epgFilename"`
- if [ "$tmpV" = "$epgTgtDir/$epgFilename" ]; then
- # ok, EPG file is younger then 5 minutes...
- printOut "$epgFilename successfully saved"
- else
- printOut "ERROR: Could not save $epgFilename to $epgTgtDir!"
- fi
- # startup enigma2
- printOut "Startup Enigma2..."
- init 3
- standBy
- fi
- # GET EPG **************************************************
- if [ ! -z "$1" -a "$1" = "g" ]; then
- printOut "Get EPG from $epgTgtDir/$epgFilename"
- tmpV=`find "$epgTgtDir/" -mmin -1440 -type f -name "$epgFilename"`
- if [ "$tmpV" = "$epgTgtDir/$epgFilename" ]; then
- # ok, EPG file is younger then 24 hours...
- # shutdown enigma2
- printOut "Shutdown Enigma2..."
- init 4
- # wait...
- sleep 3
- cp -f "$epgTgtDir/$epgFilename" "$epgSrcDir/$epgFilename"
- tmpV=`find "$epgSrcDir/" -mmin -1440 -type f -name "$epgFilename"`
- if [ "$tmpV" = "$epgSrcDir/$epgFilename" ]; then
- # ok, EPG file is younger then 24 hours...
- printOut "$epgFilename successfully saved"
- else
- printOut "ERROR: Could not save $epgFilename to $epgSrcDir!"
- fi
- # startup enigma2
- printOut "Startup Enigma2..."
- init 3
- standBy
- else
- printOut "ERROR: $epgTgtDir/$epgFilename is too old!"
- fi
- fi
- tmpV=`ls -lAh "$epgSrcDir/$epgFilename"`
- printOut "Current EPG file:"
- printOut "$tmpV"
- exit 0