summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-x[-rw-r--r--]abs/core-testing/LinHES-config/PKGBUILD40
-rwxr-xr-xabs/core-testing/LinHES-config/install_proxy.sh800
-rwxr-xr-xabs/core-testing/LinHES-config/mv_advanced.py377
-rwxr-xr-xabs/core-testing/LinHES-config/mv_common.py145
-rwxr-xr-xabs/core-testing/LinHES-config/mv_config.py17
-rwxr-xr-xabs/core-testing/LinHES-config/mv_hostype.py147
-rwxr-xr-xabs/core-testing/LinHES-config/mv_install.py1241
-rwxr-xr-xabs/core-testing/LinHES-config/mv_ir.py288
-rwxr-xr-xabs/core-testing/LinHES-config/mv_misc.py174
-rwxr-xr-xabs/core-testing/LinHES-config/mv_network.py276
-rwxr-xr-xabs/core-testing/LinHES-config/mv_screensaver.py199
-rwxr-xr-xabs/core-testing/LinHES-config/mv_smolt.py59
-rwxr-xr-xabs/core-testing/LinHES-config/mv_software.py41
-rwxr-xr-xabs/core-testing/LinHES-config/mv_webuser.py21
-rwxr-xr-xabs/core-testing/LinHES-config/systemconfig.py223
-rwxr-xr-xabs/core-testing/LinHES-config/systemconfig.sh1444
17 files changed, 3370 insertions, 2123 deletions
diff --git a/.gitignore b/.gitignore
index 30bd13f..6815683 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ pkg
mythbeselect.bin
mythinstall.bin
srclinks.*
+*.pyc
diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index f3d9638..58dcfd8 100644..100755
--- a/abs/core-testing/LinHES-config/PKGBUILD
+++ b/abs/core-testing/LinHES-config/PKGBUILD
@@ -1,12 +1,12 @@
pkgname=LinHES-config
pkgver=1.0
-pkgrel=403
+pkgrel=429
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 rsync )
+depends=(bc libstatgrab mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates rsync python-parted )
arch=('i686')
-source=(mythinstall.bin myth_user_call file_time_offset.py install-ui.xml install_proxy.sh install_functions.sh systemconfig.sh install_db_chroot.sh restore_default_settings.sh xconfig.sh timezip.py soundconfig.sh LinHES-release issue MythVantage.sh create_master.sh build_diskless.sh networkconfig.sh timezone.bin autocard.py restore_km_db_chroot.sh README ir_config.sh)
+source=(mv_install.py mv_config.py mythinstall.bin myth_user_call file_time_offset.py install-ui.xml install_proxy.sh install_functions.sh systemconfig.sh install_db_chroot.sh restore_default_settings.sh xconfig.sh timezip.py soundconfig.sh LinHES-release issue MythVantage.sh create_master.sh build_diskless.sh networkconfig.sh timezone.bin autocard.py restore_km_db_chroot.sh README ir_config.sh mv_advanced.py mv_common.py mv_ir.py mv_misc.py mv_network.py mv_screensaver.py mv_smolt.py mv_software.py mv_webuser.py mv_hostype.py systemconfig.py)
install=LinHES.install
build() {
@@ -17,18 +17,15 @@ build() {
mkdir $startdir/pkg/etc/profile.d
install -m 0755 MythVantage.sh $startdir/pkg/etc/profile.d/MythVantage.sh
mkdir -p $MVDIR/bin
- # mkdir -p $MVDIR/templates
mkdir -p $MVDIR/etc
-#copy in all the installer specific stuff
-# rsync -r --exclude=.svn ../templates $MVDIR/
+ #copy in all the installer specific stuff
install -m0700 myth_user_call $MVDIR/bin/myth_user_call
install -m 0755 install_proxy.sh $MVDIR/bin/install_proxy.sh
install -m 0755 install_functions.sh $MVDIR/bin/install_functions.sh
install -m 0755 systemconfig.sh $MVDIR/bin/systemconfig.sh
install -m 0755 xconfig.sh $MVDIR/bin/xconfig.sh
install -m 0755 ir_config.sh $MVDIR/bin/ir_config.sh
-# install -m 0755 live-install.sh $MVDIR/bin/live-install.sh
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
@@ -39,29 +36,38 @@ build() {
install -m 0755 timezone.bin $MVDIR/bin/timezone.bin
install -m 0755 timezip.py $MVDIR/bin/timezip.py
install -m 0755 autocard.py $MVDIR/bin/autocard.py
-
-
+ install -m 0755 mv_config.py $MVDIR/bin/mv_config.py
+ install -m 0755 mv_install.py $MVDIR/bin/mv_install.py
+ install -m 0755 mv_advanced.py $MVDIR/bin/
+ install -m 0755 mv_common.py $MVDIR/bin/
+ install -m 0755 mv_ir.py $MVDIR/bin/
+ install -m 0755 mv_misc.py $MVDIR/bin/
+ install -m 0755 mv_network.py $MVDIR/bin/
+ install -m 0755 mv_screensaver.py $MVDIR/bin/
+ install -m 0755 mv_smolt.py $MVDIR/bin/
+ install -m 0755 mv_software.py $MVDIR/bin/
+ install -m 0755 mv_webuser.py $MVDIR/bin/
+ install -m 0755 mv_hostype.py $MVDIR/bin/
+ install -m 0755 systemconfig.py $MVDIR/bin/
+
+ #README file displayed on install
install -m 0755 README $MVDIR/README
mkdir -p $startdir/pkg/usr/bin
install -m 0755 file_time_offset.py $startdir/pkg/usr/bin/file_time_offset.py
- #copy in the branding stuff
+
+ #Copy in the branding stuff
install -m 0755 LinHES-release $startdir/pkg/etc/LinHES-release
install -m 0755 issue $startdir/pkg/etc/issue
-# copy over the ui files
+ # copy over the ui files
install -m 0755 install-ui.xml $startdir/pkg/usr/share/mythtv/themes/default/
-#copy in the binaries
- #install -g mythtv -m 4750 mythinstall.bin $MVDIR/bin/MythVantage
+ #copy in the binaries
install -m 4755 mythinstall.bin $MVDIR/bin/MythVantage
cd $MVDIR/bin
ln -s MythVantage mythvantage
ln -s MythVantage mythinstall
cd -
-# install -g mythtv -m 4750 mythbeselect.bin $MVDIR/bin/mythbeselect
-
-# install -m 0755 startx $startdir/pkg/root/startx
-# install -m 0755 live-install.sh $startdir/pkg/root/live-install.sh
}
diff --git a/abs/core-testing/LinHES-config/install_proxy.sh b/abs/core-testing/LinHES-config/install_proxy.sh
index d39f712..b9d6b67 100755
--- a/abs/core-testing/LinHES-config/install_proxy.sh
+++ b/abs/core-testing/LinHES-config/install_proxy.sh
@@ -17,685 +17,155 @@ run=$MV_ROOT/bin/install_functions.sh
CMDLINE=$(cat /proc/cmdline)
BACKUPFILE="/myth/backup/mythconverg.sql.gz"
-#TEMPNET="Hostip"$default_interface
-#eval MYTHIP=\$${TEMPNET}
-function create_chroot_mnt_points() {
-
- echo "Creating directory for media in chroot"
- mkdir -p $mountpoint/media/cdrom
- mkdir -p $mountpoint/media/dvd
- mkdir -p $mountpoint/mnt
-
-}
-function cp_and_log () {
- ls $1 >/dev/null 2>&1
- status=$?
- if [ $status = 0 ]
- then
- echo "copying $1 to $2"
- cp -rfp $1 $2
- else
- echo "$1 is not present, skipping..."
- fi
-
-}
-
-function mdadm_find () {
-
- PREFIX=$1
- if [ -e $PREFIX/etc/KnoppMyth-version ]
- then
- MDADM_CONF="/etc/mdadm/mdadm.conf"
- else
- MDADM_CONF="/etc/mdadm.conf"
- fi
- echo "Using $MDADM_CONF"
-}
progress () {
-mypercent=`echo "$1" | cut -d. -f1`
-if [ x$mypercent = x ]
-then
-echo "" > /tmp/.install_percent
-else
-echo "${mypercent}% complete" > /tmp/.install_percent
-fi
-
-
-}
-
-function apply_new_auth () {
-#check if file is present
- if [ -f /root/myth_user_call.out ]
- then
- #read in file, running each command in chroot
- exec 4</root/myth_user_call.out
- while read LINE <&4
- do
- if [ ! x"$LINE" = x ]
- then
- #run commands in chroot
- chroot "$mountpoint" $MV_ROOT/bin/myth_user_call -i $LINE > /tmp/user_auth.update
- fi
- done
- rm -f /root/myth_user_call.out
- else
- echo "No new password changes to apply"
- fi
-}
-
-
-function backup_sql_check {
- if [ -f ${mountpoint}${BACKUPFILE} ]
- then
- echo "found ${mountpoint}${BACKUPFILE} "
- rc=0
- else
- echo "did not find ${mountpoint}${BACKUPFILE} "
- rc=1
- fi
- return $rc
-}
-
-function mdadm_assemble_all {
-
- mdadm_find /tmp
- mdadm --assemble --scan -c /tmp${MDADM_CONF}
- MDLIST=`grep ARRAY /tmp${MDADM_CONF}|tr -s [:space:]|cut -d" " -f2`
- for array in $MDLIST
- do
- echo "assembling array $array"
- mdadm --assemble -c /tmp${MDADM_CONF} $array
- sleep 2
- fsck -p $array
- done
-
-}
-
-function upgrade_mount_search {
-
- MYTH_P=`cat /tmp/etc/fstab |grep -E /myth[[:space:]] | awk ' {print $1 '} `
- umount $mountpoint/myth
-
- #should probably just mdadm all the time
- echo $MYTH_P |grep -q \/md.
- if [ $? = 0 ]
+ mypercent=`echo "$1" | cut -d. -f1`
+ if [ x$mypercent = x ]
then
- mdadm_assemble_all
- fi
-
- echo $MYTH_P |grep -q UUID
- if [ $? = 0 ]
- then
- MUUID=`echo $MYTH_P|cut -d= -f2|tr -d \"`
- echo blkid $MUUID
- blkid -t UUID=$MUUID
- if [ ! $? = 0 ]
- then
- echo "couldn't find $MUUID, starting md support"
- mdadm_assemble_all
- fi
- mount -U $MUUID $mountpoint/myth
- echo mount -U $MUUID $mountpoint/myth
- MYTHMOUNT=`blkid -t UUID=$MUUID|cut -d: -f1`
- MYTHMOUNT=`basename $MYTHMOUNT`
- echo "MYTHMOUNT is $MYTHMOUNT"
+ echo "" > /tmp/.install_percent
else
- mount $MYTH_P $mountpoint/myth
- echo mount $MYTH_P $mountpoint/myth
- MYTHMOUNT=`basename $MYTH_P`
- echo "MYTHMOUNT is $MYTHMOUNT"
- fi
- sleep 2
- backup_sql_check
- if [ $? = 1 ]
- then
- mkdir -p /new_boot/root/backup
- if [ ! -e /tmp/mythconverg.sql.gz ]
- then
- echo "Couldn't find ANY database to restore, upgrade will continue but a new database will be installed."
- else
- cp_and_log /tmp/mythconverg.sql.gz /new_boot/root/backup/mythconverg.sql.gz
- BACKUPFILE="/root/backup/mythconverg.sql.gz"
- echo "setting BACKUPFILE to $BACKUPFILE"
- fi
+ echo "${mypercent}% complete" > /tmp/.install_percent
fi
- return 0
}
-full_install () {
- if [ -f /tmp/.this_is_upgrade ]
- then
- rm /tmp/.this_is_upgrade
- fi
- echo "Partitioning $disk" > /tmp/.install_state
- progress 1
- sleep 1
- $run partition_it $disk $rootsize $datasize $swapsize
-
- echo "Formating $disk" > /tmp/.install_state
- progress 2
- sleep 1
- $run format_it $disk $rootfs $datafs
-
- echo "Preparing $disk" > /tmp/.install_state
- progress 3
- sleep 1
- $run mount_it $disk
-
- startsize=`statgrab -M disk.|grep $disk.write_bytes|cut -d= -f 2|tr -d " "`
-
- echo "STARTSIZE=$startsize">/tmp/.startsize.io
- echo "Creating $hostname" > /tmp/.install_state
-
- sleep 1
- $run copy_it $disk ALL
- rm $mountpoint/etc/fstab
- $run fstab_fix_it $disk $rootfs $datafs FULL_INSTALL
- echo "Configuring system" > /tmp/.install_state
- progress 100
- #progress 99
- sleep 1
- $run grub_it $disk
-
-
- #echo "Configuring system" > /tmp/.install_state
- #progress 100
- sleep 1
- cp_and_log /etc/systemconfig "$mountpoint"/etc
- cp_and_log /root/xorg.conf.install "$mountpoint"/etc/X11/xorg.conf.install
- #run save syssettings to save settings, then copy to new mountpoint
- $MV_ROOT/bin/restore_default_settings.sh -c save -t syssettings -h $MVHOSTNAME -d localhost
- SE=$TEMPLATES/settings/syssettings
- mkdir -p ${mountpoint}$SE
- #cp -rp $SE/* ${mountpoint}$SE/
- cp_and_log "$SE/*" "${mountpoint}$SE/"
- chown root:mythtv "$mountpoint"/etc/systemconfig
- chown -R mythtv:mythtv ${mountpoint}$SE
-
- chmod -R 775 ${mountpoint}$SE
- chmod 775 "$mountpoint"/etc/systemconfig
- mkdir -p "$mountpoint"/var/log/mythtv
- chown mythtv "$mountpoint"/var/log/mythtv
- #copy over any updates that might have occured
- #cp -rp $MV_ROOT/bin/*.sh "$mountpoint"$MV_ROOT/bin/
- cp_and_log "$MV_ROOT/bin/*.sh" "$mountpoint"$MV_ROOT/bin/
- chmod -R 755 ${mountpoint}/root
- create_chroot_mnt_points
- cp_and_log /etc/mtab "$mountpoint"/etc/mtab
- # cp_and_log /etc/hostname "$mountpoint"/etc/hostname
- apply_new_auth
-
-
- if [ $SystemType = "Master_backend" -o $SystemType = "Standalone" ]
- then
- #installing DB to local machine
- #turn off old live database, so the chroot one can start
- echo "---------------------CHROOT INSTALLDB-------------------------"
- /etc/rc.d/mysqld stop
- mount --bind /dev "$mountpoint/dev"
- mount --bind /proc "$mountpoint/proc"
- mount -t sysfs none $mountpoint/sys
- chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" 2>&1 |tee /tmp/chrootdb.out
- #chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh"
- chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,user,this_is_install
- echo "stopping mysql in chroot"
- chroot "$mountpoint" /etc/rc.d/mysqld stop
- kill_dhcp_chroot
- sleep 2
- lsof |grep new_boot
- umount -l "$mountpoint/dev"
- umount -l "$mountpoint/proc"
- umount -l "$mountpoint/sys"
-
- echo "---------------------END CHROOT INSTALLDB-------------------------"
- /etc/rc.d/mysqld start
- else
- #update remotedb with this host settings
- mount --bind /dev "$mountpoint/dev"
- mount --bind /proc "$mountpoint/proc"
- mount -t sysfs none $mountpoint/sys
- chroot "$mountpoint" DISPLAY=127.0.0.1:0 /usr/local/bin/MythVantage -t restore,default_1
- chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings
- if [ ! $? = 0 ]
- then
- touch $mountpoint/tmp/.dbsysfailed
- chmod 777 $mountpoint/tmp/.dbsysfailed
- else
- #Run second time
- chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,user,this_is_install
- chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c ACCESSCONTROL
- umount -l "$mountpoint/dev"
- umount -l "$mountpoint/proc"
- umount -l "$mountpoint/sys"
- fi
- fi
- chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced,user
- touch $mountpoint/home/mythtv/.configure && chmod 777 $mountpoint/home/mythtv/.configure
-
- echo "Done" > /tmp/.install_state
- cp_and_log /tmp/mythvantage_install.log $mountpoint/var/log/
- $run umount_it $disk
-
-}
-
-function createsquashlist(){
-if [ -f $1 ]
-then
- rm -f
-$1
-fi
-for i in bin boot etc home lib opt root sbin usr var data
-do
-echo $i >> $1
-done
-
-
-}
-
-
-
-
-function upgrade () {
- touch /tmp/.this_is_upgrade
-
- if [ ! x$rootfs = "xDo_not_format" ]
- then
- echo "Formating
- $disk" > /tmp/.install_state
- progress 2
- sleep 1
- $run format_it $disk $rootfs NO
- fi
- echo "Preparing $disk" > /tmp/.install_state
- progress 3
- sleep 1
- $run mount_it $disk
- startsize=`statgrab -M disk.|grep $disk.write_bytes|cut -d= -f 2|tr -d " "`
- echo "STARTSIZE=$startsize">/tmp/.startsize.io
- echo "Upgrading $hostname" > /tmp/.install_state
- sleep 1
- cp_and_log /tmp/etc /new_boot/etc.old
- cp_and_log /tmp/oss /new_boot/var/lib/oss.old
-
-
- SQUASHLIST="/tmp/.squashlist"
- createsquashlist $SQUASHLIST
- $run copy_it $disk $SQUASHLIST
- #copy back ssh keys
-
-# cp_and_log -rp /data/var/cache/pacman/pkg/* /new_boot/data/var/cache/pacman/pkg/
- cp_and_log "/new_boot/etc.old/ssh/*.pub" /new_boot/etc/ssh/
- cp_and_log "/new_boot/etc.old/ssh/*.key" /new_boot/etc/ssh/
- cp_and_log "/new_boot/etc.old/ssh/*key" /new_boot/etc/ssh/
- mdadm_find /tmp
- cp_and_log /tmp${MDADM_CONF} /new_boot/etc
- #cp_and_log /new_boot/etc.old/mdadm/mdadm.conf /new_boot/etc/
- cp_and_log /new_boot/etc.old/asound.state /new_boot/etc/
- if [ ! -f /tmp/etc/KnoppMyth-version ]
- then
- #passwd/shadow/group
- cp_and_log /new_boot/etc.old/passwd /new_boot/etc/
- cp_and_log /new_boot/etc.old/shadow /new_boot/etc/
- cp_and_log /new_boot/etc.old/group /new_boot/etc/
- fi
- mkdir -p "$mountpoint"/var/log/mythtv
- chown mythtv "$mountpoint"/var/log/mythtv
- if [ x$rootfs = "xDo_not_format" ]
- then
- rootfs=`grep \/\ /tmp/etc/fstab |awk ' { print $3 } '`
- fi
- #this is here to copy in the systemconfig file as soon as possible.
- cp_and_log /etc/systemconfig "$mountpoint"/etc/systemconfig
- echo "Configuring system" > /tmp/.install_state
- progress 100
- backup_sql_check
- if [ $? = 1 ]
- then
- upgrade_mount_search
- fi
- echo $run fstab_fix_it $disk UPGRADE $MYTHMOUNT
- $run fstab_fix_it $disk UPGRADE $MYTHMOUNT
- create_chroot_mnt_points
-
- #echo "Writing boot sector" > /tmp/.install_state
- #progress 99
- sleep 1
- $run grub_it $disk
- #echo "Configuring system" > /tmp/.install_state
- #progress 100
- sleep 1
- cp_and_log /etc/mtab "$mountpoint"/etc/mtab
- cp_and_log /etc/systemconfig "$mountpoint"/etc
- cp_and_log /root/xorg.conf.install "$mountpoint"/etc/X11/xorg.conf.install
-#make sure mythconverg.sql.gz is present
- #backup_sql_check
- #if [ $? = 1 ]
- #then
- # upgrade_mount_search
- #fi
- echo $CMDLINE | grep -q clean_upgrade
- status=$?
- if [ -f /tmp/etc/KnoppMyth-version -o $status = 0 ]
- then
- #run save syssettings to save settings, then copy to new mountpoint
- $MV_ROOT/bin/restore_default_settings.sh -c save -t syssettings -h $MVHOSTNAME -d localhost
- SE=$TEMPLATES/settings/syssettings
- mkdir -p ${mountpoint}$SE
- #cp -rfp $SE/* ${mountpoint}$SE/
- cp_and_log "$SE/*" "${mountpoint}$SE/"
- chown root:mythtv "$mountpoint"/etc/systemconfig
- chown -R mythtv:mythtv ${mountpoint}$SE
- chmod -R 775 ${mountpoint}$SE
- if [ ! $status = 0 ]
- then
- touch $mountpoint/home/mythtv/.kmupgrade && chmod 777 $mountpoint/home/mythtv/.kmupgrade
- fi
- fi
-
-
-
- cp_and_log "$MV_ROOT/bin/*.sh" "$mountpoint"$MV_ROOT/bin/
- chmod -R 755 ${mountpoint}/root
- chown root:mythtv "$mountpoint"/etc/systemconfig
- chmod 775 "$mountpoint"/etc/systemconfig
- #mount /proc and /dev
- mount --bind /dev "$mountpoint/dev"
- mount --bind /proc "$mountpoint/proc"
-
- chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,user,this_is_install
- #wrap this in a network check_network, no need to update the db if the import worked.
- ##### do I need to start mysql?
- /etc/rc.d/mysqld stop
- if [ $SystemType = "Master_backend" -o $SystemType = "Standalone" ]
- then
- echo $CMDLINE | grep -q clean_upgrade
- status=$?
- if [ $status = 0 ]
- then
- #new db as part of clean upgrade
- echo "--------------------------------"
- echo "clean upgrade installing new database"
- echo "--------------------------------"
- chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" |tee /tmp/chrootdb.out
- echo "############################################"
- echo "End Installing new database/clean"
- echo "############################################"
- else
- #proceed as normal
- if [ -f "$mountpoint"/$BACKUPFILE ]
- then
- echo "--------------------------------"
- echo "Restoring database with $BACKUPFILE"
- echo "--------------------------------"
- chroot "$mountpoint" "$MV_ROOT/bin/restore_km_db_chroot.sh" "$BACKUPFILE" |tee /tmp/chrootdb_km.out
- echo "############################################"
- echo "End Restoring database"
- echo "############################################"
- else
- echo "--------------------------------"
- echo "Couldn't find backup file, installing new database"
- echo "--------------------------------"
- touch /tmp/.upgrade_db_failed
- chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" |tee /tmp/chrootdb.out
- echo "############################################"
- echo "End Installing new database"
- echo "############################################"
- fi
- fi
- fi
-
- if [ -f /tmp/etc/KnoppMyth-version ]
- then
- chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c restore -t hostsettings
- #change permissions of /myth (only needed on km->linhes)
- chown -R mythtv:mythtv $mountpoint/myth
- chown -R root:root $mountpoint/myth/backup
- else
- chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings
- fi
- #
- #Run second time
- chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,user,this_is_install
- chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced,this_is_install
- echo "stopping mysql in chroot"
- chroot "$mountpoint" /etc/rc.d/mysqld stop
- apply_new_auth
- kill_dhcp_chroot
- umount -l "$mountpoint/dev"
- umount -l "$mountpoint/proc"
-
- echo "Done" > /tmp/.install_state
- cp_and_log /tmp/mythvantage_install.log $mountpoint/var/log/
-
- $run umount_it $disk
- /etc/rc.d/mysqld start
-}
-
-function netboot-full_install () {
- TEMPVAR=${CMDLINE#*nfsroot=}
- NFSROOT=${TEMPVAR%% *}
- NFSROOT=`echo $NFSROOT|cut -d: -f1`
- MAC=`/sbin/ifconfig eth0|grep HWaddr| cut -d: -f2-|awk '{ print $3}'|tr : -`
- URL="http://$NFSROOT:1337/diskless.py?HOSTNAME=$hostname&MAC=$MAC"
- echo "calling $URL"
- echo "Starting" > /tmp/.install_state
- curl $URL
- ${MV_ROOT}/bin/xconfig.sh
-}
-
-# function killdhcp () {
-# if [ -f /etc/dhcpc/dhcpcd-eth0.pid ]
-# then
-# pid=`cat /etc/dhcpc/dhcpcd-eth0.pid`
-# kill -9 $pid
-# rm -f /etc/dhcpc/dhcpcd-eth0.pid
-# rm -f /var/run/dhcpcd*
-# fi
-# if [ -f /var/run/dhcpcd-eth0.pid ]
-# then
-# pid=`cat /var/run/dhcpcd-eth0.pid`
-# kill -9 $pid
-# rm -f /var/run/dhcpcd-eth0.pid*
-# fi
-# ip address flush dev eth0
-# }
-
-
-
-function SANE_SYSETTINGS () {
-sed -e '/HOSTrootfstype/d' \
- -e '/HOSTrootfstype/d' \
- -e '/HOSTdatafstype/d' \
- -e '/HOSTOSsize/d' \
- -e '/HostUseALLdata/d' \
- -e '/HOSTDATAsize/d' \
- -e '/HOSTuprootfstype/d' \
- -e '/HostUseSWAP/d' \
- -e '/HOSTSWAPsize/d ' /tmp/templates/settings/syssettings/settings.txt > /tmp/settings.new
- mv /tmp/settings.new /tmp/templates/settings/syssettings/settings.txt
-}
-
case $1 in
- full_install_it ) full_install ;;
-
- NETBOOT)
-echo "-----------------------------------------------------------------------3-----"
- netboot-full_install ;;
-
- find_update)
-
- #TRY TO mount first partition of drive
- #copy /etc/systemconfig to live, import settings into db
- #umount drive
- echo $CMDLINE | grep -q clean_upgrade
- if [ $? = 1 ]
- then
- $run mount_it $disk
- [ -e "/new_boot/root/backup/mythconverg.sql.gz" ] && cp /new_boot/root/backup/mythconverg.sql.gz /tmp
-
-
- if [ -f /new_boot/etc/systemconfig ]
- then
- ###########ADD templates
- mkdir -p $TEMP_TEMPLATES
- cp_and_log /new_boot/$TEMPLATES $TEMP_TEMPLATES
- SANE_SYSETTINGS
- cp_and_log $TEMP_TEMPLATES/settings $TEMPLATES/
- cp_and_log /new_boot/etc/systemconfig /etc/systemconfig
- cp_and_log /new_boot/etc /tmp/etc
- cp_and_log /new_boot/var/lib/oss /tmp/oss
- [ -e /tmp/etc/mdadm.conf ] && cp_and_log /tmp/etc/mdadm.conf /etc/
-
- $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings -h $MVHOSTNAME -d 127.0.0.1
- else
- cp_and_log /new_boot/etc /tmp/etc
- [ -e /tmp/etc/mdadm.conf ] && cp_and_log /tmp/etc/mdadm.conf /etc/
- #now we search for the timezone and try to update
- TZREGION=`cat /tmp/etc/timezone | cut -d"/" -f1`
- TZSUB=`cat /tmp/etc/timezone | cut -d"/" -f2 -`
-
-
- if [ $TZREGION = $TZSUB ]
- then
- $run update_db_it HostTimeZoneRegion "$TZREGION"
- else
- $run update_db_it HostTimeZoneRegion "$TZREGION"
- $run update_db_it HostTimeZoneRegion_$TZREGION "$TZSUB"
- fi
- fi
- backup_sql_check
- echo $?
- upgrade_mount_search
- echo $?
- $run umount_it $disk
- fi
+ full_install_it )
+ mv_install.py --rootdisk=$disk --rootfs=$rootfs --rootsize=$rootsize --datafs=$datafs --datasize=$datasize --datadisk=$disk --swapsize=$swapsize -c full_install
;;
- upgrade_it)
- upgrade
+ NETBOOT)
+ echo "-----------------------------------------------------------------------3-----"
+ netboot-full_install
;;
- disk_model_it)
- model="unknown"
- size="xxx"
- case $2 in
- h* )
- model=`cat /proc/ide/$2/model`
- ;;
- s*) model=`sginfo /dev/$2|grep Product|awk ' { print $2 } '`
- ;;
- esac
- size=`parted /dev/$2 print |grep Disk|awk ' { print $3 } ' `
- echo ""$model" $size " >/tmp/model
+ find_update)
+ mv_install.py --rootdisk=$disk -c find_upgrade
;;
- network_check_it)
- #Should never return from check_network
- case $2 in
- setup_network)
- vnc_check
- install_network_setup
- ;;
-
- check_self)
- myipdefault=`ifconfig | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'`
- echo "network check myself"
- ifconfig
- ping -c 1 $myipdefault
- if [ ! $? = 0 ]
- then
- exit 3
- #can't ping yourself
- fi
- ;;
- check_gw)
- #check gateway
- echo "network check gateway"
- /sbin/route -n
- mygwdefault=`/sbin/route -n |grep $default_interface|grep UG|awk '{ print $2}'`
- echo "Default gateway seems to be $mygwdefault"
- if [ ! x$mygwdefault = x ]
- then
- sleep 2
- ping -c 5 $mygwdefault
- if [ ! $? = 0 ]
- then
- exit 4
- fi
- fi
- ;;
- check_ns)
- #check nameserver
- echo " network check nameserver"
- mydns=`cat /etc/resolv.conf|grep nameserver|head -1|awk '{ print $2}'`
- ping -c 1 $mydns
- if [ ! $? = 0 ]
- then
- exit 5
- fi
- ;;
- check_names)
- echo "network check resolve names"
- host google.com
- if [ ! $? = 0 ]
- then
- exit 6
- fi
- ;;
- host_names)
- #if host is found, then check to see if it's online
- #if hoip matchs my ip assume it's ok
- echo "network check my hostname $hostname"
- hout=`host $hostname|head -n1`
- status=$?
- hoip=`echo $hout|awk '{print $4}'`
- if [ $hoip = found: ]
- then
- status=1
- fi
-
- unkownhost=`host unkown.linhes.org |head -n1 `
- unkownhostip=`echo $unkownhost |awk '{print $4}'`
- #found host, now grab the ip
- if [ $status = 0 ]
- then
- hoip=`echo $hout|awk '{print $4}'`
- /sbin/ifconfig -a |grep -q $hoip
- if [ $? = 0 ]
- then
- echo "DNS ip matches on of my ips $hoip"
- status=0
- else
- if [ $unkownhostip = $hoip ]
- then
- echo "Bad DNS returning false hits"
- echo "Assuming hostname is OK"
- echo "DNS unknown: $unkownhostip"
- echo " HOSTDNS: $hoip "
- /sbin/ifconfig -a |grep "inet addr"
- else
- echo "IP in DNS but doesn't match mine, hostname is not safe to use"
- echo "DNS:$hoip"
- echo "HOST: "
- /sbin/ifconfig -a |grep "inet addr"
- status=7
- fi
- fi
- else
- echo "Couldn't find hostname in DNS, must be safe to use"
- status=0
- fi
- exit $status
- ;;
+ upgrade_it)
+ mv_install.py --rootdisk=$disk --rootfs=$rootfs -c upgrade
+ ;;
- esac
- exit 0
+ disk_model_it)
+ model="unknown"
+ size="xxx"
+ case $2 in
+ h* )
+ model=`cat /proc/ide/$2/model`
+ ;;
+ s*) model=`sginfo /dev/$2|grep Product|awk ' { print $2 } '`
+ ;;
+ esac
+ size=`parted /dev/$2 print |grep Disk|awk ' { print $3 } ' `
+ echo ""$model" $size " >/tmp/model
;;
+ network_check_it)
+ #Should never return from check_network
+ case $2 in
+ setup_network)
+ vnc_check
+ install_network_setup
+ ;;
+
+ check_self)
+ myipdefault=`ifconfig | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'`
+ echo "network check myself"
+ ifconfig
+ ping -c 1 $myipdefault
+ if [ ! $? = 0 ]
+ then
+ exit 3
+ #can't ping yourself
+ fi
+ ;;
+ check_gw)
+ #check gateway
+ echo "network check gateway"
+ /sbin/route -n
+ mygwdefault=`/sbin/route -n |grep $default_interface|grep UG|awk '{ print $2}'`
+ echo "Default gateway seems to be $mygwdefault"
+ if [ ! x$mygwdefault = x ]
+ then
+ sleep 2
+ ping -c 5 $mygwdefault
+ if [ ! $? = 0 ]
+ then
+ exit 4
+ fi
+ fi
+ ;;
+ check_ns)
+ #check nameserver
+ echo " network check nameserver"
+ mydns=`cat /etc/resolv.conf|grep nameserver|head -1|awk '{ print $2}'`
+ ping -c 1 $mydns
+ if [ ! $? = 0 ]
+ then
+ exit 5
+ fi
+ ;;
+ check_names)
+ echo "network check resolve names"
+ host google.com
+ if [ ! $? = 0 ]
+ then
+ exit 6
+ fi
+ ;;
+ host_names)
+ #if host is found, then check to see if it's online
+ #if hoip matchs my ip assume it's ok
+ echo "network check my hostname $hostname"
+ hout=`host $hostname|head -n1`
+ status=$?
+ hoip=`echo $hout|awk '{print $4}'`
+ if [ $hoip = found: ]
+ then
+ status=1
+ fi
+
+ unkownhost=`host unkown.linhes.org |head -n1 `
+ unkownhostip=`echo $unkownhost |awk '{print $4}'`
+
+ #found host, now grab the ip
+ if [ $status = 0 ]
+ then
+ hoip=`echo $hout|awk '{print $4}'`
+ /sbin/ifconfig -a |grep -q $hoip
+ if [ $? = 0 ]
+ then
+ echo "DNS ip matches on of my ips $hoip"
+ status=0
+ else
+ if [ $unkownhostip = $hoip ]
+ then
+ echo "Bad DNS returning false hits"
+ echo "Assuming hostname is OK"
+ echo "DNS unknown: $unkownhostip"
+ echo " HOSTDNS: $hoip "
+ /sbin/ifconfig -a |grep "inet addr"
+ else
+ echo "IP in DNS but doesn't match mine, hostname is not safe to use"
+ echo "DNS:$hoip"
+ echo "HOST: "
+ /sbin/ifconfig -a |grep "inet addr"
+ status=7
+ fi
+ fi
+ else
+ echo "Couldn't find hostname in DNS, must be safe to use"
+ status=0
+ fi
+ exit $status
+ ;;
+
+ esac
+ exit 0
+ ;;
- * )
+ * )
if [ -f /tmp/.install_state ]
then
state=`cat /tmp/.install_state`
@@ -709,7 +179,7 @@ echo "-----------------------------------------------------------------------3--
if [ -f /tmp/.startsize.io ]
then
- . /tmp/.startsize.io
+ . /tmp/.startsize.io
#finding the drive
ddrive=`df | grep $mountpoint | head -n1 | awk -F/ ' { print $3 } ' | cut -d" " -f 1|cut -b1,2,3 `
used=`statgrab -M disk.|grep ${ddrive}.write_bytes|cut -d= -f 2|tr -d " "`
@@ -731,7 +201,11 @@ echo "-----------------------------------------------------------------------3--
cond2=$(echo "$percent > 98" |bc )
if [ $cond2 -eq 1 ]
then
- percent=98
+ percent=98
+ fi
+ if [ x"${state}" = "xDone" ]
+ then
+ percent=100
fi
cond3=$(echo "$percent < 3" |bc )
if [ $cond3 -eq 0 ]
@@ -740,7 +214,7 @@ echo "-----------------------------------------------------------------------3--
fi
fi
fi
- ;;
+ ;;
esac
diff --git a/abs/core-testing/LinHES-config/mv_advanced.py b/abs/core-testing/LinHES-config/mv_advanced.py
new file mode 100755
index 0000000..f5a0f29
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_advanced.py
@@ -0,0 +1,377 @@
+# -*- coding: utf-8 -*-
+import logging, os, re
+import mv_common
+
+def setup_pacman(create_link):
+ if create_link:
+ logging.info(" Creating pacman link")
+ #LOOK
+ #This is not implmented yet, below is the bash code for reference
+ #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"
+ #fi
+
+ #for i in mv-core mv-core-testing mv-extra mv-extra-testing
+ #do
+ #echo "[$i]" > ${BASE}/etc/pacman.d/$i
+ ##add mirror if needed
+ #if [ x$PKG_MIRROR = x1 ]
+ #then
+ #echo " Server = http://$dbhost/repo/$i " >> ${BASE}/etc/pacman.d/$i
+ #fi
+ ##add user templates
+ #USERTEMPLATES="/data/home/mythtv/templates"
+ #if [ -f $USERTEMPLATES/sources/$i ]
+ #then
+ #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
+ else:
+ logging.info(" Pacman link will not be created")
+ return
+
+def setup_ncid_client(dbhost,templatefile):
+ #This always runs
+ logging.debug(" Configuring ncid client with server %s",dbhost)
+ cmd = '''sed -e "s/^set Host.*$/set Host %s /" %s >/etc/ncid/ncid.conf''' %(dbhost, templatefile)
+ return
+
+def setup_ncid_daemon(port,templatefile,Runncidd):
+ logging.info(" Configuring callerid daemon")
+ if Runncidd == "1":
+ logging.debug(" Port: %s",port)
+ mv_common.cp_and_log("/etc/ncid/ncidd.conf",templatefile)
+ cmd = '''sed -e "s/.*set ttyport.*$/set ttyport = \/dev\/%s /" %s >/etc/ncid/ncidd.conf''' %(port,templatefile)
+ mv_common.runcmd(cmd)
+ mv_common.pacinstall("ncidd")
+ mv_common.add_service("ncidd")
+ else:
+ logging.debug(" Callerid will not run")
+ mv_common.pacremove("ncidd")
+ mv_common.remove_service("ncidd")
+ return
+
+def setup_splash(Usebootsplash):
+ if Usebootsplash == "1":
+ logging.info(" Enabling splash")
+ cmd = ''' sed -i "s/^default.*0/default 1/g" /boot/grub/menu.lst'''
+ mv_common.runcmd(cmd)
+ else:
+ logging.info(" Disabling splash")
+ cmd = ''' sed -i "s/^default.*1/default 0/g" /boot/grub/menu.lst'''
+ mv_common.runcmd(cmd)
+ return
+
+def setup_hobbit(UseHobbit,SystemType,dbhost):
+ if UseHobbit == "1":
+ if SystemType == "Standalone" or SystemType == "Master_backend":
+ logging.info(" Installing hobbit server")
+ mv_common.pacinstall("hobbitserver")
+ mv_common.add_service("hobbit")
+ else:
+ logging.info(" Installing hobbit client")
+ mv_common.pacinstall("hobbit-client")
+ setup_hobbit_client(dbhost)
+ mv_common.add_service("hobbit-client")
+
+ else:
+ logging.info(" Removing Hobbit")
+ mv_common.pacremove("hobbit")
+ mv_common.pacremove("hobbit-client")
+ mv_common.remove_service("hobbit-client")
+ mv_common.remove_service("hobbitserver")
+ cmd = "rm -f /data/srv/httpd/htdocs/hobbit/index.html"
+ mv_common.runcmd(cmd)
+ return
+
+def setup_hobbit_client(dbhost):
+ logging.info(" Configuring hobbit client")
+ logging.debug(" hobbit server is %s:", dbhost)
+ cmd='''sed -i "s/^BBDISP.*$/BBDISP=%s/g" /data/srv/hobbit/client/etc/hobbitclient.cfg ''' %dbhost
+ mv_common.runcmd(cmd)
+ return
+
+def setup_evrouter(UseEvrouter,EvrouterConfig,template):
+ if UseEvrouter == "1":
+ logging.info(" Configuring everouter")
+ logging.debug(" EvrouterConfig is %s:",EvrouterConfig)
+ if EvrouterConfig == "tinker":
+ logging.debug(" tinker mode, not changing the config")
+ return
+ mv_common.pacinstall("evrouter")
+ mv_common.pacinstall("Xvfb")
+ mv_common.cp_and_log(template+EvrouterConfig,"/etc/evrouter.cfg")
+ mv_common.add_service("evrouter")
+ mv_common.add_service("Xvfb")
+ else:
+ logging.info(" Not using evrouter")
+ mv_common.pacremove("evrouter")
+ mv_common.remove_service("evrouter")
+ mv_common.remove_service("Xvfb")
+
+ return
+
+def setup_DNSmasq(RunDHCP,ip,gw,nameserver):
+ if RunDHCP == "1":
+ logging.info(" Configuring dhcp server(dnsmasq)")
+ logging.debug(" ip: %s", ip)
+ logging.debug(" gw: %s", gw)
+ logging.debug(" ns: %s", nameserver)
+ mv_common.pacinstall("dnsmasq")
+ mv_common.pacinstall("mvpmc")
+ mv_common.add_service("dnsmasq")
+ logging.debug(" Setting default route to my gw: %s",gw)
+ try:
+ f = open("/etc/dnsmasq.conf",'r')
+ dnsconf = f.readlines()
+ f.close()
+ except:
+ logging.info(" Couldn't open dnsmasq.conf")
+ return
+ for line in dnsconf:
+ outline = line
+ if re.match("^dhcp-option=3",line):
+ logging.debug(" Setting default route to my gw: %s",gw)
+ outline = "dhcp-option=3,%s\n" %gw
+ if re.match("^dhcp-option=6",line):
+ logging.debug(" Setting dns to my ip: %s",ip)
+ outline = "dhcp-option=6,%s\n" %ip
+ f.write(outline)
+ f.close()
+
+ logging.debug(" change nfsroot to my ip:%s",ip)
+ cmd = '''sed -i "s/nfsroot=.*:/nfsroot=%s:/g" /data/srv/tftp/pxelinux.cfg/default''' %ip
+ mv_common.runcmd(cmd)
+
+ logging.debug(" Adding 127.0.0.1 to resolv.conf")
+ logging.debug(" other nameserver is %s",nameserver)
+ try:
+ f = open("/etc/resolv.conf",'r')
+ dns = f.readlines()
+ f.close()
+ except:
+ dns=''
+ logging.debug(" Couldn't open resolv.conf for reading")
+ try:
+ f = open("/etc/resolv.conf",'w')
+ line="search lan\n"
+ f.write(line)
+ line="nameserver 127.0.0.1\n"
+ f.write(line)
+ line="nameserver %s\n" %nameserver
+ f.write(line)
+ for line in dns:
+ f.write(line)
+ f.close()
+ except:
+ logging.debug(" Couldn't open resolv.conf for writing")
+
+ logging.debug(" setup dongle.config")
+ cmd = ''' sed -i "s/mvpmc -f .*/mvpmc -f \/etc\/helvR10.fon -s %s \& /" /data/srv/tftp/dongle.bin.config ''' %ip
+ #COMMAND="%s/mvpmc -f .*/mvpmc -f \/etc\/helvR10.fon -s ${ip} \& /"
+ #ex ${BASE}/data/srv/tftp/dongle.bin.config <<EOF
+ mv_common.runcmd(cmd)
+ else:
+ logging.info(" removing dhcp server(dnsmasq)")
+ mv_common.pacremove("dnsmasq")
+ mv_common.pacremove("mvpmc")
+ mv_common.remove_service("dnsmasq")
+ return
+
+def setup_mythweb(UseMythWEB):
+ if UseMythWEB == "1":
+ logging.info(" Activating mythweb")
+ mv_common.pacinstall("lighttpd")
+ mv_common.pacinstall("mythweb")
+ mv_common.add_service("lighttpd")
+ else:
+ logging.info(" Removing mythweb")
+ mv_common.pacremove("lighttpd")
+ mv_common.pacremove("mythweb")
+ mv_common.remove_service("lighttpd")
+ return
+
+def setup_samba(systemconfig,data_config):
+ mythhome = data_config.MYTHHOME
+ if systemconfig["UseSamba"] == "1":
+ logging.info(" Activating windows file sharing")
+ usersamba=mythhome+"/templates/smb.conf"
+ mv_common.pacinstall("samba")
+ if not os.path.exists("/etc/samba"):
+ logging.debug(" Creating directory /etc/samba")
+ try:
+ os.makedirs("/etc/samba")
+ except:
+ pass
+
+ if os.path.exists(usersamba):
+ logging.debug(" Using user provided config file %s",usersamba)
+ cmd = "install -D -m755 %s /etc/samba/smb.conf" %usersamba
+ mv_common.runcmd(cmd)
+ else:
+ Samba_media = systemconfig["Samba_media"]
+ Samba_home = systemconfig["Samba_home"]
+ if systemconfig["Samba_mediareadonly"] == "1":
+ smreadonly = "yes"
+ else:
+ smreadonly = "no"
+
+ if systemconfig["Samba_homereadonly"] == "1":
+ shreadonly = "yes"
+ else:
+ shreadonly = "no"
+ domain = systemconfig["Samba_domain"]
+ servername = systemconfig["hostname"]
+
+ try:
+ f = open(systemconfig["TEMPLATES"]+"/samba/smb.conf.template",'r')
+ t_smbconf = f.readlines()
+ f.close()
+ except:
+ logging.info(" Couldn't open samba template file")
+ return
+
+ try:
+ f = open("/etc/samba/smb.conf",'w')
+ except:
+ logging.info(" Couldn't open samba file")
+ return
+
+ for line in t_smbconf:
+ outline = line
+ if re.match("^.*workgroup", line):
+ logging.debug(" Setting workgroup to %s",domain)
+ outline="workgroup = %s\n" %domain
+ logging.debug(" %s",outline)
+ if re.match("^.* server string",line):
+ logging.debug(" Setting server name to %s",servername)
+ outline="server string = %s\n" %servername
+ logging.debug(" %s",outline)
+ f.write(outline)
+ outline="include = %s/templates/user.shares \n" %mythhome
+ f.write(outline)
+ if Samba_media == "1":
+ outline="include = /etc/samba/smb.conf.media\n"
+ f.write(outline)
+ if Samba_home == "1":
+ outline="include = /etc/samba/smb.conf.home\n"
+ f.write(outline)
+ f.close()
+ logging.info(" Writing smb.conf.media")
+ try:
+ f = open("/etc/samba/smb.conf.media","w")
+ except:
+ logging.info(" Couldn't open smb.conf.media")
+ return
+ medialines='''
+[%s]
+path = %s
+public = yes
+only guest = yes
+writeable = %s
+printable = no
+force user = mythtv
+force group = mythtv
+create mask = 0755''' %(data_config.SMEDIA,data_config.DATAMOUNT,smreadonly)
+ f.write(medialines)
+ f.close
+ logging.debug(" %s",medialines)
+ logging.info(" Writing smb.conf.home")
+ try:
+ f = open("/etc/samba/smb.conf.home","w")
+ except:
+ logging.info(" Couldn't open smb.conf.home")
+ return
+ homelines='''
+[home]
+path = %s
+public = yes
+only guest = yes
+writeable = %s
+printable = no
+force user = mythtv
+force group = mythtv
+create mask = 0755 ''' %(data_config.MYTHHOME,shreadonly)
+ f.write(homelines)
+ f.close
+ logging.debug(" %s",homelines)
+
+
+ mv_common.add_service("nmbd")
+ mv_common.add_service("smbd")
+ else:
+ logging.info(" Removing windows file sharing")
+ mv_common.remove_service("smbd")
+ mv_common.remove_service("nmbd")
+ mv_common.pacremove("samba")
+ mv_common.pacinstall("smbclient")
+ return
+
+def setup_NFSshares(UseNFS,templatefile):
+ if UseNFS == "1":
+ logging.info(" Activating NFS server")
+ mv_common.pacinstall("nfs-utils")
+ mv_common.pacinstall("portmap")
+ cmd = '''sed -e "s/REPLACEME/*/g" %s >/etc/exports''' %templatefile
+ mv_common.add_service("nfsd")
+ mv_common.add_service("nfs-utils")
+ mv_common.add_service("portmap")
+ else:
+ logging.info(" Removing NFS server")
+ mv_common.remove_service("nfsd")
+ return
+
+def setup_dyndns(DDnsEnable):
+ if DDnsEnable == "1":
+ logging.info(" Installing Dynamic DNS client")
+ mv_common.pacinstall("inadyn")
+ mv_common.add_service("inadyn")
+ else:
+ logging.info(" Removing Dynamic DNS client")
+ mv_common.pacremove("inadyn")
+ mv_common.remove_service("inadyn")
+
+
+def setup_advanced(systemconfig,data_config):
+ logging.info("____Start of advanced configuration____")
+ create_link = False
+ if systemconfig["SystemType"] == "Master_backend":
+ create_link = True
+ setup_pacman(create_link)
+ setup_ncid_client(systemconfig["dbhost"],
+ systemconfig["TEMPLATES"]+"/ncid.conf.template")
+
+ setup_ncid_daemon(systemconfig["nciddSerialPort"],
+ systemconfig["TEMPLATES"]+"/ncidd.conf.template",
+ systemconfig["Runncidd"])
+
+ setup_splash(systemconfig["Usebootsplash"])
+ if data_config.SYSTEMTYPE == "MythVantage":
+ setup_hobbit(systemconfig["UseHobbit"],
+ systemconfig["SystemType"],
+ systemconfig["dbhost"])
+
+ setup_evrouter(systemconfig["UseEvrouter"],
+ systemconfig["EvrouterConfig"],
+ systemconfig["TEMPLATES"])
+ systemconfig["mythip"]="192.168.100.myip"
+ systemconfig["mythgw"]="192.168.100.mygw"
+ systemconfig["mythdns"]="192.168.100.100"
+
+ setup_DNSmasq(systemconfig["RunDHCP"],
+ systemconfig["mythip"],
+ systemconfig["mythgw"],
+ systemconfig["mythdns"])
+
+ setup_mythweb(systemconfig["UseMythWEB"])
+ setup_samba(systemconfig,data_config)
+ setup_NFSshares(systemconfig["UseNFS"],
+ systemconfig["TEMPLATES"]+"/exports.template")
+
+ setup_dyndns(systemconfig["DDnsEnable"])
+ logging.info("__End of advanced configuration\n")
diff --git a/abs/core-testing/LinHES-config/mv_common.py b/abs/core-testing/LinHES-config/mv_common.py
new file mode 100755
index 0000000..64ff2d6
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_common.py
@@ -0,0 +1,145 @@
+# -*- coding: utf-8 -*-
+import logging, os
+import commands
+config_file = "mv_config"
+data_config = __import__(config_file, globals(), locals(), [])
+
+def runcmd(cmd):
+ if data_config.NOOPDEBUG=="FALSE":
+ pass
+ else:
+ cmd = "echo "+cmd
+ logging.debug(" %s",cmd)
+ cmdout = commands.getstatusoutput(cmd)
+ logging.debug(" %s",cmdout)
+ return cmdout[0]
+
+def services(systemconfig):
+ logging.debug("______Start of services______")
+ logging.debug("__End services")
+
+def cp_and_log(srcfile,destfile):
+ #return
+ if not os.path.exists(srcfile):
+ logging.info("%s is not present, skipping...",srcfile)
+ else:
+ cmd = ("rsync -arhp %s %s") %(srcfile,destfile)
+ runcmd(cmd)
+
+
+def add_service(daemon):
+ logging.info(" Adding service %s",daemon)
+ cmd = "add_service.sh %s" %daemon
+ runcmd(cmd)
+
+def remove_service(daemon):
+ logging.info(" Removing service %s",daemon)
+ cmd = "remove_service.sh %s" %daemon
+ runcmd(cmd)
+
+def pkg_blacklist_check(pkg):
+ cmd = '''grep -q %s /etc/blacklist.package''' %pkg
+ rc = runcmd(cmd)
+ if rc == 0:
+ return True
+ else:
+ return False
+
+def pkg_installed_check(pkg):
+ logging.debug(" Checking if %sis installed",pkg)
+ cmd = "pacman -Q %s " %pkg
+ rc = runcmd(cmd)
+ if rc == 0:
+ return True
+ else:
+ return False
+
+
+def pacinstall(pkg):
+ logging.info(" Checking %s for install",pkg)
+ #extra pkg check
+ if pkg == "xine":
+ pacinstall("xine-ui")
+ elif pkg == "dvdcss":
+ pacinstall("libdvdcss")
+ elif pkg == "webmin":
+ add_service("webmin")
+
+ if not pkg_blacklist_check(pkg):
+ if pkg_installed_check(pkg):
+ logging.info(" %s is already installed, will not install",pkg)
+ else:
+ logging.info(" Installing %s",pkg)
+ cmd ='''pacman --noconfirm -Sf %s ''' %pkg
+ runcmd(cmd)
+ else:
+ logging.info(" %s is blacklisted, will not install",pkg)
+
+def pacremove(pkg):
+ logging.info(" Checking %s for removal",pkg)
+ if pkg == "xine":
+ pacremove("xine-ui")
+ elif pkg == "dvdcss":
+ pacremove("libdvdcss")
+ elif pkg == "webmin":
+ remove_service("webmin")
+
+ if not pkg_blacklist_check(pkg):
+ if not pkg_installed_check(pkg):
+ logging.info(" %s is not installed, will not remove",pkg)
+ else:
+ logging.info(" Removing %s",pkg)
+ cmd ='''pacman --noconfirm -R %s ''' %pkg
+ else:
+ logging.info(" %s is blacklisted, will not remove",pkg)
+
+def getpid(process):
+ return commands.getoutput('pidof %s' % process)
+
+
+def restartLCD(RESTART_LCD):
+ if RESTART_LCD :
+ logging.info(" Restarting lcd server")
+ cmd = "killall -9 mythlcdserver"
+ runcmd(cmd)
+ else:
+ logging.debug(" Not restarting MYTHLCD server")
+
+
+def reloadfe(dbhost,RESTART_LCD):
+ logging.debug("____Start of reloadfe____")
+ logging.info(" Clearing Backend cache")
+ cmd = '''/usr/bin/backend_control.sh clearcache behost %s''' %dbhost
+ runcmd(cmd)
+ restartLCD(RESTART_LCD)
+ for pid in getpid("mythfrontend"):
+ cmd = ''' kill -s USR1 %s ''' %pid
+ #runcmd(cmd)
+ logging.info(" Reloading frontend with pid of %s",pid)
+
+ logging.debug("__End of reloadfe\n")
+
+
+def restartfe(RESTART_LCD):
+ logging.debug("____Start of restartfe____")
+ logging.info(" Restarting frontend")
+ restartLCD(RESTART_LCD)
+ cmd="killall -9 mythfrontend"
+ runcmd(cmd)
+ cmd="killall -9 welcome"
+ runcmd(cmd)
+ logging.debug("__End of restartfe\n")
+
+
+def udev_trigger():
+ logging.info(" Triggering udev")
+ cmd = "udevadm settle"
+ runcmd(cmd)
+ cmd = "udevadm trigger"
+ runcmd(cmd)
+ cmd = "udevadm settle"
+ runcmd(cmd)
+ cmd = "udevadm trigger"
+ runcmd(cmd)
+
+
diff --git a/abs/core-testing/LinHES-config/mv_config.py b/abs/core-testing/LinHES-config/mv_config.py
new file mode 100755
index 0000000..d5a247d
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_config.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+SYSTEMTYPE="LinHES"
+MVHOSTNAME="larch5"
+MOUNTPOINT="/new_boot"
+DATAMOUNT="/myth"
+MYTHHOME="/home/mythtv"
+SQUASHFILE="/tmp/.squashlist"
+SQUASHLIST=("bin","boot","etc","home","lib","opt","root","sbin","usr","var","data")
+NOOPDEBUG="FALSE"
+BACKUPFILE="mythconverg.sql.gz"
+BACKUPPATH="/myth/backup/"
+TEMP_TEMPLATES="/tmp/templates"
+SMEDIA="/myth"
+
+
+
+
diff --git a/abs/core-testing/LinHES-config/mv_hostype.py b/abs/core-testing/LinHES-config/mv_hostype.py
new file mode 100755
index 0000000..0bbd16e
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_hostype.py
@@ -0,0 +1,147 @@
+# -*- coding: utf-8 -*-
+import logging, mv_common
+import os
+
+config_file = "mv_config"
+data_config = __import__(config_file, globals(), locals(), [])
+
+def setup_ntp(usepool,ntpserver):
+ if usepool:
+ logging.info("Setting ntp server to %s",ntpserver)
+ print '''sed -i "s/pool.ntp.org/$dbhost/g" ${BASE}/etc/ntp.conf'''
+ else:
+ logging.info("Not changing ntp configuration")
+
+def setup_avahi(templates):
+ file="/etc/avahi/services/mysql.service"
+ if not os.path.exists(file):
+ logging.debug(" copying in mysql.service for avahi")
+ try:
+ os.makedirs("/etc/avahi/services")
+ except:
+ logging.debug(" Couldn't create /etc/avahi/services")
+ mv_common.cp_and_log(template+"/mysql.service",file)
+ cmd="sudo sv restart avahi"
+ mv_common.runcmd(cmd)
+
+def remove_avahi_service():
+ file="/etc/avahi/services/mysql.service"
+ if os.path.exists(file):
+ logging.debug(" Removing avahi mysql.service file")
+ cmd="rm -rf %s" %file
+ runcmd(cmd)
+ cmd="sudo sv restart avahi"
+ mv_common.runcmd(cmd)
+
+def setup_db():
+ logging.debug(" Setting up the database")
+
+def setup_mysqlnetwork():
+ logging.debug(" Setting up mysql network")
+
+def setup_mysql():
+ logging.debug(" Configuring mysql")
+
+def setup_func_key():
+ if data_config.SYSTEMTYPE == "MythVantage":
+ logging.debug(" Grabbing the key for Func")
+ cmd="/usr/MythVantage/bin/grabkey.py"
+ mv_common.runcmd(cmd)
+
+def setup_func_minion(dbhost):
+ logging.info(" Setting up the func minion:")
+ logging.debug(" certmaster is %s:",dbhost)
+ cmd='''sed -i "s/^certmaster.*$/certmaster = %s/" /etc/func/minion.conf ''' %dbhost
+ 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 hostypeprint(systemconfig):
+ logging.info("______Start of hostype config_____")
+ mv_common.services(systemconfig)
+ install_list=''
+ remove_list=''
+ daemon_list=''
+ daemon_remove_list=''
+
+ if systemconfig["SystemType"] == "Standalone":
+ logging.info("Stand alone system being configured")
+ setup_ntp(False,"null")
+ remove_avahi_service()
+ if systemconfig["hostypec"]:
+ setup_db()
+ install_list=("mysql", "mythdb-initial", "avahi", "portmap", "nfs-utils", "local-website", "myth2ipod", "mythtv-status")
+ daemon_list=("mysql", "mythbackend", "avahi", "portmap", "nfs-utils", "netfs", "lighttpd")
+
+ elif systemconfig["SystemType"] == "Master_backend":
+ logging.info("Master backend system being configured")
+ setup_ntp(False,"null")
+ setup_avahi(systemconfig["TEMPLATES"])
+ install_list=("mysql", "mythdb-initial", "avahi", "portmap", "nfs-utils", "local-website", "myth2ipod", "mythtv-status")
+ daemon_list=("mysql", "mythbackend", "avahi", "portmap", "nfs-utils", "netfs", "lighttpd")
+ if data_config.SYSTEMTYPE == "MythVantage":
+ install_list.append('func')
+ install_list.append('certmaster')
+ daemon_list.append('certmaster')
+
+ elif systemconfig["SystemType"] == "Slave_backend":
+ logging.info("Slave backend system being configured")
+ setup_ntp(True,systemconfig["dbhost"])
+ remove_avahi_service()
+ if systemconfig["hostypec"]:
+ setup_db()
+ install_list=("portmap", "nfs-utils", "local-website", "avahi", 'libmysqlclient')
+ daemon_list=("mythbackend", "portmap", "nfs-utils", "netfs", "lighttpd", "avahi")
+ daemon_remove_list=('mysql')
+ if data_config.SYSTEMTYPE == "MythVantage":
+ install_list.remove("local-website")
+ daemon_list.remove("lighttpd")
+ install_list.append('func')
+ daemon_list.append('funcd')
+ remove_list.append("lighttpd")
+
+
+ elif systemconfig["SystemType"] == "Frontend_only":
+ logging.info("Frontend only system being configured")
+ setup_ntp(True,systemconfig["dbhost"])
+ remove_avahi_service()
+ install_list=("mysql-clients", "libmysqlclient", "avahi", "portmap", "nfs-utils", "local-website")
+ remove_list=("mysql")
+ daemon_list=("mysql", "mythbackend", "avahi", "portmap", "nfs-utils", "netfs", "lighttpd")
+ daemon_remove_list=("mysql", "mythbackend")
+ if data_config.SYSTEMTYPE == "MythVantage":
+ install_list.remove("local-website")
+ daemon_list.remove("lighttpd")
+ install_list.append('func')
+ daemon_list.append('funcd')
+ remove_list.append("lighttpd")
+
+
+
+ for pkg in install_list:
+ mv_common.pacinstall(pkg)
+ for pkg in remove_list:
+ mv_common.pacinstall(pkg)
+ for daemon in daemon_list:
+ mv_common.add_service(daemon)
+ for daemon in daemon_remove_list:
+ mv_common.remove_service(daemon)
+ if systemconfig["RunFrontend"] == "1":
+ logging.debug(" Will run the frontend")
+ mv_common.add_service("frontend")
+ mv_common.add_service("hal")
+ else:
+ logging.debug(" Will NOT run the frontend")
+ mv_common.remove_service("frontend")
+ mv_common.remove_service("hal")
+
+ setup_mysqlnetwork()
+ setup_mysql()
+ if data_config.SYSTEMTYPE == "MythVantage":
+ setup_func_minion(dbhost)
+ setup_func_key()
+ setup_syslog(systemconfig["dbhost"])
+ logging.info("__End of hostype config\n")
diff --git a/abs/core-testing/LinHES-config/mv_install.py b/abs/core-testing/LinHES-config/mv_install.py
new file mode 100755
index 0000000..1281932
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_install.py
@@ -0,0 +1,1241 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+import sys, os, commands, glob, time
+import getopt, re, MySQLdb
+import logging
+try:
+ import parted
+except:
+ print "module parted not found"
+
+def usage():
+ print "help text:"
+ print "example usage: --rootdisk=sda --rootfs=ext4 --rootsize=34240 --datafs=ext4 --datasize=3400 --datadisk=sda --swapsize=340 -c full_install"
+
+def clean_upgrade():
+ return False
+
+def update_db(value, data):
+ db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg")
+ try:
+ cursor = db.cursor()
+ cursor.execute("DELETE FROM settings where value=%s and hostname=%s;", (value, data_config.MVHOSTNAME))
+ cursor.execute("REPLACE INTO settings set value=%s, data=%s, hostname=%s;", (value, data, data_config.MVHOSTNAME))
+ logging.debug("Updated database with %s, %s", data, value)
+ except MySQLdb.Error, e:
+ logging.debug("Unable to update database with %s, %s", data, value)
+
+
+def progress(pgnum):
+ progressline = str(pgnum) + "% complete"
+ logging.debug("Progress: %s", pgnum)
+ f = open('/tmp/.install_percent', 'w')
+ f.write(progressline)
+ f.close()
+
+def update_status(status):
+ logging.debug("Status: %s", status)
+ f = open('/tmp/.install_state', 'w')
+ f.write(str(status))
+ f.close()
+
+def kill_dhcp_chroot():
+ logging.debug("Killing off chroot dhcpcd")
+ stddir = os.getcwd()
+ piddir = ("%s/var/run/") %data_config.MOUNTPOINT
+ try:
+ os.chdir(piddir)
+ for FILE in glob.glob("dhcpcd-*.pid"):
+ f = open(FILE, 'r')
+ pid = f.readline()
+ f.close()
+ cmd = "kill -9 %s" %pid
+ runcmd(cmd)
+ os.remove(FILE)
+ os.chdir(stddir)
+ except:
+ pass
+
+def statgrab(disk):
+ cmd = "statgrab -M disk. |grep %s.write_bytes" % hostoptions["rootdisk"]
+ out = commands.getoutput(cmd)
+ try:
+ prewritebytes = out.split("=")[1].strip()
+ except:
+ prewritebytes = "1024"
+ outline = "STARTSIZE=%s" %prewritebytes
+ f = open('/tmp/.startsize.io', 'w')
+ f.write(str(outline))
+ f.close()
+
+def backup_sql_check():
+ logging.debug("Searching for backup file")
+ try:
+ hostoptions["backupfile"]
+ except:
+ logging.debug("Backup file var is empty")
+ return False
+ if os.path.exists(data_config.MOUNTPOINT+hostoptions["backupfile"]):
+ logging.debug("Backup file %s is present", data_config.MOUNTPOINT+hostoptions["backupfile"])
+ return True
+ else:
+ logging.debug("Backup file %s is NOT present", data_config.MOUNTPOINT+hostoptions["backupfile"])
+ return False
+
+def mdadm_find(PREFIX):
+ logging.debug("Searching for mdadm.conf")
+ if os.path.exists(PREFIX+"/etc/KnoppMyth-version"):
+ mdadmconf = "/etc/mdadm/mdadm.conf"
+ else:
+ mdadmconf = "/etc/mdadm.conf"
+ logging.debug("Using %s for mdadm.conf", mdadmconf)
+ return mdadmconf
+
+def mdadm_assemble_all():
+ # read mdadm.conf and start the arrays
+ #ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977
+ logging.debug("Starting mdadm support")
+ mdadmconf_file = mdadm_find("/tmp")
+ cmd = "cdadm --assemble --scan -c /tmp/%s" %mdadmconf_file
+ runcmd(cmd)
+ mdadm_contents = ''
+ try:
+ f = open(mdadmconf_file, 'r')
+ mdadm_contents = f.readlines()
+ f.close()
+ except:
+ logging.debug(" Couldn't open mdadmconf file")
+ for line in mdadm_contents:
+ if line.startswith("ARRAY"):
+ logging.debug(" Found MD array: %s", line)
+ array = line.split()[1]
+ logging.info(" assembling array: %s", array)
+ cmd = "mdadm --assemble -c /tmp%s %s" %(mdadmconf_file, array)
+ runcmd(cmd)
+ time.sleep(2)
+ cmd = "fsck -p %s" %array
+ runcmd
+
+def copy_updates():
+ try:
+ MVROOT = os.environ["MV_ROOT"]
+ except:
+ logging.debug("MVROOT was not defined, using the default value")
+ MVROOT = "/usr/MythVantage"
+ cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin", "*.sh")
+ cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin", "*.py")
+
+def timezone_to_db(timefile):
+ logging.info("importing timezone needs")
+ try:
+ f = open(timefile)
+ timezonecontents = f.readline().strip()
+ f.close()
+ except:
+ logging.debug("Couldn't open /tmp/etc/timezone, will not set the timezone")
+ return
+ tzsplit = timezonecontents.partition('/')
+ print tzsplit
+ if tzsplit[2] == '' :
+ update_db("HostTimeZoneRegion", tzsplit[0])
+ else:
+ update_db("HostTimeZoneRegion", tzsplit[0])
+ tztemp="HostTimeZoneRegion_%s" % tzsplit[0]
+ update_db(tztemp, tzsplit[2])
+
+
+
+def cp_and_log(srcfile, destfile):
+ #return
+ if not os.path.exists(srcfile):
+ logging.info("%s is not present, skipping...", srcfile)
+ else:
+ cmd = ("rsync -arvp %s %s") %(srcfile, destfile)
+ runcmd(cmd)
+
+def cp_and_log2(srcfile, destfile, fileglob):
+ #return
+ logging.debug("cp_and_log2")
+ logging.debug("%s, %s, %s", srcfile, destfile, fileglob)
+
+ if not os.path.exists(srcfile):
+ logging.info("%s is not present, skipping...", srcfile)
+ else:
+ if fileglob == '':
+ cmd = ("rsync -arvp %s %s") %(srcfile, destfile)
+ runcmd(cmd)
+ else:
+ fileglob = "*"
+ cmd = ("rsync -arvp %s/%s %s") %(srcfile, fileglob, destfile)
+ runcmd(cmd)
+
+def runcmd(cmd):
+ if data_config.NOOPDEBUG == "FALSE":
+ pass
+ else:
+ cmd = "echo "+cmd
+ logging.debug(" %s", cmd)
+ cmdout = commands.getoutput(cmd)
+ logging.debug(" %s", cmdout)
+ return cmdout
+
+def mysqldb(cmd, inchroot):
+ if cmd == "start":
+ mycmd = " /etc/rc.d/mysqld start"
+ elif cmd == "stop":
+ mycmd = " /etc/rc.d/mysqld stop"
+ if inchroot == "chroot":
+ mycmd = " chroot %s" %mycmd
+ runcmd(mycmd)
+
+
+def mount_bind_chroot():
+ logging.debug("Mounting dev/proc/sysfs for chroot")
+ cmd = " mount --bind /dev %s" %data_config.MOUNTPOINT+"/dev"
+ runcmd(cmd)
+ cmd = " mount --bind /proc %s" %data_config.MOUNTPOINT+"/proc"
+ runcmd(cmd)
+ cmd = " mount -t sysfs none %s" %data_config.MOUNTPOINT+"/sys"
+ runcmd(cmd)
+
+def umount_bind_chroot():
+ logging.debug("UnMounting dev/proc/sysfs for chroot")
+ cmd = " umount -l %s" %data_config.MOUNTPOINT+"/dev"
+ runcmd(cmd)
+ cmd = " umount -l %s" %data_config.MOUNTPOINT+"/proc"
+ runcmd(cmd)
+ cmd = " umount -l %s" %data_config.MOUNTPOINT+"/sys"
+ runcmd(cmd)
+
+
+def partitions_removeall(diskdevice, label):
+ logging.info("Removing all partitions for %s %s", label, diskdevice)
+ device = parted.getDevice(diskdevice)
+ partdisk = parted.Disk(device)
+ partdisk.deleteAllPartitions()
+ if data_config.NOOPDEBUG == "FALSE":
+ partdisk.commit()
+
+ for partition in partdisk.partitions:
+ print "type: %s" %partition.type
+
+def create_partitions(diskdevice, size, ptype, startsector):
+ logging.debug("_____Create partitions______")
+ if size == "NO":
+ logging.info("Size is 0, skipping")
+ return "NO"
+ partlist = []
+ newstart = 0
+ totalused = 0
+ device = parted.getDevice(diskdevice)
+ partdisk = parted.Disk(device)
+ for partition in partdisk.partitions:
+ if partition.type != parted.PARTITION_FREESPACE:
+ partlist.append((partition,
+ partition.path,
+ partition.getFlag(parted.PARTITION_BOOT),
+ partition.geometry.start,
+ partition.geometry.end,
+ partition.geometry.length,
+ partition.type,
+ partition.fileSystem))
+ for slice in partlist:
+ (usedpartition, usedpath, usedbootable, usedstart, usedend, usedlength, usedtype, usedfs) = slice
+ #Start the new partition one after the end of last
+ newstart = usedend+1
+
+ if startsector == 0:
+ newstart = 0
+ if size == "ALL":
+ logging.debug(" Using the rest of the disk %s", (device.length-newstart) )
+ try:
+ geom = parted.Geometry(device=device, start=newstart, length=(device.length-newstart))
+ except:
+ logging.info("An error occured, probably invalid parition size")
+ return
+ else:
+ # convert size in MB to a length on the device in sectors
+ length = (int(size) * (1024 * 1024)) / device.sectorSize
+ logging.debug("Size is %s", length)
+ try:
+ geom = parted.Geometry(device=device, start=newstart, length=length)
+ except:
+ logging.info("An error occured, probably invalid parition size")
+ return
+ #collect device constraint
+ constraint = device.getConstraint()
+ # new partition
+ if ptype == "NORMAL":
+ newpart = parted.Partition(disk=partdisk, type=parted.PARTITION_NORMAL, geometry=geom)
+ elif ptype == "SWAP":
+ newpart = parted.Partition(disk=partdisk, type=parted.PARTITION_NORMAL, geometry=geom)
+
+ #add the partition to the disk and commit changes
+ partdisk.addPartition(partition=newpart, constraint=constraint)
+ if data_config.NOOPDEBUG == "FALSE":
+ partdisk.commit()
+ logging.info("created partition %s of %dMB and added it to %s" %
+ (newpart.getDeviceNodeName(), newpart.getSize(), diskdevice))
+ return newpart.getDeviceNodeName()
+
+
+def partition_disk():
+ global hostoptions
+ logging.info("Partitioning")
+ logging.debug("____start of partition_disk____")
+ rootdisk = hostoptions["rootdisk"]
+ datadisk = hostoptions["datadisk"]
+ label = "root"
+ partitions_removeall("/dev/"+rootdisk, label)
+ label = "data"
+ partitions_removeall("/dev/"+datadisk, label)
+ hostoptions["rootpartition"] = create_partitions("/dev/"+rootdisk, hostoptions["rootsize"], "NORMAL", 0)
+ hostoptions["swappartition"] = create_partitions("/dev/"+rootdisk, hostoptions["swapsize"], "SWAP", 1)
+ if datadisk != rootdisk:
+ hostoptions["datapartition"] = create_partitions("/dev/"+datadisk, hostoptions["datasize"], "NORMAL", 0)
+ else:
+ hostoptions["datapartition"] = create_partitions("/dev/"+datadisk, hostoptions["datasize"], "NORMAL", 1)
+ time.sleep(5)
+
+def fscmd(fstype):
+ fscmds = {"reiserfs":"mkreiserfs -q -l ROOT", "xfs": "mkfs -t xfs -f", "ext3": "mkfs.ext3", "jfs":"mkfs.jfs -q", "ext4":"mkfs.ext4", "Do_not_format":"noformat", "no_format":"noformat"}
+ try:
+ rc = fscmds[fstype]
+ except:
+ logging.critical(" %s is not a valid fs type, exiting now", fstype)
+ sys.exit(3)
+ return rc
+
+
+def format_disk(install_type):
+ logging.info("______Starting Disk Format______")
+ rootfs = fscmd(hostoptions["rootfs"])
+ datafs = fscmd(hostoptions["datafs"])
+
+ rootdisk = hostoptions["rootdisk"]
+ datadisk = hostoptions["datadisk"]
+ rootpartition = hostoptions["rootpartition"]
+ datapartition = hostoptions["datapartition"]
+ if install_type != "upgrade":
+ swapsize = hostoptions["swapsize"]
+ swappartition = hostoptions["swappartition"]
+
+ logging.debug(" Format command for rootfs %s : %s ", rootfs, rootpartition)
+ if ( rootfs != "noformat"):
+ logging.info("Starting format of %s", rootpartition)
+ cmd = " %s /dev/%s" %( rootfs, rootpartition)
+ #os.system(cmd)
+ runcmd(cmd)
+ else:
+ logging.info("Will not format root partition: %s", rootpartition)
+
+ logging.debug(" Format command for datafs %s : %s ", datafs, datapartition)
+ if (datafs != "noformat"):
+ logging.info("Starting format of %s", datapartition)
+ cmd = " %s /dev/%s" %( datafs, datapartition)
+ #os.system(cmd)
+ runcmd(cmd)
+ else:
+ logging.info("Will not format data partition: %s", datapartition)
+
+ if install_type == "install":
+ if (hostoptions["swapsize"] != "NO"):
+ logging.info("Starting format for swap %s", swappartition)
+ cmd = " mkswap /dev/%s" % swappartition
+ #os.system(cmd)
+ runcmd(cmd)
+ else:
+ logging.debug(" Swap is set to NO, will not run mkswap")
+
+ logging.debug("_____End of format______")
+
+
+def mount_it():
+ logging.info("______Mounting disk______")
+# Create mount points
+ try:
+ mountpoint = data_config.MOUNTPOINT
+ mp = mountpoint
+ logging.info("Creating mountpoints %s", mp)
+ os.makedirs(mp)
+ except OSError:
+ logging.debug(" Could not create %s", mp)
+
+# Mount root
+ cmd = "mount /dev/%s %s" %(hostoptions["rootpartition"], mountpoint)
+ runcmd(cmd)
+ #logging.debug(cmd)
+ #cmdout=commands.getoutput(cmd)
+ #logging.debug(cmdout)
+# Mount data
+#make mountpoint after mounting /
+ try:
+ mountpoint = data_config.MOUNTPOINT
+ datapoint = data_config.DATAMOUNT
+ mp = mountpoint+datapoint
+ logging.info("Creating mountpoints %s", mp)
+ os.makedirs(mp)
+ except OSError:
+ logging.debug(" Could not create %s", mp)
+
+ cmd = "mount /dev/%s %s" %(hostoptions["datapartition"], mp)
+ runcmd(cmd)
+ #logging.debug(cmd)
+ #cmdout=commands.getoutput(cmd)
+ #logging.debug(cmdout)
+
+def unmount_it():
+ logging.info("______Unmounting disk______")
+ cmd = "umount %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT)
+ runcmd(cmd)
+ time.sleep(2)
+
+ cmd = "swapoff /dev/%s" %(hostoptions["swappartition"])
+ runcmd(cmd)
+
+ cmd = "sync"
+ runcmd(cmd)
+
+ cmd = "umount %s" %(data_config.MOUNTPOINT)
+ runcmd(cmd)
+ cmd = "sync"
+ runcmd(cmd)
+
+
+def create_squashlist():
+ logging.debug("Creating squashlist")
+ squashfile = data_config.SQUASHFILE
+ f = open(squashfile, 'w')
+ for i in data_config.SQUASHLIST:
+ f.write(i)
+ f.write("\n")
+ logging.debug(i)
+ f.close()
+
+
+def copy_it(install_type):
+ logging.info("______Transferring to disk______")
+ logging.debug( install_type)
+ if ( install_type == "install"):
+ logging.info("Transferring system")
+ cmd = " unsquashfs -f -d %s /.livesys/medium/system.sqf" %(data_config.MOUNTPOINT)
+ runcmd(cmd)
+ #logging.debug(cmd)
+ #cmdout=commands.getoutput(cmd)
+
+ if ( install_type == "upgrade"):
+ logging.info("Upgrading system")
+ create_squashlist()
+ cmd = " unsquashfs -e %s -f -d %s /.livesys/medium/system.sqf" %(data_config.SQUASHFILE, data_config.MOUNTPOINT)
+ runcmd(cmd)
+ #logging.debug(cmd)
+ #cmdout=commands.getoutput(cmd)
+# Create the missing dir
+ i = ("sys", "proc", "dev", "tmp", "mnt", "media", "media/cdrom", "media/dvd", "var/log/mythtv")
+ mountpoint = data_config.MOUNTPOINT
+ for item in i:
+ try:
+ mp = mountpoint+"/"+item
+ logging.info("Creating mountpoints %s", mp)
+ os.makedirs(mp)
+ except OSError:
+ logging.debug(" __Could not create %s", mp)
+# General fixup
+ cmd = "chmod 777 %s/tmp" %(data_config.MOUNTPOINT)
+ runcmd(cmd)
+ cmd = "mknod %s/dev/null c 1 5" %(data_config.MOUNTPOINT)
+ runcmd(cmd)
+ cmd = "mknod %s/dev/console c 5 1" %(data_config.MOUNTPOINT)
+ runcmd(cmd)
+ cmd = "chmod +s %s/usr/bin/Xorg" %(data_config.MOUNTPOINT)
+ runcmd(cmd)
+ cmd = "chmod +s %s/usr/bin/crontab" %(data_config.MOUNTPOINT)
+ runcmd(cmd)
+ cmd = "chmod +s %s/usr/bin/sudo" %(data_config.MOUNTPOINT)
+ runcmd(cmd)
+ cmd = "chmod +s %s/bin/mount" %(data_config.MOUNTPOINT)
+ runcmd(cmd)
+ logging.debug("__End of copy_it__")
+
+def create_fstab(extralines):
+ logging.debug("______Creating new fstab file_______")
+ logging.info("Creating new fstab file")
+ fstabfile = data_config.MOUNTPOINT+"/etc/fstab"
+ fstab_list = []
+ f = open(fstabfile, 'w')
+ line = '''# <file system> <dir> <type> <options> <dump> <pass> \n'''
+ fstab_list.append(line)
+ line = '''none /dev/pts devpts defaults 0 0 \n'''
+ fstab_list.append(line)
+ line = '''none /dev/shm tmpfs defaults 0 0\n'''
+ fstab_list.append(line)
+ line = '''/dev/cdrom /media/cdrom auto ro,user,noauto,unhide 0 0\n'''
+ fstab_list.append(line)
+ line = '''/dev/dvd /media/dvd auto ro,user,noauto,unhide 0 0\n'''
+ fstab_list.append(line)
+ line = '''UUID=ROOTUID / auto defaults,noatime 0 1\n'''
+ fstab_list.append(line)
+ line = '''UUID=DATAUID %s auto defaults,noatime 0 1\n''' %(data_config.DATAMOUNT)
+ fstab_list.append(line)
+ line = '''UUID=SWAPUID swap swap defaults 0 0 \n'''
+ fstab_list.append(line)
+ for vline in extralines:
+ fstab_list.append(vline)
+ for outline in fstab_list:
+ logging.debug(outline)
+ f.write(outline)
+ f.close()
+
+def find_uuid(partition):
+ logging.info("Finding the UUID for %s...", partition)
+ cmd = "blkid -s UUID /dev/%s" %partition
+ tmpuuid = runcmd(cmd)
+ splituuid = tmpuuid.partition("=")
+ uuid = splituuid[2].replace('"', "")
+ logging.info("The uuid is %s", uuid)
+ return uuid.strip()
+
+def pick_out_vg():
+ logging.info("Searching for Volume Groups in old fstab")
+ vglines = []
+ f = open("/tmp/etc/fstab", 'r')
+ oldfscontents = f.readlines()
+ for line in oldfscontents:
+ if line.startswith("/dev/vg"):
+ vglines.append(line)
+ templine = line.split()
+ mdir = templine[1]
+ if not os.path.exists (mdir):
+ logging.debug("Creating dir %s for VG mount", mdir)
+ os.makedirs (mdir)
+# Might need to os.chown to mythtv:users
+ else:
+ logging.debug("Directory %s for VG mount already present", mdir)
+ return vglines
+
+def fstab_it(install_type):
+ logging.info("______Checking fstab______")
+ kmvg = []
+ fstabfile = data_config.MOUNTPOINT+"/etc/fstab"
+# Check for knoppmyth install, if found create new
+ if install_type == "upgrade":
+ if os.path.exists("/tmp/etc/KnoppMyth-version"):
+ logging.debug(" KnoppMyth-Version found, creating new fstab")
+ kmvg = pick_out_vg()
+ create_fstab(kmvg)
+ elif os.path.exists("/tmp/etc/fstab"):
+ logging.debug(" Upgrade and not Knoppmyth, using old fstab")
+ cp_and_log("/tmp/etc/fstab", fstabfile)
+# Catch all for creating new fstab
+ if not os.path.exists(data_config.MOUNTPOINT+"/etc"):
+ os.makedirs(data_config.MOUNTPOINT+"/etc")
+ if not os.path.exists(fstabfile):
+ create_fstab(kmvg)
+
+ logging.info("____UUID check for %s", "swap")
+ swapuuid = find_uuid(hostoptions["swappartition"])
+
+ logging.info("____UUID check for %s", "data")
+ datauuid = find_uuid(hostoptions["datapartition"])
+
+ logging.info("____UUID check for %s", "root")
+ rootuuid = find_uuid(hostoptions["rootpartition"])
+
+ fstabfile = data_config.MOUNTPOINT+"/etc/fstab"
+ logging.info("Correcting UUID's in %s", fstabfile)
+ f = open(fstabfile, 'r')
+ oldfscontents = f.readlines()
+ newfstab = []
+ f.close()
+ for line in oldfscontents:
+ if line.startswith("UUID"):
+ templine = line.split()
+ if ( templine[1] == "/"):
+ logging.debug(" Found Root fstab line:")
+ logging.debug( templine)
+ templine[0] = "UUID=%s" %(rootuuid)
+ newline = ''
+ for i in templine:
+ newline+=i
+ newline+=" "
+ newline+="\n"
+ logging.debug(" New fstab line:")
+ logging.debug( newline)
+ newfstab.append(newline)
+
+ if ( templine[1] == data_config.DATAMOUNT):
+ logging.debug(" Found DATA mount")
+ logging.debug( templine)
+ templine[0] = "UUID=%s" %(datauuid)
+ newline = ''
+ for i in templine:
+ newline+=i
+ newline+=" "
+ newline+="\n"
+ logging.debug(" New fstab line:")
+ logging.debug( newline)
+ newfstab.append(newline)
+
+ if ( templine[1] == "swap"):
+ if len(swapuuid) <= 5:
+ logging.debug(" swapp uuid is to small")
+ else:
+ logging.debug(" Found swap partition")
+ logging.debug( templine)
+ templine[0] = "UUID=%s" %(swapuuid)
+ newline = ''
+ for i in templine:
+ newline+=i
+ newline+=" "
+ newline+="\n"
+ logging.debug(" New fstab line:")
+ logging.debug( newline)
+ newfstab.append(newline)
+ else:
+ logging.debug(" Line didn't match, adding to newfstab:")
+ logging.debug( line)
+ newfstab.append(line)
+ logging.info("Writing out newfstab")
+ logging.debug("______This is the new fstab_____")
+ f = open(fstabfile, 'w')
+ for line in newfstab:
+ logging.debug(line)
+ f.write(line)
+ #f.write("\n")
+ f.close()
+
+def grub_it():
+ logging.info("______Start of grub install______")
+ cmd = " grub-install --recheck --no-floppy --root-directory=%s \"(hd0)\" " % data_config.MOUNTPOINT
+ logging.info("Running grub-install")
+ runcmd(cmd)
+ rootuuid = find_uuid(hostoptions["rootpartition"])
+ cmd = " mkinitcpio -g %s/boot/kernel26.img" % data_config.MOUNTPOINT
+ logging.info("Running mkinitcpio")
+ runcmd(cmd)
+ logging.info("Adding root uuid to grub menu")
+ grubfile = data_config.MOUNTPOINT+"/boot/grub/menu.lst"
+ try:
+ f = open(grubfile, 'r')
+ oldgrub = f.readlines()
+ newgrub = []
+ f.close()
+ for line in oldgrub:
+ if line.startswith("kernel"):
+ templine = line.split()
+ logging.debug(" Found kernel Root grubline:")
+ logging.debug( templine)
+ templine[2] = "root=/dev/disk/by-uuid/%s" %(rootuuid)
+ newline = ''
+ for i in templine:
+ newline+=i
+ newline+=" "
+ newline+="\n"
+ logging.debug(" New grub menu.lst line:")
+ logging.debug( newline)
+ newgrub.append(newline)
+ else:
+ logging.debug("Line didn't match, adding to newgrub:")
+ logging.debug( line)
+ newgrub.append( line)
+ logging.info("Writing out new grub file")
+ logging.debug("______This is the new grub_____")
+ f = open(grubfile, 'w')
+ for line in newgrub:
+ logging.debug(line)
+ f.write(line)
+ f.close()
+ except:
+ logging.debug("Couldn't open grub file")
+
+def fix_permissions():
+ logging.info("Fixing permissions")
+ SE = os.environ["TEMPLATES"]+"/settings/syssettings"
+ cmd = " chmod -R 755 %s" %(data_config.MOUNTPOINT+SE)
+ runcmd(cmd)
+ cmd = " chmod 755 %s" %(data_config.MOUNTPOINT+"/etc/systemconfig")
+ runcmd(cmd)
+ cmd = " chmod 755 %s" %(data_config.MOUNTPOINT+"/root")
+ runcmd(cmd)
+ cmd = " chown root:mythtv %s" %(data_config.MOUNTPOINT+"/etc/systemconfig")
+ runcmd(cmd)
+ cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+SE)
+ runcmd(cmd)
+ cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+"/var/log/mythtv")
+ runcmd(cmd)
+
+def apply_new_auth():
+ logging.info("_____Applying Password updates_______")
+ passfile = "/root/myth_user_call.out"
+ try:
+ MVROOT = os.environ["MV_ROOT"]
+ except:
+ logging.debug("MVROOT was not defined, using the default value")
+ MVROOT = "/usr/MythVantage"
+ if data_config.NOOPDEBUG == "FALSE":
+ cmdprefix = "chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i "
+ else:
+ cmdprefix = "echo chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i "
+ try:
+ f = open(passfile, 'r')
+ passcmds = f.readlines()
+ f.close()
+ for cmd in passcmds:
+ execmd = cmdprefix+cmd
+# Using os.system because runcmd fails
+ logging.debug(execmd)
+ os.system(execmd)
+ except:
+ logging.debug("Applying password updates failed, couldn't open %s", passfile)
+ logging.debug
+
+def swapsearch():
+#currently unused!
+ partlist = []
+ stddir = os.getcwd()
+ os.chdir("/sys/block")
+ partitionlist = glob.glob("*")
+ for item in partitionlist:
+ try:
+ newitem = item.strip().rpartition(" ")[2]
+ if (not newitem == '') and (not newitem.startswith("loop")):
+ path = "/dev/"+newitem.strip()
+ path = path.strip()
+ device = parted.getDevice(path)
+ (cylinders, heads, sectors) = device.biosGeometry
+ sizeInBytes = device.length * device.sectorSize
+ disk = parted.Disk(device)
+ for partition in disk.partitions:
+ if partition.type == parted.PARTITION_PROTECTED or \
+ partition.type == parted.PARTITION_METADATA or \
+ partition.type == parted.PARTITION_FREESPACE:
+ continue
+
+ partlist.append((partition,
+ partition.path,
+ partition.getFlag(parted.PARTITION_BOOT),
+ partition.geometry.start,
+ partition.geometry.end,
+ partition.geometry.length,
+ partition.type,
+ partition.fileSystem))
+ for slice in partlist:
+ (partition, path, bootable, start, end, length, type, fs) = slice
+ if partition.getFlag(parted.PARTITION_SWAP) or fs.type == "linux-swap":
+ print "found swap"
+ print path
+ except:
+ pass
+ os.chdir(stddir)
+
+def sane_settings(file):
+ #Remove some settings from file_name
+ removeline = ("HOSTrootfstype", "HOSTrootfstype", "HOSTdatafstype", "HOSTOSsize", "HostUseALLdata", "HOSTDATAsize", "HOSTuprootfstype", "HostUseSWAP", "HOSTSWAPsize")
+ logging.debug("__Running sane settings")
+ try:
+ f = open(file, 'r')
+ filecontents = f.readlines()
+ f.close()
+ except:
+ logging.debug(" Couldn't find file %s to sane", file)
+ try:
+ f = open(file, 'w')
+ for line in filecontents:
+ for item in removeline:
+ if line.startsize(line.strip()):
+ logging.debug(" Found a line to remove in %s, %s", file, line)
+ else:
+ f.write(line)
+ except:
+ logging.debug(" Couldn't open file %s for writing", file)
+ logging.debug(" __End sane settings")
+
+def restore_default_settings():
+ try:
+ MVROOT = os.environ["MV_ROOT"]
+ except:
+ 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)
+ runcmd(cmd)
+ SE = os.environ["TEMPLATES"]+"/settings/syssettings/"
+ cp_and_log(SE, data_config.MOUNTPOINT+SE)
+ cp_and_log("/etc/mtab", data_config.MOUNTPOINT+"/etc/mtab")
+ copy_updates()
+ fix_permissions()
+
+def full_install(hostoptions):
+ logging.info("______Start of full install______")
+ try:
+ MVROOT = os.environ["MV_ROOT"]
+ except:
+ logging.debug(" MVROOT was not defined, using the default value")
+ MVROOT = "/usr/MythVantage"
+
+ try:
+ os.remove("/tmp/.this_is_upgrade")
+ except OSError:
+ logging.debug(" File /tmp/.this_is_upgrade not present, couldn't delete it")
+ pass
+# Partition disk
+ statusmsg = "Partitioning %s" %( hostoptions["rootdisk"])
+ update_status(statusmsg)
+ progress(1)
+ if data_config.NOOPDEBUG == "FALSE":
+ partition_disk()
+ else:
+ logging.debug(" Debug mode, skipping partitioning step")
+
+# Format disk
+ statusmsg = "Preparing %s" %( hostoptions["rootdisk"])
+ update_status(statusmsg)
+ progress(2)
+ format_disk("install")
+
+
+# Mount partitions
+ statusmsg = "Mounting %s" %( hostoptions["rootdisk"])
+ update_status(statusmsg)
+ progress(3)
+ mount_it()
+
+# Find number of bytes written to disk before starting copy. This is used
+# to have a somewhat decent progress indication.
+ statgrab( hostoptions["rootdisk"])
+ msg = "Creating %s" %(systemconfig["hostname"])
+ update_status(msg)
+
+# Copy system to disk
+ copy_it("install")
+# Remove old fstab so that a new one is created
+ fstabfile = data_config.MOUNTPOINT+"/etc/fstab"
+ try:
+ os.remove(fstabfile)
+ except OSError:
+ logging.debug(" ERROR: deleting %s", fstabfile)
+ fstab_it("full_install")
+# Configure system
+ msg = "Configuring system"
+ update_status(msg)
+ progress(98)
+ grub_it()
+# Configuring the system
+ logging.info("______Configuring system________")
+ cp_and_log("/etc/systemconfig", data_config.MOUNTPOINT+"/etc/systemconfig")
+ cp_and_log("/root/xorg.conf.install", data_config.MOUNTPOINT+"/etc/X11/xorg.conf.install")
+ restore_default_settings()
+ #try:
+ #MVROOT=os.environ["MV_ROOT"]
+ #except:
+ #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)
+ #runcmd(cmd)
+ #SE=os.environ["TEMPLATES"]+"/settings/syssettings"
+ #cp_and_log(SE, data_config.MOUNTPOINT+SE)
+ #cp_and_log("/etc/mtab", data_config.MOUNTPOINT+"/etc/mtab")
+ #cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin/", "*.sh")
+ #cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin/", "*.py")
+ #fix_permissions()
+ apply_new_auth()
+ if ( systemconfig["SystemType"] == "Master_backend" or systemconfig["SystemType"] == "Standalone" ):
+# This install will need a DB, so install it
+ logging.info("______Installing Database in CHROOT________")
+ mysqldb("stop", '')
+ mount_bind_chroot()
+ cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT)
+ runcmd(cmd)
+ logging.info("Running systemconfig in chroot")
+ #cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ runcmd(cmd)
+ mysqldb("stop", "chroot")
+ kill_dhcp_chroot()
+ logging.info("____End Database in CHROOT____")
+ mysqldb("start", '')
+ umount_bind_chroot()
+ 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)
+# 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)
+ runcmd(cmd)
+ if ( 'x' == '1' ):
+ logging.debug("touching /tmp/.dbsysfailed")
+ else:
+ #cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ runcmd(cmd)
+ cmd = " chroot %s %s/bin/restore_default_settings.sh -c ACCESSCONTROL " %(data_config.MOUNTPOINT, MVROOT)
+ runcmd(cmd)
+ umount_bind_chroot()
+ #cmd = " chroot %s %s/bin/systemconfig.sh advanced, user" %(data_config.MOUNTPOINT, MVROOT)
+ #runcmd(cmd)
+ cmd = " touch %s%s/.configure" %(data_config.MOUNTPOINT, data_config.MYTHHOME)
+ runcmd(cmd)
+ cmd = " chmod 777 %s%s/.configure" %(data_config.MOUNTPOINT, data_config.MYTHHOME)
+ runcmd(cmd)
+ msg = "Done"
+ update_status(msg)
+ cp_and_log("/tmp/mythvantage_install.log", data_config.MOUNTPOINT+"/var/log/mythvantage_install.log")
+ cp_and_log("/tmp/mv_debug.log", data_config.MOUNTPOINT+"/var/log/mv_debug.log")
+ unmount_it()
+ logging.debug("_____End of full install_____")
+
+def find_upgrade():
+ logging.info("_____Start of find_upgrade_____")
+ global hostoptions
+ #try to mount first partition of disk
+ #copy old /etc/systemconfig to live, import settings into db
+ #umount drive.
+ #check for clean upgrade
+ if ( clean_upgrade() ):
+ logging.info("Clean upgrade requested, not using old data")
+ return
+ mount_it()
+ oldbackupfile = data_config.MOUNTPOINT+"/root/backup/"+data_config.BACKUPFILE
+ newbackupfile = "/tmp/"+data_config.BACKUPFILE
+ if os.path.exists(oldbackupfile):
+ logging.debug("Setting backup file to %s", newbackupfile)
+ hostoptions["backupfile"] = newbackupfile
+ cp_and_log(oldbackupfile, newbackupfile)
+
+ srcfile = data_config.MOUNTPOINT+"/etc/systemconfig"
+ logging.info("Searching for systemconfig file %s", srcfile)
+ if os.path.exists(srcfile):
+ logging.info("Found systemconfig file %fs", srcfile)
+ TEMPLATES = os.environ["TEMPLATES"]+"/settings/syssettings"
+ cp_and_log2(data_config.MOUNTPOINT+TEMPLATES, data_config.TEMP_TEMPLATES, '')
+ sane_settings("/tmp/templates/settings/syssettings/settings.txt")
+ cp_and_log2(data_config.TEMP_TEMPLATES, TEMPLATES, '')
+ cp_and_log(srcfile, "/etc/systemconfig")
+ cp_and_log(data_config.MOUNTPOINT+"/etc/", "/tmp/etc/")
+ cp_and_log(data_config.MOUNTPOINT+"/var/lib/oss/", "/tmp/oss")
+ cp_and_log("/tmp/etc/mdadm.conf", "/etc/mdadm.conf")
+ else:
+ logging.info("Could not find systemconfig file %s", srcfile)
+ cp_and_log(data_config.MOUNTPOINT+"/etc/", "/tmp/etc/")
+ cp_and_log("/tmp/etc/mdadm.conf", "/etc")
+ timezone_to_db("/tmp/etc/timezone")
+ unmount_it()
+ logging.debug("End of find_upgrade")
+
+def upgrade_mount_search():
+ #Search for data/myth partition based on contents of fstab
+ logging.debug("______Start of upgrade_mount_search_____")
+ cmd = "umount %s%s" %(data_config.MOUNTPOINT, data_config.DATAMOUNT)
+ runcmd(cmd)
+ fstab_list = []
+ fstab_data_mount = ''
+ try:
+ f = open("/tmp/etc/fstab", 'r')
+ oldfscontents = f.readlines()
+ f.close()
+ ## ['UUID=', '/myth', 'auto', 'defaults, noatime', '0', '1']
+ #for line in oldfscontents:
+ #mountdir=line.split()
+ #if mountdir[1] == (data_config.DATAMOUNT):
+ #fstablist.append(mountdir)
+ except:
+ logging.debug(" Couldn't open /tmp/etc/fstab")
+ for line in oldfscontents:
+ if line.startswith("#"):
+ continue
+ mountdir=line.split()
+ try:
+ if mountdir[1] == (data_config.DATAMOUNT):
+ fstablist.append(mountdir)
+ except:
+ continue
+ #search fstab for data/myth mountpoint
+ for i in fstab_list:
+ if i[1] == data_config.DATAMOUNT:
+ fstab_data_mount = i[0]
+ break
+
+ #start software raid support if needed
+ for i in fstab_list:
+ if i[0].startswith("/dev/md"):
+ logging.debug(" starting software raid support")
+ mdadm_assemble_all
+
+
+ if re.search("UUID", fstab_data_mount):
+ fstab_data_uuid = fstab_data_mount.split("=")[1]
+ cmd = "blkid -t UUID=%s" %fstab_data_uuid
+ retcode = call(cmd, shell=True)
+ if retcode != 0:
+ logging.debug(" Couldn't find uuid %s, starting md support", fstab_data_uuid)
+ mdadm_assemble_all
+ #hoping everything is up and running and data/myth will be available for mount
+ cmd = "mount -U %s %s" %(fstab_data_uuid, data_config.MOUNTPOINT)
+ runcmd(cmd)
+ cmd = "blkid -t UUID=%s|cut -d: -f1" %fstab_data_uuid
+ logging.debug(cmd)
+ datadisk = commands.getoutput(cmd)
+ cmd = "basename %s" %datadisk
+ datadisk = commands.getoutput(cmd)
+ else:
+ cmd = "mount %s %s" %(fstab_data_mount, data_config.MOUNTPOINT)
+ runcmd(cmd)
+ cmd = "basename %s" %fstab_data_mount
+ datadisk = commands.getoutput(cmd)
+ time.sleep(3)
+# hostoptions["backupfile"]=data_config.BACKUPPATH+data_config.BACKUPFILE
+ if not backup_sql_check():
+ newbackupfile = "/tmp/"+data_config.BACKUPFILE
+ if os.path.exists(newbackupfile):
+ logging.debug("Setting backup file to %s", newbackupfile)
+ cp_and_log(newbackupfile, data_config.MOUNTPOINT+newbackupfile)
+ hostoptions["backupfile"] = newbackupfile
+ else:
+ logging.info("Couldn't find any database to restore, upgrade will continue with a new database")
+
+
+
+def upgrade(hostoptions):
+
+ try:
+ MVROOT = os.environ["MV_ROOT"]
+ except:
+ logging.debug("MVROOT was not defined, using the default value")
+ MVROOT = "/usr/MythVantage"
+ logging.info("______Start of upgrade______")
+ cmd = "touch /tmp/.this_is_upgrade"
+ runcmd(cmd)
+ if hostoptions["rootfs"] == "Do_not_format":
+ logging.info("Will not format root filesystem")
+ else:
+ statusmsg = "Preparing %s" %( hostoptions["rootdisk"])
+ update_status(statusmsg)
+ progress(2)
+ format_disk("upgrade")
+ #sys.exit(2)
+ statusmsg = "Mounting %s" %( hostoptions["rootdisk"])
+ update_status(statusmsg)
+ progress(3)
+ mount_it()
+ hostoptions["backupfile"] = data_config.BACKUPPATH+data_config.BACKUPFILE
+ statgrab( hostoptions["rootdisk"])
+ msg = "Upgrading %s" %(systemconfig["hostname"])
+ update_status(msg)
+ time.sleep(3)
+ copy_it("upgrade")
+ cmd = "rm -rf %s/etc.old" %data_config.MOUNTPOINT
+ runcmd(cmd)
+
+ cp_and_log("/tmp/etc/", data_config.MOUNTPOINT+"/etc.old/")
+ cp_and_log("/tmp/oss", data_config.MOUNTPOINT+"/var/lib/oss.old")
+ srcfile = "%s/etc.old/ssh/" %(data_config.MOUNTPOINT)
+ destfile = "%s/etc/ssh/" %(data_config.MOUNTPOINT)
+ cp_and_log2(srcfile, destfile, '*.pub')
+ cp_and_log2(srcfile, destfile, '*.key')
+ cp_and_log2(srcfile, destfile, '*key')
+ mdfile = mdadm_find("/tmp")
+ cp_and_log("/tmp"+mdfile, data_config.MOUNTPOINT+"/etc")
+ srcfile = "%s/etc.old/asound.state" %(data_config.MOUNTPOINT)
+ destfile = "%s/etc/asound.state" %(data_config.MOUNTPOINT)
+ cp_and_log(srcfile, destfile)
+ if not os.path.exists("/tmp/etc/KnoppMyth-version"):
+ logging.debug(" standard upgrade, restoring auth files")
+ cp_and_log(data_config.MOUNTPOINT+"/etc.old/passwd", data_config.MOUNTPOINT+"/etc/passwd")
+ cp_and_log(data_config.MOUNTPOINT+"/etc.old/shadow", data_config.MOUNTPOINT+"/etc/shadow")
+ cp_and_log(data_config.MOUNTPOINT+"/etc.old/group", data_config.MOUNTPOINT+"/etc/group")
+ msg = "Configuring system"
+
+ update_status(msg)
+ progress(98)
+ logging.info("______Configuring system________")
+ cp_and_log("/etc/systemconfig", data_config.MOUNTPOINT+"/etc/systemconfig")
+ if not backup_sql_check():
+ upgrade_mount_search()
+ fstab_it("upgrade")
+ time.sleep(1)
+ grub_it()
+ time.sleep(1)
+ #needed to get around a bug with pacman
+ cp_and_log("/root/xorg.conf.install", data_config.MOUNTPOINT+"/etc/X11/xorg.conf.install")
+ cp_and_log("/etc/mtab", data_config.MOUNTPOINT+"/etc/mtab")
+ if clean_upgrade() or os.path.exists("/tmp/etc/KnoppMyth-version"):
+ logging.debug("clean upgrade or knoppmyth upgrade detected, running restore settings")
+ restore_default_settings()
+ if clean_upgrade():
+ file = "%s/%s/.kmupgrade" %(data_config.MOUNTPOINT, data_config.MYTHHOME)
+ cmd = "touch %s && chmod 777 %s" %(file, file)
+ runcmd(cmd)
+ copy_updates()
+ fix_permissions()
+ mount_bind_chroot()
+ logging.info("Running systemconfig in chroot")
+ #cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ runcmd(cmd)
+ mysqldb("stop", "")
+ if ( systemconfig["SystemType"] == "Master_backend" or systemconfig["SystemType"] == "Standalone" ):
+ if clean_upgrade() or not backup_sql_check():
+ logging.info("Installing new database")
+ cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT)
+ runcmd(cmd)
+ else:
+ logging.info("Restoring database")
+ cmd = " chroot %s %s/bin/restore_km_db_chroot.sh %s|tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT, hostoptions["backupfile"])
+ 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)
+ runcmd(cmd)
+ logging.debug("Correcting permissions because of km->linhes upgrade")
+ cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT)
+ runcmd(cmd)
+ 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)
+ runcmd(cmd)
+
+ logging.info("Running systemconfig in chroot 2nd time")
+ #cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ runcmd(cmd)
+ #logging.info("Running systemconfig in chroot")
+ #cmd = " chroot %s %s/bin/systemconfig.sh advanced" %(data_config.MOUNTPOINT, MVROOT)
+ #runcmd(cmd)
+ mysqldb("stop", 'chroot')
+ apply_new_auth()
+ kill_dhcp_chroot()
+ umount_bind_chroot()
+ cp_and_log("/tmp/mythvantage_install.log", data_config.MOUNTPOINT+"/var/log/mythvantage_install.log")
+ cp_and_log("/tmp/mv_debug.log", data_config.MOUNTPOINT+"/var/log/mv_debug.log")
+ unmount_it()
+ msg = "Done"
+ update_status(msg)
+ mysqldb("start", '')
+
+
+
+
+def main(argv):
+ global hostoptions
+ try:
+ opts, args = getopt.getopt(argv, 'c:h', ["help", "rootdisk=", "rootfs=", "rootsize=", "datafs=", "datasize=", "datadisk=", "swapsize=", "datapartition=" ] )
+ except getopt.GetoptError, why:
+ print why
+ usage()
+ sys.exit(2)
+ hostoptions = {"op": 'null'}
+ for opt, arg in opts:
+ if opt in ("-h", "--help"):
+ usage()
+ sys.exit(0)
+ elif opt in ( "--rootdisk"):
+ hostoptions["rootdisk"] = arg
+ hostoptions["rootpartition"] = arg+str(1)
+ elif opt in ("--rootfs"):
+ hostoptions["rootfs"] = arg
+ elif opt in ("--rootsize"):
+ hostoptions["rootsize"] = arg
+ elif opt in ("--datafs"):
+ hostoptions["datafs"] = arg
+ elif opt in ("--datasize"):
+ hostoptions["datasize"] = arg
+ elif opt in ("--datadisk"):
+ hostoptions["datadisk"] = arg
+ elif opt in ("--datapartition"):
+ hostoptions["datapartition"] = arg
+ elif opt in ("--swapsize"):
+ hostoptions["swapsize"] = arg
+
+ elif opt in ("-c"):
+ validop = ["full_install", "upgrade", "netboot", "find_upgrade"]
+ if arg not in validop:
+ logging.critical("-c %s is not a valid option", arg)
+ sys.exit(2)
+ else:
+ hostoptions["op"] = arg
+ try:
+ hostoptions["datadisk"]
+ except:
+ hostoptions["datadisk"] = hostoptions["rootdisk"]
+ hostoptions["datapartition"] = hostoptions["datadisk"]+str(3)
+ try:
+ hostoptions["datapartition"]
+ except:
+ hostoptions["datapartition"] = hostoptions["datadisk"]+str(3)
+ hostoptions["swappartition"] = hostoptions["rootdisk"] + str(2)
+
+
+ if ( hostoptions["op"] == "full_install" ) :
+ full_install(hostoptions)
+ elif (hostoptions["op"] == "upgrade" ) :
+ hostoptions["datafs"] = "no_format"
+ find_upgrade()
+ upgrade(hostoptions)
+ elif (hostoptions["op"] == "find_upgrade" ) :
+ find_upgrade()
+ return hostoptions
+
+
+#____________________________________________setup the logging______________________________________________________
+LOG_FILENAME = '/tmp/mv_status.log'
+DEBUGLOG = '/tmp/mv_debug.log'
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
+ datefmt='%m-%d %H:%M',
+ filename=DEBUGLOG,
+ filemode='a')
+# define a Handler which writes INFO messages or higher to the sys.stderr
+console = logging.StreamHandler()
+console.setLevel(logging.INFO)
+# set a format which is simpler for console use
+#formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
+formatter = logging.Formatter("%(message)s")
+# tell the handler to use this format
+console.setFormatter(formatter)
+# add the handler to the root logger
+logging.getLogger('').addHandler(console)
+
+#infoformatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
+infoformatter = logging.Formatter("%(message)s")
+infofile = logging.FileHandler(LOG_FILENAME, 'w')
+infofile.setFormatter(infoformatter)
+infofile.setLevel(logging.INFO)
+logging.getLogger('').addHandler(infofile)
+
+#Read in systemconfig
+global systemconfig
+systemconfig = {}
+file_name = "/etc/systemconfig"
+try:
+ config_file = open(file_name)
+except:
+ logging.debug("%s could not be opened", file_name)
+ config_file = ''
+
+for line in config_file:
+ line = line.strip()
+ if line and line[0] is not "#" and line[-1] is not "=":
+ var, val = line.rsplit("=", 1)
+ val = val.strip('"')
+ systemconfig[var.strip()] = val.strip()
+
+
+if __name__ == "__main__":
+ config_file = "mv_config"
+ data_config = __import__(config_file, globals(), locals(), [])
+ logging.debug("___________START OF DEBUG_________________________")
+ cmdoptions = main(sys.argv[1:])
+ logging.debug("______cmd line options______")
+ for i in cmdoptions.items():
+ logging.debug (i)
+ logging.debug("______systemconfig______")
+ for i in systemconfig.items():
+ logging.debug(i)
+ logging.debug("______hostoptions______")
+ for i in hostoptions.items():
+ logging.debug(i)
+ pass
+
diff --git a/abs/core-testing/LinHES-config/mv_ir.py b/abs/core-testing/LinHES-config/mv_ir.py
new file mode 100755
index 0000000..b3552c5
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_ir.py
@@ -0,0 +1,288 @@
+# -*- coding: utf-8 -*-
+import logging, mv_common
+import os, re , glob
+from time import time, localtime, strftime
+import time
+
+def setup_lirc_links(mythhome):
+ logging.debug(" Creating links for lirc")
+ if not os.path.exists(mythhome+"/.mythtv"):
+ logging.debug(" Creating %s/.mythtv",mythhome)
+ try:
+ os.mkdir(mythhome+"/.mythtv")
+ except:
+ logging.debug(" Couldn't create .mythtv ")
+ return
+ os.chown(mythhome+"/.mythtv","mythtv","mythtv")
+
+ if not os.path.exists(mythhome+"/.mythtv/lircrc"):
+ logging.debug(" Creating symlink for myth lircrc")
+ os.symlink("/etc/lircrc",mythhome+"/.mythtv/lircrc")
+ else:
+ logging.debug(" %s/lircrc already present",mythhome)
+
+ if not os.path.exists(mythhome+"/.lircrc"):
+ logging.debug(" Creating symlink for lircrc")
+ os.symlink("/etc/lircrc",mythhome+"/.lircrc")
+ else:
+ logging.debug(" %s/.lircrc already present",mythhome)
+
+def scrub_modules(filename,module):
+ logging.debug(" scrubbing %s from %s",module,filename)
+ cmd = '''sed -i -e '/.*#%s/d' %s''' %(module,filename)
+ mv_common.runcmd(cmd)
+
+def add_module(filename,module):
+ logging.debug(" adding %s to %s",module,filename)
+ cmd = ''' echo %s >> %s ''' %(module,filename)
+ mv_common.runcmd(cmd)
+
+def unload_all_lirc():
+ logging.debug(" Unloading all lirc modules")
+ cmd = "sv stop lircd"
+ mv_common.runcmd(cmd)
+ cmd = "killall -9 lircd"
+ mv_common.runcmd(cmd)
+ cmd = '''modprobe -r $(lsmod |grep ^lirc |awk '{print $1}') '''
+ mv_common.runcmd(cmd)
+
+
+
+def include_file( incfile,filename):
+ logging.debug(" including %s within %s",filename,incfile)
+ try:
+ f = open( incfile, 'a')
+ except:
+ logging.debug(" Couldn't open %s for writing",incfile)
+ return
+ line = '''include "%s" ''' %filename
+ logging.debug(" %s",line)
+ f.write(line)
+ f.write("\n")
+ f.close()
+
+def setup_ir_remote(Remotetype,templates):
+ logging.debug(" Setup of remote type %s",Remotetype)
+ if Remotetype == "no_remote":
+ mv_common.remove_service(lircd)
+ elif Remotetype == "tinker":
+ pass
+ else:
+ currenttime = strftime("%b-%d-%Y-%H:%M:%S", localtime())
+ cmd = "mv /etc/lircd.conf /etc/lircd.conf-%s" %currenttime
+ mv_common.runcmd(cmd)
+ cmd = "mv /etc/lircrc /etc/lircrc-%s" %currenttime
+ mv_common.runcmd(cmd)
+ files = templates + "/remotes/" + Remotetype + "/lircd*"
+ logging.debug(" Using %s",files)
+ for filename in glob.glob(files):
+ # Ignore subfolders
+ if os.path.isdir (filename):
+ logging.debug(" %s is a dir, skipping",filename)
+ continue
+ include_file("/etc/lircd.conf",filename)
+ files = templates + "/remotes/" + Remotetype + "/lircrc*"
+ logging.debug(" Using %s",files)
+ for filename in glob.glob(files):
+ # Ignore subfolders
+ if os.path.isdir (filename):
+ logging.debug(" %s is a dir, skipping",filename)
+ continue
+ include_file("/etc/lircrc",filename)
+ cmd = "chmod 755 /etc/lircrc"
+ mv_common.runcmd(cmd)
+ mv_common.add_service("lircd")
+
+
+def setup_ir_receiver(ReceiverType,TEMPLATES):
+ logging.info(" Configuring receiver %s", ReceiverType)
+ if ReceiverType == "Serial":
+ scrub_modules("/etc/modules.mythvantage","lirc")
+ add_module("/etc/modules/.mythvantage","lirc_serial #lirc")
+ cmd = "load-modules-mythvantage.sh"
+ mv_common.runcmd(cmd)
+ mv_common.remove_service("igdaemon")
+ mv_common.remove_service("tatir")
+
+ elif ReceiverType == "Usb-imon":
+ scrub_modules("/etc/modules.mythvantage","lirc")
+ add_module("/etc/modules/.mythvantage","lirc_imon #lirc")
+ cmd = "load-modules-mythvantage.sh"
+ mv_common.runcmd(cmd)
+ mv_common.remove_service("igdaemon")
+ mv_common.remove_service("tatir")
+
+ elif ReceiverType == "Hauppauge":
+ scrub_modules("/etc/modules.mythvantage","lirc")
+ add_module("/etc/modules/.mythvantage","lirc_i2c #lirc")
+ mv_common.cp_and_log(TEMPLATES+"/modules/lirc_i2c.conf" ,
+ "/etc/modprobe.d/lirc_i2c.conf")
+ cmd = "rmmod lirc_i2c"
+ mv_common.runcmd(cmd)
+ cmd = "load-modules-mythvantage.sh"
+ mv_common.runcmd(cmd)
+ mv_common.remove_service("igdaemon")
+ mv_common.remove_service("tatir")
+
+ elif ReceiverType == "iguanaIR-usb":
+ scrub_modules("/etc/modules.mythvantage","lirc")
+ mv_common.add_service("igdaemon")
+ mv_common.remove_service("tatir")
+
+ elif ReceiverType == "tatir":
+ scrub_modules("/etc/modules.mythvantage","lirc")
+ mv_common.add_service("tatir")
+ mv_common.remove_service("igdaemon")
+
+ else:
+ logging.debug(" didn't match receiver, using genric case")
+ scrub_modules("/etc/modules.mythvantage","lirc")
+ mv_common.remove_service("igdaemon")
+ mv_common.remove_service("tatir")
+
+def setup_blaster_proto(HostBlasterType,Hostnumblaster,TEMPLATES,systemconfig):
+ logging.debug(" Start of setup_blaster_proto")
+ logging.debug(" HostBlasterType: %s", HostBlasterType)
+ logging.debug(" Hostnumblaster: %s" , Hostnumblaster)
+ if not HostBlasterType == "pvr150" and not HostBlasterType == "None":
+ for i in range(int(Hostnumblaster)):
+ try:
+ proto = systemconfig["HostTransmitproto_"+str(i+1)]
+ logging.debug(" proto: %s",proto)
+ except:
+ logging.info(" unkown proto for %s",i+1)
+ continue
+ template=TEMPLATES+"/transmit/%s/lircd.conf" %proto
+ if os.path.exists(template):
+ logging.debug(" include blaster template: %s",proto)
+ include_file("/etc/lircd.conf",template)
+ else:
+ logging.debug(" template: %s is not present",template)
+ logging.info("------NEED TO SETUP CHANGE_CHANNEL------")
+
+
+def setup_blaster_transmiter(HostBlasterType):
+ logging.debug(" Start of setup_blaster_transmiter")
+ logging.info(" HostBlasterType : %s", HostBlasterType)
+
+ if HostBlasterType == "Receiver":
+ logging.info(" Blaster is receiver, skipping module config for Blaster")
+ return
+
+ if HostBlasterType == "no blaster":
+ scrub_modules("/etc/modules.mythvantage","blaster")
+ elif HostBlasterType == "Serial":
+ scrub_modules("/etc/modules.mythvantage","blaster")
+ add_module("/etc/modules/.mythvantage","lirc_serial #blaster")
+ cmd = "load-modules-mythvantage.sh"
+ mv_common.runcmd(cmd)
+ elif HostBlasterType == "pvr150":
+ scrub_modules("/etc/modules.mythvantage", "blaster")
+ scrub_modules("/etc/modules.mythvantage", "lirc")
+ add_module("/etc/modules/.mythvantage", "lirc_pvr150 #blaster")
+ add_module("/etc/modules/.mythvantage", "lirc_pvr150 #lirc")
+ cmd = "rmmod lirc_i2c"
+ mv_common.runcmd(cmd)
+ cmd = "load-modules-mythvantage.sh"
+ mv_common.runcmd(cmd)
+ else:
+ scrub_modules("/etc/modules.mythvantage","blaster")
+
+def setup_lcd(LCDtype, TEMPLATES, Remotetype):
+ logging.debug(" Start of setup_lcd")
+ logging.debug(" LCDType: %s", LCDtype)
+ logging.debug(" Remotetype: %s", Remotetype)
+ if LCDtype == "tinker":
+ logging.info(" tinker mode detected")
+ return
+
+ if LCDtype == "no_lcd":
+ logging.info(" Disabling LCD support")
+ cmd = "sv stop lcdd"
+ mv_common.runcmd(cmd)
+ #sometimes it doesn't want to die
+ cmd = "killall -9 LCDd"
+ mv_common.runcmd(cmd)
+ cmd = "load-modules-mythvantage.sh UNLOAD LCD"
+ mv_common.runcmd(cmd)
+ scrub_modules("/etc/modules.mythvantage", "LCD")
+ mv_common.remove_service("lcdd")
+ else:
+ lcdmodule="%s/LCD/%s/modules" %(TEMPLATES,LCDtype)
+ if os.path.exists(lcdmodule):
+ logging.debug(" Adding module for LCD")
+ scrub_modules("/etc/modules.mythvantage", "LCD")
+ cmd = "cat %s >> /etc/modules.mythvantage" %lcdmodule
+ if Remotetype != "tinker":
+ lcdlirc = "%s/LCD/%s" %(TEMPLATES,LCDtype)
+ if os.path.exists(lcdlirc+"/lircrc"):
+ logging.debug(" LCD seems to support lirc")
+ #setup the lirc aspect of the lcd
+ #copied from setup_ir_remote
+ files = lcdlirc+"/lircd*"
+ logging.debug(" Using %s",files)
+ for filename in glob.glob(files):
+ # Ignore subfolders
+ if os.path.isdir (filename):
+ logging.debug(" %s is a dir, skipping",filename)
+ continue
+ include_file("/etc/lircd.conf",filename)
+ files = lcdlirc+"/lircrc*"
+ logging.debug(" Using %s",files)
+ for filename in glob.glob(files):
+ # Ignore subfolders
+ if os.path.isdir (filename):
+ logging.debug(" %s is a dir, skipping",filename)
+ continue
+ include_file("/etc/lircrc",filename)
+ cmd = "chmod 755 /etc/lircrc"
+ mv_common.runcmd(cmd)
+
+def setup_ir(systemconfig, data_config):
+ rc = False
+ logging.info("____Start of IR____")
+ if systemconfig["Remotetype"] == "tinker":
+ logging.info(" Tinker mode detected")
+ else:
+ if not systemconfig["HostBlasterType"]:
+ HostBlasterType = "unknown"
+ Hostnumblaster = "0"
+ else:
+ HostBlasterType = systemconfig["HostBlasterType"]
+ Hostnumblaster = systemconfig["Hostnumblaster"]
+
+ if systemconfig["HostBlasterType"] == "pvr150":
+ remotetype = "hauppauge-blaster"
+ logging.debug(" pvr150 blaster selected, setting remote to hauppauge-blaster")
+ else:
+ remotetype = systemconfig["Remotetype"]
+
+ setup_ir_remote(remotetype,systemconfig["TEMPLATES"])
+ setup_lirc_links(data_config.MYTHHOME)
+
+ if systemconfig["ReceiverType"]:
+ setup_ir_receiver(systemconfig["ReceiverType"],
+ systemconfig["TEMPLATES"])
+ else:
+ setup_ir_receiver("unknown", systemconfig["TEMPLATES"])
+ unload_all_lirc()
+ setup_blaster_proto(HostBlasterType,
+ Hostnumblaster,
+ systemconfig["TEMPLATES"],
+ systemconfig)
+ setup_blaster_transmiter(HostBlasterType)
+ cmd = "load-modules-mythvantage.sh"
+ mv_common.runcmd(cmd)
+ time.sleep(2)
+ mv_common.udev_trigger()
+ cmd="sv start lircd"
+ mv_common.runcmd(cmd)
+ rc = [ True , True ]
+ if systemconfig["LCDtype"]:
+ setup_lcd(systemconfig["LCDtype"],
+ systemconfig["TEMPLATES"],
+ systemconfig["Remotetype"])
+ else:
+ logging.debug(" LCD not defined")
+ logging.info("__End IR\n")
+ return rc \ No newline at end of file
diff --git a/abs/core-testing/LinHES-config/mv_misc.py b/abs/core-testing/LinHES-config/mv_misc.py
new file mode 100755
index 0000000..27aeb98
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_misc.py
@@ -0,0 +1,174 @@
+# -*- coding: utf-8 -*-
+import logging, mv_common
+import os, re
+from urllib2 import Request, urlopen, URLError, HTTPError
+
+config_file = "mv_config"
+data_config = __import__(config_file, globals(), locals(), [])
+
+def setup_zip(MVROOT,zipcode):
+ logging.debug("____Setting up the zipcode____")
+
+ if zipcode:
+ cmd="%s/bin/restore_default_settings.sh -c ZIP -c %s" %(MVROOT,zipcode)
+ mv_common.runcmd(cmd)
+ #Let's also speed things up for those in North America
+ cmd="mkdir /usr/bin/perlbin/vendor/tv_grabbers_non_na"
+ mv_common.runcmd(cmd)
+ cmd="mv /usr/bin/perlbin/vendor/tv_grab_* /usr/bin/perlbin/vendor/tv_grabbers_non_na"
+ mv_common.runcmd(cmd)
+ cmd="mv /usr/bin/perlbin/vendor/tv_grabbers_non_na/tv_grab_na* /usr/bin/perlbin/vendor/"
+ mv_common.runcmd(cmd)
+ else:
+ logging.debug(" Zipcode is not set")
+
+ logging.debug("__End of zipcode\n")
+
+def setup_tz(timezone,TEMPLATES):
+ logging.info("____Setting up the timezone____")
+
+ if not timezone:
+ timezone="unknown"
+ logging.info(" Setting timezone to %s",timezone)
+ try:
+ logging.debug(" Removing /etc/localtime")
+ os.remove("/etc/localtime")
+ except:
+ logging.debug(" Couldn't remove /etc/localtime")
+ pass
+
+ srclink="/usr/share/zoneinfo/%s" %timezone
+ logging.debug(" symlinking %s to /etc/localtime",srclink)
+ try:
+ os.symlink(srclink,"/etc/localtime")
+ except:
+ logging.critical(" Couldn't make symlink for /etc/localtime")
+ cmd = '''sed -e "s/^TIMEZONE=.*$/TIMEZONE=\\"%s\\" /" /etc/rc.conf > $TEMPLATES/rc.conf''' %re.escape(timezone)
+ mv_common.runcmd(cmd)
+
+ if os.path.exists("/etc/php/php.ini"):
+ logging.info(" Changing timezone for php")
+ cmd = '''sed -i "s/^.*date.timezone.*$/date.timezone=%s/" ${BASE}/etc/php/php.ini''' %re.escape(timezone)
+ mv_common.runcmd(cmd)
+
+ mv_common.cp_and_log(TEMPLATES+"/rc.conf","/etc/rc.conf")
+ logging.info("__End of timezone\n")
+
+def setup_nfs(systemconfig):
+ nfslist=[]
+ logging.info("____Start of setup_nfs____")
+ scrubnfs(systemconfig["TEMPLATES"])
+
+ if systemconfig["HaveCentralNFS"] == "yes":
+ logging.debug(" Using a Central NFS server")
+ if systemconfig["NFSserver"] == "file:nfsmap":
+ #if it's a file check for it, failure results in downloading attempt from MBE
+ nfsmap_file=data_config.MYTHHOME+"/templates/nfsmap"
+ if not os.path.exists(nfsmap_file):
+ logging.debug(" Couldn't find local %s",nfsmap_file)
+ logging.info(" Trying to download nfsmap from MBE")
+ nfsmap_file = download_nfsmap(systemconfig["dbhost"])
+ nfslist = process_nfsmap_file(nfsmap_file)
+ # if it's an ip parse ip and download file
+ elif re.search(systemconfig["NFSserver"],":nfsmap"):
+ ip=systemconfig["NFSserver"].split(":")[0]
+ nfsmap_file = download_nfsmap(ip)
+ nfslist = process_nfsmap_file(nfsmap_file)
+ #else treat it as a single mount point
+ else:
+ item = (systemconfig["NFSserver"] , systemconfig["NFSmount"])
+ nfslist.append(item)
+ setup_nfs_fstab(nfslist)
+ logging.info("__End of nfs\n")
+
+def setup_sleep(systemconfig):
+ logging.debug("____Setting up sleep____")
+ autoshutdown = systemconfig["AutoShutdown"]
+ stime1 = systemconfig["Shutdowntime"]
+ stime2 = systemconfig["Shutdowntime2"]
+ cstime1=''
+
+ if autoshutdown == "1" :
+ if not stime1 == "-1" :
+ cstime1 = stime1
+ cshutdown = cstime1
+ if not stime2 == "-1" :
+ if cstime1 :
+ cshutdown = "%s,%s" %(cstime1,stime2)
+ else:
+ cshutdown = stime2
+ logging.debug(" Shutdown time at %s",cshutdown)
+ cmd='''sed -e "s/HOUR/%s/g" %s/cron.template | crontab - -u mythtv''' %(cshutdown,systemconfig["TEMPLATES"])
+ mv_common.runcmd(cmd)
+ else:
+ logging.info(" Shutdown not enabled")
+ cmd='''sed -e "/00 HOUR.*/d" %s/cron.template | crontab - -u mythtv''' %systemconfig["TEMPLATES"]
+ mv_common.runcmd(cmd)
+
+ logging.debug("__End of sleep\n")
+
+
+def process_nfsmap_file(mapfile):
+ logging.debug(" processing nfsmap file %s",mapfile)
+ nfslist = []
+ try:
+ f = open(mapfile,"r")
+ for line in f.readlines():
+ if line.startswith("#"):
+ continue
+ item = line.split()
+ if len(item) <= 1 :
+ continue
+ logging.debug(" %s",item)
+ nfslist.append(item)
+ except :
+ logging.critical("Couldn't read file %s, or some other error",mapfile)
+ return nfslist
+
+def scrubnfs(templates):
+ logging.info(" Scrubbing nfs")
+ mv_common.cp_and_log("/etc/fstab",templates+"/fstab.conf.template")
+ #used this sed cmd because it's clean and took me forever to figure out =)
+ cmd='''sed '/^#STARTSCRUB.*$/,/^#ENDSCRUB.*$/d' %s/fstab.conf.template > /etc/fstab''' %templates
+ mv_common.runcmd(cmd)
+
+def download_nfsmap(ip):
+ nfsmap_file="/tmp/nfsmap"
+ myurl="http://%s:1337/templates/nfsmap" %ip
+ req = Request(myurl)
+ try:
+ f = urlopen(req)
+ logging.info(" downloading %s", myurl)
+ local_file = open(nfsmap_file, "w")
+ #Write to our local file
+ local_file.write(f.read())
+ local_file.close()
+ #handle errors
+ except HTTPError, e:
+ logging.info(" File download failed")
+ logging.debug(" %s", myurl)
+ logging.debug(" HTTP Error: %s", e.code)
+ except URLError, e:
+ logging.info(" File download failed")
+ logging.debug(" %s",myurl)
+ logging.debug(" URL Error: %s ", e.reason)
+
+ return nfsmap_file
+
+def setup_nfs_fstab(nfslist):
+ logging.info(" Adding nfs paths to fstab")
+ try:
+ f = open('/etc/fstab', 'a')
+ line = "#STARTSCRUB --------------anything in this block will be scrubbed\n"
+ f.write(line)
+ for s, m in nfslist:
+ line = "%s %s nfs \n" %(s,m)
+ logging.debug(" %s",line)
+ f.write(line)
+ line = "#ENDSCRUB\n"
+ f.write(line)
+ f.close()
+ except:
+ logging.critical(" *Couldn't open /etc/fstab for writing")
+ logging.debug(" Done adding nfs paths to fstab")
+
diff --git a/abs/core-testing/LinHES-config/mv_network.py b/abs/core-testing/LinHES-config/mv_network.py
new file mode 100755
index 0000000..ca29c7d
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_network.py
@@ -0,0 +1,276 @@
+# -*- coding: utf-8 -*-
+import sys , os, commands , glob, time, re
+import logging
+import mv_common
+global etcnetdir
+etcnetdir = "/etc/net/ifaces"
+
+
+def setup_MYTH_IP(systemconfig):
+ default_interface = systemconfig["default_interface"]
+ try:
+ defaultip = systemconfig["Hostip"+default_interface]
+ except:
+ logging.debug(" Error occured finding the defaultip")
+ defaultip = "127.0.0.1"
+ logging.debug(" Using %s as default ip", defaultip)
+ return defaultip
+
+def setup_MYTH_DHCP(systemconfig):
+ default_interface = systemconfig["default_interface"]
+ try:
+ defaultdhcp = systemconfig["HostUSEDHCP"+default_interface]
+ except:
+ logging.critical(" *Error occured finding default dhcp")
+ defaultdhcp = "0"
+ logging.debug(" Using %s as dhcp value for %s", default_interface, defaultdhcp)
+ return defaultdhcp
+
+def flush(netdev):
+ logging.debug(" Flushing %s",netdev)
+ cmd = '''ip address flush dev %s''' %netdev
+ mv_common.runcmd(cmd)
+
+def kill_dhcp(basedir):
+ logging.debug(" _Start of kill_dhcp")
+ logging.debug(" Killing off dhcpd")
+ stddir = os.getcwd()
+ piddir = ("%s/var/run/") %basedir
+ try:
+ os.chdir(piddir)
+ for FILE in glob.glob("dhcpcd-*.pid"):
+ f = open(FILE,'r')
+ pid = f.readline()
+ f.close
+ cmd = "kill -9 %s" %pid
+ mv_common.runcmd(cmd)
+ os.remove(FILE)
+ os.chdir(stddir)
+ except:
+ pass
+
+def setup_nameserver(dns):
+ logging.info(" Adding %s for DNS", dns)
+ cmd = '''grep -q %s /etc/resolv.conf''' %dns
+ status = mv_common.runcmd(cmd)
+ if not status == 0 :
+ cmd = ''' echo "nameserver %s" >> /etc/resolv.conf ''' %dns
+ mv_common.runcmd(cmd)
+
+
+
+def setup_hostname(systemconfig):
+ logging.debug(" _Start of setup_hostname")
+ try:
+ hostname = systemconfig["hostname"]
+ except:
+ logging.critical(" *Hostname could not be set")
+ logging.info(" Using default value of me")
+ hostname = "me"
+ logging.info(" Setting the hostname to %s", hostname)
+ cmd = "cat /etc/hosts | grep -v 127.0.0.1 | grep -v %s > /tmp/hosts" %hostname
+ mv_common.runcmd(cmd)
+ if systemconfig["mythdhcp"] == "1" :
+ logging.debug(" not using dhcp")
+ cmd = ''' echo 127.0.0.1 localhost > /etc/hosts '''
+ mv_common.runcmd(cmd)
+ cmd = ''' echo %s %s > /etc/hosts ''' %(systemconfig["mythip"], systemconfig["hostname"])
+ mv_common.runcmd(cmd)
+ else:
+ cmd = ''' echo 127.0.0.1 %s localhost > /etc/hosts ''' %systemconfig["hostname"]
+ mv_common.runcmd(cmd)
+ cmd = '''cat /tmp/hosts >> /etc/hosts '''
+ mv_common.runcmd(cmd)
+
+def setup_interface(netdev,systemconfig):
+ logging.debug(" _Start of setup_interface for %s",netdev)
+ nettrans = {'Hostip':'ip',
+ 'Hostnetmask':'netmask',
+ 'HostActive':'isactive',
+ 'HostDNS':'dns',
+ 'HostUSEDHCP':'UseDHCP',
+ 'HostGW':'GW',
+ 'HostMTU':'mtu',
+ 'HOST_iswireless':"wireless",
+ 'HostESSID':'ESSID',
+ 'HostKey':'key',
+ 'HostUseEncryption':'ENCRYPT'}
+ netinfo = {}
+ #populate the netinfo dict
+ for netitem in nettrans:
+ if systemconfig[netitem+netdev]:
+ netinfo[nettrans[netitem]] = systemconfig[netitem+netdev]
+ else:
+ netinfo[nettrans[netitem]] = False
+ logging.debug(" %s:%s",netitem,netinfo[nettrans[netitem]])
+ logging.info(" %s wireless: %s", netdev,netinfo["wireless"])
+ try:
+ os.makedirs(etcnetdir)
+ except:
+ logging.debug(" Could not create %s",etcnetdir)
+
+ optionfile=etcnetdir+"/"+netdev+"/options"
+ if not os.path.exists(optionfile):
+ os.makedirs(etcnetdir+"/"+netdev)
+ mv_common.cp_and_log(systemconfig["TEMPLATES"]+"/etcnet/eth/options", optionfile)
+
+ if netinfo["isactive"] == "1" :
+ change_iface_state(netdev,"enabled")
+ else:
+ change_iface_state(netdev,"disabled")
+
+ if netinfo["wireless"] == "1" :
+ logging.info(" Enabling wireless extensions")
+ cmd = ''' sed -i -e 's/^CONFIG_WIRELESS=.*$/CONFIG_WIRLESS=yes/g' %s/%s/options''' %(etcnetdir,netdev)
+ mv_common.runcmd(cmd)
+ #set the key and essid
+ cmd = ''' echo "essid %s" > %s/%s/iwconfig ''' %(netinfo["ESSID"], etcnetdir, netdev)
+ mv_common.runcmd(cmd)
+ if netinfo["ENCRYPT"] == "1":
+ logging.info(" Enabling encryption")
+ cmd = '''echo "key %s" >> %s/%s/iwconfig ''' %(netinfo["KEY"], etcnetdir, netdev)
+ mv_common.runcmd(cmd)
+ else:
+ logging.info(" Disabling wireless extensions")
+ cmd = '''sed -i -e 's/^CONFIG_WIRLESS=.*$/CONFIG_WIRLESS=no/g' %s/%s/options''' %(etcnetdir, netdev)
+ mv_common.runcmd(cmd)
+
+ if netinfo["UseDHCP"] == "0" :
+ logging.info(" Enabling DHCP support")
+ cmd = ''' sed -i -e 's/^BOOTPROTO=.*$/BOOTPROTO=dhcp/g' %s/%s/options''' %(etcnetdir, netdev)
+ mv_common.runcmd(cmd)
+ else:
+ logging.info(" Using static ip address of %s",netinfo["ip"])
+ cmd = ''' sed -i -e 's/^BOOTPROTO=.*$/BOOTPROTO=static/g' %s/%s/options''' %(etcnetdir, netdev)
+ mv_common.runcmd(cmd)
+ cmd = '''echo "default via %s" > %s/%s/ipv4route''' %(netinfo["GW"], etcnetdir, netdev)
+ mv_common.runcmd(cmd)
+ cmd = '''echo "%s%s" > %s/%s/ipv4address ''' %(netinfo["ip"], netinfo["netmask"], etcnetdir, netdev)
+ mv_common.runcmd(cmd)
+ setup_nameserver(netinfo["dns"])
+
+ if netinfo["mtu"] :
+ logging.info(" Setting mtu to %s", netinfo["mtu"])
+ cmd = '''sed -i '/^mtu.*$/d' %s/%s/iplink''' %(etcnetdir,netdev)
+ mv_common.runcmd(cmd)
+ cmd = ''' echo "mtu %s" >> %s/%s/iplink''' %(netinfo["mtu"], etcnetdir,netdev)
+ mv_common.runcmd(cmd)
+ else:
+ logging.info(" Using default mtu value")
+ cmd = '''sed -i '/^mtu.*$/d' %s/%s/iplink''' %(etcnetdir,netdev)
+ mv_common.runcmd(cmd)
+
+
+def change_iface_state(netdev, state):
+ if state == "enabled":
+ logging.info(" Activating %s", netdev)
+ cmd = '''sed -i -e 's/^ONBOOT=.*$/ONBOOT=yes/g' %s/%s/options''' %(etcnetdir,netdev)
+ mv_common.runcmd(cmd)
+ cmd = '''sed -i -e 's/^DISABLED=.*$/DISABLED=no/g' %s/%s/options ''' %(etcnetdir,netdev)
+ mv_common.runcmd(cmd)
+ else:
+ logging.info(" Disabling %s", netdev)
+ cmd = '''sed -i -e 's/^ONBOOT=.*$/ONBOOT=no/g' %s/%s/options''' %(etcnetdir,netdev)
+ mv_common.runcmd(cmd)
+ cmd = '''sed -i -e 's/^DISABLED=.*$/DISABLED=yes/g' %s/%s/options ''' %(etcnetdir,netdev)
+ mv_common.runcmd(cmd)
+ cmd = "/sbin/ifconfig %s down" %netdev
+ mv_common.runcmd(cmd)
+ cmd = "ip address flush %s" %netdev
+ mv_common.runcmd(cmd)
+
+def find_active(systemconfig):
+ interfacelist=('eth0', 'eth1', 'wlan0', 'wlan1')
+ logging.debug(" _Start of find_active")
+
+ if systemconfig["mythdhcp"] == "1":
+ try:
+ os.remove("/etc/resolv.conf")
+ except:
+ logging.debug(" couldn't remove /etc/resolv.conf")
+ cmd = ''' echo search lan > /etc/resolv.conf '''
+ mv_common.runcmd(cmd)
+ cmd = ''' echo nameserver 127.0.0.1 >> /etc/resolv.conf '''
+ mv_common.runcmd(cmd)
+
+ for netdev in interfacelist:
+ currentnet = "HostActive" + netdev
+ try:
+ systemconfig[currentnet]
+ except:
+ logging.debug(" %s is not defined",currentnet)
+ continue
+ if systemconfig[currentnet] == "1" :
+ setup_interface(netdev,systemconfig)
+ else:
+ change_iface_state(netdev, "disabled")
+
+def vnc_netboot_check():
+ logging.debug(" Start of VNC/NETBOOT check")
+ vnc = False
+ netboot = False
+ try:
+ f = open('/proc/cmdline', 'r')
+ bootoptions = f.readlines()
+ f.close()
+ except:
+ logging.critical(" *Couldn't open /proc/cmdline")
+ logging.debug(" Assuming it's ok to fiddle with the network")
+ return True
+ bootoptions = bootoptions[0]
+ if re.match("vnc",bootoptions) != None :
+ logging.debug(" Found VNC option")
+ vnc = True
+ if re.match("nfsroot",bootoptions) != None :
+ logging.debug(" Found netboot option")
+ netboot = True
+
+ return (vnc or netboot)
+
+def start_network():
+ if not vnc_netboot_check():
+ logging.info(" Restarting network")
+ cmd ="/etc/net/scripts/network.init reload"
+ mv_common.runcmd(cmd)
+ cmd ="/etc/net/scripts/network.init reload"
+ mv_common.runcmd(cmd)
+ else:
+ logging.info(" Will not restart network due to netboot/vnc")
+
+
+def stop_network():
+ if not vnc_netboot_check():
+ logging.info(" Stopping network")
+ cmd ="/etc/net/scripts/network.init stop"
+ mv_common.runcmd(cmd)
+ kill_dhcp("")
+ interfacelist=('eth0', 'eth1', 'wlan0', 'wlan1')
+ for i in interfacelist:
+ flush(i)
+ else:
+ logging.info(" Will not stop network due to netboot/vnc")
+ pass
+
+
+
+def setup_network (systemconfig):
+ logging.info("____Start of network____")
+ logging.info(" Setting up the network")
+ setup_hostname(systemconfig)
+ find_active(systemconfig)
+ logging.info("__End of network\n")
+
+
+
+##this is used by the install process to start the network
+def install_network_setup(systemconfig):
+ logging.info("____Start of network_install____")
+ logging.info(" Setting up the network")
+ #setup_MYTH_vars
+ setup_hostname(systemconfig)
+ stop_network()
+ find_active(systemconfig)
+ start_network()
+ logging.info("__End of network install \n")
+
+
diff --git a/abs/core-testing/LinHES-config/mv_screensaver.py b/abs/core-testing/LinHES-config/mv_screensaver.py
new file mode 100755
index 0000000..2da970c
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_screensaver.py
@@ -0,0 +1,199 @@
+# -*- coding: utf-8 -*-
+import logging, mv_common
+import re
+import os
+
+
+def mplayer_saver_check (cmd,templatefile):
+ logging.debug(" Checking for heartbeat command in mplayer.conf")
+ mplayerconf = "/etc/mplayer/mplayer.conf"
+ if not os.path.exists(mplayerconf):
+ logging.debug(" copying in mplayer template file")
+ mv_common.cp_and_log(templatefile, mplayerconf)
+
+ try:
+ f = open(mplayerconf, 'r')
+ mplayerconf_contents = f.readlines()
+ f.close()
+ except:
+ logging.debug(" Couldn't open %s for reading",mplayerconf)
+ mplayerconf_contents = "#\n"
+
+ try:
+ f = open(mplayerconf, 'w')
+ except:
+ logging.debug(" Couldn't open %s for writing",mplayerconf)
+ return
+
+ for line in mplayerconf_contents:
+ if re.match("^.*stop-xscreensaver",line):
+ continue
+ elif re.match("^.*heartbeat-cmd",line):
+ continue
+ else:
+ f.write(line)
+
+ f.write("stop-xscreensaver = 0\n")
+ line='''heartbeat-cmd="%s"\n''' %cmd
+ f.write(line)
+ f.close()
+
+
+def killxscreensaver():
+ logging.info(" Stopping xscreensaver")
+ cmd="xscreensaver-command --exit "
+ mv_common.runcmd(cmd)
+ cmd="killall xscreensaver "
+ mv_common.runcmd(cmd)
+
+def killgscreensaver():
+ logging.info(" Stopping gnome-screensaver")
+ cmd="gnome-screensaver-command --exit "
+ mv_common.runcmd(cmd)
+ cmd="killall gnome-screensaver "
+ mv_common.runcmd(cmd)
+
+
+def setup_x_screensaver(idle,theme,screenconfigfile,templatefile):
+ logging.info(" Configuring X screensaver")
+ killgscreensaver()
+ logging.debug(" Why can't xscreensaver have a nice configuration !")
+
+ if not os.path.exists(screenconfigfile):
+ logging.debug(" copying in new template file")
+ mv_common.cp_and_log(templatefile,screenconfigfile)
+
+ try:
+ f = open(screenconfigfile, 'r')
+ screenconfigcontents=f.readlines()
+ f.close()
+ except:
+ logging.info("Couldn't open %s for reading",screenconfigfile)
+ return
+ try:
+ f = open(screenconfigfile, 'w')
+ except:
+ logging.info("Couldn't open %s for writing",screenconfigfile)
+ return
+
+ startline=0
+ foundline=0
+
+ for k, line in enumerate(screenconfigcontents):
+ if re.match("programs:",line):
+ startline = k
+ if re.search(theme,line):
+ foundline = k
+ themenumber=foundline-startline-2
+
+ for line in screenconfigcontents:
+ if re.match("selected.*$",line):
+ continue
+
+ if re.match("timeout",line):
+ logging.info(" Setting idletime to %s",idle)
+ outline = "timeout: 0:%s:00 \n" %idle
+ f.write(outline)
+ elif re.match("mode",line):
+ if theme == "Random":
+ logging.info(" Setting theme to %s", "Random")
+ outline = "mode: random \n"
+ f.write(outline)
+ outline = "selected: -1 \n"
+ f.write(outline)
+ continue
+
+ elif theme == "Blank":
+ logging.info(" Setting theme to %s", "blank")
+ outline = "mode: blank \n"
+ f.write(outline)
+ outline = "selected: -1 \n"
+ f.write(outline)
+ continue
+
+ else:
+ logging.info(" Setting theme to %s", theme)
+ outline = "mode: one\n"
+ f.write(outline)
+ logging.debug(" Theme number is %s",themenumber)
+ outline = "selected: %s\n" %themenumber
+ f.write(outline)
+ continue
+
+ else:
+ outline = line
+ f.write(outline)
+ f.close()
+ logging.debug("__End of xscreensaver")
+
+def setup_gnome_screensaver(theme,idletime):
+ logging.info(" Configuring gnome screensaver")
+
+ logging.info(" Disabling lock screen")
+ cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /apps/gnome-screensaver/lock_enabled false'''
+ mv_common.runcmd(cmd)
+
+ logging.info(" Setting idletime to %s",idletime)
+ cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type int -s "/apps/gnome-screensaver/idle_delay" %s''' %idletime
+ mv_common.runcmd(cmd)
+
+ logging.info(" Setting mode to single")
+ cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string -s "/apps/gnome-screensaver/mode" single'''
+ mv_common.runcmd(cmd)
+
+ if theme == "Random":
+ logging.info(" setting theme to random")
+ cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string -s "/apps/gnome-screensaver/mode" random'''
+ mv_common.runcmd(cmd)
+
+ elif theme == "Blank":
+ logging.info(" setting theme to blank")
+ cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string -s "/apps/gnome-screensaver/themes" blank'''
+ mv_common.runcmd(cmd)
+
+ else:
+ logging.info(" setting theme to %s",theme)
+ cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --set --type list --list-type=string /apps/gnome-screensaver/themes [screensavers-%s]''' %theme
+ mv_common.runcmd(cmd)
+
+ killxscreensaver()
+ logging.info("__End gnome screensaver")
+
+
+
+
+def setup_screensaver (systemconfig,data_config):
+ logging.info("____Start of screensaver configuration____")
+ screensavertype = systemconfig["Screensavertype"]
+ theme = systemconfig["Screensavertheme"]
+ idletime = systemconfig["Screensaveridle"]
+ configfile = data_config.MYTHHOME+"/.xscreensaver"
+ templatefile = systemconfig["TEMPLATES"]+"/xscreensaver.template"
+ mtemplate = systemconfig["TEMPLATES"]+"/mplayer.conf.template"
+
+ if screensavertype == "xscreensaver":
+ mv_common.pacinstall("xscreensaver")
+ mv_common.pacremove("gnome-screensaver")
+ setup_x_screensaver(idletime, theme, configfile, templatefile)
+ mplayer_saver_check("/usr/bin/xscreensaver-command -deactivate &",mtemplate)
+
+ elif screensavertype == "gscreensaver":
+ mv_common.pacinstall("xscreensaver")
+ mv_common.pacinstall("gnome-screensaver")
+ setup_gnome_screensaver(theme,idletime)
+ mplayer_saver_check("/usr/bin/gnome-screensaver-command -p &",mtemplate)
+
+ elif screensavertype == "none":
+ mv_common.pacremove("xscreensaver")
+ mv_common.pacremove("gnome-screensaver")
+ killgscreensaver()
+ killxscreensaver()
+
+ elif screensavertype == "tinker" :
+ logging.debug(" screensaver tinker mode detected")
+ else:
+ logging.debug(" Unknown screensaver")
+ logging.info("__End of screensaver\n")
+
+
+
diff --git a/abs/core-testing/LinHES-config/mv_smolt.py b/abs/core-testing/LinHES-config/mv_smolt.py
new file mode 100755
index 0000000..5fd3722
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_smolt.py
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+import logging
+import mv_common
+
+def read_release(stype):
+ if stype == "LinHES":
+ rfile = "/etc/LinHES-release"
+ else:
+ rfile = "/etc/MythVantage-release"
+
+ try:
+ f= open(rfile,'r')
+ releasename = f.readlines()[0]
+ f.close()
+ except:
+ logging.debug(" Couldn't open %s",rfile)
+ releasename = "unknown"
+
+ return releasename
+
+
+def setup_smolt_type(SystemType,Remotetype,RunFrontend,mythhome,stype):
+ logging.debug("____Start of setup_smolt_type____")
+ releasename = read_release(stype)
+
+ if SystemType == "Standalone":
+ smoltsystem = 6
+ MVRELEASE="%s (Standalone)" %releasename
+ elif SystemType == "Master_backend":
+ if RunFrontend == "1":
+ smoltsystem = 2
+ MVRELEASE="%s (MBE with Frontend)" %releasename
+ else:
+ smoltsystem=1
+ MVRELEASE="%s (MBE)" %releasename
+ elif SystemType == "Slave_backend":
+ if RunFrontend == "1" :
+ smoltsystem = 4
+ MVRELEASE="%s (SLAVE with Frontend)" %releasename
+ else:
+ smoltsystem = 5
+ MVRELEASE="%s (SLAVE)" %releasename
+ elif SystemType == "Frontend_only":
+ smoltsystem = 3
+ MVRELEASE="%s ( Frontend only)" %releasename
+
+ logging.debug(" smolt type is %s : %s", MVRELEASE,smoltsystem)
+ smoltfile = mythhome+"/.mythtv/smolt.info"
+ cmd = ''' echo "%s" > /etc/os_myth_release ''' %MVRELEASE
+ mv_common.runcmd(cmd)
+
+ cmd = '''echo "systemtype=%s" > %s''' %(smoltsystem,smoltfile)
+ mv_common.runcmd(cmd)
+
+ cmd = '''echo "remote=%s" >> %s ''' %(Remotetype,smoltfile)
+ mv_common.runcmd(cmd)
+
+ logging.debug("__End of setup_smolt_type")
+
diff --git a/abs/core-testing/LinHES-config/mv_software.py b/abs/core-testing/LinHES-config/mv_software.py
new file mode 100755
index 0000000..047a235
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_software.py
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+import logging, mv_common
+import os, re
+
+def setup_software(systemconfig, data_config):
+ logging.info("____Start of Software install____")
+ default_disabled = ("mythphone", "mytharchive", "mythbrowser", "mythnews",
+ "mythgame", "mythflix", "mythweather",
+ "mythappletrailers", "mythstream", "mythvodka")
+
+ default_installed=("mythcontrols", "mythgallery", "mythmovies",
+ "mythmusic", "mythsmolt", "mythvideo")
+ other_pkg=("miro", "xe", "romdb", "xine", "dvdcss", "webmin")
+
+ for pkg in default_disabled:
+ try:
+ if systemconfig[pkg] == "1":
+ mv_common.pacinstall(pkg)
+ else:
+ mv_common.pacremove(pkg)
+ except:
+ logging.debug(" ERROR-- %s is not defined", pkg)
+
+ for pkg in default_installed:
+ try:
+ if systemconfig[pkg] == "0":
+ mv_common.pacremove(pkg)
+ else:
+ mv_common.pacinstall(pkg)
+ except:
+ logging.debug(" ERROR-- %s is not defined", pkg)
+
+ for pkg in other_pkg:
+ try:
+ if systemconfig[pkg] == "1":
+ mv_common.pacinstall(pkg)
+ elif systemconfig[pkg] == "0":
+ mv_common.pacremove(pkg)
+ except:
+ logging.debug(" ERROR-- %s is not defined", pkg)
+ logging.info("__End Software\n ") \ No newline at end of file
diff --git a/abs/core-testing/LinHES-config/mv_webuser.py b/abs/core-testing/LinHES-config/mv_webuser.py
new file mode 100755
index 0000000..a8517a8
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_webuser.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+import logging, mv_common
+#import os
+
+def setup_web_auth(UseMythWEB_auth):
+ logging.info("____Start of setup_web_auth____")
+ if UseMythWEB_auth == str(1):
+ #enable auth
+ logging.info(" Enabling authorization for mythweb")
+ cmd='''sed -i "s/^.*include.*auth-inc.conf.*$/include \\"\/etc\/lighttpd\/auth-inc.conf\\"/g" /etc/lighttpd/lighttpd.conf'''
+ mv_common.runcmd(cmd)
+ else:
+ #disable auth
+ logging.info(" Disabling authorization for mythweb")
+ cmd='''sed -i "s/^.*include.*auth-inc.conf.*$/#include \\"\/etc\/lighttpd\/auth-inc.conf\\"/g" /etc/lighttpd/lighttpd.conf'''
+ mv_common.runcmd(cmd)
+ logging.debug("Restarting lighttpd")
+ cmd="sudo sv restart lighttpd"
+ mv_common.runcmd(cmd)
+ logging.info("__End of webauth\n")
+
diff --git a/abs/core-testing/LinHES-config/systemconfig.py b/abs/core-testing/LinHES-config/systemconfig.py
new file mode 100755
index 0000000..7e5e3b1
--- /dev/null
+++ b/abs/core-testing/LinHES-config/systemconfig.py
@@ -0,0 +1,223 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+import sys, os, commands, glob, time
+import getopt, re, MySQLdb
+import logging
+import mv_common , mv_network
+import inspect
+#____________________________________________setup the logging______________________________________________________
+LOG_FILENAME = '/tmp/systemconfig.log'
+DEBUGLOG = '/tmp/systemconfig_debug.log'
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
+ datefmt='%m-%d %H:%M',
+ filename=DEBUGLOG,
+ filemode='w')
+# define a Handler which writes INFO messages or higher to the sys.stderr
+console = logging.StreamHandler()
+console.setLevel(logging.INFO)
+# set a format which is simpler for console use
+#formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
+formatter = logging.Formatter("%(message)s")
+# tell the handler to use this format
+console.setFormatter(formatter)
+# add the handler to the root logger
+logging.getLogger('').addHandler(console)
+
+#infoformatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
+infoformatter = logging.Formatter("%(message)s")
+infofile = logging.FileHandler(LOG_FILENAME, 'w')
+infofile.setFormatter(infoformatter)
+infofile.setLevel(logging.INFO)
+logging.getLogger('').addHandler(infofile)
+
+
+def usage():
+ logging.info("tell people how to use this")
+
+def setup_x(systemconfig):
+ cmd = "%s/bin/xconfig.sh" %systemconfig["MVROOT"]
+ mv_common.runcmd(cmd)
+
+def main(argv):
+ try:
+ MVROOT = os.environ["MV_ROOT"]
+ except:
+ logging.debug("MVROOT was not defined, using the default value")
+ MVROOT = "/usr/MythVantage"
+
+ global cmdmodule
+ global systemconfig
+ systemconfig["MVROOT"]=MVROOT
+ restartlcd = False
+ cmdmodule={"misc":False , "sleep":False , "hostype":False , "hostypec":False , "advanced":False , "audio":False , "network":False , "advancedX":False , "webuser":False , "restartfe":False , "reloadfe":False , "ddns":False , "screensaver":False , "ir":False , "this_is_install":False , "user":False, "software":False, "smolt":False, "all":False}
+ try:
+ opts, args = getopt.getopt(argv, 'c:hm:', ["help","modules" ] )
+ except getopt.GetoptError, why:
+ print why
+ usage()
+ print "exception happened"
+ sys.exit(2)
+ for opt, arg in opts:
+ if opt in ("-h", "--help"):
+ usage()
+ sys.exit(0)
+ elif opt in ("-m"):
+ for i in arg.split(","):
+ cmdmodule[i]=True
+
+ if cmdmodule["this_is_install"] or cmdmodule["hostypec"]:
+ systemconfig["hostypec"] = True
+ cmdmodule["smolt"] = True
+
+ systemconfig["mythip"] = mv_network.setup_MYTH_IP(systemconfig)
+ systemconfig["mythdhcp"] = mv_network.setup_MYTH_DHCP(systemconfig)
+
+ if cmdmodule["all"]:
+ logging.info("*** WILL RUN ALL MODULES ***")
+ cmdmodule["hostype"] = True
+ cmdmodule["ir"]= True
+ cmdmodule["network"] = True
+ cmdmodule["audio"] = True
+ cmdmodule["misc"] = True
+ cmdmodule["sleep"] = True
+ cmdmodule["webuser"] = True
+ cmdmodule["ddns"] = True
+ cmdmodule["screensaver"] = True
+ cmdmodule["advanced"] = True
+ cmdmodule["software"] = True
+ cmdmodule["advancedX"] = True
+ cmdmodule["smolt"] = True
+ cmdmodule["user"] = True
+
+
+ if cmdmodule["hostype"]:
+ import mv_hostype
+ cmdmodule["advancedX"] = False
+ setup_x(systemconfig)
+ cmdmodule["ir"] = True
+ mv_hostype.hostypeprint(systemconfig)
+ cmdmodule["smolt"] = True
+
+ if cmdmodule["network"]:
+ mv_network.setup_network(systemconfig)
+
+
+
+ if cmdmodule["ir"] == True:
+ import mv_ir
+ restart = mv_ir.setup_ir(systemconfig,data_config)
+ restartfe = restart[0]
+ restartlcd = restart[1]
+ if restartfe == True:
+ logging.debug(" Setting the frontend to restart due to lirc change")
+ cmdmodule["restartfe"] = True
+ cmdmodule["smolt"] = True
+
+
+ if cmdmodule["audio"] == True:
+ logging.debug("______Start of Audio Configuration______")
+ if not systemconfig["Audiotype"] == "tinker":
+ cmd="%s/bin/soundconfig.sh -t real -i %s -d %s" %(MVROOT,systemconfig["Audiotype"],systemconfig["SoundDevice"])
+ mv_common.runcmd(cmd)
+ else:
+ logging.debug(" Tinker mode(audio), not changing configuration")
+ logging.debug("__End of audio")
+
+ if cmdmodule["misc"]:
+ import mv_misc
+ mv_misc.setup_zip(MVROOT,systemconfig["zipcode"])
+ mv_misc.setup_tz(systemconfig["timezone"],systemconfig["TEMPLATES"])
+ mv_misc.setup_nfs(systemconfig)
+
+ if cmdmodule["sleep"]:
+ mv_misc.setup_sleep(systemconfig)
+
+ if cmdmodule["webuser"]:
+ import mv_webuser
+ mv_webuser.setup_web_auth(systemconfig["UseMythWEB_auth"])
+
+ if cmdmodule["ddns"]:
+ print " LOOK FOR DDNS"
+
+ if cmdmodule["screensaver"]:
+ import mv_screensaver
+ mv_screensaver.setup_screensaver(systemconfig, data_config)
+
+ if cmdmodule["advanced"]:
+ import mv_advanced
+ mv_advanced.setup_advanced(systemconfig, data_config)
+
+ if cmdmodule["software"]:
+ import mv_software
+ mv_software.setup_software(systemconfig, data_config)
+
+ if cmdmodule["advancedX"]:
+ setup_x(systemconfig)
+
+ if cmdmodule["restartfe"]:
+ mv_common.restartfe(restartlcd)
+
+ if cmdmodule["reloadfe"]:
+ mv_common.reloadfe(systemconfig["dbhost"],restartlcd)
+
+ if cmdmodule["smolt"]:
+ import mv_smolt
+ mv_smolt.setup_smolt_type(systemconfig["SystemType"],
+ systemconfig["Remotetype"],
+ systemconfig["RunFrontend"],
+ data_config.MYTHHOME,
+ data_config.SYSTEMTYPE)
+
+ if cmdmodule["user"]:
+ logging.info("____Start of ssh user____")
+ if systemconfig["rootSSH"] == "1" :
+ logging.info(" Allowing ssh access for root")
+ cmd = '''sed -i "s/^.*PermitRootLogin.*$/PermitRootLogin yes/" /etc/ssh/sshd_config'''
+ mv_common.runcmd(cmd)
+ else:
+ logging.info(" Removing ssh access for root")
+ cmd = '''sed -i "s/^.*PermitRootLogin.*$/PermitRootLogin no/" /etc/ssh/sshd_config'''
+ mv_common.runcmd(cmd)
+ logging.info("__End of ssh user\n")
+
+if __name__ == "__main__":
+
+ config_file = "mv_config"
+ data_config = __import__(config_file, globals(), locals(), [])
+ #Read in systemconfig
+ global systemconfig
+ systemconfig = {"hostypec":False}
+ file_name = "/etc/systemconfig"
+ try:
+ config_file = open(file_name)
+ except:
+ logging.critical("%s could not be opened", file_name)
+ sys.exit(1)
+
+ for line in config_file:
+ line = line.strip()
+ if line and line[0] is not "#" and line[-1] is not "=":
+ var, val = line.rsplit("=", 1)
+ val = val.strip('"')
+ systemconfig[var.strip()] = val.strip()
+ systemconfig["TEMPLATES"] = os.environ["TEMPLATES"]
+ logging.debug("______START OF DEBUG______")
+ main(sys.argv[1:])
+ #logging.debug("______cmd line options______")
+ #for i in cmdmodule.items():
+ #logging.debug (i)
+ #logging.debug("______systemconfig______")
+ #for i in systemconfig.items():
+ #logging.debug(i)
+ #pass
+
+
+
+
+
+
+
+
+
+
diff --git a/abs/core-testing/LinHES-config/systemconfig.sh b/abs/core-testing/LinHES-config/systemconfig.sh
index 54d3b01..4f58ee2 100755
--- a/abs/core-testing/LinHES-config/systemconfig.sh
+++ b/abs/core-testing/LinHES-config/systemconfig.sh
@@ -4,1453 +4,11 @@
#Any changes made to config files will be removed when systemconfig.sh is run
#
#JM
-###################################################################
-#set -x
-. /etc/profile
-#MVRELEASE=`cat /etc/mythvantage-release |cut -d" " -f -2`
-MVRELEASE=`cat /etc/LinHES-release `
echo $@ >/tmp/systemconfig.call
echo "----------------------start of systemconfig $@ ----------------------"
-BASE=""
-
-#TEMPLATES="/usr/share/templates"
. /etc/profile
-MYTHHOME=$BASE/home/mythtv
. $MV_ROOT/bin/networkconfig.sh
-PACMAN="pacman --noconfirm"
postfix=`cat ${BASE}/usr/local/share/mythtv/.releasetype`
-PKGBLACKLIST=$BASE/etc/blacklist.package
-
-if [ x$1 = x"Mysql_only" ]
- then
- rm -f /tmp/mysql.txt
- sed -e "s/^DBHostName=.*$/DBHostName=$2/" $TEMPLATES/mysql.txt > /tmp/mysql.txt
- exit 0
- fi
-
-
-if [ -f /etc/systemconfig ]
-then
- . /etc/systemconfig
- setup_MYTH_vars
-TEMPNET="Hostip"$default_interface
-echo $TEMPNET
-eval MYTHIP=\$${TEMPNET}
-else
- echo "could not find /etc/systemconfig"
- exit 1
-fi
-
-
-function cp_and_log () {
- if [ -e $1 ]
- then
- echo "copying $1 to $2"
- cp -rfp "$1" "$2"
- else
- echo "$1 is not present, skipping..."
- fi
-
-}
-
-
-#-----------------------------------------------------
-
-
-function setupmysql {
-#setup mysql.txt to find the database servers
-echo "running setup mysql"
- if [ $SystemType = "Master_backend" ]
- then
- if [ $MYTHDHCP = 0 ]
- then
- #this grabs eth0, as that is all thats supported.
-# dbhost=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1`
- dbhost=`ifconfig | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'`
- sed -e "s/^dbhost=.*$/dbhost=\"$dbhost\"/" /etc/systemconfig >/tmp/systemconfig.old
- cp_and_log /tmp/systemconfig.old ${BASE}/etc/systemconfig
- ##logic to change master_serverip and backend_serverip in db
-
- ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost
- else
-
- dbhost=$MYTHIP
- sed -e "s/^dbhost=.*$/dbhost=\"$dbhost\"/" /etc/systemconfig >/tmp/systemconfig.old
- cp_and_log /tmp/systemconfig.old ${BASE}/etc/systemconfig
- #logic to change dbhost in db
- ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost
- fi
- fi
-
- if [ $SystemType = "Slave_backend" ]
- then
- if [ $MYTHDHCP = 0 ]
- then
- #this grabs eth0, as that is all thats supported.
- #slavehost=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1`
- slavehost=`ifconfig | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'`
- ##logic to change backend_serverip in db
- ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s slave -a $slavehost
- else
- slavehost=$MYTHIP
-
- #logic to change backend_serverif in db
- ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s slave -a $slavehost
- fi
- fi
-
- MYSQLTXT=${BASE}/usr/share/mythtv/mysql.txt
- if [ $SystemType = "Standalone" ]
- then
- sed -e "s/^DBHostName=.*$/DBHostName="localhost"/" $TEMPLATES/mysql.txt > $MYSQLTXT
- else
- sed -e "s/^DBHostName=.*$/DBHostName=$dbhost/" $TEMPLATES/mysql.txt > $MYSQLTXT
- fi
- rm ${BASE}/home/mythtv/.mythtv/mysql.txt
- rm ${BASE}${MV_ROOT}/bin/mythtv/.mythtv/mysql.txt
- if [ -f ${BASE}/home/mythtv/templates/mysql.txt ]
- then
- cp_and_log ${BASE}/home/mythtv/templates/mysql.txt $MYSQLTXT
- fi
-
- chmod 755 $MYSQLTXT
- chown mythtv $MYSQLTXT
-
-}
-
-function setupmysqlnetwork(){
-MFILE=etc/my.cnf
-grep "#skip-networking" $BASE/$MFILE
-status=$?
-
-
-
- if [ $SystemType = "Standalone" ]
- 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"
- fi
-
- fi
-
- if [ $SystemType = "Master_backend" ]
- then
- sed -ie "s/^skip-networking/#skip-networking/g" $BASE/$MFILE
- if [ $status = 1 ]
- then
- sudo sv restart mysql
- echo "restarting mysql with network"
- fi
-
- fi
-
-
-}
-
-
-function settimezone {
-#set the timezone
-if [ x"$timezone" = x ]
-then
- timezone="unknown"
-fi
-rm ${BASE}/etc/localtime
-echo $timezone
-ln -s "/usr/share/zoneinfo/$timezone" ${BASE}/etc/localtime
- sed -e "s~^TIMEZONE=.*$~TIMEZONE=\"${timezone}\"~" ${BASE}/etc/rc.conf > $TEMPLATES/rc.conf
-
-
-if [ -f ${BASE}/etc/php/php.ini ]
-then
- echo "changing timezone in php.ini"
- sed -i "s/^.*date.timezone.*$/date.timezone=${timezone}/" ${BASE}/etc/php/php.ini
-fi
-
-
-
-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
-# else
-# exit 1
-fi
-
-}
-
-
-# function setupreceiver {
-# case $ReceiverType in
-# tinker) echo "do nothing"
-# ;;
-# Serial) echo "setup serial lirc"
-# sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-# echo "lirc_serial #lirc" >> ${BASE}/etc/modules.mythvantage
-# 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
-# ;;
-# esac
-#
-#
-# }
-
-
-function setupevrouter {
- if [ x$UseEvrouter = x1 ]
- then
- case x$EvrouterConfig in
- xtinker )
- echo "do nothing for evrouter"
- ;;
- x ) echo "empty evrouter"
- ;;
- * ) echo "setup evrouter for $EvrouterConfig "
- cp_and_log $TEMPLATES/evrouter/$EvrouterConfig /etc/evrouter.cfg
- daemon_add="evrouter Xvfb $daemon_add"
-
- ;;
- esac
- else
- # disable evrouter
- daemon_remove="evrouter Xvfb $daemon_remove"
- fi
-
-
-
-
-}
-
-
-
-function scrubnfs {
- cp_and_log /etc/fstab $TEMPLATES/fstab.conf.template
-
- sed '/^#STARTSCRUB.*$/,/^#ENDSCRUB.*$/d' $TEMPLATES/fstab.conf.template > ${BASE}/etc/fstab
-}
-
-function setupfstab () {
-# setupfstab $NFSserver $NFSshare $NFSmount
- echo "#STARTSCRUB --------------anything in this block will be scrubbed" >> ${BASE}/etc/fstab
- 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
- echo "#ENDSCRUB" >> ${BASE}/etc/fstab
-}
-
-function setupncidclient
-{
- sed -e "s/^set Host.*$/set Host $dbhost /" $TEMPLATES/ncid.conf.template >${BASE}/etc/ncid/ncid.conf
-}
-
-function setupnciddaemon {
- if [ x$Runncidd = x1 ]
- then
- cp_and_log /etc/ncid/ncidd.conf $TEMPLATES/ncidd.conf.template
- sed -e "s/.*set ttyport.*$/set ttyport = \/dev\/$nciddSerialPort /" $TEMPLATES/ncidd.conf.template >${BASE}/etc/ncid/ncidd.conf
- fi
-
-}
-
-function setupntp () {
- #this is used for backend or standlone types
- if [ $1 = "1" ]
- then
- #MBE/STD use deafult
- echo "Not changing ntp config"
- else
- #echo "server $dbhost" >> ${BASE}/etc/ntp.conf
- echo "setting ntp to $dbhost"
- sed -i "s/pool.ntp.org/$dbhost/g" ${BASE}/etc/ntp.conf
- fi
-
-
-}
-
-function setupplugins (){
-
-pkglistinstall=""
-pkglistremove=""
-#default enabled
-for i in mythcontrols mythgallery mythmovies mythmusic mythsmolt mythvideo
-do
- eval pkgvalue=\$${i}
- if [ x$pkgvalue = x ]
- then
- pkglistinstall="$pkglistinstall $i$postfix"
- else
- if [ x$pkgvalue = x1 ]
- then
- pkglistinstall="$pkglistinstall $i$postfix"
- else
- pkglistremove="$pkglistremove $i$postfix"
- fi
- fi
-done
-
-#default disabled
-for i in mythphone mytharchive mythbrowser mythnews mythgame mythflix mythweather mythappletrailers mythstream mythvodka
-do
- eval pkgvalue=\$${i}
- if [ x$pkgvalue = x ]
- then
- pkglistremove="$pkglistremove $i$postfix"
- else
- if [ x$pkgvalue = x1 ]
- then
- pkglistinstall="$pkglistinstall $i$postfix"
- else
- pkglistremove="$pkglistremove $i$postfix"
- fi
- fi
-done
-#everything else
-for i in miro xe romdb xine dvdcss webmin
-do
- eval pkgvalue=\$${i}
- case $i in
- xine)
- if [ x$pkgvalue = x1 ]
- then
- pkglistinstall="$pkglistinstall xine-ui"
- else
- pkglistremove="$pkglistremove xine-ui"
- fi
- ;;
- dvdcss)
- if [ x$pkgvalue = x1 ]
- then
- pkglistinstall="$pkglistinstall libdvdcss"
- else
- pkglistremove="$pkglistremove libdvdcss"
- fi
- ;;
- webmin)
- ##Daemon_add is here because webmin is on the software page instead of the advanced screen
- if [ x$pkgvalue = x1 ]
- then
- pkglistinstall="$pkglistinstall webmin"
- daemon_add="webmin $daemon_add"
- else
- pkglistremove="$pkglistremove webmin"
- daemon_remove="webmin $daemon_remove"
- fi
- ;;
- *)
- if [ x$pkgvalue = x1 ]
- then
- pkglistinstall="$pkglistinstall $i"
- else
- pkglistremove="$pkglistremove $i"
- fi
- ;;
-esac
-
-done
-
-
-install="$pkglistinstall $install"
-remove="$pkglistremove $remove"
-
-}
-
-function LCDcheck () {
-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"
- ;;
-esac
-}
-
-
-function packages () {
-#see which plugins need to be installed
-echo " Starting to install Packages"
-setupplugins
-LCDcheck
-if [ ! -f $PKGBLACKLIST ]
-then
- touch $PKGBLACKLIST
-fi
- for i in $remove
- do
- if [ ! x$i = xnone ]
- then
- echo "-----------$i --------------"
- grep -q $i $PKGBLACKLIST
- if [ $? = 1 ]
- then
- pacman -Q $i 2>/dev/null
- #VAR=`pacman -Q $i 2>&1 `
- if [ $? = 0 ]
- then
- if [ $i = "mythweb$postfix" ]
- then
- pacman --noconfirm -R mythweb$postfix
- echo removed $i
- else
- pacman --noconfirm -Rs $i
- echo removed $i
- fi
- fi
- else
- echo "$i is black listed"
- fi
- fi
- done
-
-
- for i in $install
- do
- if [ ! x$i = xnone ]
- then
- echo "-----------$i --------------"
- grep -q $i $PKGBLACKLIST
- if [ $? = 1 ]
- then
- pacman -Q $i 2>/dev/null
- #VAR=`pacman -Q $i 2>&1 `
- # echo $VAR |grep -vq error:
-
- if [ ! $? = 0 ]
- then
- pacman --noconfirm -Sf $i
- echo installed $i
- else
- echo "$i already installed"
- fi
- else
- echo "$i is black listed"
- fi
- fi
- done
-}
-
-function daemons {
-echo "Daemons on boot"
-
- 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
-
-
- for i in $daemon_add
- do
- sv check $i 1>/dev/null
- status=$?
- add_service.sh $i
-
- if [ $status -eq 0 ]
- then
- case $i in
- mysql*) sv hup $i
- ;;
- mythback*) sv hup $i
- ;;
- lirc* ) sv hup $i
- ;;
- frontend) sv check frontend 1>/dev/null
- ;;
-
- smbd ) sv hup $i
- ;;
- nmbd ) sv hup $i
- ;;
- evrouter) sv restart $i
- ;;
- *) sv down $i
- sleep 1
- sv up $i
- ;;
- esac
- fi
-
- done
-
-}
-
-
-function services
-{
-ser_install=""
-ser_daemon_add=""
-ser_remove=""
-ser_daemon_remove=""
-if [ x$UseEvrouter = x1 ]
-then
- ser_daemon_add="evrouter Xvfb $ser_daemon_add"
-else
- ser_daemon_remove="evrouter Xvfb $ser_remove"
-fi
-
-if [ x$RunDHCP = x1 ]
-then
- 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"
-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
-
-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
-
-#samba
-if [ x$UseSamba = x1 ]
-then
- ser_install="samba $ser_install"
- ser_daemon_add="nmbd smbd $ser_daemon_add "
- if [ x$Samba_mediareadonly = x1 ]
- then
- smreadonly="no"
- else
- smreadonly="yes"
- fi
-
- if [ x$Samba_homereadonly = x1 ]
- then
- shreadonly="no"
- else
- shreadonly="yes"
- fi
-
- if [ ! -d ${BASE}/etc/samba ]
- then
- mkdir ${BASE}/etc/samba
- fi
-
- if [ -f ${MYTHHOME}/templates/smb.conf ]
- then
- install -D -m755 ${MYTHHOME}/templates/smb.conf ${BASE}/etc/samba/smb.conf
- else
- sed -e "s/^.*workgroup =.*$/ workgroup = $Samba_domain/g " \
- -e "s/^.*server string = .*$/ server string = $hostname/g" $TEMPLATES/samba/smb.conf.template > ${BASE}/etc/samba/smb.conf
-
- if [ x$Samba_media = "x1" ]
- then
- echo "include = /etc/samba/smb.conf.media" >> ${BASE}/etc/samba/smb.conf
- sed -e "s/^.*writeable.*$/writeable = $smreadonly/g" $TEMPLATES/samba/smb.conf.media > ${BASE}/etc/samba/smb.conf.media
- fi
-
- if [ x$Samba_home = "x1" ]
- then
- echo "include = /etc/samba/smb.conf.home" >> ${BASE}/etc/samba/smb.conf
- sed -e "s/^.*writeable.*$/writeable = $shreadonly/g" $TEMPLATES/samba/smb.conf.home > ${BASE}/etc/samba/smb.conf.home
-
- fi
-
- fi
-else
- ser_remove="samba $ser_remove"
- ser_install="smbclient $ser_install"
- ser_daemon_remove="smbd nmbd $ser_daemon_remove"
-fi
-
-
-if [ x$UseNFS = x1 ]
-then
- ser_install="nfs-utils portmap $ser_install"
- ser_daemon_add="nfsd nfs-utils 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"
-fi
-
-if [ x$Runncidd = x1 ]
-then
- 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"
-fi
-
-
-if [ x$UseEvrouter = x1 ]
-then
- 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"
-else
- ser_daemon_remove="inadyn $ser_daemon_remove"
- ser_remove="inadyn $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
-
-
-
-#Setting the default, just to avoid the or statement..
-#if [ x$UseHobbit = x ]
-#then
-# UseHobbit=0
-#fi
-
-#if [ x$UseHobbit = x1 ]
-#then
-# case $SystemType in
-# Standalone|Master_backend )
-# ser_daemon_add="hobbit $ser_daemon_add"
-# ser_install="hobbitserver $ser_install"
-# ;;
-#
-# *) ser_daemon_add="hobbit-client $ser_daemon_add"
-# ser_install="hobbit-client $ser_install"
-# ;;
-# esac
-#else
-# ser_daemon_remove="hobbit hobbit-client $ser_daemon_remove"
-# ser_remove="hobbit-client hobbitserver $ser_remove"
-# rm -f /data/srv/httpd/htdocs/hobbit/index.html
-#
-# fi
-
-
-
-}
-
-
-
-function setupsleep {
-if [ x$AutoShutdown = x1 ]
-then
- cronshutdowntime=""
- if [ x$Shutdowntime != x-1 ]
- then
- cronshutdowntime=$Shutdowntime
- fi
- if [ x$Shutdowntime2 != x-1 ]
- then
- if [ x$cronshutdowntime = x ]
- then
- cronshutdowntime=$Shutdowntime2
- else
- cronshutdowntime="${cronshutdowntime},${Shutdowntime2}"
- fi
- fi
-
- sed -e "s/HOUR/$cronshutdowntime/g" $TEMPLATES/cron.template | crontab - -u mythtv
-else
- sed -e "/00 HOUR.*/d" $TEMPLATES/cron.template | crontab - -u mythtv
-fi
-
-}
-
-
-function setuppacman () {
-#setup link to httpd dir
-echo "Configuring pacman"
-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"
- fi
-
- for i in mv-core mv-core-testing mv-extra mv-extra-testing
- do
- echo "[$i]" > ${BASE}/etc/pacman.d/$i
- #add mirror if needed
- if [ x$PKG_MIRROR = x1 ]
- then
- echo " Server = http://$dbhost/repo/$i " >> ${BASE}/etc/pacman.d/$i
- fi
- #add user templates
- USERTEMPLATES="/data/home/mythtv/templates"
- if [ -f $USERTEMPLATES/sources/$i ]
- then
- 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
-
-
-}
-
-
-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/
- fi
-}
-
-function process_nfsmap () {
-#first look for a local copy of nfsmap
-if [ $1 = noip ]
-then
- if [ -f /data/home/mythtv/templates/nfsmap ]
- then
- NFSMAP="/data/home/mythtv/templates/nfsmap"
- else
- mv -f /tmp/nfsmap /tmp/nfsmap.old
- wget -O /tmp/nfsmap http://$dbhost:1337/templates/nfsmap
- if [ $? = 0 ]
- then
- NFSMAP="/tmp/nfsmap"
- fi
- fi
-else
- mv -f /tmp/nfsmap /tmp/nfsmap.old
- wget -O /tmp/nfsmap http://$1:1337/templates/nfsmap
- if [ $? = 0 ]
- then
- NFSMAP="/tmp/nfsmap"
- fi
-fi
-
- if [ -f $NFSMAP ]
- then
- #read in file
- while read line
- do
- NFSserver=`echo "$line"|cut -d" " -f1`
- NFSmount=`echo "$line"|cut -d" " -f2`
- setupfstab $NFSserver $NFSmount
- done <$NFSMAP
- else
- echo "couldn't find nfsmap"
-
- fi
-}
-
-function setupcnfs () {
- scrubnfs
- if [ $HaveCentralNFS = "yes" ]
- then
- case x$NFSserver in
- xfile:nfsmap )
- process_nfsmap noip
- ;;
- *:nfsmap )
- nfsmapip=`echo "$NFSserver" | cut -d: -f1 `
- process_nfsmap $nfsmapip
- ;;
- *) setupfstab $NFSserver $NFSmount
- esac
-
- #if [ ! x"$NFSserver" = "xfile:nfsmap" ]
- #then
- # setupfstab $NFSserver $NFSmount
- #else
- # process_nfsmap
- #fi
- else
- echo "fe_nfs"
- #if no central nfs found, then use the mbe.
- if [ $SystemType = "Frontend_only" ]
- then
- setupfstab ${dbhost}:/myth /myth
- fi
- fi
-
-}
-
-function setupbootsplash () {
-
-if [ x$Usebootsplash = x1 ]
-then
- COMMAND="%s/^default.*0/default 1/g"
-else
- COMMAND="%s/^default.*1/default 0/g"
-fi
-
-ex ${BASE}/boot/grub/menu.lst <<EOF
-:$COMMAND
-:wq
-EOF
-
-}
-
-function setuphobbitclient () {
-COMMAND="%s/^BBDISP=.*$/BBDISP=$dbhost/g"
-
-
-ex ${BASE}/data/srv/hobbit/client/etc/hobbitclient.cfg <<EOF
-:$COMMAND
-:wq
-EOF
-
-}
-
-function setupSyslog () {
-COMMAND="%s/^destination d_remote.*$/destination d_remote \{tcp\(\"${dbhost}\" port\(514\)\) \;\} \;/"
-ex ${BASE}/etc/syslog-ng.conf <<EOF
-:$COMMAND
-:wq
-EOF
-
-
-
-
-}
-
-function setupfuncminion () {
-COMMAND="%s/^certmaster.*$/certmaster = ${dbhost}/"
-ex ${BASE}/etc/func/minion.conf <<EOF
-:$COMMAND
-:wq
-EOF
-}
-
-function setupDNSMASQ(){
-if [ x$RunDHCP = x1 ]
-then
- echo "DNSMASQ setup"
-
-#set default route to my GW
-COMMAND="%s/^dhcp-option=3.*$/dhcp-option=3,${route}/"
-ex ${BASE}/etc/dnsmasq.conf <<EOF
-:$COMMAND
-:wq
-EOF
-
-#setup dns to my ip
-COMMAND="%s/^dhcp-option=6.*$/dhcp-option=6,${ip}/"
-ex ${BASE}/etc/dnsmasq.conf <<EOF
-:$COMMAND
-:wq
-EOF
-
-
-#change nfsroot to my ip
-COMMAND="%s/nfsroot=.*:/nfsroot=${ip}:/"
-ex ${BASE}/data/srv/tftp/pxelinux.cfg/default <<EOF
-:$COMMAND
-:wq
-EOF
-
-#add 127.0.0.1 to /etc/resolv.conf
- echo "search lan" > ${BASE}/etc/resolv.conf
- echo "nameserver 127.0.0.1" >> ${BASE}/etc/resolv.conf
- echo "nameserver $nameserver" >> ${BASE}/etc/resolv.conf
-fi
-
-#setup dongle.config
-COMMAND="%s/mvpmc -f .*/mvpmc -f \/etc\/helvR10.fon -s ${ip} \& /"
-ex ${BASE}/data/srv/tftp/dongle.bin.config <<EOF
-:$COMMAND
-:wq
-EOF
-
-
-
-#setup dongle.config
-
-}
-
-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
- killall -9 mythlcdserver
-fi
-if [ x = x$PID ]
-then
- echo "Mythfrontend not running, will not reload"
-else
- kill -s USR1 $PID
-fi
-exit 0
-
-}
-
-
-function setup_db (){
-
- install="mysql avahi"
- daemon_add="mysql"
- packages
- daemons
-status=1
-mysqlstatus=1
-while [ ! $status = 0 ]
-do
- sv stop mysql
- sleep 1
- sv start mysql
- mysqlstatus=$?
- if [ $mysqlstatus = 0 ]
- then
- mysql -e "show databases;"
- showstatus=$?
- if [ $showstatus = 0 ]
- then
- pacman --noconfirm -R mythdb-initial
- pacman --noconfirm -S mythdb-initial
- $MV_ROOT/bin/restore_default_settings.sh -c load
- if [ $SystemType = "Master_backend" ]
- then
- $MV_ROOT/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost
- fi
- #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
- pacman --noconfirm --nodeps -S webcalendar
- status=0
- fi
- fi
- fi
-done
-}
-
-function setup_web_auth {
- if [ x$UseMythWEB_auth = x1 ]
- then
- #enable auth
- sed -ie "s/^.*include.*auth-inc.conf.*$/include \"\/etc\/lighttpd\/auth-inc.conf\"/g" /etc/lighttpd/lighttpd.conf
- else
- #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 mplayer_saver_check () {
- if [ ! -f $BASE/etc/mplayer/mplayer.conf ]
- then
- mkdir -p $BASE/etc/mplayer
- touch $BASE/etc/mplayer/mplayer.conf
- #cp -f $TEMPLATES/mplayer.conf.template $BASE/etc/mplayer/mplayer.conf
- fi
- grep -q stop-xscreensaver $BASE/etc/mplayer/mplayer.conf
- if [ $? = 0 ]
- then
- sed -i "s/^.*stop-xscreensaver.*$/stop-xscreensaver = 1 / g" $BASE/etc/mplayer/mplayer.conf
- else
- echo stop-xscreensaver = 1 >> $BASE/etc/mplayer/mplayer.conf
- fi
- grep -q heartbeat-cmd $BASE/etc/mplayer/mplayer.conf
- if [ $? = 0 ]
- then
- sed -i '/^.*heartbeat-cmd.*$/d' $BASE/etc/mplayer/mplayer.conf
- #sed -i "s/^.*heartbeat-cmd.*$/heartbeat-cmd=\"$1\"/ g" $BASE/etc/mplayer/mplayer.conf
- fi
- echo "heartbeat-cmd = \"$1\"" >> $BASE/etc/mplayer/mplayer.conf
-}
-
-
-
-function killxscreensaver {
- xscreensaver-command --exit &
- killall xscreensaver &
-}
-
-function killgscreensaver(){
- gnome-screensaver-command --exit &
- killall gnome-screensaver &
-}
-
-
-function setupscreensaver {
-#copy in template
-
-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 -i "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-1))
- sed -i "s/^selected.*$/selected: $sspos/g" $MYTHHOME/.xscreensaver
-
- ;;
- esac
- mplayer_saver_check "/usr/bin/xscreensaver-command -deactivate &"
- ;;
- 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
- mplayer_saver_check "/usr/bin/gnome-screensaver-command -p &"
- 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
-
-
-
-}
-#----------------------------------------------------MAIN PROGRAM-------------------------------------------
-#misc,sleep,hostype,advanced,audio
-eval LAST=\$$#
-LIST=`echo $LAST | tr , " " `
-
-hosttypechange="false"
-
-
-for i in $LIST
-do
-echo $i
-case $i in
- misc) showmisc="true"
- ;;
- sleep) showsleep="true"
- ;;
- hostype) showhost="true"
- showX="true"
- ;;
- hostypec) hosttypechange="true"
- ;;
- advanced) showadvanced="true"
- ;;
- audio) showaudio="true"
- ;;
- network) shownetwork="true"
- ;;
- advancedX) showX="true"
- ;;
- webuser) setup_web_auth
- ;;
- restartfe) killall -9 mythfrontend
- killall -9 mythwelcome
- exit 0
- ;;
- reloadfe) reloadfe
- ;;
- ddns) services
- install=$ser_install
- remove=$ser_remove
- daemon_add=$ser_daemon_add
- daemon_remove=$ser_daemon_remove
- ;;
- screensaver)
- services
- install=$ser_install
- remove=$ser_remove
- daemon_add=$ser_daemon_add
- daemon_remove=$ser_daemon_remove
- showscreensaver="true"
- ;;
- ir)
- showir="true"
- ;;
-
- this_is_install) MV_NEW_INSTALL="true"
- ;;
- user)
- if [ x$rootSSH = "x1" ]
- then
- sed -i "s/^.*PermitRootLogin.*$/PermitRootLogin yes/" $BASE/etc/ssh/sshd_config
- else
- sed -i "s/^.*PermitRootLogin.*$/PermitRootLogin no/" $BASE/etc/ssh/sshd_config
- fi
- sv hup sshd
- ;;
- esac
-done
-
-if [ x$MV_NEW_INSTALL = xtrue ]
-then
- hosttypechange="false"
-fi
-
-
-
-# exit 1
-
-#network
-if [ x"$shownetwork" = xtrue ]
-then
- OLDHOSTNAME=`hostname`
- NEWHOSTNAME=$hostname
- if [ ! $OLDHOSTNAME = $NEWHOSTNAME ]
- then
-
- ${MV_ROOT}/bin/restore_default_settings.sh -cuhostname -o -h$OLDHOSTNAME
- RESTART_FE="true"
- hostname $NEWHOSTNAME
- if [ $SystemType != "Frontend_only" ]
- then
- sv restart mythbackend
- fi
-
- fi
-
- setup_network
- CMDLINE=$(cat /proc/cmdline)
- echo $CMDLINE |grep -q netboot
- NETBOOT=$?
- if [ x$NETBOOT = x1 ]
- then
- echo "loading network"
- ${BASE}/etc/net/scripts/network.init reload
- ${BASE}/etc/net/scripts/network.init restart
- else
- echo "netboot, will not start network"
- fi
-fi
-
-
-if [ x$showhost = "xtrue" ]
-then
- . $MV_ROOT/bin/ir_config.sh
- setupir
- case $SystemType in
- Standalone)
- setupntp 1
- services
-
- if [ x$hosttypechange = "xtrue" ]
- then
- setup_db
- fi
- if [ -f ${BASE}/etc/avahi/services/mysql.service ]
- then
- rm -f ${BASE}/etc/avahi/services/mysql.service
- sudo sv restart avahi
- fi
-
- install="mysql mythdb-initial avahi portmap nfs-utils local-website $ser_install"
- remove="none $ser_remove"
-
- daemon_add="mysql mythbackend avahi portmap nfs-utils netfs lighttpd $ser_daemon_add"
- daemon_remove="none $ser_daemon_remove"
-
- ;;
- Master_backend)
- setupntp 1
- services
-
- if [ ! -f ${BASE}/etc/avahi/services/mysql.service ]
- then
- mkdir ${BASE}/etc/avahi/services
- cp $TEMPLATES/mysql.service ${BASE}/etc/avahi/services/mysql.service
- sudo sv restart avahi
- fi
-
- install="mysql mythdb-initial avahi portmap nfs-utils local-website myth2ipod mythtv-status $ser_install "
- remove="$ser_remove"
-
- daemon_add="mysql mythbackend avahi portmap nfs-utils netfs lighttpd $ser_daemon_add"
- daemon_remove="$ser_daemon_remove"
- ;;
- Slave_backend)
- setupntp 0
- services
- if [ x$hosttypechange = "xtrue" ]
- then
- setup_db
- fi
- if [ -f ${BASE}/etc/avahi/services/mysql.service ]
- then
- rm -f ${BASE}/etc/avahi/services/mysql.service
- sudo sv restart avahi
- fi
-
- #cp $TEMPLATES/mysql.service ${BASE}/etc/avahi/services/mysql.service
- install="mysql avahi local-website portmap nfs-utils $ser_install "
- remove=" $ser_remove"
-
- daemon_add="mythbackend avahi portmap nfs-utils netfs lighttpd $ser_daemon_add"
- daemon_remove="$ser_daemon_remove"
- ;;
- Frontend_only)
- #Add values for services
- setupntp 0
- services
- if [ -f ${BASE}/etc/avahi/services/mysql.service ]
- then
- rm -f ${BASE}/etc/avahi/services/mysql.service
- sudo sv restart avahi
- fi
-
- install="libmysqlclient mysql-clients portmap nfs-utils avahi local-website $ser_install"
- remove="mysql mythweb$postfix $ser_remove"
-
- daemon_add="avahi portmap nfs-utils netfs lighttpd $ser_daemon_add "
- daemon_remove="mysql mythbackend $ser_daemon_remove"
- ;;
- esac
- #setupSyslog
-
-fi
-
-#apply these to ALL types
-
-
-
-
-#systemtype
-
-if [ x$showhost = "xtrue" ]
-then
- setupmysqlnetwork
- setupmysql
-
- #setupremote
- #REMOTE FIND ME JM
-
- #grab the new dbhost key
- #/usr/bin/grabkey.py
-fi
-
-#audio
-
-if [ x$showaudio = "xtrue" ]
-then
- #setupsoundtype
- if [ ! x$Audiotype = xtinker ]
- then
- ${MV_ROOT}/bin/soundconfig.sh -t real -i $Audiotype -d $SoundDevice
- fi
-fi
-
-#should always run
-packages
-
-#misc
-
-if [ x$showmisc = "xtrue" ]
-then
- setupzipcode
- settimezone
- setupcnfs
-fi
-
-#sleep
-if [ x$showsleep = "xtrue" ]
-then
- setupsleep
-fi
-
-if [ x$showX = "xtrue" ]
-then
- ${MV_ROOT}/bin/xconfig.sh
-fi
-
-#advanced
-if [ x$showadvanced = "xtrue" ]
-then
- if [ ! x$showhost = "xtrue" ]
- then
- services
- install="none $ser_install"
- remove="none $ser_remove"
- daemon_add=" none $ser_daemon_add"
- daemon_remove="none $ser_daemon_remove"
- packages
-
-
- if [ x$SystemType = xMaster_backend ]
- then
- setuppacman link
- else
- setuppacman
- fi
- fi
- setupncidclient
- setupnciddaemon
- setupbootsplash
- setuphobbitclient
- #setupreceiver
- setupevrouter
- #setupblaster
- #setupLCD
- setupDNSMASQ
-
-
-
-fi
-
-if [ x$showscreensaver = xtrue ]
-then
- setupscreensaver
-fi
-
-if [ x$showir = xtrue ]
-then
- . $MV_ROOT/bin/ir_config.sh
- setupir
-fi
-
-daemons
-#add check for lcd, and restart if needed.
-
-if [ x$RESTART_FE = xtrue ]
-then
- reloadfe
-fi
-
-
-
-
-case $SystemType in
- Standalone) smoltsystem=6
- MVRELEASE="$MVRELEASE (Standalone)"
- ;;
-Master_backend)
- if [ x$RunFrontend = x1 ]
- then
- smoltsystem=2
- MVRELEASE="$MVRELEASE (MBE with Frontend)"
- else
- smoltsystem=1
- MVRELEASE="$MVRELEASE (MBE)"
- fi
- ;;
-Slave_backend)
- if [ x$RunFrontend = x1 ]
- then
- smoltsystem=5
- MVRELEASE="$MVRELEASE (SLAVE with Frontend)"
- else
- smoltsystem=5
- MVRELEASE="$MVRELEASE (SLAVE)"
- fi
- ;;
- Frontend_only)
- smoltsystem=3
- MVRELEASE="$MVRELEASE ( Frontend only)"
- ;;
-esac
-echo $MVRELEASE > /etc/os_myth_release
-echo "systemtype=$smoltsystem" > /home/mythtv/.mythtv/smolt.info 2>/dev/null
-echo "remote=$Remotetype" >> /home/mythtv/.mythtv/smolt.info 2>/dev/null
+systemconfig.py -m $@