From 048e83695f2b4cb9ddc118e128a7d08f7d48e651 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sun, 23 Sep 2012 13:44:08 -0500
Subject: LinHES-config:  ensure that xymonserver is installed after upgrades. 
 This requires a --dbonly pacman call and then later a normal pacman install. 
  This was needed because after upgrades /home/xymon is still on the FS and
 the xymonserver package failed to to install because of it

---
 abs/core/LinHES-config/PKGBUILD           | 12 ++--
 abs/core/LinHES-config/mv_common.py       |  4 ++
 abs/core/LinHES-config/mv_hostype.py      | 91 +++++++++++++++++++++----------
 abs/core/LinHES-config/mv_install.py      |  2 +-
 abs/core/LinHES-config/mv_supplemental.py |  7 ++-
 abs/core/LinHES-config/systemconfig.py    |  2 +-
 6 files changed, 81 insertions(+), 37 deletions(-)

diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD
index a5b0db5..32b397c 100755
--- a/abs/core/LinHES-config/PKGBUILD
+++ b/abs/core/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=2.3
-pkgrel=141
+pkgrel=152
 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'
@@ -125,7 +125,7 @@ build() {
     install -o root -g root  -D -m 0755 blacklist_pcspkr.conf $startdir/pkg/etc/modprobe.d/blacklist_pcspkr.conf
     install -o root -g root  -D -m 0755 blacklist_nouveau.conf $startdir/pkg/etc/modprobe.d/blacklist_nouveau.conf
 }
