From 384da89ebb8060c6c8f20aaffcf17e1feab56374 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Fri, 15 Jan 2016 19:23:33 +0000
Subject: LinHES-system: myth_mtc.cron: don't run optimize on frontend_only
 systems

myth_mtc.py: add --noidlecheck option to not check forsystem idle. This is probably wise to only use for testing.
---
 abs/core/LinHES-system/PKGBUILD      |  6 +++---
 abs/core/LinHES-system/myth_mtc.cron | 17 ++++++++++++-----
 abs/core/LinHES-system/myth_mtc.py   | 22 +++++++++++++++++-----
 3 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD
index 26fc453..5501add 100755
--- a/abs/core/LinHES-system/PKGBUILD
+++ b/abs/core/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-system
 pkgver=8.3
-pkgrel=23
+pkgrel=24
 arch=('i686' 'x86_64')
 install=system.install
 pkgdesc="Everything that makes LinHES an automated system"
@@ -84,7 +84,7 @@ md5sums=('76842f8cff548d2c1289e0992a8b84dd'
          'de32a1c50101265dd7f6ca5037f7a26a'
          '2d7b8414ddce5f401331342ac1529c22'
          '76b2637cac0452b3acdbeeb4e8a5474b'
-         'cd81693e73556ff09565799516e81554'
+         '8e5d224788154fea8639a37eecdaefd9'
          'dc3eef2a624754e16805d72bbe488b67'
          '617af86b901538817ebdcaf646248dc5'
          '542e670e78d117657f93141e9689f54d'
@@ -139,7 +139,7 @@ md5sums=('76842f8cff548d2c1289e0992a8b84dd'
          'eb879fee9603a05d5420d4ce8ed9e450'
          '02c810c2f47b7c4495fdacaf54189473'
          '1aac1872bf9569ea58ceb2f6f766a654'
-         '3a9fb38db8ad0736d85d5f85dbb948d7'
+         '1fb7b4badf30508b0a761a2ae7d7887d'
          '4d7164800122243be6513b29c8fc498e'
          'd14fdc38878c70011754317b0f2ea59e'
          '36bdfa8d877cea20ca3870faf08e08d5'
diff --git a/abs/core/LinHES-system/myth_mtc.cron b/abs/core/LinHES-system/myth_mtc.cron
index ff8e84a..6d70058 100755
--- a/abs/core/LinHES-system/myth_mtc.cron
+++ b/abs/core/LinHES-system/myth_mtc.cron
@@ -1,5 +1,6 @@
 #!/bin/bash
 MYTH_RUN_STATUS=1
+. /etc/systemconfig
 . /etc/profile
 
 date=`date +%Y-%m-%d`
@@ -31,13 +32,19 @@ then
 
     if ! grep -q "Finished Optimize" $logFile
     then
-        MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --optimize | $log
-        if [ $? = 0 ]
+        if [ $SystemType = Frontend_only ]
         then
-            echo "" | $log
+            echo "Will not run Optimize on Frontend Only systems." | $log
+            echo "Finished Optimize" | $log
         else
-            echo "Time Exceeded" | $log
-            exit
+            MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --optimize | $log
+            if [ $? = 0 ]
+            then
+                echo "" | $log
+            else
+                echo "Time Exceeded" | $log
+                exit
+            fi
         fi
     fi
 
diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py
index ee4fde2..e62592f 100755
--- a/abs/core/LinHES-system/myth_mtc.py
+++ b/abs/core/LinHES-system/myth_mtc.py
@@ -84,8 +84,20 @@ def bail_if_another_is_running():
 
 def run_stuff():
     print "\n%s" %get_timestamp()
-    if not subprocess.call(["/usr/bin/python2", "/usr/LH/bin/idle.py"]):
-        if ("--check_home" in sys.argv) or (len(sys.argv) == 1):
+
+    if (len(sys.argv) == 1) or ("--noidlecheck" in sys.argv) and (len(sys.argv) == 2):
+        runall = True
+    else:
+        runall = False
+
+    if ("--noidlecheck" in sys.argv):
+        print "No system idle check will be done."
+        idle = 0
+    else:
+        idle = subprocess.call(["/usr/bin/python2", "/usr/LH/bin/idle.py"])
+
+    if not idle:
+        if ("--check_home" in sys.argv) or runall:
             print "\n#######################################"
             print "\n%s Checking size of MythTV home" %(get_timestamp())
             if not check_home():
@@ -93,7 +105,7 @@ def run_stuff():
             else:
                 return True
 
-        if ("--optimize" in sys.argv) or (len(sys.argv) == 1):
+        if ("--optimize" in sys.argv) or runall:
             print "\n#######################################"
             print "\n%s Running Optimize" %(get_timestamp())
             if not optimize():
@@ -101,13 +113,13 @@ def run_stuff():
             else:
                 return True
 
-        if ("--backup" in sys.argv) or (len(sys.argv) == 1):
+        if ("--backup" in sys.argv) or runall:
             print "\n#######################################"
             print "\n%s Running Backup" %(get_timestamp())
             if not os.system('/usr/LH/bin/lh_system_backup_job'):
                 print "\nFinished Backup"
 
-        if ("--update" in sys.argv) or (len(sys.argv) == 1):
+        if ("--update" in sys.argv) or runall:
             print "\n#######################################"
             print "\n%s Running System Update" %(get_timestamp())
             if not os.system('/usr/LH/bin/lh_system_host_update'):
-- 
cgit v0.12

