EPG-Backup

    • 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"

      HTML-Quellcode

      1. #!/bin/sh
      2. # Schorschis EPG Backup: V1.0 / 2015/12/13
      3. #
      4. # USAGE:
      5. # epg_backup.sh OR epg_backup s --> SAVE EPG
      6. # epg_backup.sh g --> GET (overwrite) EPG
      7. #
      8. # CRON EXAMPLE SAVE EPG:
      9. # min hour day month dow command
      10. # 0 7 * * * /usr/script/epg_backup.sh > /tmp/epg_backup_save.log 2>&1
      11. #
      12. # CRON EXAMPLE GET EPG:
      13. # min hour day month dow command
      14. # 30 7 * * * /usr/script/epg_backup.sh g > /tmp/epg_backup_get.log 2>&1
      15. #
      16. # USER SETUP ***********************************************
      17. # epg filename:
      18. epgFilename='epg.dat'
      19. # target directory (without a trailing slash!)
      20. epgTgtDir='/media/autofs/timeshift'
      21. # END USER SETUP *******************************************
      22. # FUNCTIONS ************************************************
      23. # set PATH
      24. requiredPaths='/usr/bin /bin /sbin'
      25. function setPath() {
      26. for p in $1; do
      27. case ":$PATH:" in
      28. *":$p:"*)
      29. # dir already exist in PATH variable, do nothing
      30. ;;
      31. *)
      32. # add required dir to the PATH variable
      33. [ -d "$p" ] && PATH="$PATH:$p"
      34. ;;
      35. esac
      36. done
      37. }
      38. [ ! -z "$requiredPaths" ] && setPath "$requiredPaths"
      39. printOut() {
      40. echo $(date "+%d.%m.%Y %H:%M:%S")" - $1"
      41. }
      42. standBy() {
      43. if [ $standBy -eq 1 ]; then
      44. printOut "Switching receiver into standby mode..."
      45. WEBIF=0
      46. cnt=0
      47. until [ $WEBIF -eq 1 ]; do
      48. if [ $cnt -gt 12 ]; then
      49. # slept 2 minutes, break out...
      50. printOut "WARNING: WebIF is not started"
      51. break
      52. fi
      53. cnt=`expr $cnt + 1`
      54. # Web-Interface reachable?
      55. if [ $(wget -q -O - 'http://127.0.0.1' | grep -cim 1 "<html") = "0" ]; then
      56. printOut "WebIF is not reachable: Sleeping $cnt..."
      57. sleep 10
      58. else
      59. printOut "OK: WebIF is reachable, switching receiver into standby mode..."
      60. # PowerState: 0 = Toggle Standby; 1 = Deepstandby; 2 = Reboot; 3 = Restart Enigma2; 4 = Wakeup form Standby; 5 = Standby
      61. tmpV=`wget -O - -q http://127.0.0.1/web/powerstate?newstate=5 | grep "\(<\|</\)e2instandby" | tr -d '\n' | sed "s/.*<e2instandby>\(.*\)<\/e2instandby.*/\\1\n/"`
      62. WEBIF=1
      63. break
      64. fi
      65. done
      66. fi
      67. }
      68. # POWERSTATE?
      69. 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"`
      70. if [ "$tmpV" = "false" ]; then
      71. standBy=0
      72. else
      73. standBy=1
      74. fi
      75. # EPG source directory
      76. epgSrcDir=`grep -m 1 "^config.misc.epgcachepath" /etc/enigma2/settings | cut -d "=" -f2 | sed "s/\s*//g" | sed "s/\/$//g"`
      77. # VALIDATION ***********************************************
      78. if [ ! -d "$epgTgtDir" ]; then
      79. printOut "ERROR: Target directory "$epgTgtDir" not found!"
      80. exit 1
      81. fi
      82. if [ ! -d "$epgSrcDir" ]; then
      83. printOut "ERROR: Source directory "$epgSrcDir" not found!"
      84. exit 1
      85. fi
      86. #if [ ! -s "$epgSrcDir/$epgFilename" ]; then
      87. # printOut "ERROR: EPG file "$epgSrcDir/$epgFilename" not found or file is empty!"
      88. # exit 1
      89. #fi
      90. # END VALIDATION *******************************************
      91. # SAVE EPG *************************************************
      92. if [ -z "$1" -o "$1" = "s" ]; then
      93. printOut "Saving EPG to $epgSrcDir/$epgFilename"
      94. # shutdown enigma2
      95. printOut "Shutdown Enigma2..."
      96. init 4
      97. # wait...
      98. sleep 3
      99. # check...
      100. if [ -s "$epgSrcDir/$epgFilename" ]; then
      101. cp -f "$epgSrcDir/$epgFilename" "$epgTgtDir/$epgFilename"
      102. fi
      103. tmpV=`find "$epgTgtDir/" -mmin -5 -type f -name "$epgFilename"`
      104. if [ "$tmpV" = "$epgTgtDir/$epgFilename" ]; then
      105. # ok, EPG file is younger then 5 minutes...
      106. printOut "$epgFilename successfully saved"
      107. else
      108. printOut "ERROR: Could not save $epgFilename to $epgTgtDir!"
      109. fi
      110. # startup enigma2
      111. printOut "Startup Enigma2..."
      112. init 3
      113. standBy
      114. fi
      115. # GET EPG **************************************************
      116. if [ ! -z "$1" -a "$1" = "g" ]; then
      117. printOut "Get EPG from $epgTgtDir/$epgFilename"
      118. tmpV=`find "$epgTgtDir/" -mmin -1440 -type f -name "$epgFilename"`
      119. if [ "$tmpV" = "$epgTgtDir/$epgFilename" ]; then
      120. # ok, EPG file is younger then 24 hours...
      121. # shutdown enigma2
      122. printOut "Shutdown Enigma2..."
      123. init 4
      124. # wait...
      125. sleep 3
      126. cp -f "$epgTgtDir/$epgFilename" "$epgSrcDir/$epgFilename"
      127. tmpV=`find "$epgSrcDir/" -mmin -1440 -type f -name "$epgFilename"`
      128. if [ "$tmpV" = "$epgSrcDir/$epgFilename" ]; then
      129. # ok, EPG file is younger then 24 hours...
      130. printOut "$epgFilename successfully saved"
      131. else
      132. printOut "ERROR: Could not save $epgFilename to $epgSrcDir!"
      133. fi
      134. # startup enigma2
      135. printOut "Startup Enigma2..."
      136. init 3
      137. standBy
      138. else
      139. printOut "ERROR: $epgTgtDir/$epgFilename is too old!"
      140. fi
      141. fi
      142. tmpV=`ls -lAh "$epgSrcDir/$epgFilename"`
      143. printOut "Current EPG file:"
      144. printOut "$tmpV"
      145. exit 0
      Alles anzeigen

      Beste Grüße
      Schorsch

      ------------------------------------------------------------
      OSCam-Config