diff options
author | James Meyer <james.meyer@operamail.com> | 2012-04-21 18:26:48 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-04-21 18:26:48 (GMT) |
commit | 1acb6351868760d8f9705a5ee4282dfa91cd5252 (patch) | |
tree | 095ffcf38ea84f04c95ae74fd0dbf03d583996b5 /abs | |
parent | c6e57b34bcfc0102646f8d6167d8818aa51404ef (diff) | |
download | linhes_pkgbuild-1acb6351868760d8f9705a5ee4282dfa91cd5252.zip linhes_pkgbuild-1acb6351868760d8f9705a5ee4282dfa91cd5252.tar.gz linhes_pkgbuild-1acb6351868760d8f9705a5ee4282dfa91cd5252.tar.bz2 |
LinHES-config: add myth_settings_wrapper, and convert exisiting programs to use it.
myth_settings_wrapper.sh is a wrapper around mythutils and is used to update a few database settings and also to save/restore settings during install.
Diffstat (limited to 'abs')
-rw-r--r-- | abs/core/LinHES-config/PKGBUILD | 11 | ||||
-rw-r--r-- | abs/core/LinHES-config/install_db_chroot.sh | 13 | ||||
-rwxr-xr-x | abs/core/LinHES-config/mv_install.py | 12 | ||||
-rw-r--r-- | abs/core/LinHES-config/myth_settings_wrapper.sh | 249 |
4 files changed, 269 insertions, 16 deletions
diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD index de71e5b..6c0ad04 100644 --- a/abs/core/LinHES-config/PKGBUILD +++ b/abs/core/LinHES-config/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-config pkgver=2.3 -pkgrel=64 +pkgrel=65 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' @@ -18,7 +18,8 @@ source=(mv_install.py systemconfig.sh install_db_chroot.sh restore_default_settings.sh - xconfig.sh + myth_settings_wrapper.sh + xconfig.sh timezip.py soundconfig.sh LinHES-release @@ -68,6 +69,7 @@ build() { install -m 0755 install_db_chroot.sh $MVDIR/bin/install_db_chroot.sh install -m 0755 restore_km_db_chroot.sh $MVDIR/bin/restore_km_db_chroot.sh install -m 0755 restore_default_settings.sh $MVDIR/bin/restore_default_settings.sh + install -m 0755 myth_settings_wrapper.sh $MVDIR/bin/myth_settings_wrapper.sh install -m 0755 soundconfig.sh $MVDIR/bin/soundconfig.sh install -m 0755 networkconfig.sh $MVDIR/bin/networkconfig.sh install -m 0755 create_master.sh $MVDIR/bin/create_master.sh @@ -101,15 +103,16 @@ build() { install -m 0755 issue $startdir/pkg/etc/issue } -md5sums=('64fad755c12f8eb12940e216e403354e' +md5sums=('ffd40d21a9a868364045368053cb69c9' '16b98fcb3753ef6cfc35075c326d30e4' 'e36da536dd651ef182e7642337889e77' '985891a43f7c4c983eb2a362162f1a0f' '2f0b85d37b15956b3d92419c886e040c' '893aa1adae52b641ab8cdac53ecf98c0' 'c20f73d4da5d7e15e1f3eb85c7dcb49a' - '8ac1cfd2eca0f641737da0d0aca416a7' + '68199e861c2933ccbb84735b9b440157' '9ae8d79f620c6d19973c55c32a921874' + '6aea8876ab690e0edf817fe6cb5b7abc' '960017a34d9cc78af6298f45aad6eb8e' 'ecf9e5df20683a769c4a8a8f2d65de85' '6d32a88e76b0a97b0ce67d37ef6394aa' diff --git a/abs/core/LinHES-config/install_db_chroot.sh b/abs/core/LinHES-config/install_db_chroot.sh index 94305d2..bb7bbcf 100644 --- a/abs/core/LinHES-config/install_db_chroot.sh +++ b/abs/core/LinHES-config/install_db_chroot.sh @@ -31,17 +31,18 @@ do then pacman --noconfirm -R mythdb-initial pacman --noconfirm -S mythdb-initial - $MV_ROOT/bin/restore_default_settings.sh -c load - 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/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 update_db_settings HostServiceMythWEB "1" echo 'UseMythWEB="1"' >> /etc/systemconfig #update database to allow user jobs on this host. - $MV_ROOT/bin/restore_default_settings.sh -c USERJOBALLOW - $MV_ROOT/bin/restore_default_settings.sh -c ACCESSCONTROL + $MV_ROOT/bin/myth_settings_wrapper.sh -c USERJOBALLOW + $MV_ROOT/bin/myth_settings_wrapper.sh -c ACCESSCONTROL if [ -d /data/srv/mysql/mythconverg ] #if [ -d /var/lib/mysql/mythconverg ] then @@ -51,7 +52,7 @@ do fi # if [ $SystemType = "Master_backend" ] # then -# $MV_ROOT/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost +# $MV_ROOT/bin/myth_settings_wrapper.sh -c BECONFIG -s master -a $dbhost # fi fi fi diff --git a/abs/core/LinHES-config/mv_install.py b/abs/core/LinHES-config/mv_install.py index 9763522..a7389ca 100755 --- a/abs/core/LinHES-config/mv_install.py +++ b/abs/core/LinHES-config/mv_install.py @@ -1022,7 +1022,7 @@ def restore_default_settings(): logging.debug(" MVROOT was not defined, using the default value") MVROOT = "/usr/MythVantage" logging.info("Saving syssettings") - cmd = "%s/bin/restore_default_settings.sh -c save -t syssettings -h %s -d localhost" %(MVROOT, data_config.MVHOSTNAME) + cmd = "%s/bin/myth_settings_wrapper.sh -c save -t syssettings -h %s -d localhost" %(MVROOT, data_config.MVHOSTNAME) runcmd(cmd) SE = os.environ["TEMPLATES"]+"/settings/syssettings/" cp_and_log(SE, data_config.MOUNTPOINT+SE) @@ -1102,7 +1102,7 @@ def full_install(hostoptions): #logging.debug(" MVROOT was not defined, using the default value") #MVROOT="/usr/MythVantage" #logging.info("Saving syssettings") - #cmd="%s/bin/restore_default_settings.sh -c save -t syssettings -h %s -d localhost" %(MVROOT, data_config.MVHOSTNAME) + #cmd="%s/bin/myth_settings_wrapper.sh -c save -t syssettings -h %s -d localhost" %(MVROOT, data_config.MVHOSTNAME) #runcmd(cmd) #SE=os.environ["TEMPLATES"]+"/settings/syssettings" #cp_and_log(SE, data_config.MOUNTPOINT+SE) @@ -1138,7 +1138,7 @@ def full_install(hostoptions): cmd = " chroot %s DISPLAY=127.0.0.1:0 %s/bin/MythVantage -t restore, default 1" %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) # Need to check for to touch /tmp/.dbsysfailed - cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) + cmd = " chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) if ( 'x' == '1' ): logging.debug("touching /tmp/.dbsysfailed") @@ -1148,7 +1148,7 @@ def full_install(hostoptions): rc = runcmd(cmd)[0] if rc != 0 : error_out("Running systemconfig") - cmd = "chroot %s %s/bin/restore_default_settings.sh -c ACCESSCONTROL " %(data_config.MOUNTPOINT, MVROOT) + cmd = "chroot %s %s/bin/myth_settings_wrapper.sh -c ACCESSCONTROL " %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) umount_bind_chroot() cmd = " touch %s%s/.configure" %(data_config.MOUNTPOINT, data_config.MYTHHOME) @@ -1391,7 +1391,7 @@ def upgrade(hostoptions): runcmd(cmd) if os.path.exists("/tmp/etc/KnoppMyth-version"): - cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t hostsettings " %(data_config.MOUNTPOINT, MVROOT) + cmd = " chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t hostsettings " %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) logging.debug("Correcting permissions because of km->linhes upgrade") cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT) @@ -1399,7 +1399,7 @@ def upgrade(hostoptions): cmd = " chown -R root:root %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT+"/backup") runcmd(cmd) else: - cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) + cmd = " chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) logging.info("Running systemconfig in chroot 2nd time") diff --git a/abs/core/LinHES-config/myth_settings_wrapper.sh b/abs/core/LinHES-config/myth_settings_wrapper.sh new file mode 100644 index 0000000..bcba9d1 --- /dev/null +++ b/abs/core/LinHES-config/myth_settings_wrapper.sh @@ -0,0 +1,249 @@ +#!/bin/bash +. /etc/profile +. /etc/systemconfig +shopt -s -o nounset +echo $@ >> /tmp/restore.out +#TEMPLATES="/usr/share/templates/settings" +TEMPLATES="$TEMPLATES/settings" +TABLES="settings keybindings jumppoints" +MYTHDBUSER=mythtv +MYTHTVPASSWD=mythtv +declare -r OPTSTRING="c:e:t:d:h:s:a:z:Ho" +Thistemplate="" +declare -i OVERRIDE=0 +declare -i EVERYTHING=0 + +gen_xml="/tmp/generated.xml" + +function ARG_ERR() { + if [ x$OPTARG = "x" ] + then + echo "$SWITCH NEEDS AND ARG" + exit 11 + fi +} + +function ALSADEVICE () { +#ALSA:hw:1,4 + if [ x$Audiotype = xALSA ] + then + SoundDevice=ALSA:$SoundDevice + MixerDevice="ALSA:default" + else + MixerDevice="/dev/mixer" + fi + +} + +function load_xml(){ + xml_file=$1 + mythutil --import-settings --infile $xml_file + cat $xml_file + } + +function define_xml() { +xml_data=${1} +xml_hostname=${2} +xml_table=${3} +xml_value=${4} + +cat >$gen_xml <<EOF + +<!DOCTYPE mythutils_exported_settings> +<exported_xml> + <record> + <data>$xml_data</data> + <hostname>$xml_hostname</hostname> + <table>$xml_table</table> + <value>$xml_value</value> + </record> +</exported_xml> +EOF + +} + + + +if [ $# -eq 0 ] +then + echo "Valid options are:" + echo " -c (save|restore|load|uhostname|BECONFIG|ZIP|ACCESSCONTROL)" + echo " -t (syssettings|hostsettings)" + echo " -d databasename" + echo " -h hostname" + echo " -s systemtype (master|slave|standalone|frontendonly)" + echo " -a ipaddress" + echo " -z zipcode" + echo " -o override (only used upgrade installs)" + exit 1 +fi + + + + +while getopts "$OPTSTRING" SWITCH +do + case $SWITCH in + # \?) echo "unkown option" + # exit 11 ;; + c) echo "$SWITCH" "$OPTARG" + ARG_ERR + OPERATION=$OPTARG + ;; + t) echo "$SWITCH" "$OPTARG" + ARG_ERR + Thistemplate=$OPTARG + + if [ x$Thistemplate = x"syssettings" ] + then + echo "template is syssettings" + loadhost=false + elif [ x$Thistemplate = x"hostsettings" ] + then + echo "template is hostsettings" + Thistemplate=syssettings + loadhost=true + else + echo "invalid template name" + exit 1 + fi + ;; + d) echo "$SWITCH" "$OPTARG" + ARG_ERR + if [ $OVERRIDE = 1 ] + then + ovdbhost=$OPTARG + else + dbhost=$OPTARG + fi + ;; + h) echo "$SWITCH" "$OPTARG" + ARG_ERR + if [ $OVERRIDE = 1 ] + then + oldhostname=$hostname + hostname=$OPTARG + else + hostname=$OPTARG + fi + + ;; + s) echo "$SWITCH" "$OPTARG" + ARG_ERR + SYSTEMTYPE=$OPTARG + ;; + a) echo "$SWITCH" "$OPTARG" + ARG_ERR + IP_ADDRESS=$OPTARG + ;; + z) echo "$SWITCH" "$OPTARG" + ARG_ERR + ZIPCODE=$OPTARG + ;; + o) OVERRIDE=1 + ;; + + esac +done + +echo $OVERRIDE + +case $OPERATION in + + restore) + #used to restore settings from syssettings + if [ -d $TEMPLATES/$Thistemplate ] + then + mythutil --import-settings --infile $TEMPLATES/$Thistemplate/syssettings.xml --hostname $hostname + else + echo "couldn't find $TEMPLATES/$Thistemplate" + fi + ;; + + save) + #export settings from database to xml file + if [ ! -d $TEMPLATES/$Thistemplate ] + then + mkdir -p $TEMPLATES/$Thistemplate + fi + mythutil --export-settings --outfile $TEMPLATES/$Thistemplate/syssettings.xml --generic + + ;; + + load) + #this loads the distro default file, it's not active by any hosts + mythutil --import-settings --infile $TEMPLATES/$Thistemplate/distro_default.xml + ;; + + + + BECONFIG) + if [ $SYSTEMTYPE = "master" ] + then + define_xml ${IP_ADDRESS} $hostname settings BackendServerIP + load_xml + define_xml ${IP_ADDRESS} '' settings MasterServerIP + load_xml $gen_xml + + fi + + if [ $SYSTEMTYPE = "slave" ] + then + define_xml ${IP_ADDRESS} $hostname settings BackendServerIP + load_xml $gen_xml + fi + ;; + ZIP) + define_xml $ZIPCODE $hostname settings locale + load_xml $gen_xml + #$MYSQLCMD_C "delete from settings where value='locale' and hostname=\"$hostname\";" + #$MYSQLCMD_C "REPLACE INTO settings set data='$ZIPCODE' , value='locale' , hostname=\"$hostname\";" + + + ;; + MUSICFRONT) + ALSADEVICE + define_xml $SoundDevice $hostname settings AudioOutputDevice + load_xml $gen_xml + define_xml $MixerDevice $hostname settings MixerDevice + load_xml $gen_xml + + #need to reload the settings. + systemconfig.sh reloadfe + ;; + MUSICMYTH) + ALSADEVICE + define_xml $SoundDevice $hostname settings MusicOutputDevice + load_xml $gen_xml + + ;; + uhostname) + #used when the hostname is changed. + # + #call myth_util $oldhostname $hostname + + ;; + USERJOBALLOW) + echo "UserJOBALLOW callremoved" + + ;; + + ACCESSCONTROL) + LIST="Hostaccessnetwork Hostaccesshostype HostaccesshostypeSystemtype Hostaccessmisc Hostaccesssleep Hostaccessadvanced HostaccessadvancedX Hostaccesssound" + + for i in $LIST + do + define_xml 1 $i settings $hostname + load_xml $gen_xml + done + + LIST="HostaccesshostypeSystemtype Hostaccessuser" + for i in $LIST + do + define_xml 0 $i settings $hostname + load_xml $gen_xml + done + ;; +esac + + |