diff options
Diffstat (limited to 'abs/core-testing/LinHES-config/install_proxy.sh')
-rwxr-xr-x | abs/core-testing/LinHES-config/install_proxy.sh | 155 |
1 files changed, 96 insertions, 59 deletions
diff --git a/abs/core-testing/LinHES-config/install_proxy.sh b/abs/core-testing/LinHES-config/install_proxy.sh index f251c70..f950b83 100755 --- a/abs/core-testing/LinHES-config/install_proxy.sh +++ b/abs/core-testing/LinHES-config/install_proxy.sh @@ -1,5 +1,6 @@ #!/bin/bash #chroot and /tmp +export TERM=vt100 MVHOSTNAME=larch5 . /etc/profile TEMP_TEMPLATES=/tmp/templates @@ -19,6 +20,19 @@ BACKUPFILE="/myth/backup/mythconverg.sql.gz" #TEMPNET="Hostip"$default_interface #eval MYTHIP=\$${TEMPNET} +function cp_and_log () { + ls $1 2>&1 >/dev/null + status=$? + if [ $status = 0 ] + then + echo "copying $1 to $2" + cp -rfp $1 $2 + else + echo "$1 is not present, skipping..." + fi + +} + progress () { mypercent=`echo "$1" | cut -d. -f1` @@ -73,7 +87,7 @@ function upgrade_mount_search { if [ $? = 1 ] then mkdir -p /new_boot/root/backup - cp -f /tmp/mythconverg.sql.gz /new_boot/root/backup/mythconverg.sql.gz + 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 @@ -119,37 +133,48 @@ full_install () { echo "Configuring system" > /tmp/.install_state progress 100 sleep 1 - cp -f /etc/systemconfig "$mountpoint"/etc + cp_and_log /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 localhost SE=$TEMPLATES/settings/syssettings mkdir -p ${mountpoint}$SE - cp -rp $SE/* ${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 #copy over any updates that might have occured - cp -f $MV_ROOT/bin/*.sh "$mountpoint"$MV_ROOT/bin/ + #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 - cp /etc/mtab "$mountpoint"/etc/mtab + 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 + #turn off old live database, so the chroot one can start + echo "---------------------CHROOT INSTALLDB-------------------------" /etc/rc.d/mysqld stop mount --bind /dev "$mountpoint/dev" - chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" > /tmp/chrootdb.out + mount --bind /proc "$mountpoint/proc" + 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,this_is_install echo "stopping mysql in chroot" chroot "$mountpoint" /etc/rc.d/mysqld stop - umount "$mountpoint/dev" - - #/etc/rc.d/mysqld start + kill_dhcp_chroot + sleep 2 + lsof |grep new_boot + umount -l "$mountpoint/dev" + umount -l "$mountpoint/proc" + + echo "---------------------END CHROOT INSTALLDB-------------------------" + /etc/rc.d/mysqld start else #update remotedb with this host settings chroot "$mountpoint" DISPLAY=127.0.0.1:0 /usr/local/bin/MythVantage -t restore,default_1 @@ -168,8 +193,9 @@ full_install () { touch $mountpoint/home/mythtv/.configure && chmod 777 $mountpoint/home/mythtv/.configure echo "Done" > /tmp/.install_state - cp /tmp/mythvantage_install.log $mountpoint/var/log/ - $run unmount_it $disk + cp_and_log /tmp/mythvantage_install.log $mountpoint/var/log/ + $run umount_it $disk + } function createsquashlist(){ @@ -207,8 +233,8 @@ function upgrade () { echo "STARTSIZE=$startsize">/tmp/.startsize.io echo "Upgrading $hostname" > /tmp/.install_state sleep 1 - cp -rf /tmp/etc /new_boot/etc.old - cp -rf /tmp/oss /new_boot/var/lib/oss.old + cp_and_log /tmp/etc /new_boot/etc.old + cp_and_log /tmp/oss /new_boot/var/lib/oss.old SQUASHLIST="/tmp/.squashlist" @@ -216,17 +242,18 @@ function upgrade () { $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/ - cp -fp /new_boot/etc.old/mdadm.conf /new_boot/etc/ +# 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/ + 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 -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/ + 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 if [ x$rootfs = "xDo_not_format" ] @@ -236,7 +263,7 @@ function upgrade () { $run fstab_fix_it $disk UPGRADE #this is here to copy in the systemconfig file as soon as possible. - cp -f /etc/systemconfig "$mountpoint"/etc + cp_and_log /etc/systemconfig "$mountpoint"/etc/systemconfig echo "Writing boot sector" > /tmp/.install_state progress 99 @@ -245,8 +272,8 @@ function upgrade () { echo "Configuring system" > /tmp/.install_state progress sleep 1 - cp /etc/mtab "$mountpoint"/etc/mtab - cp -f /etc/systemconfig "$mountpoint"/etc + cp_and_log /etc/mtab "$mountpoint"/etc/mtab + cp_and_log /etc/systemconfig "$mountpoint"/etc #make sure mythconverg.sql.gz is present backup_sql_check if [ $? = 1 ] @@ -261,7 +288,8 @@ function upgrade () { $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 -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 @@ -273,7 +301,7 @@ function upgrade () { - cp -f $MV_ROOT/bin/*.sh "$mountpoint"$MV_ROOT/bin/ + 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 @@ -293,7 +321,10 @@ function upgrade () { echo "--------------------------------" echo "clean upgrade installing new database" echo "--------------------------------" - chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" > /tmp/chrootdb.out + 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 ] @@ -301,13 +332,19 @@ function upgrade () { echo "--------------------------------" echo "Restoring database" echo "--------------------------------" - chroot "$mountpoint" "$MV_ROOT/bin/restore_km_db_chroot.sh" "$BACKUPFILE" > /tmp/chrootdb_km.out + 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" > /tmp/chrootdb.out + chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" |tee /tmp/chrootdb.out + echo "############################################" + echo "End Installing new database" + echo "############################################" fi fi @@ -326,14 +363,14 @@ function upgrade () { 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" + kill_dhcp_chroot + umount -l "$mountpoint/dev" + umount -l "$mountpoint/proc" echo "Done" > /tmp/.install_state - cp /tmp/mythvantage_install.log $mountpoint/var/log/ + cp_and_log /tmp/mythvantage_install.log $mountpoint/var/log/ - $run unmount_it $disk + $run umount_it $disk /etc/rc.d/mysqld start } @@ -349,22 +386,22 @@ function netboot-full_install () { ${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 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 +# } @@ -402,17 +439,17 @@ echo "-----------------------------------------------------------------------3-- then ###########ADD templates mkdir -p $TEMP_TEMPLATES - cp -pr /new_boot/$TEMPLATES $TEMP_TEMPLATES + cp_and_log /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 - [ -e /tmp/etc/mdadm.conf ] && cp -rf /tmp/etc/mdadm.conf /etc/ + 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 -rf /new_boot/etc /tmp/etc - [ -e /tmp/etc/mdadm.conf ] && cp -rf /tmp/etc/mdadm.conf /etc/ + 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 -` |