From 7a7490cd1120193f64e4fb1462ca61cdc2ec89ad Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Thu, 19 Mar 2009 20:18:32 -0500
Subject: LinHES-config: systemconfig.sh now supports both gnome and X
 screensaver. New Mythvantage to support either selection.

---
 abs/core-testing/LinHES-config/PKGBUILD        |   2 +-
 abs/core-testing/LinHES-config/systemconfig.sh | 468 +++++++++++++++----------
 2 files changed, 279 insertions(+), 191 deletions(-)

diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index 00addde..c1f1a14 100644
--- a/abs/core-testing/LinHES-config/PKGBUILD
+++ b/abs/core-testing/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=1.0
-pkgrel=314
+pkgrel=340
 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev )
 pkgdesc="Install and configure your system"
 depends=(bc libstatgrab  mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates )
diff --git a/abs/core-testing/LinHES-config/systemconfig.sh b/abs/core-testing/LinHES-config/systemconfig.sh
index 16c51f3..ebc3489 100755
--- a/abs/core-testing/LinHES-config/systemconfig.sh
+++ b/abs/core-testing/LinHES-config/systemconfig.sh
@@ -23,7 +23,7 @@ PKGBLACKLIST=$BASE/etc/blacklist.package
 
 if [ x$1 = x"Mysql_only" ]
     then
-	rm -f /tmp/mysql.txt
+    rm -f /tmp/mysql.txt
         sed -e "s/^DBHostName=.*$/DBHostName=$2/" $TEMPLATES/mysql.txt > /tmp/mysql.txt
         exit 0
     fi
@@ -31,14 +31,14 @@ if [ x$1 = x"Mysql_only" ]
 
 if [ -f /etc/systemconfig ]
 then
-	. /etc/systemconfig
+    . /etc/systemconfig
     setup_MYTH_vars
 TEMPNET="Hostip"$default_interface
 echo $TEMPNET
 eval MYTHIP=\$${TEMPNET}
 else
-	echo "could not find /etc/systemconfig"
-	exit 1
+    echo "could not find /etc/systemconfig"
+    exit 1
 fi
 
 
@@ -126,23 +126,23 @@ status=$?
 
 
     if [ $SystemType = "Standalone" ]
-         then
+        then
             sed -ie "s/^#skip-networking/skip-networking/g" $BASE/$MFILE
             if [ $status = 0 ]
             then
                 sudo sv restart mysql
-	        echo "restarting mysql with   no network"
+            echo "restarting mysql with   no network"
             fi
 
         fi
 
     if [ $SystemType = "Master_backend" ]
     then
-          sed -ie "s/^skip-networking/#skip-networking/g" $BASE/$MFILE
+        sed -ie "s/^skip-networking/#skip-networking/g" $BASE/$MFILE
             if [ $status = 1 ]
             then
                 sudo sv restart mysql
-		        echo "restarting mysql with  network"
+                echo "restarting mysql with  network"
             fi
 
     fi
@@ -162,25 +162,25 @@ echo $timezone
 ln -s "/usr/share/zoneinfo/$timezone"  ${BASE}/etc/localtime
         sed -e "s~^TIMEZONE=.*$~TIMEZONE=\"${timezone}\"~" ${BASE}/etc/rc.conf > $TEMPLATES/rc.conf
 
-       # echo CLOCK="UTC" > ${BASE}/etc/conf.dclock
-       # echo CLOCK_SYSTOCH="yes" >> ${BASE}/etc/conf.d/clock
-       # echo TIMEZONE="$timezone" >> ${BASE}/etc/conf.d/clock
+    # echo CLOCK="UTC" > ${BASE}/etc/conf.dclock
+    # echo CLOCK_SYSTOCH="yes" >> ${BASE}/etc/conf.d/clock
+    # echo TIMEZONE="$timezone" >> ${BASE}/etc/conf.d/clock
 cp_and_log $TEMPLATES/rc.conf ${BASE}/etc/rc.conf
 #Check for Atomic Ant
