diff options
author | James Meyer <james.meyer@operamail.com> | 2009-06-21 23:59:31 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2009-06-21 23:59:31 (GMT) |
commit | c9d85b81497f3036db26d3d481108072ba2ac560 (patch) | |
tree | 11fd73c4c6e54d35945424c765381ff1c00a56ec /abs/core-testing/LinHES-config/mv_hostype.py | |
parent | 1baf8111524169f6d9349223e7764a43e2525a1a (diff) | |
download | linhes_pkgbuild-c9d85b81497f3036db26d3d481108072ba2ac560.zip linhes_pkgbuild-c9d85b81497f3036db26d3d481108072ba2ac560.tar.gz linhes_pkgbuild-c9d85b81497f3036db26d3d481108072ba2ac560.tar.bz2 |
LinHES-config: several minor fixes and finish some functions that slipped through the cracks.
introduce remove_file
fix slave and fe only
finish mysql_network_connection
finish mysql_network
fix ownership for .mythtv ir mv_ir
fix myth_ip to always report the ip even if dhcp is used
Diffstat (limited to 'abs/core-testing/LinHES-config/mv_hostype.py')
-rwxr-xr-x | abs/core-testing/LinHES-config/mv_hostype.py | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/abs/core-testing/LinHES-config/mv_hostype.py b/abs/core-testing/LinHES-config/mv_hostype.py index 093ed5a..b3899ff 100755 --- a/abs/core-testing/LinHES-config/mv_hostype.py +++ b/abs/core-testing/LinHES-config/mv_hostype.py @@ -29,19 +29,80 @@ def remove_avahi_service(): if os.path.exists(file): logging.debug(" Removing avahi mysql.service file") cmd="rm -rf %s" %file - runcmd(cmd) + mv_common.runcmd(cmd) cmd="sudo sv restart avahi" mv_common.runcmd(cmd) def setup_db(): logging.debug(" Setting up the database") -def setup_mysqlnetwork(): +def setup_mysqlnetwork(EnableNetwork): logging.debug(" Setting up mysql network") + mysqlconf = "/etc/my.cnf" + cmd = '''grep "#skip-networking" %s ''' %mysqlconf + status = mv_common.runcmd(cmd) + + if EnableNetwork : + logging.debug(" Enabling mysql networking") + if status == 0 : + logging.debug(" Network is already enabled for mysql") + else: + cmd = '''sed -ie "s/^skip-networking/#skip-networking/g" %s ''' %mysqlconf + mv_common.runcmd(cmd) + mv_common.restart_service("mysqld") + else: + logging.debug(" Disabling mysql networking") + if status == 1 : + logging.debug(" Network is already disabled for mysql") + else: + cmd = '''sed -ie "s/#skip-networking/skip-networking/g" %s ''' %mysqlconf + mv_common.runcmd(cmd) + mv_common.restart_service("mysqld") + +def setup_mysql_connection(systemconfig): + logging.info(" Configuring database connection") + mythip = systemconfig["mythip"] + systemtype = systemconfig["SystemType"] + mv_root = systemconfig["MVROOT"] + mysqltxt = "/usr/share/mythtv/mysql.txt" + templates = systemconfig["TEMPLATES"] + mysqltemplate = templates + "/mysql.txt" + dbhost = systemconfig["dbhost"] + + if systemtype == "Master_backend": + logging.debug(" Setting dbhost to %s in systemconfig", mythip) + dbhost = mythip + cmd = '''sed -ei "s/^dbhost=.*$/dbhost=\"%s\"/" /etc/systemconfig ''' %dbhost + mv_common.runcmd(cmd) + 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) + mv_common.runcmd(cmd) + + if systemtype == "Slave_backend": + slavehost = mythip + logging.debug(" Changing slave in settings: %s", slavehost) + cmd = '''%s/bin/restore_default_settings.sh -c BECONFIG -s slave -a %s ''' %(mv_root, slavehost) + mv_common.runcmd(cmd) + + if systemtype == "Master_backend": + logging.debug(" changing mysql.txt file to use localhost") + cmd = '''sed -e "s/^DBHostName=.*$/DBHostName="localhost"/" %s > %s ''' %(mysqltemplate, mysqltxt) + 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) -def setup_mysql(): - logging.debug(" Configuring mysql") def setup_func_key(): if data_config.SYSTEMTYPE == "MythVantage": @@ -67,12 +128,14 @@ def hostypeprint(systemconfig): remove_list='' daemon_list='' daemon_remove_list='' + run_mysqlnetwork = False if systemconfig["SystemType"] == "Standalone": logging.info("Stand alone system being configured") setup_ntp(False,"null") remove_avahi_service() - setup_mysqlnetwork(False) + EnableNetwork = False + run_mysqlnetwork = True if systemconfig["hostypec"]: setup_db() install_list=("mysql", "mythdb-initial", "avahi", "portmap", "nfs-utils", "local-website", "myth2ipod", "mythtv-status") @@ -84,7 +147,8 @@ def hostypeprint(systemconfig): setup_avahi(systemconfig["TEMPLATES"]) install_list=("mysql", "mythdb-initial", "avahi", "portmap", "nfs-utils", "local-website", "myth2ipod", "mythtv-status") daemon_list=("mysql", "mythbackend", "avahi", "portmap", "nfs-utils", "netfs", "lighttpd") - setup_mysqlnetwork(True) + EnableNetwork = True + run_mysqlnetwork = True if data_config.SYSTEMTYPE == "MythVantage": install_list.append('func') install_list.append('certmaster') @@ -142,7 +206,12 @@ def hostypeprint(systemconfig): mv_common.remove_service("hal") - setup_mysql() + if run_mysqlnetwork: + setup_mysqlnetwork(EnableNetwork) + else: + logging.debug(" Not running setup_mysql_connection") + + setup_mysql_connection(systemconfig) if data_config.SYSTEMTYPE == "MythVantage": setup_func_minion(dbhost) setup_func_key() |