summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/mv_hostype.py
diff options
context:
space:
mode:
authorCecil Hugh Watson <knoppmyth@gmail.com>2009-09-26 01:57:08 (GMT)
committerCecil Hugh Watson <knoppmyth@gmail.com>2009-09-26 01:57:08 (GMT)
commit7b29169fff9e7c624890c5edffe85def8a293136 (patch)
tree47753889faa3a2063b66d1c7e7681e703eb1b39a /abs/core/LinHES-config/mv_hostype.py
parentc491dea779dac29afff3578bf8245943817c2339 (diff)
downloadlinhes_pkgbuild-7b29169fff9e7c624890c5edffe85def8a293136.zip
linhes_pkgbuild-7b29169fff9e7c624890c5edffe85def8a293136.tar.gz
linhes_pkgbuild-7b29169fff9e7c624890c5edffe85def8a293136.tar.bz2
LinHES 6.01.00
Diffstat (limited to 'abs/core/LinHES-config/mv_hostype.py')
-rwxr-xr-xabs/core/LinHES-config/mv_hostype.py230
1 files changed, 230 insertions, 0 deletions
diff --git a/abs/core/LinHES-config/mv_hostype.py b/abs/core/LinHES-config/mv_hostype.py
new file mode 100755
index 0000000..d6ec0ed
--- /dev/null
+++ b/abs/core/LinHES-config/mv_hostype.py
@@ -0,0 +1,230 @@
+# -*- coding: utf-8 -*-
+import logging, mv_common
+import os
+
+config_file = "mv_config"
+data_config = __import__(config_file, globals(), locals(), [])
+
+def setup_ntp(usepool,ntpserver):
+ if usepool:
+ logging.info("Setting ntp server to %s",ntpserver)
+ print '''sed -i "s/pool.ntp.org/$dbhost/g" ${BASE}/etc/ntp.conf'''
+ else:
+ logging.info("Not changing ntp configuration")
+
+def setup_avahi(templates):
+ file="/etc/avahi/services/mysql.service"
+ if not os.path.exists(file):
+ logging.debug(" copying in mysql.service for avahi")
+ try:
+ os.makedirs("/etc/avahi/services")
+ except:
+ logging.debug(" Couldn't create /etc/avahi/services")
+ mv_common.cp_and_log(templates+"/mysql.service",file)
+ cmd="sudo sv restart avahi"
+ mv_common.runcmd(cmd)
+
+def remove_avahi_service():
+ file="/etc/avahi/services/mysql.service"
+ if os.path.exists(file):
+ logging.debug(" Removing avahi mysql.service file")
+ cmd="rm -rf %s" %file
+ 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(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_func_key():
+ if data_config.SYSTEMTYPE == "MythVantage":
+ logging.debug(" Grabbing the key for Func")
+ cmd="/usr/MythVantage/bin/grabkey.py"
+ mv_common.runcmd(cmd)
+
+def setup_func_minion(dbhost):
+ logging.info(" Setting up the func minion:")
+ logging.debug(" certmaster is %s:",dbhost)
+ #cmd='''sed -i "s/^certmaster.*$/certmaster = %s/" /etc/func/minion.conf ''' %dbhost
+ #mv_common.runcmd(cmd)
+ cmd='''sed -i "s/^certmaster.*$/certmaster = %s/" /etc/certmaster/minion.conf ''' %dbhost
+ mv_common.runcmd(cmd)
+
+def setup_syslog(dbhost):
+ logging.debug(" Setting syslog to log to %s",dbhost)
+ cmd ='''sed -i "s/^destination d_remote.*$/destination d_remote \{tcp\(\"%s\" port\(514\)\) \;\} \;/" /etc/syslog-ng.conf''' %dbhost
+ return
+
+def hostypeprint(systemconfig):
+ logging.info("______Start of hostype config_____")
+ mv_common.services(systemconfig)
+ install_list=''
+ 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()
+ EnableNetwork = False
+ run_mysqlnetwork = True
+ if systemconfig["hostypec"]:
+ setup_db()
+ install_list=["mysql", "mythdb-initial", "avahi", "portmap", "nfs-utils", "local-website", "myth2ipod", "mythtv-status"]
+ daemon_list=["mysql", "mythbackend", "avahi", "portmap", "nfs-utils", "netfs", "lighttpd"]
+ if data_config.SYSTEMTYPE == "MythVantage":
+ install_list.append('ghosd')
+
+ elif systemconfig["SystemType"] == "Master_backend":
+ logging.info("Master backend system being configured")
+ setup_ntp(False,"null")
+ 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"]
+ EnableNetwork = True
+ run_mysqlnetwork = True
+ if data_config.SYSTEMTYPE == "MythVantage":
+ install_list.append('func')
+ daemon_list.append('func')
+ install_list.append('certmaster')
+ daemon_list.append('certmaster')
+ install_list.append('ghosd')
+
+ elif systemconfig["SystemType"] == "Slave_backend":
+ logging.info("Slave backend system being configured")
+ setup_ntp(True,systemconfig["dbhost"])
+ remove_avahi_service()
+ if systemconfig["hostypec"]:
+ setup_db()
+ install_list = ["portmap", "nfs-utils", "local-website", "avahi", "libmysqlclient" ]
+ daemon_list = ["mythbackend", "portmap", "nfs-utils", "netfs", "lighttpd", "avahi" ]
+ daemon_remove_list=('mysql')
+ if data_config.SYSTEMTYPE == "MythVantage":
+ install_list.remove("local-website")
+ daemon_list.remove("lighttpd")
+ install_list.append('func')
+ daemon_list.append('funcd')
+ remove_list.append("lighttpd")
+ install_list.append('ghosd')
+
+
+ elif systemconfig["SystemType"] == "Frontend_only":
+ logging.info("Frontend only system being configured")
+ setup_ntp(True,systemconfig["dbhost"])
+ remove_avahi_service()
+ install_list=["mysql-clients", "libmysqlclient", "avahi", "portmap", "nfs-utils", "local-website"]
+ remove_list=["mysql"]
+ daemon_list=["mysql", "mythbackend", "avahi", "portmap", "nfs-utils", "netfs", "lighttpd"]
+ daemon_remove_list=("mysql", "mythbackend")
+ if data_config.SYSTEMTYPE == "MythVantage":
+ install_list.remove("local-website")
+ daemon_list.remove("lighttpd")
+ install_list.append('func')
+ daemon_list.append('funcd')
+ remove_list.append("lighttpd")
+ install_list.append('ghosd')
+
+
+ for pkg in install_list:
+ mv_common.pacinstall(pkg)
+ for pkg in remove_list:
+ mv_common.pacinstall(pkg)
+ for daemon in daemon_list:
+ mv_common.add_service(daemon)
+ for daemon in daemon_remove_list:
+ mv_common.remove_service(daemon)
+ if systemconfig["RunFrontend"] == "1":
+ logging.debug(" Will run the frontend")
+ mv_common.add_service("frontend")
+ mv_common.add_service("hal")
+ if data_config.SYSTEMTYPE == "MythVantage":
+ mv_common.add_service("ghosd")
+ else:
+ logging.debug(" Will NOT run the frontend")
+ mv_common.remove_service("frontend")
+ mv_common.remove_service("hal")
+ if data_config.SYSTEMTYPE == "MythVantage":
+ mv_common.remove_service("ghosd")
+
+
+ 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(systemconfig["dbhost"])
+ setup_func_key()
+ setup_syslog(systemconfig["dbhost"])
+ logging.info("__End of hostype config\n")