From c0d6b85efd2c93411be26976412e0fd8924d62a0 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Thu, 8 Dec 2011 16:18:56 -0600
Subject: LinHES-config: move network module to top of the list.  When multiple
 modules are run and network is in the list, network will run first. -Add
 support for creating the .mythtv dir if it's not present -simple logic to
 catch an error if the network can not be reached, when checking for extra
 support for func,xymon.

---
 abs/core/LinHES-config/PKGBUILD        |  8 ++++----
 abs/core/LinHES-config/mv_common.py    | 19 +++++++++++++++++++
 abs/core/LinHES-config/mv_hostype.py   | 15 ++++++++++-----
 abs/core/LinHES-config/systemconfig.py |  9 ++++++++-
 4 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD
index 1f9f50b..42597bc 100644
--- a/abs/core/LinHES-config/PKGBUILD
+++ b/abs/core/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=2.3
-pkgrel=50
+pkgrel=51
 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev LinHes-config )
 pkgdesc="Install and configure your system"
 depends=('bc' 'libstatgrab'  'mysql-python' 'expect' 'curl' 'dnsutils' 'parted'
@@ -123,7 +123,7 @@ md5sums=('f6bca2af75ddb0902f0fa9ff4b6e4fd7'
          '3d1e4a119f38cff0498bf8a67e94e4b3'
          '71fd2d0d448fc2fcd15415a1beed7109'
          '5f3259afe031fda189edae41dd1458f0'
-         'c50dc0d6e103b16ccf8c41eb83991441'
+         'dc150c1e2c915a55a616d1af5bb1f6de'
          'b845de3e05c1734cce4b9ac5e8f1baaf'
          '4d0464a1bef1819f6f9c100609eb55ad'
          '5e69839659d65ddda35b8a9982dc29e9'
@@ -132,7 +132,7 @@ md5sums=('f6bca2af75ddb0902f0fa9ff4b6e4fd7'
          'fe5e31b833cc6707209e9d656b6eb53c'
          'f0988a801216b44c96bf17e24a23e3a9'
          '23d0e12b7ca1cc6ea6b993c1d7ff20b9'
-         '3deb6a41a6b4e9f4f125678fa26078c6'
-         '5e3e06b31c40fe6b0e74860a8137b720'
+         '952ddc53f1c1ceee2139888219ce1bdf'
+         '892ba04c504b9be04b2573d015382eae'
          '2596460462cf6c889cf8f95485537b20'
          'a63ff9ef5250965aeabc74bfa8e43981')
diff --git a/abs/core/LinHES-config/mv_common.py b/abs/core/LinHES-config/mv_common.py
index 0f78312..b5939f2 100755
--- a/abs/core/LinHES-config/mv_common.py
+++ b/abs/core/LinHES-config/mv_common.py
@@ -108,6 +108,25 @@ def link_file(srcfile,link_name):
 
     return
 
+def mkdir_mythhome(mythhome):
+     if not os.path.exists(mythhome+"/.mythtv"):
+        logging.debug("    Creating %s/.mythtv",mythhome)
+        try:
+            os.mkdir(mythhome+"/.mythtv")
+        except:
+            logging.debug("   Couldn't create .mythtv ")
+            return
+        try:
+            os.chown(mythhome+"/.mythtv", mythuid, mythgid)
+            logging.debug("*    Couldn't chown of %s", mythhome)
+        except:
+            cmd = ''' chown -R mythtv %s/.mythtv''' %mythhome
+            runcmd(cmd)
+            cmd = ''' chgrp -R mythtv %s/.mythtv''' %mythhome
+            runcmd(cmd)
+            pass
+
+
 
 def add_service(daemon):
     logging.info("    Adding service %s",daemon)
diff --git a/abs/core/LinHES-config/mv_hostype.py b/abs/core/LinHES-config/mv_hostype.py
index 9f26e57..bdc12f4 100755
--- a/abs/core/LinHES-config/mv_hostype.py
+++ b/abs/core/LinHES-config/mv_hostype.py
@@ -101,7 +101,7 @@ def setup_mysql_connection(systemconfig):
     dbhost = systemconfig.get("dbhost")
     uuid = gen_uuid()
     config_xml=generate_config_xml(uuid,dbhost)
-
+    mv_common.mkdir_mythhome(data_config.MYTHHOME)
 
 
     if systemtype == "Master_backend":
@@ -244,10 +244,15 @@ def hostypeprint(systemconfig):
     logging.info("______Start of hostype config_____")
 
     url = 'http://%s:1337/extra.cfg.txt' %systemconfig.get("dbhost")
-    ex = mv_common.config_extra_reader(url)
-    xymon_supported=ex.read_config('xymon')
-    rsyslog_network=ex.read_config('rsyslog_network')
-    func_supported=ex.read_config('func')
+    try:
+        ex = mv_common.config_extra_reader(url)
+        xymon_supported=ex.read_config('xymon')
+        rsyslog_network=ex.read_config('rsyslog_network')
+        func_supported=ex.read_config('func')
+    except:
+        xymon_supported=False
+        rsyslog_network=False
+        func_supported=False
 
     mv_common.services(systemconfig)
     install_list=''
diff --git a/abs/core/LinHES-config/systemconfig.py b/abs/core/LinHES-config/systemconfig.py
index 31d2164..aa94aec 100755
--- a/abs/core/LinHES-config/systemconfig.py
+++ b/abs/core/LinHES-config/systemconfig.py
@@ -92,9 +92,10 @@ def main(argv):
 
     if cmdmodule["all"]:
         logging.info("***    WILL RUN ALL MODULES   ***")
+        cmdmodule["network"] = True
         cmdmodule["hostype"] = True
         cmdmodule["ir"]= True
-        cmdmodule["network"] = True
+        #cmdmodule["network"] = True
         cmdmodule["audio"] = True
         cmdmodule["misc"] = True
         cmdmodule["sleep"] = True
@@ -107,6 +108,12 @@ def main(argv):
         cmdmodule["smolt"] = True
         cmdmodule["user"] = True
 
+    if cmdmodule["network"]:
+        restartfe = mv_network.setup_network(systemconfig, cmdmodule["this_is_install"])
+        if restartfe == True :
+            logging.debug("    Setting the frontend to restart due to network change")
+            cmdmodule["restartfe"] = True
+
 
     if cmdmodule["hostype"]:
         import mv_hostype
-- 
cgit v0.12

