From 822ebc824685b558d6baa1fe81d2ce58e2235808 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Sat, 29 Sep 2012 15:10:02 -0500 Subject: LinHES config: several changes here - added modules config_xml calling this will setup config.xml for mythtv and root user - install_db_chroot.sh will now generate the default settings and load them into a table - mv_install now calles myth_settings_wrapper.sh to load the default db --- abs/core/LinHES-config/PKGBUILD | 16 ++--- abs/core/LinHES-config/config.install | 14 +--- abs/core/LinHES-config/install_db_chroot.sh | 9 ++- abs/core/LinHES-config/mv_common.py | 2 +- abs/core/LinHES-config/mv_hostype.py | 95 ++----------------------- abs/core/LinHES-config/mv_install.py | 23 ++++-- abs/core/LinHES-config/myth_settings_wrapper.sh | 29 +++++++- abs/core/LinHES-config/systemconfig.py | 86 +++++++++++++++++++++- 8 files changed, 155 insertions(+), 119 deletions(-) diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD index 0b862f8..a7ea24b 100755 --- a/abs/core/LinHES-config/PKGBUILD +++ b/abs/core/LinHES-config/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-config pkgver=2.3 -pkgrel=153 +pkgrel=167 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' @@ -125,7 +125,7 @@ build() { install -o root -g root -D -m 0755 blacklist_pcspkr.conf $startdir/pkg/etc/modprobe.d/blacklist_pcspkr.conf install -o root -g root -D -m 0755 blacklist_nouveau.conf $startdir/pkg/etc/modprobe.d/blacklist_nouveau.conf } -md5sums=('70ea19d41cf33ec8ae26c4e8cb5cd240' +md5sums=('59e18e35359bebcd9d639c5e5b5d290d' 'f33e1a6f7985091b8d47cbaf7433f90f' '1afacd0337d95f140b2a1777c27f041a' '2596460462cf6c889cf8f95485537b20' @@ -133,11 +133,11 @@ md5sums=('70ea19d41cf33ec8ae26c4e8cb5cd240' 'fda01259a4bc74d83c9092d338bd247a' '768504ef10ecd11a22875ccea9fcf62b' 'f73d6d6f98839e900cb6685bf5dc4eae' - '68199e861c2933ccbb84735b9b440157' + '408688e3bcb2cefe512f9a89863137c8' '2a7f3b34e522acfd08283b86c8926aba' - '4a538bdfbb2833c48bcffb4f82729de6' + '36f5017e25c200354a954b17819aa1b2' '689b01f7636e09b2f9657c6ce6006ee7' - 'ecf9e5df20683a769c4a8a8f2d65de85' + 'c8b5d6ad73595aa96bf04df9df2fd869' 'a6faa20d905e2fd92ce79acab044b759' '8ba06c2ce6129371548cc360ccca27f8' '5f890ea9bda6aef652d2560ca19dac07' @@ -148,7 +148,7 @@ md5sums=('70ea19d41cf33ec8ae26c4e8cb5cd240' '3d1e4a119f38cff0498bf8a67e94e4b3' '71fd2d0d448fc2fcd15415a1beed7109' 'af6b3c5ec0d974b3e19ff1ed50662ee5' - 'eff2543a8dd0fa13f10360d1594d823d' + '5f60c90ae0f48d71224d4dd6afad61ff' 'b845de3e05c1734cce4b9ac5e8f1baaf' 'e869e2c72212881db1e4fa40b116efe5' '8b7dce4a3a0a281fa6656aa8781a648e' @@ -157,11 +157,11 @@ md5sums=('70ea19d41cf33ec8ae26c4e8cb5cd240' 'fe5e31b833cc6707209e9d656b6eb53c' 'ecb52b9b7a9ac0c8988093c1dfdda635' '23d0e12b7ca1cc6ea6b993c1d7ff20b9' - '8f442cfe2574af3e4520a124e28fcd7c' + '67b651a8cd0dcccb368fe7d2402f05f3' 'b4900090d841d3e390cb840cf16afd85' '85101b79d1ee30bff8244c810828033f' '923197a517cb83d77263e8cea8b8c16a' - '6aef6f4484c45c5135b77199f63ab317' + 'f49d9ff1e6c3e484c9679079c74ad048' '2596460462cf6c889cf8f95485537b20' '4cba2bb55c6b8e27c57a6171f42d0455' '4804aa93aaad3dfcfff08cd9ffd68836' diff --git a/abs/core/LinHES-config/config.install b/abs/core/LinHES-config/config.install index fb905fb..2da71ff 100644 --- a/abs/core/LinHES-config/config.install +++ b/abs/core/LinHES-config/config.install @@ -26,19 +26,11 @@ pre_upgrade() { # arg 1: the new package version # arg 2: the old package version post_upgrade() { - . /etc/profile - ps -ef|grep mysqld|grep -v grep - status=$? - echo "status $status" - if [ $status = 0 ] + if [ ! -f /etc/blacklist.package ] then - restore_default_settings.sh -c load + echo "List of packages to ignore" > /etc/blacklist.package + echo "one package per line" >> /etc/blacklist.package fi - if [ ! -f /etc/blacklist.package ] - then - echo "List of packages to ignore" > /etc/blacklist.package - echo "one package per line" >> /etc/blacklist.package - fi cat /etc/LinHES-release > /etc/os_myth_release if [ ! -f /usr/share/mythtv/config.xml ] diff --git a/abs/core/LinHES-config/install_db_chroot.sh b/abs/core/LinHES-config/install_db_chroot.sh index bb7bbcf..272b556 100644 --- a/abs/core/LinHES-config/install_db_chroot.sh +++ b/abs/core/LinHES-config/install_db_chroot.sh @@ -31,9 +31,14 @@ do then pacman --noconfirm -R mythdb-initial pacman --noconfirm -S mythdb-initial + + #This piece only populates the distro_default tables + #save off distro_default + $MV_ROOT/bin/myth_settings_wrapper.sh -c save-default + + #load default into distro_default tables $MV_ROOT/bin/myth_settings_wrapper.sh -c load - #change this to mythutil - #DISPLAY=127.0.0.1:0 $MV_ROOT/bin/MythVantage -t restore,default_1 + $MV_ROOT/bin/myth_settings_wrapper.sh -c restore -t syssettings $MV_ROOT/bin/systemconfig.sh misc,hostype,this_is_install diff --git a/abs/core/LinHES-config/mv_common.py b/abs/core/LinHES-config/mv_common.py index 1cb761e..f1210ba 100755 --- a/abs/core/LinHES-config/mv_common.py +++ b/abs/core/LinHES-config/mv_common.py @@ -219,7 +219,7 @@ def pacinstall(pkg): elif pkg == "xymonclient": if os.path.exists('/home/xymon/client'): cmd='''pacman --noconfirm --dbonly -Sddf xymonclient''' - mv_common.runcmd(cmd) + runcmd(cmd) if not pkg_blacklist_check(pkg): if pkg_installed_check(pkg): diff --git a/abs/core/LinHES-config/mv_hostype.py b/abs/core/LinHES-config/mv_hostype.py index 5655986..473cc94 100755 --- a/abs/core/LinHES-config/mv_hostype.py +++ b/abs/core/LinHES-config/mv_hostype.py @@ -60,77 +60,16 @@ def setup_mysqlnetwork(EnableNetwork): mv_common.restart_service("mysql") -def generate_config_xml(uuid,dbhost): - configxml_t =''' - - - - %s - - - - %s - mythtv - mythtv - mythconverg - 0 - - - - - ''' - 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) - mv_common.mkdir_mythhome(data_config.MYTHHOME,"mythtv","mythtv") - - - - 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) - 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) - - #setup link for root user - mv_common.mkdir_mythhome("/root","root","root") - home_xml_file="/root/.mythtv/config.xml" - mv_common.link_file(configxml_file,home_xml_file) - - + mv_root = systemconfig.get("MVROOT") if systemtype == "Master_backend": logging.debug(" Setting dbhost to %s in systemconfig", mythip) @@ -154,6 +93,7 @@ def setup_mysql_connection(systemconfig): if systemtype == "Standalone": + #THIS IS NEVER CALLED ANYMORE, need to move the mysql.txt stuff logging.debug(" changing mysql.txt file to use localhost") cmd = '''sed -e "s/^DBHostName=.*$/DBHostName="localhost"/" %s > %s ''' %(mysqltemplate, mysqltxt) mv_common.runcmd(cmd) @@ -171,31 +111,6 @@ def setup_mysql_connection(systemconfig): #mv_common.runcmd(cmd) b=mv_common.runcmd_output(cmd) logging.debug(b) - #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) - #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) - diff --git a/abs/core/LinHES-config/mv_install.py b/abs/core/LinHES-config/mv_install.py index aa895da..338e5dc 100755 --- a/abs/core/LinHES-config/mv_install.py +++ b/abs/core/LinHES-config/mv_install.py @@ -1563,6 +1563,13 @@ def full_install(hostoptions): restore_default_settings() #also calls copy_updates, fix permissions + #setup symlink + mount_bind_chroot() + logging.info("Running systemconfig in chroot") + cmd = "chroot %s %s/bin/systemconfig.sh config_xml,this_is_install" %(data_config.MOUNTPOINT, MVROOT) + umount_bind_chroot() + + mount_bind_chroot() apply_new_auth() umount_bind_chroot() @@ -1596,14 +1603,16 @@ def full_install(hostoptions): else: logging.info("______No database required, continuing configuration________") mount_bind_chroot() - cmd = "chroot %s DISPLAY=127.0.0.1:0 %s/bin/MythVantage -t restore, default 1" %(data_config.MOUNTPOINT, MVROOT) - runcmd(cmd) - move_myth_home("backup") + #cmd = "chroot %s DISPLAY=127.0.0.1:0 %s/bin/MythVantage -t restore, default 1" %(data_config.MOUNTPOINT, MVROOT) + #runcmd(cmd) + + + #move_myth_home("backup") if systemconfig["SystemType"] == "Slave_backend": double_mount() else: double_mount(fe_only=True) - move_myth_home("restore") + #move_myth_home("restore") # Need to check for to touch /tmp/.dbsysfailed #cmd = " chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) #runcmd(cmd) @@ -1615,8 +1624,14 @@ def full_install(hostoptions): rc = runcmd(cmd)[0] if rc != 0 : error_out("Running systemconfig") + + #restore defaults here! + cmd = "chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t distro_default " %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + cmd = "chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) + cmd = "chroot %s %s/bin/myth_settings_wrapper.sh -c ACCESSCONTROL " %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) umount_bind_chroot() diff --git a/abs/core/LinHES-config/myth_settings_wrapper.sh b/abs/core/LinHES-config/myth_settings_wrapper.sh index 90d41de..6ceec7f 100644 --- a/abs/core/LinHES-config/myth_settings_wrapper.sh +++ b/abs/core/LinHES-config/myth_settings_wrapper.sh @@ -68,7 +68,7 @@ EOF if [ $# -eq 0 ] then echo "Valid options are:" - echo " -c (save|restore|load|uhostname|BECONFIG|ZIP|ACCESSCONTROL)" + echo " -c (save|save-default|restore|load|uhostname|BECONFIG|ZIP|ACCESSCONTROL)" echo " -t (syssettings|hostsettings)" echo " -d databasename" echo " -h hostname" @@ -99,11 +99,18 @@ do then echo "template is syssettings" loadhost=false + elif [ x$Thistemplate = x"hostsettings" ] then echo "template is hostsettings" Thistemplate=syssettings loadhost=true + + elif [ x$Thistemplate = x"distro_default" ] + then + echo "template is distro_default" + loadhost=false + elif [ x$Thistemplate = x"custom" ] then echo "template is custom" @@ -112,6 +119,7 @@ do exit 1 fi ;; + d) echo "$SWITCH" "$OPTARG" ARG_ERR if [ $OVERRIDE = 1 ] @@ -156,7 +164,10 @@ case $OPERATION in restore) #used to restore settings from syssettings - if [ -d $TEMPLATES/$Thistemplate ] + if [ x$Thistemplate = "xdistro_default" ] + then + mythutil --restore-settings --groupname distro_default + elif [ -d $TEMPLATES/$Thistemplate ] then mythutil --import-settings --infile $TEMPLATES/$Thistemplate/syssettings.xml --hostname $hostname else @@ -174,6 +185,19 @@ case $OPERATION in ;; + save-default) + #export settings from database to xml file + Thistemplate="system-default" + if [ ! -d $TEMPLATES/$Thistemplate ] + then + mkdir -p $TEMPLATES/$Thistemplate + fi + mythutil --export-settings --outfile $TEMPLATES/$Thistemplate/distro_default.xml --distro-default + + ;; + + + load) if [ x$Thistemplate = "xcustom" ] then @@ -182,6 +206,7 @@ case $OPERATION in else #this loads the distro default file, it's not active by any hosts + Thistemplate="system-default" mythutil --import-settings --infile $TEMPLATES/$Thistemplate/distro_default.xml fi ;; diff --git a/abs/core/LinHES-config/systemconfig.py b/abs/core/LinHES-config/systemconfig.py index 59df527..d65a1c6 100755 --- a/abs/core/LinHES-config/systemconfig.py +++ b/abs/core/LinHES-config/systemconfig.py @@ -51,6 +51,84 @@ def setup_x(systemconfig): cmd = "%s/bin/xconfig.sh" %systemconfig.get("MVROOT") mv_common.runcmd(cmd) + +def generate_config_xml(uuid,dbhost): + configxml_t =''' + + + + %s + + + + %s + mythtv + mythtv + mythconverg + 0 + + + + + ''' + configxml= configxml_t %(uuid,dbhost) + return configxml + +def gen_uuid(): + cmd = "/usr/bin/uuidgen" + uuid = mv_common.runcmd_output(cmd) + return uuid + +def setup_config_xml(systemconfig): + #setup mysql.txt and 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" + + templates = systemconfig.get("TEMPLATES") + mysqltemplate = templates + "/mysql.txt" + dbhost = systemconfig.get("dbhost") + uuid = gen_uuid() + config_xml=generate_config_xml(uuid,dbhost) + mv_common.mkdir_mythhome(data_config.MYTHHOME,"mythtv","mythtv") + + + + 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) + 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) + + #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) + + + + + + + + def main(argv): try: MVROOT = os.environ["MV_ROOT"] @@ -74,7 +152,8 @@ def main(argv): "plugins":False, "smolt":False, "all":False, "dhcp_request":False , "func":False, "supplemental":False, - "vnc":False, "fileshare":False } + "vnc":False, "fileshare":False, + "config_xml":False } try: opts, args = getopt.getopt(argv, 'c:hm:d:', ["help","modules" ] ) except getopt.GetoptError, why: @@ -121,6 +200,7 @@ def main(argv): cmdmodule["user"] = True cmdmodule["vnc"] = True cmdmodule["fileshare"] = True + cmdmodule["config_xml"] = True ##putting this here until I can create the seperate share module #if cmdmodule["fileshare"]: @@ -139,6 +219,10 @@ def main(argv): logging.debug(" Setting the frontend to restart due to network change") cmdmodule["restartfe"] = True + if cmdmodule["config_xml"]: + setup_config_xml(systemconfig) + + if cmdmodule["func"]: from mv_hostype import setup_func_minion setup_func_minion(systemconfig.get("dbhost"),systemconfig.get("hostname")) -- cgit v0.12