- if grep disablemodules=agpart,intel_agp /proc/cmdline >/dev/null
- then
- 	cat /etc/rc.conf |  sed -e '/MOD_BLACKLIST/ c\MOD_BLACKLIST=($ALSABLACKLIST agpart intel_agp)' > /etc/rc.conf.aa
-	mv /etc/rc.conf /etc/rc.conf.preaa
-	mv /etc/rc.conf.aa /etc/rc.conf
+if grep disablemodules=agpart,intel_agp /proc/cmdline >/dev/null
+then
+    cat /etc/rc.conf |  sed -e '/MOD_BLACKLIST/ c\MOD_BLACKLIST=($ALSABLACKLIST agpart intel_agp)' > /etc/rc.conf.aa
+    mv /etc/rc.conf /etc/rc.conf.preaa
+    mv /etc/rc.conf.aa /etc/rc.conf
 # else
 # 	exit 1
- fi
+fi
 
 }
 
 
 function setupreceiver {
-   case $ReceiverType in
+case $ReceiverType in
     tinker) echo "do nothing"
             ;;
     Serial) echo "setup serial lirc"
@@ -189,26 +189,26 @@ function setupreceiver {
             load-modules-mythvantage.sh
             ;;
     Usb-imon) echo "setup receiver-usb-imon"
-              sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-              echo "lirc_imon     #lirc" >> ${BASE}/etc/modules.mythvantage
-              load-modules-mythvantage.sh
-              ;;
-   Hauppauge) echo "setup hauppauge reciever (lirc_i2c)"
-              sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-              echo "lirc_i2c   #lirc" >> ${BASE}/etc/modules.mythvantage
-              cp_and_log $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf
-              rmmod lirc_i2c 2>/dev/null
-              load-modules-mythvantage.sh
-             ;;
-           *)   sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-              ;;
+            sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+            echo "lirc_imon     #lirc" >> ${BASE}/etc/modules.mythvantage
+            load-modules-mythvantage.sh
+            ;;
+Hauppauge) echo "setup hauppauge reciever (lirc_i2c)"
+            sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+            echo "lirc_i2c   #lirc" >> ${BASE}/etc/modules.mythvantage
+            cp_and_log $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf
+            rmmod lirc_i2c 2>/dev/null
+            load-modules-mythvantage.sh
+            ;;
+        *)   sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+            ;;
     esac
 
 
 }
 
 function setupremote {
-     case $Remotetype in
+    case $Remotetype in
         no_remote) echo "No remote selected"
                 daemon_remove="lircd $daemon_remove"
                 ;;
