summaryrefslogtreecommitdiffstats
path: root/abs
diff options
context:
space:
mode:
Diffstat (limited to 'abs')
-rwxr-xr-x[-rw-r--r--]abs/core-testing/LinHES-config/PKGBUILD10
-rwxr-xr-xabs/core-testing/LinHES-config/install_proxy.sh794
-rwxr-xr-xabs/core-testing/LinHES-config/mv_config.py16
-rwxr-xr-xabs/core-testing/LinHES-config/mv_install.py1246
4 files changed, 1400 insertions, 666 deletions
diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index c035c80..b6c2628 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=402
+pkgrel=403
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 )
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)
install=LinHES.install
build() {
@@ -39,8 +39,10 @@ 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 README $MVDIR/README
mkdir -p $startdir/pkg/usr/bin
diff --git a/abs/core-testing/LinHES-config/install_proxy.sh b/abs/core-testing/LinHES-config/install_proxy.sh
index d39f712..cb387b9 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 ]
+ mypercent=`echo "$1" | cut -d. -f1`
+ if [ x$mypercent = x ]
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
+ echo "" > /tmp/.install_percent
else
- echo "No new password changes to apply"
+ echo "${mypercent}% complete" > /tmp/.install_percent
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 ]
- 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"
- 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
- 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 " "`
@@ -740,7 +210,7 @@ echo "-----------------------------------------------------------------------3--
fi
fi
fi
- ;;
+ ;;
esac
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..02cf1d9
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_config.py
@@ -0,0 +1,16 @@
+# -*- 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="TRUE"
+BACKUPFILE="mythconverg.sql.gz"
+BACKUPPATH="/myth/backup/"
+TEMP_TEMPLATES="/tmp/templates"
+
+
+
+
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..f9359e4
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_install.py
@@ -0,0 +1,1246 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+import sys , os, commands , shutil,glob,time
+import getopt,re
+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 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(hostoptions["backupfile"]):
+ logging.debug("Backup file %s is present",hostoptions["backupfile"])
+ return True
+ else:
+ logging.debug("Backup file %s is NOT present",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("LOOK TIMEZONE TO DB needs to be completed")
+
+
+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)
+ #if os.path.isdir(srcfile):
+ #logging.info("Copying directory %s to %s",srcfile,destfile)
+ #try:
+ #shutil.copytree(srcfile,destfile)
+ #except:
+ #logging.debug("Couldn't copy directory %s using file by file", srcfile)
+ #try:
+ #stddir=os.getcwd()
+ #os.chdir(srcfile)
+ #for FILE in glob.glob("*"):
+ #print FILE
+ #shutil.copy2(FILE, destfile+"/"+FILE)
+ #os.chdir(stddir)
+ #except:
+ #logging.info("Dir File by file failed: %s", srcfile)
+
+ #elif os.path.isfile(srcfile):
+ #logging.info("Copying File %s to %s",srcfile,destfile)
+ #try:
+ #shutil.copy(srcfile,destfile)
+ #except:
+ #logging.info("Couldn't copy file %s",srcfile)
+ #else:
+ #logging.debug("Src file is not a file or a directory")
+
+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)
+ #if os.path.isdir(srcfile):
+ #logging.info("Copying directory %s to %s",srcfile,destfile)
+ #try:
+ #shutil.copytree(srcfile,destfile)
+ #except:
+ #logging.debug("Couldn't copy directory %s using file by file", srcfile)
+ #try:
+ #stddir=os.getcwd()
+ #os.chdir(srcfile)
+ #for FILE in glob.glob(fileglob):
+ #logging.debug("copying file %s to %s" ,FILE,destfile+FILE)
+ #shutil.copy2(FILE, destfile+FILE)
+ #os.chdir(stddir)
+ #except:
+ #logging.info("Dir File by file failed: %s", srcfile)
+ #elif os.path.isfile(srcfile):
+ #logging.info("Copying File %s to %s",srcfile,destfile)
+ #try:
+ #shutil.copy(srcfile,destfile)
+ #except:
+ #logging.info("Couldn't copy file %s",srcfile)
+ #else:
+ #logging.debug("Src file is not a file or a directory")
+
+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 -1 -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:
+ 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()
+
+
+# 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)
+ 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)
+ 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 %s",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)
+ hostoptions["backupfile"]=newbackupfile
+ else:
+ logging.info("Couldn't find any database to restore, upgrade will continue with a new database")
+
+
+
+def upgrade(hostoptions):
+# unmount_it()
+# find_upgrade()
+ 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.MOUNTPOINT+data_config.BACKUPPATH+data_config.BACKUPFILE
+ statgrab( hostoptions["rootdisk"])
+ msg="Upgrading %s" %(systemconfig["hostname"])
+ update_status(msg)
+ time.sleep(3)
+ copy_it("upgrade")
+
+ 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)
+ 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)
+ 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='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)
+
+#Read in systemconfig
+global systemconfig
+systemconfig = {}
+file_name = "/etc/systemconfig"
+config_file= open(file_name)
+
+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(), [])
+
+ 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
+