summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/mv_hostype.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2011-12-07 19:31:23 (GMT)
committerJames Meyer <james.meyer@operamail.com>2011-12-07 19:31:23 (GMT)
commiteb5fd1b1e7dfc1e909e0f941bb7717bd6d9271a3 (patch)
tree73a81b02c746dfb2c24058e61d6ce752b226c1b7 /abs/core/LinHES-config/mv_hostype.py
parent711e8aa3f3b8ee301550227b285ee3593e304564 (diff)
downloadlinhes_pkgbuild-eb5fd1b1e7dfc1e909e0f941bb7717bd6d9271a3.zip
linhes_pkgbuild-eb5fd1b1e7dfc1e909e0f941bb7717bd6d9271a3.tar.gz
linhes_pkgbuild-eb5fd1b1e7dfc1e909e0f941bb7717bd6d9271a3.tar.bz2
LinHES-config: - Add ability to poll the MBE to see if xymon & fun is supported.
- If a new feature is supported, install the client - Create config.xml in /usr/share/mythtv and symlink it into mythtv home dir. - setup a network enabled rsyslog - For new installs fix fstab to include ACL's
Diffstat (limited to 'abs/core/LinHES-config/mv_hostype.py')
-rwxr-xr-xabs/core/LinHES-config/mv_hostype.py203
1 files changed, 176 insertions, 27 deletions
diff --git a/abs/core/LinHES-config/mv_hostype.py b/abs/core/LinHES-config/mv_hostype.py
index fd04a18..9f26e57 100755
--- a/abs/core/LinHES-config/mv_hostype.py
+++ b/abs/core/LinHES-config/mv_hostype.py
@@ -59,15 +59,50 @@ def setup_mysqlnetwork(EnableNetwork):
mv_common.runcmd(cmd)
mv_common.restart_service("mysqld")
+
+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= configxml_t %(uuid,dbhost)
+ return configxml
+
+def gen_uuid():
+ cmd = "/usr/bin/uuidgen"
+ uuid = mv_common.runcmd_output(cmd)
+ return uuid
+
def setup_mysql_connection(systemconfig):
+ #setup mysql.txt and config.xml
logging.info(" Configuring database connection")
mythip = systemconfig.get("mythip")
systemtype = systemconfig.get("SystemType")
mv_root = systemconfig.get("MVROOT")
mysqltxt = "/usr/share/mythtv/mysql.txt"
+ configxml_file = "/usr/share/mythtv/config.xml"
+
templates = systemconfig.get("TEMPLATES")
mysqltemplate = templates + "/mysql.txt"
dbhost = systemconfig.get("dbhost")
+ uuid = gen_uuid()
+ config_xml=generate_config_xml(uuid,dbhost)
+
+
if systemtype == "Master_backend":
logging.debug(" Setting dbhost to %s in systemconfig", mythip)
@@ -101,6 +136,20 @@ def setup_mysql_connection(systemconfig):
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)
+
+
+
@@ -110,24 +159,96 @@ def setup_func_key():
cmd="/usr/MythVantage/bin/grabkey.py"
mv_common.runcmd(cmd)
-def setup_func_minion(dbhost):
- logging.info(" Setting up the func minion:")
+def setup_func_minion(dbhost,hostname):
+ logging.info(" Setting up the func minion: %s", hostname)
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)
+ cmd='''sed -i "s/^minion_name.*$/minion_name = %s/" /etc/func/minion.conf ''' %hostname
+ 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 setup_rsyslog_server(enable_network):
+ syslog_conf_file="/etc/rsyslog.d/network.conf"
+ syslog_client_file="/etc/rsyslog.d/client.conf"
+ contents='''
+# ######### Receiving Messages from Remote Hosts ##########
+# TCP Syslog Server:
+# provides TCP syslog reception and GSS-API (if compiled to support it)
+$ModLoad imtcp.so # load module
+$InputTCPServerRun 514 # start up TCP listener at port 514
+# UDP Syslog Server:
+$ModLoad imudp.so # provides UDP syslog reception
+$UDPServerRun 514 # start a UDP syslog server at standard port 514
+'''
+ mv_common.remove_file(syslog_client_file)
+ if enable_network:
+ logging.info("____Enabling rsyslog network____")
+ try:
+ f = open(syslog_conf_file,'w')
+ except:
+ print "%s could not be opened" %syslog_conf_file
+ logging.debug("could not open %s" %syslog_conf_file)
+ return
+ f.write(contents)
+ f.write("\n")
+ f.close()
+ else:
+ logging.info("____Disabline rsyslog network____")
+ mv_common.remove_file(syslog_conf_file)
+
+ return
+
+def setup_rsyslog_client(rsyslog_server):
+ contents='''
+# Remote Logging (we use TCP for reliable delivery)
+# An on-disk queue is created for this action. If the remote host is
+# down, messages are spooled to disk and sent when it is up again.
+$WorkDirectory /var/spool/rsyslog # where to place spool files
+$ActionQueueFileName uniqName # unique name prefix for spool files
+$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
+$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
+$ActionQueueType LinkedList # run asynchronously
+$ActionResumeRetryCount -1 # infinite retries if host is down
+# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
+*.* @@%s:514
+'''
+
+ logging.info("____Enabling rsyslog network client____")
+ logging.info(" syslog_server: %s", rsyslog_server)
+ syslog_client_file="/etc/rsyslog.d/client.conf"
+ syslog_conf_file="/etc/rsyslog.d/network.conf"
+ try:
+ f = open(syslog_client_file,'w')
+ except:
+ print "%s could not be opened" %syslog_client_file
+ return
+ f.write(contents %rsyslog_server)
+ f.write("\n")
+ f.close()
+ mv_common.remove_file(syslog_conf_file)
+ cmd="mkdir -p /var/spool/rsyslog"
+ mv_common.runcmd(cmd)
+ return
+
def hostypeprint(systemconfig):
if mv_common.read_config(mv_common.module_config,"hostype") == False :
logging.info("____Skipping of hostype, config disabled____")
return
logging.info("______Start of hostype config_____")
+
+ url = 'http://%s:1337/extra.cfg.txt' %systemconfig.get("dbhost")
+ ex = mv_common.config_extra_reader(url)
+ xymon_supported=ex.read_config('xymon')
+ rsyslog_network=ex.read_config('rsyslog_network')
+ func_supported=ex.read_config('func')
+
mv_common.services(systemconfig)
install_list=''
remove_list=''
@@ -135,6 +256,9 @@ def hostypeprint(systemconfig):
daemon_remove_list=''
run_mysqlnetwork = False
+ profile_status="/etc/profile.d/z_myth_status.sh"
+ myth_status="/usr/LH/bin/myth_status.sh"
+
if systemconfig.get("SystemType") == "Standalone":
logging.info("Stand alone system being configured")
setup_ntp(False,"null")
@@ -145,8 +269,16 @@ def hostypeprint(systemconfig):
setup_db()
install_list=["mysql", "mythdb-initial", "avahi", "rpcbind", "nfs-utils", "local-website", "myth2ipod", "mythtv-status"]
daemon_list=["mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs", "lighttpd"]
- if data_config.SYSTEMTYPE == "MythVantage":
- install_list.append('ghosd')
+
+
+ mv_common.link_file(myth_status,profile_status)
+ setup_rsyslog_server(False)
+ if func_supported:
+ install_list.append('func')
+ daemon_list.append('funcd')
+ install_list.append('certmaster')
+ daemon_list.append('certmaster')
+
elif systemconfig.get("SystemType") == "Master_backend":
logging.info("Master backend system being configured")
@@ -156,48 +288,64 @@ def hostypeprint(systemconfig):
daemon_list=["mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs", "lighttpd"]
EnableNetwork = True
run_mysqlnetwork = True
- if data_config.SYSTEMTYPE == "MythVantage":
+ mv_common.link_file(myth_status,profile_status)
+
+ setup_rsyslog_server(True)
+ if func_supported:
+ #if data_config.SYSTEMTYPE == "MythVantage":
install_list.append('func')
- daemon_list.append('func')
+ daemon_list.append('funcd')
install_list.append('certmaster')
daemon_list.append('certmaster')
- install_list.append('ghosd')
+
elif systemconfig.get("SystemType") == "Slave_backend":
logging.info("Slave backend system being configured")
setup_ntp(True,systemconfig.get("dbhost"))
remove_avahi_service()
+ mv_common.link_file(myth_status,profile_status)
+
if systemconfig.get("hostypec"):
setup_db()
- install_list = ["rpcbind", "nfs-utils", "local-website", "avahi", "libmysqlclient" ]
- daemon_list = ["mythbackend", "rpcbind", "nfs-common", "netfs", "lighttpd", "avahi" ]
+ install_list = ["rpcbind", "nfs-utils", "avahi", "libmysqlclient" ]
+ daemon_list = ["mythbackend", "rpcbind", "nfs-common", "netfs", "avahi" ]
+
daemon_remove_list=('mysql')
- if data_config.SYSTEMTYPE == "MythVantage":
- install_list.remove("local-website")
- daemon_list.remove("lighttpd")
+ daemon_list.remove("lighttpd")
+ remove_list.append("lighttpd")
+
+ if func_supported:
install_list.append('func')
daemon_list.append('funcd')
- remove_list.append("lighttpd")
- install_list.append('ghosd')
+
+ if xymon_supported:
+ install_list.append('xymonclient')
+ daemon_list.append('xymon-client')
+
+ setup_rsyslog_client(systemconfig.get("dbhost"))
elif systemconfig.get("SystemType") == "Frontend_only":
logging.info("Frontend only system being configured")
setup_ntp(True,systemconfig.get("dbhost"))
remove_avahi_service()
- install_list=["mysql-clients", "libmysqlclient", "avahi", "rpcbind", "nfs-utils", "local-website"]
- remove_list=["mysql"]
- daemon_list=["mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs", "lighttpd"]
- daemon_remove_list=("mysql", "mythbackend")
- if data_config.SYSTEMTYPE == "MythVantage":
- install_list.remove("local-website")
- daemon_list.remove("lighttpd")
+ install_list=["mysql-clients", "libmysqlclient", "avahi", "rpcbind", "nfs-utils"]
+ remove_list=["mysql","lighttpd"]
+
+ daemon_list=["mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs" ]
+ daemon_remove_list=["mysql", "mythbackend","lighttpd"]
+ if xymon_supported:
+ install_list.append('xymonclient')
+ daemon_list.append('xymon-client')
+
+ if func_supported:
install_list.append('func')
daemon_list.append('funcd')
- remove_list.append("lighttpd")
- install_list.append('ghosd')
+ #install_list.append('ghosd')
+ setup_rsyslog_client(systemconfig.get("dbhost"))
+ mv_common.restart_service("rsyslog")
for pkg in install_list:
mv_common.pacinstall(pkg)
for pkg in remove_list:
@@ -206,6 +354,7 @@ def hostypeprint(systemconfig):
mv_common.add_service(daemon)
for daemon in daemon_remove_list:
mv_common.remove_service(daemon)
+
if systemconfig.get("RunFrontend") == "1":
logging.debug(" Will run the frontend")
mv_common.add_service("frontend")
@@ -226,8 +375,8 @@ def hostypeprint(systemconfig):
logging.debug(" Not running setup_mysql_connection")
setup_mysql_connection(systemconfig)
- if data_config.SYSTEMTYPE == "MythVantage":
- setup_func_minion(systemconfig.get("dbhost"))
- setup_func_key()
- setup_syslog(systemconfig.get("dbhost"))
+ if func_supported:
+ setup_func_minion(systemconfig.get("dbhost"),systemconfig.get("hostname"))
+
+
logging.info("__End of hostype config\n")