@@ -235,21 +235,21 @@ function setupremote {
                 daemon_add="lircd $daemon_add"
                 sv hup lircd
 
-		if [ ! -e /home/mythtv/.mythtv/lircrc ]
-		then
-			if [ ! -d /home/mythtv/.mythtv ]
-			then
-				mkdir /home/mythtv/.mythtv
-				chown mythtv:mythtv /home/mythtv/.mythtv
-			fi
+        if [ ! -e /home/mythtv/.mythtv/lircrc ]
+        then
+            if [ ! -d /home/mythtv/.mythtv ]
+            then
+                mkdir /home/mythtv/.mythtv
+                chown mythtv:mythtv /home/mythtv/.mythtv
+            fi
 
-			ln -s /etc/lircrc /home/mythtv/.mythtv/lircrc 2> /dev/null
-		fi
-		if [ ! -e /home/mythtv/.lircrc ]
-		then
+            ln -s /etc/lircrc /home/mythtv/.mythtv/lircrc 2> /dev/null
+        fi
+        if [ ! -e /home/mythtv/.lircrc ]
+        then
 
-			ln -s /etc/lircrc /home/mythtv/.lircrc 2> /dev/null
-		fi
+            ln -s /etc/lircrc /home/mythtv/.lircrc 2> /dev/null
+        fi
 
 
                 ;;
@@ -261,11 +261,11 @@ function setupblaster {
         #cd $TEMPLATES/transmit/$Blastertype
         #for i in lircd*
         #do
-         #       cat lircd.conf  >> ${BASE}/etc/lircd.conf
+        #       cat lircd.conf  >> ${BASE}/etc/lircd.conf
         #done
-      #  REMOTE_NAME${BASE}/usr/bin/change_chan.sh=`grep name lircd.conf* |awk -F" " ' { print $2 } '`
-         sed -e "s/^REMOTE_NAME=.*$/REMOTE_NAME=${Blastertype} /" $TEMPLATES/change_chan.sh > ${BASE}/usr/bin/change_chan.sh
-          chmod 755 ${BASE}/usr/bin/change_chan.sh
+    #  REMOTE_NAME${BASE}/usr/bin/change_chan.sh=`grep name lircd.conf* |awk -F" " ' { print $2 } '`
+        sed -e "s/^REMOTE_NAME=.*$/REMOTE_NAME=${Blastertype} /" $TEMPLATES/change_chan.sh > ${BASE}/usr/bin/change_chan.sh
+        chmod 755 ${BASE}/usr/bin/change_chan.sh
         #channel change script change
         setupremote
 
@@ -297,7 +297,7 @@ function setupevrouter {
 }
 
 function setupLCD {
-   case x$LCDtype in
+case x$LCDtype in
     xtinker) echo "do nothing"
             ;;
     xno_lcd) echo "disabling lcd"
@@ -308,19 +308,19 @@ function setupLCD {
             ;;
         x) echo "empty lcd" ;;
 
-         *) echo "setup lcd"
+        *) echo "setup lcd"
             if [ -f $TEMPLATES/LCD/$LCDtype/modules  ]
             then
-              sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage
-              cat $TEMPLATES/LCD/$LCDtype/modules >> ${BASE}/etc/modules.mythvantage
-              #should also modprobe
+            sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage
+            cat $TEMPLATES/LCD/$LCDtype/modules >> ${BASE}/etc/modules.mythvantage
+            #should also modprobe
             fi
 
 
             if [ -f $TEMPLATES/LCD/$LCDtype/LCDd.conf ]
             then
                 cp_and_log  $TEMPLATES/LCD/$LCDtype/LCDd.conf /etc
-               # install="lcdproc $install"
+            # install="lcdproc $install"
                 daemon_add="lcdd $daemon_add"
                 load-modules-mythvantage.sh
                 RESTART_FE="true"
@@ -339,20 +339,20 @@ function setupLCD {
 
 
 function scrubnfs {
-	   cp_and_log /etc/fstab $TEMPLATES/fstab.conf.template
-       grep -v nfs   $TEMPLATES/fstab.conf.template > ${BASE}/etc/fstab
-   }
+    cp_and_log /etc/fstab $TEMPLATES/fstab.conf.template
+    grep -v nfs   $TEMPLATES/fstab.conf.template > ${BASE}/etc/fstab
+}
 
 function setupfstab () {
 #    	setupfstab $NFSserver $NFSshare $NFSmount
-         echo "$1 $2  nfs" >> ${BASE}/etc/fstab
-         if [ ! -e "$2" ]
-         then
-           mkdir -p "$2"
-           chown mythtv:mythtv "$2"
-         fi
-         if [ x$DCONFIG = x  ]
-         then
+        echo "$1 $2  nfs" >> ${BASE}/etc/fstab
+        if [ ! -e "$2" ]
+        then
+        mkdir -p "$2"
+        chown mythtv:mythtv "$2"
+        fi
+        if [ x$DCONFIG = x  ]
+        then
             mount $2 &
         fi
 
@@ -394,7 +394,7 @@ pkglistremove=""
 #default enabled
 for i in mythcontrols mythgallery mythmovietime mythmusic mythsmolt mythvideo
 do
-    eval pkgvalue=\$${i}
+	eval pkgvalue=\$${i}
     if [ x$pkgvalue = x ]
     then
         pkglistinstall="$pkglistinstall $i$postfix"
@@ -474,17 +474,17 @@ remove="$pkglistremove $remove"
 
 }
 function LCDcheck () {
- case x$LCDtype in
+case x$LCDtype in
     xtinker) echo "do nothing lcd "
             ;;
     xno_lcd) echo "no  lcd "
