From daa272b5f5dac869f2c247452d9c1c72f885dda5 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Wed, 5 Nov 2008 14:45:30 -0600 Subject: Add KM->LinHES upgrade support. Very basic support only imports the hostname and restores the database(if needed). All other information is left behind. --- abs/core-testing/live-installer/PKGBUILD | 7 +- .../live-installer/install_functions.sh | 100 ++++---------- abs/core-testing/live-installer/install_proxy.sh | 151 +++++++++------------ .../live-installer/restore_km_db_chroot.sh | 53 ++++++++ 4 files changed, 148 insertions(+), 163 deletions(-) create mode 100644 abs/core-testing/live-installer/restore_km_db_chroot.sh diff --git a/abs/core-testing/live-installer/PKGBUILD b/abs/core-testing/live-installer/PKGBUILD index 3ac1ab6..7eb5436 100755 --- a/abs/core-testing/live-installer/PKGBUILD +++ b/abs/core-testing/live-installer/PKGBUILD @@ -1,12 +1,11 @@ pkgname=live-installer pkgver=1.0 -pkgrel=60 +pkgrel=77 pkgdesc="Install and configure your system" depends=(bc libstatgrab mysql-python expect curl dnsutils parted sg3_utils nmbscan) 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) - +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) install=live.install build() { @@ -29,6 +28,7 @@ build() { install -m 0755 xconfig.sh $MVDIR/bin/xconfig.sh # install -m 0755 live-install.sh $MVDIR/bin/live-install.sh install -m 0755 install_db_chroot.sh $MVDIR/bin/install_db_chroot.sh + install -m 0755 restore_km_db_chroot.sh $MVDIR/bin/restore_km_db_chroot.sh install -m 0755 restore_default_settings.sh $MVDIR/bin/restore_default_settings.sh install -m 0755 soundconfig.sh $MVDIR/bin/soundconfig.sh install -m 0755 networkconfig.sh $MVDIR/bin/networkconfig.sh @@ -37,6 +37,7 @@ 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 + mkdir -p $startdir/pkg/usr/bin install -m 0755 file_time_offset.py $startdir/pkg/usr/bin/file_time_offset.py #copy in the branding stuff diff --git a/abs/core-testing/live-installer/install_functions.sh b/abs/core-testing/live-installer/install_functions.sh index 96f5e96..bafb27a 100755 --- a/abs/core-testing/live-installer/install_functions.sh +++ b/abs/core-testing/live-installer/install_functions.sh @@ -255,41 +255,9 @@ unmount_it () { umount /dev/${disk}3 } -#linux-live version of copy_it -# copy_it () { -# #rsync -rvp --exclude=/mnt --exclude=\/$mountpoint / \/$mountpoint -# lzmdir=`find /mnt/live/mnt -name data.lzm -execdir pwd \;| tail -1` -# cd $lzmdir -# if [ x$1 = xALL ] -# then -# LIST=`ls *.lzm` -# else -# LIST=`echo $1 | tr , " " ` -# fi -# -# for i in $LIST -# do -# echo "Transferring $i" -# lzm2dir $i \/$mountpoint -# done -# for i in sys proc dev tmp -# do -# mkdir /$mountpoint/$i -# -# done -# chmod 777 /$mountpoint/tmp -# mknod /$mountpoint/dev/null c 1 3 -# mknod /$mountpoint/dev/null c 1 5 -# mknod /$mountpoint/dev/console c 5 1 -# chmod +s /$mountpoint/usr/bin/Xorg -# chmod +s /$mountpoint/usr/bin/crontab -# chmod +s /$mountpoint/usr/bin/sudo -# chmod +s /$mountpoint/bin/mount -# -# } copy_it () { - + if [ x$1 = xALL ] then echo "Transferring system" @@ -371,7 +339,7 @@ function find_uuid() { uuid=`blkid -s UUID /dev/$1 |cut -d= -f2|cut -d\" -f2` echo $uuid for $1 FOUNDUUID=$uuid - + } @@ -409,13 +377,22 @@ case $1 in then create_fstab fi - if [ x$5 = xUPGRADE ] + #was 5 + if [ x$3 = xUPGRADE ] then - cp -f /tmp/etc/fstab /$mountpoint/etc/fstab + if [ ! -f /tmp/etc/KnoppMyth-version ] + then + if [ -f /tmp/etc/fstab ] + then + cp -f /tmp/etc/fstab /$mountpoint/etc/fstab + else + create_fstab + fi + else + create_fstab + fi fi -# if [ x$5 = xFULL_INSTALL ] -# then #search for UUID FOUNDUUID="" find_uuid ${2}1 @@ -430,54 +407,31 @@ case $1 in FOUNDUUID="" find_uuid ${2}3 DATAUUID=$FOUNDUUID -# fi - - - - sed -i -e "s/.*\/\ .*$/UUID=$ROOTUUID \/ auto defaults,noatime 0 1/g" /$mountpoint/etc/fstab + sed -i -e "s/.*\/\ .*$/UUID=$ROOTUUID \/ auto defaults,noatime 0 1/g" /$mountpoint/etc/fstab sed -i -e "s/.*\/myth\ .*$/UUID=$DATAUUID \/myth auto defaults,noatime 0 1/g" /$mountpoint/etc/fstab sed -i -e "s/.*swap\ .*$/UUID=$SWAPUUID swap swap defaults 0/g" /$mountpoint/etc/fstab -# sed -e "s/\ \/\ .*$/\ \/ $3 defaults 0 1/g"\ -# -e "s/\ \/myth .*$/\ \/myth $4 defaults 0 1/g" /$mountpoint/etc/fstab > /tmp/fstab -# -# -# cp /tmp/fstab /$mountpoint/etc/fstab +#if Knoppmyth upgrade then loop through old fstab picking out vg + + ;; grub_it ) - #linux-live - #grub-install --recheck --no-floppy --root-directory=/$mountpoint /dev/$disk grub-install --recheck --no-floppy --root-directory=/$mountpoint "(hd0)" - - - #fixing fstab -# if [ ! -f /$mountpoint/etc/fstab ] -# then -# cp -f /$mountpoint/etc/fstab.install /$mountpoint/etc/fstab -# fi -# sed -e s/hda/$disk/g /$mountpoint/etc/fstab > /tmp/newfstab -# cp -f /tmp/newfstab /$mountpoint/etc/fstab - - #fixing grub/menu.1st - FOUNDUUID="" - find_uuid ${disk}1 - ROOTUUID=$FOUNDUUID -# sed -e s/hda/$disk/g /$mountpoint/boot/grub/menu.lst > /tmp/menu.lst - - sed -i -e "s/root=.\S*/root=\/dev\/disk\/by-uuid\/$ROOTUUID/g" /$mountpoint/boot/grub/menu.lst - - -#cp -f /tmp/menu.lst /$mountpoint/boot/grub/menu.lst - #cp /etc/X11/xorg.conf /$mountpoint/etc/X11/xorg.conf - mkinitcpio -g /$mountpoint/boot/kernel26.img + #fixing grub/menu.1st + FOUNDUUID="" + find_uuid ${disk}1 + ROOTUUID=$FOUNDUUID + sed -i -e "s/root=.\S*/root=\/dev\/disk\/by-uuid\/$ROOTUUID/g" /$mountpoint/boot/grub/menu.lst + mkinitcpio -g /$mountpoint/boot/kernel26.img ;; umount_it) - umount \/$mountpoint/myth umount \/$mountpoint + ;; + esac diff --git a/abs/core-testing/live-installer/install_proxy.sh b/abs/core-testing/live-installer/install_proxy.sh index a9b52a5..d5aec45 100755 --- a/abs/core-testing/live-installer/install_proxy.sh +++ b/abs/core-testing/live-installer/install_proxy.sh @@ -52,6 +52,23 @@ function apply_new_auth () { } +function backup_sql_check { + + if [ -f $mountpoint/myth/backup/mythconverg.sql.gz ] + then + return 0 + else + return 1 + fi +} + +function upgrade_mount_search { + MYTH_P=`cat /tmp/etc/fstab |grep /myth| awk ' {print $1 '} ` + umount $mountpoint/myth + mount $MYTH_P $mountpoint/myth + return 0 + +} full_install () { @@ -93,7 +110,7 @@ full_install () { progress 100 sleep 1 cp -f /etc/systemconfig "$mountpoint"/etc - #run save syssettings to save settings, then copy to new mountpoint + #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 @@ -139,7 +156,7 @@ full_install () { fi chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced 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 @@ -182,7 +199,8 @@ function upgrade () { 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 @@ -193,22 +211,18 @@ function upgrade () { 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 [ ! -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/ + fi 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 @@ -216,17 +230,35 @@ function upgrade () { 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 +#make sure mythconverg.sql.gz is present + if [ ! backup_sql_check ] + then + upgrade_mount_search + fi + + if [ -f /tmp/etc/KnoppMyth-version ] + 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 -rp $SE/* ${mountpoint}$SE/ + chown root:mythtv "$mountpoint"/etc/systemconfig + chown -R mythtv:mythtv ${mountpoint}$SE + chmod -R 775 ${mountpoint}$SE + touch $mountpoint/home/mythtv/.kmupgrade && chmod 777 $mountpoint/home/mythtv/.kmupgrade + fi + 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 - touch $mountpoint/home/mythtv/.configure && chmod 777 $mountpoint/home/mythtv/.configure + touch $mountpoint/home/mythtv/.configure && chmod 777 $mountpoint/home/mythtv/.configure #mount /proc and /dev mount --bind /dev "$mountpoint/dev" mount --bind /proc "$mountpoint/proc" @@ -234,8 +266,11 @@ function upgrade () { 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? + /etc/rc.d/mysqld stop + chroot "$mountpoint" "$MV_ROOT/bin/restore_km_db_chroot.sh" > /tmp/chrootdb_km.out 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 @@ -246,6 +281,7 @@ function upgrade () { cp /tmp/mythvantage_install.log $mountpoint/var/log/ $run unmount_it $disk + /etc/rc.d/mysqld start } function netboot-full_install () { @@ -278,66 +314,6 @@ 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' \ @@ -367,18 +343,19 @@ echo "-----------------------------------------------------------------------3-- 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 + 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 + else + cp -rf /new_boot/etc /tmp/etc fi + $run umount_it $disk ;; diff --git a/abs/core-testing/live-installer/restore_km_db_chroot.sh b/abs/core-testing/live-installer/restore_km_db_chroot.sh new file mode 100644 index 0000000..9467ffd --- /dev/null +++ b/abs/core-testing/live-installer/restore_km_db_chroot.sh @@ -0,0 +1,53 @@ +#!/bin/bash +. /etc/profile +. /etc/systemconfig +set -x +#myhost=`cat /etc/hostname` +myhost=$hostname +hostname $myhost +mount -t proc none /proc +DBFILE=$1 + +if [ $SystemType = "Master_backend" -o $SystemType = "Standalone" ] + then + #restore database + pacman --noconfirm -Sf mysql + status=1 + mysqlstatus=1 + while [ ! $status = 0 ] + do + /etc/rc.d/mysqld stop + sleep 1 + /etc/rc.d/mysqld start + mysqlstatus=$? + if [ $mysqlstatus = 0 ] + then + mysql -e "show databases;" + showstatus=$? + if [ $showstatus = 0 ] + then + #load database + pacman --noconfirm -R mythdb-initial + pacman --noconfirm -S mythdb-initial + echo "restoring old database" + gunzip -c /myth/backup/mythconverg.sql.gz > /myth/backup/mythconverg.sql + mysql mythconverg < /myth/backup/mythconverg.sql + + + if [ -d /var/lib/mysql/mythconverg ] + then + status=0 + fi + fi + fi + done + rm -f /myth/backup/mythconverg.sql + else + exit 0 + fi + +#/etc/rc.d/mysqld stop +#umount /proc + + + -- cgit v0.12