From fa3e0f88f1a55d88f522d770e0e8386efe924825 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sat, 17 Jan 2009 17:09:38 -0600
Subject: backport of timezip.py from mv->linhes

remove BECONFIG from running during the db_chroot process, as it already runs during systemconfig.
---
 abs/core-testing/LinHES-config/PKGBUILD            |  2 +-
 .../LinHES-config/install_db_chroot.sh             |  9 ++--
 abs/core-testing/LinHES-config/systemconfig.sh     |  2 +
 abs/core-testing/LinHES-config/timezip.py          | 50 +++++++++++++++++++---
 4 files changed, 53 insertions(+), 10 deletions(-)

diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index ef13c04..ff8612c 100755
--- a/abs/core-testing/LinHES-config/PKGBUILD
+++ b/abs/core-testing/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=1.0
-pkgrel=194
+pkgrel=197
 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev )
 pkgdesc="Install and configure your system"
 depends=(bc libstatgrab  mysql-python expect curl dnsutils parted sg3_utils nmbscan )
diff --git a/abs/core-testing/LinHES-config/install_db_chroot.sh b/abs/core-testing/LinHES-config/install_db_chroot.sh
index 5dcef79..94305d2 100755
--- a/abs/core-testing/LinHES-config/install_db_chroot.sh
+++ b/abs/core-testing/LinHES-config/install_db_chroot.sh
@@ -35,10 +35,7 @@ do
             DISPLAY=127.0.0.1:0  $MV_ROOT/bin/MythVantage  -t  restore,default_1
             $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings
             $MV_ROOT/bin/systemconfig.sh misc,hostype,this_is_install
-            if [ $SystemType = "Master_backend" ]
-            then
-                $MV_ROOT/bin/restore_default_settings.sh  -c  BECONFIG  -s master  -a $dbhost
-            fi
+
             update_db_settings HostServiceMythWEB "1"
             echo 'UseMythWEB="1"' >> /etc/systemconfig
 
@@ -52,6 +49,10 @@ do
          #   pacman --noconfirm --nodeps  -S webcalendar
 	    status=0
 	   fi
+#        if [ $SystemType = "Master_backend" ]
+#        then
+#             $MV_ROOT/bin/restore_default_settings.sh  -c  BECONFIG  -s master  -a $dbhost
+#        fi
    	fi
     fi
 done
diff --git a/abs/core-testing/LinHES-config/systemconfig.sh b/abs/core-testing/LinHES-config/systemconfig.sh
index 66ef9cd..59b5cef 100755
--- a/abs/core-testing/LinHES-config/systemconfig.sh
+++ b/abs/core-testing/LinHES-config/systemconfig.sh
@@ -58,6 +58,7 @@ function cp_and_log () {
 
 function setupmysql  {
 #setup mysql.txt to find the database servers
+echo "running setup mysql"
         if [ $SystemType = "Master_backend" ]
         then
             if [ $MYTHDHCP = 0 ]
@@ -68,6 +69,7 @@ function setupmysql  {
                 sed -e "s/^dbhost=.*$/dbhost=\"$dbhost\"/" /etc/systemconfig >/tmp/systemconfig.old
                 cp_and_log /tmp/systemconfig.old ${BASE}/etc/systemconfig
                 ##logic to change master_serverip and backend_serverip  in db
+
                 ${BASE}${MV_ROOT}/bin/restore_default_settings.sh  -c BECONFIG -s master -a $dbhost
             else
 
diff --git a/abs/core-testing/LinHES-config/timezip.py b/abs/core-testing/LinHES-config/timezip.py
index ad9bbd0..18f338f 100755
--- a/abs/core-testing/LinHES-config/timezip.py
+++ b/abs/core-testing/LinHES-config/timezip.py
@@ -20,6 +20,8 @@ def printvars():
     print "BEhostname:" + BEhostname
     print "zipcode:" + zipcode
     print "timezone:" + tz
+    print "timezone region:" + tz_region
+    print "timezone subregion:" + tz_subregion
     print "nfsip:" + nfsip
     print "nfstoggle:" + nfstoggle
     print "nfsmount:"  + nfsmount
@@ -30,6 +32,8 @@ def selectvars():
     global BEhostname
     global zipcode
     global tz
+    global tz_region
+    global tz_subregion
     global nfsip
     global nfstoggle
     global nfsmount
@@ -41,10 +45,7 @@ def selectvars():
     # execute SQL statement
     cursor.execute("select hostname from settings where value='BackendServerIP' and data=(%s)",(masterdb))
     result = cursor.fetchone()
-    try:
-        BEhostname=result[0]
-    except TypeError:
-        BEhostname=""
+    BEhostname=result[0]
 
     cursor.execute("select data from settings where value='HostZipcode' and hostname=(%s)",(BEhostname))
     result = cursor.fetchone()
@@ -80,14 +81,29 @@ def selectvars():
         tz=result[0]
     except TypeError:
         tz=""
+##########
+    cursor.execute("select data from settings where value='HostTimeZoneRegion' and hostname=(%s)",(BEhostname))
+    result = cursor.fetchone()
+    try:
+        tz_region=result[0]
+    except TypeError:
+        tz=""
+    tempsubregion="HostTimeZoneRegion_" + tz_region
 
+    cursor.execute("select data from settings where value=%s and hostname=(%s)",(tempsubregion,BEhostname))
+    result = cursor.fetchone()
+    try:
+        tz_subregion=result[0]
+    except TypeError:
+        tz_subregion=""
+###############
     if  ( thishostname != BEhostname ):
         cursor.execute("select data from settings where value='GlobalServiceHobbitserver'")
         result = cursor.fetchone()
         try:
             hobbitclient=result[0]
         except TypeError:
-            hobbitclient="0"
+            hobbitclient="1"
 
 
 
@@ -117,6 +133,27 @@ def insertvars():
             cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostTimeZone'",(tz,thishostname))
             print "updating timezone"
 
+    cursor.execute("select *  from settings where value='HostTimeZoneRegion' and hostname=(%s)",(thishostname))
+    result = cursor.fetchone()
+    if ( tz != ""):
+         if (result == None):
+            cursor.execute("INSERT INTO  settings (value,data,hostname) VALUES ('HostTimeZoneRegion',(%s),(%s))",(tz_region,thishostname))
+            print "inserting timezone region"
+         else:
+            cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostTimeZoneRegion'",(tz_region,thishostname))
+            print "updating timezone region"
+
+    tempsubregion="HostTimeZoneRegion_" + tz_region
+    cursor.execute("select *  from settings where value=%s and hostname=(%s)",(tempsubregion,thishostname))
+    result = cursor.fetchone()
+    if ( tz != ""):
+         if (result == None):
+            cursor.execute("INSERT INTO  settings (value,data,hostname) VALUES ((%s),(%s),(%s))",(tempsubregion,tz_subregion,thishostname))
+            print "inserting timezone subregion"
+         else:
+            cursor.execute("update settings set data=(%s) where hostname=(%s) and value=(%s)",(tempsubregion,tz_subregion,thishostname))
+            print "updating timezone subregion"
+
 
 #start of NFSIP
     cursor.execute("select data from settings where value='HostCentralNFSIP' and hostname=(%s)",(thishostname))
@@ -160,6 +197,9 @@ def main(argv):
     global BEhostname
     global zipcode
     global tz
+    global tz_region
+    global tz_subregion
+
     global nfsip
     global hobbitclient
     try:
-- 
cgit v0.12