-                       ;;
+                    ;;
     xxosd) install="xosd lcdproc $install"
             ;;
         x) echo "lcd empty "
         ;;
- *)
-     install="lcdproc $install"
+*)
+    install="lcdproc $install"
     ;;
 esac
 }
@@ -556,16 +556,16 @@ fi
 function daemons {
 echo "Daemons on boot"
 
-     for i in $daemon_remove
-     do
-    	   sv check $i 1>/dev/null
+    for i in $daemon_remove
+    do
+        sv check $i 1>/dev/null
             status=$?
-	   if [ $status -eq 0 ]
-	   then
-		sv down $i
-	   fi
-	        remove_service.sh $i
-     done
+    if [ $status -eq 0 ]
+    then
+        sv down $i
+    fi
+            remove_service.sh $i
+    done
 
 
     for i in $daemon_add
@@ -574,8 +574,8 @@ echo "Daemons on boot"
         status=$?
         add_service.sh $i
 
-		if [ $status -eq 0 ]
-		then
+        if [ $status -eq 0 ]
+        then
                     case $i in
                         mysql*) sv hup $i
                                         ;;
@@ -596,8 +596,8 @@ echo "Daemons on boot"
                             sleep 1
                             sv up $i
                         ;;
-	           esac
-                 fi
+            esac
+                fi
 
         done
 
@@ -619,32 +619,32 @@ fi
 
 if [ x$RunDHCP = x1 ]
 then
-           ser_daemon_add="dnsmasq  $ser_daemon_add"
-           ser_install="dnsmasq mvpmc  $ser_install"
+        ser_daemon_add="dnsmasq  $ser_daemon_add"
+        ser_install="dnsmasq mvpmc  $ser_install"
 
 else
-           ser_daemon_remove="dnsmasq  $ser_daemon_remove"
-           ser_remove="dnsmasq mvpmc  $ser_remove"
+        ser_daemon_remove="dnsmasq  $ser_daemon_remove"
+        ser_remove="dnsmasq mvpmc  $ser_remove"
 fi
 
 if [ x$RunFrontend = x1 ]
 then
-           ser_daemon_add="frontend hal   $ser_daemon_add"
-           ser_install=" $ser_install"
-           showX=true
- else
-           ser_daemon_remove="frontend hal  $ser_daemon_remove"
-           ser_remove="$ser_remove"
- fi
+        ser_daemon_add="frontend hal   $ser_daemon_add"
+        ser_install=" $ser_install"
+        showX=true
+else
+        ser_daemon_remove="frontend hal  $ser_daemon_remove"
+        ser_remove="$ser_remove"
+fi
 
 if [ x$UseMythWEB = x1 ]
 then
             ser_install="lighttpd  mythweb$postfix $ser_install"
             ser_daemon_add="lighttpd $ser_daemon_add"
- else
-           ser_remove="mythweb$postfix $ser_remove"
-           ser_daemon_remove="$ser_daemon_remove"
- fi
+else
+        ser_remove="mythweb$postfix $ser_remove"
+        ser_daemon_remove="$ser_daemon_remove"
+fi
 
 #samba
 if [ x$UseSamba = x1 ]
@@ -700,48 +700,56 @@ fi
 
 if [ x$UseNFS = x1 ]
 then
-      ser_install="nfs-utils portmap $ser_install"
-      ser_daemon_add="nfsd nfslock portmap $ser_daemon_add"
-       sed -e "s/REPLACEME/*/g" $TEMPLATES/exports.template > ${BASE}/etc/exports
+    ser_install="nfs-utils portmap $ser_install"
+    ser_daemon_add="nfsd nfslock portmap $ser_daemon_add"
+    sed -e "s/REPLACEME/*/g" $TEMPLATES/exports.template > ${BASE}/etc/exports
 
 else
