diff options
author | James Meyer <james.meyer@operamail.com> | 2009-08-17 17:16:31 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2009-08-17 17:16:31 (GMT) |
commit | 997dbedae9ea47fbb46ec15f8827cf1a8065c11e (patch) | |
tree | e20e579880f339682d8ede709369769269a365e0 /abs/mv-core/MythVantage-config/install_proxy.sh | |
parent | da98b0f401f135cb5a04270dbfc46c5dafc43d9d (diff) | |
download | linhes_pkgbuild-997dbedae9ea47fbb46ec15f8827cf1a8065c11e.zip linhes_pkgbuild-997dbedae9ea47fbb46ec15f8827cf1a8065c11e.tar.gz linhes_pkgbuild-997dbedae9ea47fbb46ec15f8827cf1a8065c11e.tar.bz2 |
mv-core: bring it up to date so that it works again
Diffstat (limited to 'abs/mv-core/MythVantage-config/install_proxy.sh')
-rwxr-xr-x | abs/mv-core/MythVantage-config/install_proxy.sh | 616 |
1 files changed, 161 insertions, 455 deletions
diff --git a/abs/mv-core/MythVantage-config/install_proxy.sh b/abs/mv-core/MythVantage-config/install_proxy.sh index 9019349..71b675b 100755 --- a/abs/mv-core/MythVantage-config/install_proxy.sh +++ b/abs/mv-core/MythVantage-config/install_proxy.sh @@ -1,6 +1,6 @@ #!/bin/bash -#chroot and /tmp -MVHOSTNAME=mvi +export TERM=vt100 +MVHOSTNAME=larch5 . /etc/profile TEMP_TEMPLATES=/tmp/templates disk=$2 @@ -14,475 +14,177 @@ run=$MV_ROOT/bin/install_functions.sh . /etc/systemconfig 2>/dev/null . $MV_ROOT/bin/networkconfig.sh CMDLINE=$(cat /proc/cmdline) - -#TEMPNET="Hostip"$default_interface -#eval MYTHIP=\$${TEMPNET} +BACKUPFILE="/myth/backup/mythconverg.sql.gz" 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 -} - - - -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 "Formatting $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 "Installing data" > /tmp/.install_state - - sleep 1 - $run copy_it $disk ALL - rm $mountpoint/etc/fstab - $run fstab_fix_it $disk $rootfs $datafs FULL_INSTALL - - progress 99 - sleep 1 - $run grub_it $disk - - - echo "Configuring system" > /tmp/.install_state - progress 100 - sleep 1 - cp -f /etc/systemconfig "$mountpoint"/etc - #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 127.0.0.1 - SE=$TEMPLATES/settings/syssettings - mkdir -p ${mountpoint}$SE - cp -rp $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 - #copy over any updates that might have occured - cp -f $MV_ROOT/bin/*.sh "$mountpoint"$MV_ROOT/bin/ - chmod -R 755 ${mountpoint}/root - cp /etc/mtab "$mountpoint"/etc/mtab - apply_new_auth - mkdir -p $mountpoint/var/log/func - mkdir -p $mountpoint/var/log/certmaster - - if [ $SystemType = "Master_backend" -o $SystemType = "Standalone" ] + mypercent=`echo "$1" | cut -d. -f1` + if [ x$mypercent = x ] then - #installing DB to local machine - #turn off old live database, so the chroot one can start - /etc/rc.d/mysqld stop - mount --bind /dev "$mountpoint/dev" - chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" > /tmp/chrootdb.out - chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install - echo "stopping mysql in chroot" - chroot "$mountpoint" /etc/rc.d/mysqld stop - umount "$mountpoint/dev" - - #/etc/rc.d/mysqld start + echo "" > /tmp/.install_percent else - #update remotedb with this host settings - 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,this_is_install - chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c ACCESSCONTROL - fi + echo "${mypercent}% complete" > /tmp/.install_percent fi - chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced - echo "Done" > /tmp/.install_state - cp /tmp/mythvantage_install.log $mountpoint/var/log/ - $run unmount_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 -do -echo $i >> $1 -done - - } - - -function upgrade () { - touch /tmp/.this_is_upgrade - - if [ ! x$rootfs = "xDo_not_format" ] - then - echo "Formatting $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 "Installing data" > /tmp/.install_state - sleep 1 - cp -rf /tmp/etc /new_boot/etc.old - cp -rf /tmp/oss /new_boot/var/lib/oss.old - #$run copy_it $disk bin.lzm,boot.lzm,etc.lzm,home.lzm,lib.lzm,opt.lzm,root.lzm,sbin.lzm,usr.lzm,var.lzm - SQUASHLIST="/tmp/.squashlist" - createsquashlist $SQUASHLIST - $run copy_it $disk $SQUASHLIST - #copy back ssh keys - - cp -rp /data/var/cache/pacman/pkg/* /new_boot/data/var/cache/pacman/pkg/ - cp -fp /new_boot/etc.old/ssh/*.pub /new_boot/etc/ssh/ - cp -fp /new_boot/etc.old/ssh/*.key /new_boot/etc/ssh/ - cp -fp /new_boot/etc.old/ssh/*key /new_boot/etc/ssh/ - - #funckeys - cadir=/etc/pki/func/ca - mv /new_boot/etc/pki /new_boot/etc/pki.new - cp -rp /new_boot/etc.old/pki /new_boot/etc/ - #passwd/shadow/group - cp -fp /new_boot/etc.old/passwd /new_boot/etc/ - cp -fp /new_boot/etc.old/shadow /new_boot/etc/ - cp -fp /new_boot/etc.old/group /new_boot/etc/ - - if [ x$rootfs = "xDo_not_format" ] - then - #rootfs=`grep ${disk}1 /tmp/etc/fstab |awk ' { print $3 } '` - rootfs=`grep \/\ /tmp/etc/fstab |awk ' { print $3 } '` - fi -# #datafs=`grep ${disk}3 /tmp/etc/fstab |awk ' { print $3 } '` -# datafs=`grep \/data /tmp/etc/fstab |awk ' { print $3 } '|head 1` - $run fstab_fix_it $disk UPGRADE - - echo "Writing boot sector" > /tmp/.install_state - progress 99 - sleep 1 - $run grub_it $disk - - - echo "Configuring system" > /tmp/.install_state - progress - sleep 1 - cp /etc/mtab "$mountpoint"/etc/mtab - cp -f /etc/systemconfig "$mountpoint"/etc - cp -f $MV_ROOT/bin/*.sh "$mountpoint"$MV_ROOT/bin/ - chmod -R 755 ${mountpoint}/root - chown root:mythtv "$mountpoint"/etc/systemconfig - chmod 775 "$mountpoint"/etc/systemconfig - mkdir -p $mountpoint/var/log/func - mkdir -p $mountpoint/var/log/certmaster - #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,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? - 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 - # - #Run second time - chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install - chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced,this_is_install - apply_new_auth - umount "$mountpoint/dev" - umount "$mountpoint/proc" - echo "Done" > /tmp/.install_state - cp /tmp/mythvantage_install.log $mountpoint/var/log/ - - $run unmount_it $disk -} - -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 vnc_check() { -# CMDLINE=$(cat /proc/cmdline) -# echo $CMDLINE |grep -q vnc -# USEVNC=$? -# echo $CMDLINE |grep -q nfsroot -# NETBOOT=$? -# echo $USEVNC -# if [ ! x$USEVNC = x0 ] -# then -# echo "not using vnc" -# if [ ! x$NETBOOT = x0 ] -# then -# echo "not using netboot" -# else -# echo "using netboot" -# USEVNC=0 -# fi -# -# else -# echo " using vnc" -# fi -# } - - -# function network_setup () { -# DEVICE=eth0 -# if [ ! -f /etc/systemconfig ] -# then -# exit 1 -# fi -# -# if [ ! x$USEVNC = x0 ] -# then -# echo "Resetting the network" -# killdhcp -# if [ $UseDHCP = 0 ] -# then -# /sbin/dhcpcd $DEVICE -# if [ ! $? = 0 ] -# then -# exit 2 -# fi -# fi -# else -# echo "using vnc/netboot, will not reset network" -# echo "nameserver $nameserver" > /etc/resolv.conf -# return 0 -# fi -# -# if [ $UseDHCP = 1 ] -# then -# -# /sbin/ifconfig $DEVICE $ip -# /sbin/route add default gw $route -# echo "nameserver $nameserver" > /etc/resolv.conf -# -# fi -# -# -# } - -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 - $run mount_it $disk - if [ -f /new_boot/etc/systemconfig ] - then - ###########ADD templates - mkdir -p $TEMP_TEMPLATES - cp -pr /new_boot/$TEMPLATES $TEMP_TEMPLATES - SANE_SYSETTINGS - cp -rp $TEMP_TEMPLATES/settings $TEMPLATES/ - - - cp /new_boot/etc/systemconfig /etc/systemconfig - cp -rf /new_boot/etc /tmp/etc - cp -rf /new_boot/var/lib/oss /tmp/oss - - $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings -h $MVHOSTNAME -d 127.0.0.1 - fi - $run umount_it $disk + full_install_it ) + mv_install.py --rootdisk=$disk --rootfs=$rootfs --rootsize=$rootsize --datafs=$datafs --datasize=$datasize --datadisk=$disk --swapsize=$swapsize -c full_install + rc=$? + echo "mv_install.py exit code $rc" + if [ $rc != 0 ] + then + echo "mv_install error" >> /tmp/.install_error + fi + exit $rc ;; - upgrade_it) - #"$MV_ROOT/bin/install_proxy.sh upgrade_it " + install_drive + " " + rootfs + "&" - 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}'` - ping -c 1 $myipdefault - if [ ! $? = 0 ] - then - exit 3 - #can't ping yourself - fi - ;; - check_gw) - #check gateway - mygwdefault=`/sbin/route |grep $default_interface|grep UG|awk '{ print $2}'` - if [ ! x$mygwdefault = x ] - then - ping -c 1 $mygwdefault - if [ ! $? = 0 ] - then - exit 4 - fi - fi - ;; - check_ns) - #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) - host google.com - if [ ! $? = 0 ] - then - exit 6 - fi - ;; - host_names) - #if host is found, then check to see if it's online - #if not online, assume it's ok to use this hostname - - hout=`host $hostname` - status=$? - #found host, now grab the ip - if [ $status = 0 ] - then - hoip=`echo $hout|awk '{print $4}'` - ping -c 1 $hoip - if [ $? = 0 ] - then - status=0 - else - status=1 - fi - fi - if [ $status = 0 ] - then - exit 7 - fi - - - ;; + 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 + + if [ $hoip = "out;" ] + then + #;; connection timed out; no servers could be reached + echo "DNS servers not found" + 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 + ;; - * ) - state=`cat /tmp/.install_state` + * ) + if [ -f /tmp/.install_state ] + then + state=`cat /tmp/.install_state` + else + state=" " + fi if [ x"${state}" = "xConfiguring system" ] then progress "" @@ -490,7 +192,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 " "` @@ -509,10 +211,14 @@ echo "-----------------------------------------------------------------------3-- total=$TOTALSIZE fi percent=`echo "scale=2 ; ($used/$total) * 100 " |bc ` - cond2=$(echo "$percent > 100" |bc ) + cond2=$(echo "$percent > 98" |bc ) if [ $cond2 -eq 1 ] then - percent=100 + percent=98 + fi + if [ x"${state}" = "xDone" ] + then + percent=100 fi cond3=$(echo "$percent < 3" |bc ) if [ $cond3 -eq 0 ] @@ -521,7 +227,7 @@ echo "-----------------------------------------------------------------------3-- fi fi fi - ;; + ;; esac |