summaryrefslogtreecommitdiffstats
path: root/abs/mv-core/MythVantage-config/restore_default_settings.sh
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2009-03-05 22:08:43 (GMT)
committerJames Meyer <james.meyer@operamail.com>2009-03-05 22:08:43 (GMT)
commitcaf0fa1d12384c6590bbf24e8b4e91fa2e192b2b (patch)
treef03f28ee0ae7e9a168b74c29025cc4069aa527a7 /abs/mv-core/MythVantage-config/restore_default_settings.sh
parent82a1476578afeebcd97289e68563f392dd902460 (diff)
downloadlinhes_pkgbuild-caf0fa1d12384c6590bbf24e8b4e91fa2e192b2b.zip
linhes_pkgbuild-caf0fa1d12384c6590bbf24e8b4e91fa2e192b2b.tar.gz
linhes_pkgbuild-caf0fa1d12384c6590bbf24e8b4e91fa2e192b2b.tar.bz2
bring mythvantage restore_default_settings up to date
Diffstat (limited to 'abs/mv-core/MythVantage-config/restore_default_settings.sh')
-rwxr-xr-xabs/mv-core/MythVantage-config/restore_default_settings.sh93
1 files changed, 65 insertions, 28 deletions
diff --git a/abs/mv-core/MythVantage-config/restore_default_settings.sh b/abs/mv-core/MythVantage-config/restore_default_settings.sh
index e2b7044..dcf5e23 100755
--- a/abs/mv-core/MythVantage-config/restore_default_settings.sh
+++ b/abs/mv-core/MythVantage-config/restore_default_settings.sh
@@ -13,6 +13,7 @@ Thistemplate=""
declare -i OVERRIDE=0
declare -i EVERYTHING=0
+
function CMD_DEFINE () {
#add override check
if [ x$Thistemplate = xsyssettings -a $OVERRIDE -eq 1 ]
@@ -28,21 +29,24 @@ function CMD_DEFINE () {
}
function SQL_DEFINE () {
+ thostname=`echo ${hostname}|tr -C [:alpha:] _`
+ echo "Using $thostname for temp table postfix"
+
#$1 is the table name
if [ $1 = "settings" ]
then
- ALTERSQL="Alter table temp_${1}_${hostname} add unique ( value )"
+ ALTERSQL="Alter table temp_${1}_${thostname} add unique ( value )"
else
ALTERSQL=";"
fi
- CREATESQL="create table temp_${1}_${hostname} like $1;"
- COPY_TMP_SQL="replace into temp_${1}_${hostname} (select * from $1 where hostname=\"$hostname\");"
- INSERTSQL="LOAD DATA local INFILE '/tmp/$1.txt' REPLACE INTO TABLE temp_${1}_${hostname} FIELDS TERMINATED BY '\t';"
+ CREATESQL="create table temp_${1}_${thostname} like $1;"
+ COPY_TMP_SQL="replace into temp_${1}_${thostname} (select * from $1 where hostname=\"$hostname\");"
+ INSERTSQL="LOAD DATA local INFILE '/tmp/$1.txt' REPLACE INTO TABLE temp_${1}_${thostname} FIELDS TERMINATED BY '\t';"
#INSERTSQL="LOAD DATA local INFILE '$TEMPLATES/$Thistemplate/$1.txt' REPLACE INTO TABLE temp_${1}_${hostname} FIELDS TERMINATED BY '\t';"
DROPSQL="delete from $1 where hostname=\"$hostname\";"
- COPY_BCK_SQL="replace into $1 (select * from temp_${1}_${hostname} where hostname=\"$hostname\");"
- DROP_TABLE="Drop table temp_${1}_${hostname}"
+ COPY_BCK_SQL="replace into $1 (select * from temp_${1}_${thostname} where hostname=\"$hostname\");"
+ DROP_TABLE="Drop table temp_${1}_${thostname}"
}
function ARG_ERR() {
@@ -58,7 +62,11 @@ function ALSADEVICE () {
if [ x$Audiotype = xALSA ]
then
SoundDevice=ALSA:$SoundDevice
+ MixerDevice="ALSA:default"
+ else
+ MixerDevice="/dev/mixer"
fi
+
}
@@ -67,7 +75,7 @@ if [ $# -eq 0 ]
then
echo "Valid options are:"
echo " -c (save|restore|load|uhostname|BECONFIG|ZIP|ACCESSCONTROL)"
- echo " -t (syssettings)"
+ echo " -t (syssettings|hostsettings)"
echo " -d databasename"
echo " -h hostname"
echo " -s systemtype (master|slave|standalone|frontendonly)"
@@ -94,11 +102,17 @@ do
Thistemplate=$OPTARG
if [ x$Thistemplate = x"syssettings" ]
- then
- echo ""
- else
- echo "invalid template name"
- exit 1
+ 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"
@@ -165,22 +179,40 @@ case $OPERATION in
#used to restore settings from syssettings
if [ -d $TEMPLATES/$Thistemplate ]
then
- cd $TEMPLATES/$Thistemplate
- for i in $TABLES
- do
- SQL_DEFINE $i
- sed -e "s/REPLACEME/$hostname/g" $i.txt > /tmp/$i.txt
- #echo $MYSQLCMD "$SELECTSQL"
- echo $i
- $MYSQLCMD "$CREATESQL"
- $MYSQLCMD "$ALTERSQL"
- $MYSQLCMD "$COPY_TMP_SQL"
- $MYSQLCMD "$INSERTSQL"
- $MYSQLCMD "$DROPSQL"
- $MYSQLCMD "$COPY_BCK_SQL "
- $MYSQLCMD "$DROP_TABLE "
- #rm /tmp/$i.txt
- done
+ cd $TEMPLATES/$Thistemplate
+ if [ $loadhost = false ]
+ then
+ for i in $TABLES
+ do
+ SQL_DEFINE $i
+ sed -e "s/REPLACEME/$hostname/g" $i.txt > /tmp/$i.txt
+ #echo $MYSQLCMD "$SELECTSQL"
+ echo $i
+ $MYSQLCMD "$CREATESQL"
+ $MYSQLCMD "$ALTERSQL"
+ $MYSQLCMD "$COPY_TMP_SQL"
+ $MYSQLCMD "$INSERTSQL"
+ $MYSQLCMD "$DROPSQL"
+ $MYSQLCMD "$COPY_BCK_SQL "
+ $MYSQLCMD "$DROP_TABLE "
+ #rm /tmp/$i.txt
+ done
+ fi
+ if [ $loadhost = true ]
+ then
+ #only load the settings table with values HOST
+ i=settings
+ SQL_DEFINE $i
+ sed -e "s/REPLACEME/$hostname/g" $i.txt > /tmp/$i.txt
+ echo $i
+ $MYSQLCMD "$CREATESQL"
+ $MYSQLCMD "$ALTERSQL"
+ $MYSQLCMD "$INSERTSQL"
+ $MYSQLCMD "$COPY_TMP_SQL"
+ $MYSQLCMD "$DROPSQL"
+ $MYSQLCMD "$COPY_BCK_SQL"
+ $MYSQLCMD "$DROP_TABLE "
+ fi
else
echo "couldn't find $TEMPLATES/$Thistemplate"
fi
@@ -282,7 +314,9 @@ case $OPERATION in
MUSICFRONT)
ALSADEVICE
$MYSQLCMD_C "delete from settings where value='AudioOutputDevice' and hostname=\"$hostname\";"
+ $MYSQLCMD_C "delete from settings where value='MixerDevice' and hostname=\"$hostname\";"
$MYSQLCMD_C "REPLACE INTO settings set data='$SoundDevice', value='AudioOutputDevice' , hostname=\"$hostname\";"
+ $MYSQLCMD_C "REPLACE INTO settings set data='$MixerDevice', value='MixerDevice' , hostname=\"$hostname\";"
#need to reload the settings.
systemconfig.sh reloadfe
;;
@@ -316,6 +350,9 @@ case $OPERATION in
done
SQL="update settings set data='0' where value='HostaccesshostypeSystemtype' and hostname=\"$hostname\" ;"
$MYSQLCMD_C "$SQL"
+ SQL="update settings set data='0' where value='Hostaccessuser' and hostname=\"$hostname\" ;"
+ $MYSQLCMD_C "$SQL"
+ ;;
esac
#SELECT * INTO OUTFILE 'data.txt'