-      ser_remove="$ser_remove"
-      ser_daemon_remove="nfsd  $ser_daemon_remove"
+    ser_remove="$ser_remove"
+    ser_daemon_remove="nfsd  $ser_daemon_remove"
 fi
 
 if [ x$Runncidd = x1 ]
 then
-           ser_daemon_add="ncidd ncid $ser_daemon_add"
-           ser_install="ncid $ser_install"
+        ser_daemon_add="ncidd ncid $ser_daemon_add"
+        ser_install="ncid $ser_install"
 else
-           ser_daemon_remove="ncidd ncid $ser_daemon_remove"
-           ser_remove="ncid $ser_remove"
+        ser_daemon_remove="ncidd ncid $ser_daemon_remove"
+        ser_remove="ncid $ser_remove"
 fi
 
 
 if [ x$UseEvrouter = x1 ]
 then
-           ser_install="evrouter Xvfb $ser_install"
-  else
-           ser_remove="evrouter $ser_remove"
+        ser_install="evrouter Xvfb $ser_install"
+else
+        ser_remove="evrouter $ser_remove"
 fi
 
 
 if [ x$DDnsEnable = x1 ]
 then
-           ser_daemon_add="inadyn $ser_daemon_add"
-           ser_install="inadyn $ser_install"
+        ser_daemon_add="inadyn $ser_daemon_add"
+        ser_install="inadyn $ser_install"
 else
-           ser_daemon_remove="inadyn $ser_daemon_remove"
-           ser_remove="inadyn $ser_remove"
+        ser_daemon_remove="inadyn $ser_daemon_remove"
+        ser_remove="inadyn $ser_remove"
 fi
 
-if [ x$XScreensaver = x1 ]
-then
-           ser_install="gnome-screensaver $ser_install"
-else
-           ser_remove="gnome-screensaver $ser_remove"
-fi
+case x$Screensavertype in
+    xxscreensaver)   ser_install="xscreensaver $ser_install"
+                    ser_remove="gnome-screensaver $ser_remove"
+                ;;
+    xgscreensaver)  ser_install="xscreensaver gnome-screensaver $ser_install"
+
+                ;;
+    xnone) ser_remove="gnome-screensaver xscreensaver $ser_remove"
+                ;;
+
+    xtinker) echo "tinker mode for screensaver"
+    ;;
+
+    esac
 
 
 
@@ -805,7 +813,7 @@ fi
 function setuppacman () {
 #setup link to httpd dir
 echo "Configuring pacman"
-  if [ ! x$1 = x ]
+if [ ! x$1 = x ]
     then
         ln -s ${BASE}/data/var ${BASE}/data/srv/httpd/htdocs/repo
         echo "creating the link for the pacman repo mirror"
@@ -823,14 +831,14 @@ echo "Configuring pacman"
         USERTEMPLATES="/data/home/mythtv/templates"
         if [ -f $USERTEMPLATES/sources/$i ]
         then
-             echo "Adding user  $i"
+            echo "Adding user  $i"
             cat $USERTEMPLATES/sources/$i  >> ${BASE}/etc/pacman.d/$i
         fi
         cat $TEMPLATES/sources/$i  >> ${BASE}/etc/pacman.d/$i
         echo "setting local mirror to $dbhost for $i "
     done
 
-     #sed -e "s/REPLACEME/$dbhost/g"  $TEMPLATES/sources/svc_pkg > /etc/pacman.d/svc_pkg
+    #sed -e "s/REPLACEME/$dbhost/g"  $TEMPLATES/sources/svc_pkg > /etc/pacman.d/svc_pkg
 
 
 }
@@ -840,10 +848,10 @@ function setupzipcode () {
     if [ ! x$zipcode = x ]
     then
         ${MV_ROOT}/bin/restore_default_settings.sh -c ZIP  -z $zipcode
-	#Let's also speed things up for those in North America
-	mkdir /usr/bin/perlbin/vendor/tv_grabbers_non_na
-	mv /usr/bin/perlbin/vendor/tv_grab_*  /usr/bin/perlbin/vendor/tv_grabbers_non_na
-	mv  /usr/bin/perlbin/vendor/tv_grabbers_non_na/tv_grab_na*  /usr/bin/perlbin/vendor/
+    #Let's also speed things up for those in North America
+    mkdir /usr/bin/perlbin/vendor/tv_grabbers_non_na
+    mv /usr/bin/perlbin/vendor/tv_grab_*  /usr/bin/perlbin/vendor/tv_grabbers_non_na
+    mv  /usr/bin/perlbin/vendor/tv_grabbers_non_na/tv_grab_na*  /usr/bin/perlbin/vendor/
     fi
 }
 
