diff options
author | Britney Fransen <brfransen@gmail.com> | 2015-02-04 22:21:37 (GMT) |
---|---|---|
committer | Britney Fransen <brfransen@gmail.com> | 2015-02-04 22:21:37 (GMT) |
commit | f398554642cf0eea2331762687a4e85c916909af (patch) | |
tree | d8b79dd06bb498cadf2fd24ef21234dce00ecc73 /abs | |
parent | b96ea1f1faba3420cd4a07f172e664146e8c1d31 (diff) | |
download | linhes_pkgbuild-f398554642cf0eea2331762687a4e85c916909af.zip linhes_pkgbuild-f398554642cf0eea2331762687a4e85c916909af.tar.gz linhes_pkgbuild-f398554642cf0eea2331762687a4e85c916909af.tar.bz2 |
LinHES-system: myth_mtc improvments
Diffstat (limited to 'abs')
-rwxr-xr-x | abs/core/LinHES-system/PKGBUILD | 6 | ||||
-rwxr-xr-x | abs/core/LinHES-system/myth_mtc.cron | 49 | ||||
-rwxr-xr-x | abs/core/LinHES-system/myth_mtc.py | 31 |
3 files changed, 63 insertions, 23 deletions
diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 9fdc47b..2f77eaf 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system pkgver=8.3 -pkgrel=3 +pkgrel=4 arch=('i686' 'x86_64') install=system.install pkgdesc="Everything that makes LinHES an automated system" @@ -80,7 +80,7 @@ md5sums=('8415c4b2587a8a1e6a312484c1edafcb' 'de32a1c50101265dd7f6ca5037f7a26a' '301884fb60521627fffd1160b2cf5181' '76b2637cac0452b3acdbeeb4e8a5474b' - '0149e77a12d30f1050dd3990f6f1f123' + 'bfd41a145bec93270e21ad8d51662c48' 'dc3eef2a624754e16805d72bbe488b67' '617af86b901538817ebdcaf646248dc5' '542e670e78d117657f93141e9689f54d' @@ -132,7 +132,7 @@ md5sums=('8415c4b2587a8a1e6a312484c1edafcb' '410795ef9039e4c6c0484e706ecfd567' 'eb879fee9603a05d5420d4ce8ed9e450' '02c810c2f47b7c4495fdacaf54189473' - 'fae4162988de9525ba3f9341e17f9c52' + '4559a466e2dd2141308bd44f7794e837' '474d5c6883fcfffae4f199aceb3b1356' '8fe800181dcdf45bb7d7b36e4de8409e' '36bdfa8d877cea20ca3870faf08e08d5' diff --git a/abs/core/LinHES-system/myth_mtc.cron b/abs/core/LinHES-system/myth_mtc.cron index 4f63dec..637c0d6 100755 --- a/abs/core/LinHES-system/myth_mtc.cron +++ b/abs/core/LinHES-system/myth_mtc.cron @@ -4,20 +4,55 @@ MYTH_RUN_STATUS=1 date=`date +%Y-%m-%d` timestamp=`date +'%Y-%m-%d %H:%M'` -logFile="/var/log/$date/myth_mtc.log" +hostname=`hostname` +logFile="/var/log/${date}/${hostname}_myth_mtc.log" if [ ! -f $logFile ]; then touch $logFile + echo "" | logger -t myth_mtc fi #check logfile for Finished and if not run myth_mtc.py -if ! grep -q "Finished" $logFile +if ! grep -q "Finished Maintenance" $logFile then - MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py >> $logFile 2>&1 - if [ $? = 0 ] + if ! grep -q "Finished Optimize" $logFile then - echo "Finished $timestamp" >> $logFile - else - echo "Time Exceeded $timestamp" >> $logFile + MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --optimize | logger -t myth_mtc + if [ $? = 0 ] + then + echo "" | logger -t myth_mtc + else + echo "Time Exceeded" | logger -t myth_mtc + exit + fi + fi + + if ! grep -q "Finished Backup" $logFile + then + MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --backup | logger -t myth_mtc + if [ $? = 0 ] + then + echo "" | logger -t myth_mtc + else + echo "Time Exceeded" | logger -t myth_mtc + exit + fi + fi + + if ! grep -q "Finished Update" $logFile + then + MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --update | logger -t myth_mtc + if [ $? = 0 ] + then + echo "" | logger -t myth_mtc + else + echo "Time Exceeded" | logger -t myth_mtc + exit + fi + fi + + if grep -q "Finished Optimize" $logFile && grep -q "Finished Backup" $logFile && grep -q "Finished Update" $logFile + then + echo "Finished Maintenance" | logger -t myth_mtc fi fi diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py index b1ec75d..dcb3886 100755 --- a/abs/core/LinHES-system/myth_mtc.py +++ b/abs/core/LinHES-system/myth_mtc.py @@ -1,13 +1,11 @@ #!/usr/bin/python2 import sys, subprocess -import optparse import re import socket import os import datetime,time import shlex sys.dont_write_bytecode = True -import idle try: from MythTV import MythBE @@ -30,7 +28,7 @@ def optimize(): result = cursor.fetchall() except: print "\n%s Problem getting tables from the database" %(get_timestamp()) - return + return 1 ops=["REPAIR","OPTIMIZE","ANALYZE"] for row in result: ctable=row[0] @@ -38,6 +36,7 @@ def optimize(): print " %s %s" %(op,ctable) cmd= "%s table %s" %(op,ctable) cursor.execute(cmd) + return 0 def cleanup_inuseprograms(): fourHoursAgo=datetime.datetime.today() - datetime.timedelta(hours=4) @@ -60,18 +59,24 @@ def bail_if_another_is_running(): def run_stuff(): print "\n%s" %get_timestamp() - if idle.main(): - print "\n#######################################" - print "\n%s Running Optimize" %(get_timestamp()) - optimize() + if not subprocess.call(["/usr/bin/python2", "/usr/LH/bin/idle.py"]): + if ("--optimize" in sys.argv) or (len(sys.argv) == 1): + print "\n#######################################" + print "\n%s Running Optimize" %(get_timestamp()) + if not optimize(): + print "\nFinished Optimize" - print "\n#######################################" - print "\n%s Running Backup" %(get_timestamp()) - os.system('/usr/LH/bin/lh_system_backup_job') + if ("--backup" in sys.argv) or (len(sys.argv) == 1): + print "\n#######################################" + print "\n%s Running Backup" %(get_timestamp()) + if not os.system('/usr/LH/bin/lh_system_backup_job'): + print "\nFinished Backup" - print "\n#######################################" - print "\n%s Running System Update" %(get_timestamp()) - os.system('/usr/LH/bin/lh_system_host_update') + if ("--update" in sys.argv) or (len(sys.argv) == 1): + print "\n#######################################" + print "\n%s Running System Update" %(get_timestamp()) + if not os.system('/usr/LH/bin/lh_system_host_update'): + print "\nFinished Update" print "\n#######################################" continue_loop=False |