From b4cbf8341a0142ae3accedf7d1d4d9ae6b0e4060 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Tue, 5 Dec 2017 20:33:02 +0000
Subject: LinHES-config: systemconfig.py: change config_xml file location to
 /home/mythtv/.mythtv and link root and share.

myth_settings_wrapper.sh: add new mythtv 29 network setting

mv_install.py: start mysql eariler for master backend installs so systemconfig will correct BackendIP and BackendAddr.
---
 abs/core/LinHES-config/PKGBUILD                 |  8 +--
 abs/core/LinHES-config/mv_install.py            |  3 +-
 abs/core/LinHES-config/myth_settings_wrapper.sh |  6 ++
 abs/core/LinHES-config/systemconfig.py          | 74 +++++++++++--------------
 4 files changed, 44 insertions(+), 47 deletions(-)

diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD
index 1bf5b89..a296661 100755
--- a/abs/core/LinHES-config/PKGBUILD
+++ b/abs/core/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=8.5
-pkgrel=1
+pkgrel=2
 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'
@@ -141,7 +141,7 @@ package() {
     install -o root -g root  -D -m 0755 blacklist_nouveau.conf $pkgdir/etc/modprobe.d/blacklist_nouveau.conf
 }
 
-md5sums=('fe70208a7c11f7e2115655ad0004ddaf'
+md5sums=('518c868141fe443e9258144c029ed3f9'
          '51525188ac6f6034422c5d71d0c84408'
          'f6e9dd7bc6cf0aaa3bd203dab4cb79b9'
          '2596460462cf6c889cf8f95485537b20'
@@ -151,7 +151,7 @@ md5sums=('fe70208a7c11f7e2115655ad0004ddaf'
          'b1427dcdbba2ed2924a86a5a1d1cd6a3'
          '27e4fcacca9b9662dd782fbdc92fceea'
          '2a7f3b34e522acfd08283b86c8926aba'
-         'b596d2e3779a434435bc0f0277b1ba3e'
+         'da60447a2a5fe0e6f5aaed2e677281ef'
          '4239a837227ff97a24c5335de47ce029'
          'f0376c98a7986897406d393186c0365e'
          '157e73d0f90d7b306aba8f5921aeedd3'
@@ -180,7 +180,7 @@ md5sums=('fe70208a7c11f7e2115655ad0004ddaf'
          '0e1c98392887b6efcb3f8b04ead7c4f9'
          '3cb673adb83b6afa52cffaa621b9d96b'
          '781f161a79c3188a31c8615b8258b241'
-         'dc56af9523253917c9feee0f083b4781'
+         '44e32e7015612cbf5d9f6539f4b6799b'
          '6cb0aac63623a44463c4209862d2baa0'
          'cdd5008ee77e67c1d51ad73a24612485'
          '2596460462cf6c889cf8f95485537b20'
diff --git a/abs/core/LinHES-config/mv_install.py b/abs/core/LinHES-config/mv_install.py
index 11af990..f414942 100644
--- a/abs/core/LinHES-config/mv_install.py
+++ b/abs/core/LinHES-config/mv_install.py
@@ -1621,6 +1621,8 @@ def full_install(hostoptions):
         cmd = "chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT)
         runcmd(cmd)
 
+        mysqldb("start","chroot")
+
         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]
@@ -1629,7 +1631,6 @@ def full_install(hostoptions):
 
         #move_myth_home("backup")
 
-        mysqldb("start","chroot")
         double_mount()
         mysqldb("stop", "chroot")
 
diff --git a/abs/core/LinHES-config/myth_settings_wrapper.sh b/abs/core/LinHES-config/myth_settings_wrapper.sh
index 37d5e33..b20b6bc 100644
--- a/abs/core/LinHES-config/myth_settings_wrapper.sh
+++ b/abs/core/LinHES-config/myth_settings_wrapper.sh
@@ -230,6 +230,8 @@ case $OPERATION in
             then
                 define_xml ${IP_ADDRESS} $hostname settings BackendServerIP
                 load_xml $gen_xml
+                define_xml ${IP_ADDRESS} $hostname settings BackendServerAddr
+                load_xml $gen_xml
                 define_xml ${IP_ADDRESS} '' settings MasterServerIP
                 load_xml $gen_xml
 
@@ -239,6 +241,8 @@ case $OPERATION in
             then
                 define_xml ${IP_ADDRESS} $hostname settings BackendServerIP
                 load_xml $gen_xml
+                define_xml ${IP_ADDRESS} $hostname settings BackendServerAddr
+                load_xml $gen_xml
             fi
 
 
@@ -254,6 +258,8 @@ case $OPERATION in
             then
                 define_xml '' $hostname settings BackendServerIP
                 load_xml $gen_xml
+                define_xml '' $hostname settings BackendServerAddr
+                load_xml $gen_xml
             fi
 
 
diff --git a/abs/core/LinHES-config/systemconfig.py b/abs/core/LinHES-config/systemconfig.py
index ef5fef1..bd02408 100755
--- a/abs/core/LinHES-config/systemconfig.py
+++ b/abs/core/LinHES-config/systemconfig.py
@@ -1,6 +1,7 @@
 #!/usr/bin/python2
 # -*- coding: utf-8 -*-
 import sys,  os,  commands,  glob,  time
+from time import time, localtime, strftime
 import getopt,  re,  MySQLdb
 import logging
 import mv_common , mv_network
@@ -67,9 +68,9 @@ def setup_x(systemconfig):
     if  mv_common.read_config(mv_common.module_config,"xorg")  == False  :
         logging.info("____Skipping of Xorg, config disabled____")
     else:
-	if not os.path.exists('/usr/share/icons/default'):
-		if os.path.exists('/usr/share/icons/Vanilla-DMZ-AA'):
- 	            os.symlink('/usr/share/icons/Vanilla-DMZ-AA','/usr/share/icons/default');
+        if not os.path.exists('/usr/share/icons/default'):
+            if os.path.exists('/usr/share/icons/Vanilla-DMZ-AA'):
+                mv_common.link_file('/usr/share/icons/Vanilla-DMZ-AA','/usr/share/icons/default');
         if systemconfig.get("UseXLargeMouse") == "1" :
             cmd = "echo Xcursor.size: 48 > %s/.Xdefaults" %data_config.MYTHHOME
         else:
@@ -81,26 +82,8 @@ def setup_x(systemconfig):
 
 
 def generate_config_xml(uuid,dbhost):
-    #configxml_t ='''
-#<Configuration>
-  #<UPnP>
-    #<UDN>
-      #<MediaRenderer>%s</MediaRenderer>
-    #</UDN>
-    #<MythFrontend>
-      #<DefaultBackend>
-        #<DBHostName>%s</DBHostName>
-        #<DBUserName>mythtv</DBUserName>
-        #<DBPassword>mythtv</DBPassword>
-        #<DBName>mythconverg</DBName>
-        #<DBPort>0</DBPort>
-      #</DefaultBackend>
-    #</MythFrontend>
-  #</UPnP>
-#</Configuration>
-    #'''
     configxml_t='''
-    <Configuration>
+<Configuration>
   <LocalHostName>my-unique-identifier-goes-here</LocalHostName>
   <Database>
     <PingHost>1</PingHost>
@@ -136,11 +119,16 @@ def gen_uuid():
 
 def setup_config_xml(systemconfig):
     #setup mysql.txt and config.xml
-    logging.info("   setup config xml")
+    logging.info("   setup config.xml")
 
     mv_root = systemconfig.get("MVROOT")
     mysqltxt = "/usr/share/mythtv/mysql.txt"
-    configxml_file = "/usr/share/mythtv/config.xml"
+    #mythfrontend will delete and create config.xml in the mythhome dir
+    #this breaks the link to /usr/share/mythtv/config.xml and causes other
+    #users (root) to be out of sync mythtv user
+    configxml_file = data_config.MYTHHOME + "/.mythtv/config.xml"
+    configxml_share_link = "/usr/share/mythtv/config.xml"
+    configxml_root_link = "/root/.mythtv/config.xml"
 
     templates = systemconfig.get("TEMPLATES")
     mysqltemplate = templates + "/mysql.txt"
@@ -148,18 +136,29 @@ def setup_config_xml(systemconfig):
     uuid = gen_uuid()
     config_xml=generate_config_xml(uuid,dbhost)
     mv_common.mkdir_mythhome(data_config.MYTHHOME,"mythtv","mythtv")
-
-
+    mv_common.mkdir_mythhome("/root","root","root")
 
     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)
+
+    #backup config.xml files and delete
+    currenttime = strftime("%b-%d-%Y-%H:%M:%S", localtime())
+    for i in [ configxml_file , configxml_share_link, configxml_root_link ]:
+        if os.path.islink(i):
+            # path is a link, delete it
+            logging.info("    Removing link %s ", i)
+            mv_common.remove_file(i)
+        else:
+            # path is a file, backup and delete unless it is mythhome
+            if configxml_file != i:
+                cmd = "mv %s %s-%s" %(i,i,currenttime)
+                mv_common.runcmd_output(cmd)
+
+    #create config.xml
     try:
+        logging.info("    Writing %s", configxml_file)
         f = open(configxml_file,  'w')
 
         for outline in config_xml:
@@ -168,18 +167,9 @@ def setup_config_xml(systemconfig):
     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.remove_file(home_xml_file)
-    mv_common.link_file(configxml_file,home_xml_file)
-
-
-
-
+    #link /usr/share/mythtv/config.xml and /root/.mythtv/config.xml
+    mv_common.link_file(configxml_file,configxml_share_link)
+    mv_common.link_file(configxml_file,configxml_root_link)
 
 
 
-- 
cgit v0.12