@@ -887,21 +895,21 @@ fi
 }
 
 function setupcnfs () {
-     scrubnfs
+    scrubnfs
         if [ $HaveCentralNFS = "yes" ]
-	then
+    then
             case x$NFSserver in
                 xfile:nfsmap )
                                 process_nfsmap noip
                                 ;;
-               *:nfsmap )
+            *:nfsmap )
                                 nfsmapip=`echo "$NFSserver" | cut -d: -f1 `
                                 process_nfsmap $nfsmapip
                                 ;;
                 *)  setupfstab $NFSserver $NFSmount
                 esac
 
-	    #if [ ! x"$NFSserver" = "xfile:nfsmap" ]
+        #if [ ! x"$NFSserver" = "xfile:nfsmap" ]
             #then
             #    setupfstab $NFSserver $NFSmount
             #else
@@ -914,7 +922,7 @@ function setupcnfs () {
             then
                 setupfstab ${dbhost}:/myth /myth
             fi
-	fi
+    fi
 
 }
 
@@ -1012,19 +1020,19 @@ EOF
 }
 
 function reloadfe(){
-   PID=`ps -ef |grep mythfrontend|grep -v grep |awk  '{print $2 }'`
-   /usr/bin/backend_control.sh  clearcache  behost $dbhost
-   if [ x$RESTART_LCD = xtrue ]
-   then
+PID=`ps -ef |grep mythfrontend|grep -v grep |awk  '{print $2 }'`
+/usr/bin/backend_control.sh  clearcache  behost $dbhost
+if [ x$RESTART_LCD = xtrue ]
+then
     killall -9 mythlcdserver
-   fi
-   if [  x = x$PID ]
-   then
-       echo "Mythfrontend not running, will not reload"
-   else
+fi
+if [  x = x$PID ]
+then
+    echo "Mythfrontend not running, will not reload"
+else
         kill -s USR1 $PID
-   fi
-   exit 0
+fi
+exit 0
 
 }
 
@@ -1045,7 +1053,7 @@ do
     mysqlstatus=$?
     if [ $mysqlstatus = 0 ]
     then
-   	mysql -e "show databases;"
+    mysql -e "show databases;"
         showstatus=$?
         if [ $showstatus = 0 ]
         then
@@ -1059,13 +1067,13 @@ do
             #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
-	   if [ -d /data/srv/mysql/mythconverg ]
-	   then
-	    pacman --noconfirm -R webcalendar
+    if [ -d /data/srv/mysql/mythconverg ]
+    then
+        pacman --noconfirm -R webcalendar
             pacman --noconfirm --nodeps  -S webcalendar
-	    status=0
-	   fi
-   	fi
+        status=0
+    fi
+    fi
     fi
 done
 }
@@ -1076,29 +1084,108 @@ function setup_web_auth {
         #enable auth
         sed -ie "s/^.*include.*auth-inc.conf.*$/include \"\/etc\/lighttpd\/auth-inc.conf\"/g" /etc/lighttpd/lighttpd.conf
     else
-         #disable auth
+        #disable auth
         sed -ie "s/^.*include.*auth-inc.conf.*$/#include \"\/etc\/lighttpd\/auth-inc.conf\"/g" /etc/lighttpd/lighttpd.conf
     fi
     sudo sv restart lighttpd
 
 }
 