-md5sums=('d27979591231e647f59c23ae18a3d37b'
+md5sums=('70ea19d41cf33ec8ae26c4e8cb5cd240'
          'f33e1a6f7985091b8d47cbaf7433f90f'
          '1afacd0337d95f140b2a1777c27f041a'
          '2596460462cf6c889cf8f95485537b20'
@@ -148,7 +148,7 @@ md5sums=('d27979591231e647f59c23ae18a3d37b'
          '3d1e4a119f38cff0498bf8a67e94e4b3'
          '71fd2d0d448fc2fcd15415a1beed7109'
          'af6b3c5ec0d974b3e19ff1ed50662ee5'
-         '65c2dad8748210c3c0098efab377c330'
+         'eff2543a8dd0fa13f10360d1594d823d'
          'b845de3e05c1734cce4b9ac5e8f1baaf'
          'e869e2c72212881db1e4fa40b116efe5'
          '8b7dce4a3a0a281fa6656aa8781a648e'
@@ -157,11 +157,11 @@ md5sums=('d27979591231e647f59c23ae18a3d37b'
          'fe5e31b833cc6707209e9d656b6eb53c'
          'ecb52b9b7a9ac0c8988093c1dfdda635'
          '23d0e12b7ca1cc6ea6b993c1d7ff20b9'
-         'cc5ee06e2182bb825ca3712a1c1afb64'
-         '919909f4d23b9ee3caf71193c042cc40'
+         '8f442cfe2574af3e4520a124e28fcd7c'
+         'b4900090d841d3e390cb840cf16afd85'
          '85101b79d1ee30bff8244c810828033f'
          '923197a517cb83d77263e8cea8b8c16a'
-         '60611c3f90dbaafde9c41421b2bf759d'
+         '6aef6f4484c45c5135b77199f63ab317'
          '2596460462cf6c889cf8f95485537b20'
          '4cba2bb55c6b8e27c57a6171f42d0455'
          '4804aa93aaad3dfcfff08cd9ffd68836'
diff --git a/abs/core/LinHES-config/mv_common.py b/abs/core/LinHES-config/mv_common.py
index a1b3bef..1cb761e 100755
--- a/abs/core/LinHES-config/mv_common.py
+++ b/abs/core/LinHES-config/mv_common.py
@@ -216,6 +216,10 @@ def pacinstall(pkg):
         pacinstall("dolphin-emu")
     elif pkg == "webonlinhes":
         pacinstall("web-on-linhes")
+    elif pkg == "xymonclient":
+        if os.path.exists('/home/xymon/client'):
+            cmd='''pacman --noconfirm --dbonly -Sddf xymonclient'''
+            mv_common.runcmd(cmd)
 
     if  not pkg_blacklist_check(pkg):
         if pkg_installed_check(pkg):
diff --git a/abs/core/LinHES-config/mv_hostype.py b/abs/core/LinHES-config/mv_hostype.py
index 2cbd97a..5655986 100755
--- a/abs/core/LinHES-config/mv_hostype.py
+++ b/abs/core/LinHES-config/mv_hostype.py
@@ -104,6 +104,34 @@ def setup_mysql_connection(systemconfig):
     mv_common.mkdir_mythhome(data_config.MYTHHOME,"mythtv","mythtv")
 
 
+
+    delfile = data_config.MYTHHOME + "/.mythtv/mysql.txt"
+    mv_common.remove_file(delfile)
+    delfile = mv_root + "/bin/mythtv/.mythtv/mysql.txt"
+    mv_common.remove_file(delfile)
+    filecheck = data_config.MYTHHOME + "/templates/mysql.txt"
+    if os.path.exists(filecheck):
+        logging.info("    Scrapping all the previous work and using %s for mysql.txt", filecheck)
+        mv_common.cp_and_log(filecheck, mysqltxt)
+    try:
+        f = open(configxml_file,  'w')
+
+        for outline in config_xml:
+            f.write(outline)
+        f.close()
+    except:
+        logging.debug("    Couldn't write config.xml")
+
+    home_xml_file=data_config.MYTHHOME + "/.mythtv/config.xml"
+    mv_common.link_file(configxml_file,home_xml_file)
+
+    #setup link for root user
+    mv_common.mkdir_mythhome("/root","root","root")
+    home_xml_file="/root/.mythtv/config.xml"
+    mv_common.link_file(configxml_file,home_xml_file)
+
+
+
     if systemtype == "Master_backend":
         logging.debug("    Setting dbhost to %s in systemconfig", mythip)
         dbhost = mythip
@@ -112,7 +140,8 @@ def setup_mysql_connection(systemconfig):
         logging.debug("    Changing dbhost in settings table for master_backend")
         #cmd = '''%s/bin/restore_default_settings.sh -c BECONFIG -s master -a %s ''' %(mv_root, dbhost)
         cmd = '''%s/bin/myth_settings_wrapper.sh -c BECONFIG -s master -a %s ''' %(mv_root, dbhost)
-        mv_common.runcmd(cmd)
+        b=mv_common.runcmd_output(cmd)
+        logging.debug(b)
         #mv_common.reloadfe(systemconfig.get("dbhost"),True)
 
     if systemtype == "Slave_backend":
@@ -120,7 +149,9 @@ def setup_mysql_connection(systemconfig):
         logging.debug("    Changing slave in settings: %s", slavehost)
         cmd = '''%s/bin/myth_settings_wrapper.sh -c BECONFIG -s slave -a %s ''' %(mv_root, slavehost)
         #cmd = '''%s/bin/restore_default_settings.sh -c BECONFIG -s slave  -a %s ''' %(mv_root, slavehost)
-        mv_common.runcmd(cmd)
+        b=mv_common.runcmd_output(cmd)
+        logging.debug(b)
+
 
     if systemtype == "Standalone":
         logging.debug("   changing mysql.txt file to use localhost")
@@ -130,36 +161,40 @@ def setup_mysql_connection(systemconfig):
         #mv_common.reloadfe(systemconfig.get("dbhost"),True)
 
         cmd = '''%s/bin/myth_settings_wrapper.sh -c BECONFIG -s standalone  ''' %(mv_root)
-        mv_common.runcmd(cmd)
+        b=mv_common.runcmd_output(cmd)
+        logging.debug(b)
+
         #mv_common.reloadfe(systemconfig.get("dbhost"),True)
 
         logging.debug("   Running beconfig a 2nd time")
         cmd = '''%s/bin/myth_settings_wrapper.sh -c BECONFIG -s standalone  ''' %(mv_root)
-        mv_common.runcmd(cmd)
-    else:
-        logging.debug("   changing mysql.txt file to use %s", dbhost)
-        cmd = '''sed -e "s/^DBHostName=.*$/DBHostName=%s/" %s > %s ''' %(dbhost, mysqltemplate, mysqltxt)
-        mv_common.runcmd(cmd)
-
-    delfile = data_config.MYTHHOME + "/.mythtv/mysql.txt"
-    mv_common.remove_file(delfile)
-    delfile = mv_root + "/bin/mythtv/.mythtv/mysql.txt"
-    mv_common.remove_file(delfile)
-    filecheck = data_config.MYTHHOME + "/templates/mysql.txt"
-    if os.path.exists(filecheck):
-        logging.info("    Scrapping all the previous work and using %s for mysql.txt", filecheck)
-        mv_common.cp_and_log(filecheck, mysqltxt)
-    try:
-        f = open(configxml_file,  'w')
-
-        for outline in config_xml:
-            f.write(outline)
-        f.close()
-    except:
-        logging.debug("    Couldn't write config.xml")
-
-    home_xml_file=data_config.MYTHHOME + "/.mythtv/config.xml"
-    mv_common.link_file(configxml_file,home_xml_file)
+        #mv_common.runcmd(cmd)
+        b=mv_common.runcmd_output(cmd)
+        logging.debug(b)
+    #else:
+        #logging.debug("   changing mysql.txt file to use %s", dbhost)
+        #cmd = '''sed -e "s/^DBHostName=.*$/DBHostName=%s/" %s > %s ''' %(dbhost, mysqltemplate, mysqltxt)
+        #mv_common.runcmd(cmd)
+
+    #delfile = data_config.MYTHHOME + "/.mythtv/mysql.txt"
+    #mv_common.remove_file(delfile)
+    #delfile = mv_root + "/bin/mythtv/.mythtv/mysql.txt"
+    #mv_common.remove_file(delfile)
+    #filecheck = data_config.MYTHHOME + "/templates/mysql.txt"
+    #if os.path.exists(filecheck):
+        #logging.info("    Scrapping all the previous work and using %s for mysql.txt", filecheck)
+        #mv_common.cp_and_log(filecheck, mysqltxt)
+    #try:
+        #f = open(configxml_file,  'w')
+
+        #for outline in config_xml:
+            #f.write(outline)
+        #f.close()
+    #except:
+        #logging.debug("    Couldn't write config.xml")
+
+    #home_xml_file=data_config.MYTHHOME + "/.mythtv/config.xml"
+    #mv_common.link_file(configxml_file,home_xml_file)
 
 
 
diff --git a/abs/core/LinHES-config/mv_install.py b/abs/core/LinHES-config/mv_install.py
index 54f4051..aa895da 100755
--- a/abs/core/LinHES-config/mv_install.py
+++ b/abs/core/LinHES-config/mv_install.py
@@ -1922,7 +1922,7 @@ def upgrade(hostoptions):
     mount_bind_chroot()
     #make symlink only..no need to double_mount as fstab should already have that, unless it's a clean upgrade
     double_mount(upgrade=True)
-    logging.info("Running systemconfig in chroot time")
+    logging.info("Running systemconfig in chroot")
     cmd = "chroot %s %s/bin/systemconfig.sh all,this_is_install" %(data_config.MOUNTPOINT, MVROOT)
     rc = runcmd(cmd)[0]
     if rc != 0 :
diff --git a/abs/core/LinHES-config/mv_supplemental.py b/abs/core/LinHES-config/mv_supplemental.py
index 608e997..2b8bd2f 100755
--- a/abs/core/LinHES-config/mv_supplemental.py
+++ b/abs/core/LinHES-config/mv_supplemental.py
@@ -31,7 +31,7 @@ def windowmanager(systemconfig):
     logging.info("__End of windowmanager \n")
 
 
-def supplemental(systemconfig):
+def supplemental(systemconfig,this_is_install = False):
     logging.info("____Start of supplemental config ____")
     try:
         supplemental=systemconfig.get("supplemental")
@@ -39,6 +39,11 @@ def supplemental(systemconfig):
         supplemental = "0"
     if supplemental == "1":
         logging.info("     Installing supplemental system\n")
+        if this_is_install == True:
+            if os.path.exists('/home/xymon/server'):
+                cmd='''pacman --noconfirm --dbonly -Sddf xymonserver'''
+                mv_common.runcmd(cmd)
+
         cmd='''/usr/LH/bin/install_supplemental_service.sh'''
         mv_common.runcmd(cmd)
     logging.info("__End of supplemental\n")
\ No newline at end of file
diff --git a/abs/core/LinHES-config/systemconfig.py b/abs/core/LinHES-config/systemconfig.py
index 73cb45b..59df527 100755
--- a/abs/core/LinHES-config/systemconfig.py
+++ b/abs/core/LinHES-config/systemconfig.py
@@ -275,7 +275,7 @@ def main(argv):
     if cmdmodule["supplemental"] or cmdmodule["this_is_install"]:
         import mv_supplemental
         mv_supplemental.windowmanager(systemconfig)
-        mv_supplemental.supplemental(systemconfig)
+        mv_supplemental.supplemental(systemconfig,cmdmodule["this_is_install"])
 
     if cmdmodule["vnc"]:
         import mv_vnc
-- 
cgit v0.12