-function setupXscreensaver {
+
+function killxscreensaver {
+    xscreensaver-command --exit &
+    killall xscreensaver &
+}
+
+function killgscreensaver(){
+    gnome-screensaver-command --exit &
+    killall gnome-screensaver &
+}
+
+
+function setupscreensaver {
 #copy in template
 
-#start it if not already running.
-    if [ x$XScreensaver = x1 ]
-    then
-        #check if it's running, it not start it.
-        if [ ! x$MV_NEW_INSTALL = "xtrue" ]
-        then
-            su - mythtv -c "/usr/bin/gnome-screensaver "
-        fi
-    else
-        #kill it
-        gnome-screensaver-command --exit &
-        killall gnome-screensaver &
-    fi
+case x$Screensavertype in
+    xxscreensaver)
+                killgscreensaver
+                #why can't it have a nice conf tool like gconf
+                if [ ! -f  $MYTHHOME/.xscreensaver ]
+                then
+                    #copy in template
+                    cp -f $TEMPLATES/xscreensaver.template $MYTHHOME/.xscreensaver
+                fi
+                #change the idle
+                    sed -ie "s/^timeout.*$/timeout:    0:$Screensaveridle:00/g" $MYTHHOME/.xscreensaver
+
+                #set the mode
+                    case x$Screensavertheme in
+                    xRandom)
+                      sed -i "s/^mode.*$/mode:     random/g" $MYTHHOME/.xscreensaver
+                    ;;
+                    xBlank)
+                        sed -i "s/^mode.*$/mode:    blank/g" $MYTHHOME/.xscreensaver
+                    ;;
+                    *)  sed -i "s/^mode.*$/mode:    one/g" $MYTHHOME/.xscreensaver
+                        #set the theme
+                        start=`awk '/programs/{print NR" "}' $MYTHHOME/.xscreensaver`
+                        ss=`awk  '/'$Screensavertheme'/{print NR" "}' $MYTHHOME/.xscreensaver`
+                        sspos=$((ss-start))
+                        sed -i "s/^selected.*$/selected:   $sspos/g" $MYTHHOME/.xscreensaver
+
+                    ;;
+                 esac
+
+
+
+
+
+
+                ;;
+    xgscreensaver)
+                gconftool-2 --direct   --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory  --type bool   --set /apps/gnome-screensaver/lock_enabled false
+                gconftool-2 --direct  --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory  --type int -s "/apps/gnome-screensaver/idle_delay" $Screensaveridle
+                gconftool-2 --direct  --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory  --type string -s "/apps/gnome-screensaver/mode" single
+
+                case x$Screensavertheme in
+                    xRandom)
+                        gconftool-2 --direct  --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory  --type string -s "/apps/gnome-screensaver/mode" random
+
+                    ;;
+                    xBlank)
+                        gconftool-2 --direct  --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory  --type string -s "/apps/gnome-screensaver/themes" blank
+                    ;;
+
+                    *)
+                     gconftool-2  --direct  --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --set --type list --list-type=string /apps/gnome-screensaver/themes [screensavers-$Screensavertheme]
+                     ;;
+                 esac
+
+                killxscreensaver
+                ;;
+    xnone)       killgscreensaver
+                killxscreensaver
+                ;;
+
+    xtinker) echo "tinker mode for setupscreensaver"
+    ;;
+
+    esac
+
+#
+# #start it if not already running.
+#     if [ x$XScreensaver = x1 ]
+#     then
+#         #check if it's running, it not start it.
+#         if [ ! x$MV_NEW_INSTALL = "xtrue" ]
+#         then
+#             su - mythtv -c "/usr/bin/gnome-screensaver "
+#         fi
+#     else
+#         #kill it
+#         gnome-screensaver-command --exit &
+#         killall gnome-screensaver &
+#     fi
 
 
 
@@ -1120,7 +1207,7 @@ case $i in
     sleep) showsleep="true"
         ;;
     hostype) showhost="true"
-             showX="true"
+            showX="true"
         ;;
     hostypec) hosttypechange="true"
             ;;
@@ -1136,16 +1223,16 @@ case $i in
         ;;
     restartfe)  killall -9 mythfrontend
                 killall -9 mythwelcome
-                 exit 0
+                exit 0
         ;;
     reloadfe)  reloadfe
         ;;
     ddns) services
-          install=$ser_install
-          remove=$ser_remove
-          daemon_add=$ser_daemon_add
-          daemon_remove=$ser_daemon_remove
-         ;;
+        install=$ser_install
+        remove=$ser_remove
+        daemon_add=$ser_daemon_add
+        daemon_remove=$ser_daemon_remove
+        ;;
 
     this_is_install) MV_NEW_INSTALL="true"
         ;;
@@ -1155,7 +1242,7 @@ done
 
 if [ x$MV_NEW_INSTALL = xtrue ]
 then
-	hosttypechange="false"
+    hosttypechange="false"
 fi
 
 
@@ -1203,7 +1290,7 @@ case $SystemType in
             services
             if [ x$hosttypechange = "xtrue" ]
             then
-             setup_db
+            setup_db
             fi
             if [ -f   ${BASE}/etc/avahi/services/mysql.service     ]
             then
@@ -1220,7 +1307,7 @@ case $SystemType in
             daemon_remove="none $ser_daemon_remove"
 
     ;;
-   Master_backend)
+Master_backend)
             setupntp 1
             services
 
@@ -1242,7 +1329,7 @@ case $SystemType in
             services
             if [ x$hosttypechange = "xtrue" ]
             then
-             setup_db
+            setup_db
             fi
             if [    -f   ${BASE}/etc/avahi/services/mysql.service     ]
             then
@@ -1272,7 +1359,7 @@ case $SystemType in
 
         daemon_add="avahi portmap nfslock netfs lighttpd $ser_daemon_add "
         daemon_remove="mysql   mythbackend  $ser_daemon_remove"
-   ;;
+;;
 
 
 esac
@@ -1300,7 +1387,7 @@ fi
 
 if [ x$showaudio = "xtrue" ]
 then
-	#setupsoundtype
+    #setupsoundtype
     if [ ! x$Audiotype = xtinker  ]
     then
         ${MV_ROOT}/bin/soundconfig.sh -t real -i $Audiotype -d $SoundDevice
@@ -1314,15 +1401,15 @@ packages
 
 if [ x$showmisc = "xtrue" ]
 then
-	setupzipcode
-	settimezone
+    setupzipcode
+    settimezone
     setupcnfs
 fi
 
 #sleep
 if [ x$showsleep = "xtrue" ]
 then
-	setupsleep
+    setupsleep
 fi
 
 if [ x$showX = "xtrue" ]
@@ -1349,7 +1436,7 @@ then
             else
             setuppacman
         fi
-     fi
+    fi
     setupncidclient
     setupnciddaemon
     setupbootsplash
@@ -1359,7 +1446,8 @@ then
     setupblaster
     setupLCD
     setupDNSMASQ
-    setupXscreensaver
+    setupscreensaver
+
 
 fi
 
@@ -1378,9 +1466,9 @@ fi
 
 case $SystemType in
     Standalone)  smoltsystem=6
-                     MVRELEASE="$MVRELEASE  (Standalone)"
+                    MVRELEASE="$MVRELEASE  (Standalone)"
                     ;;
-   Master_backend)
+Master_backend)
             if [ x$RunFrontend = x1 ]
             then
                 smoltsystem=2
@@ -1390,7 +1478,7 @@ case $SystemType in
                 MVRELEASE="$MVRELEASE  (MBE)"
             fi
             ;;
-   Slave_backend)
+Slave_backend)
             if [ x$RunFrontend = x1 ]
             then
                 smoltsystem=5
@@ -1400,9 +1488,9 @@ case $SystemType in
                 MVRELEASE="$MVRELEASE  (SLAVE)"
             fi
             ;;
-     Frontend_only)
-          smoltsystem=3
-          MVRELEASE="$MVRELEASE  ( Frontend only)"
+    Frontend_only)
+        smoltsystem=3
+        MVRELEASE="$MVRELEASE  ( Frontend only)"
             ;;
 esac
 echo $MVRELEASE > /etc/os_myth_release
-- 
cgit v0.12

