From: <bl...@us...> - 2003-10-17 21:03:48
|
Update of /cvsroot/devil-linux/build/scripts/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv1157/build/scripts/scripts Modified Files: pre_init Added Files: upgrade-config Log Message: Initial checkin of code to upgrade etc/config on boot --- NEW FILE: upgrade-config --- #!/bin/sh TMPD=/shm/var/tmp/upd-etc.$$ TMPF=/shm/var/tmp/upd-tmp.$$ RESULT=/shm/var/tmp/upd-res.$$ RAMDISKDIR="/shm" #DIALOG="dialog --clear --aspect 76 --no-shadow" DIALOG="dialog --clear --no-shadow" BACKTITLE="Devil-Linux configuration upgrade" pause() { echo read -n 1 -p "Press any key to continue ..." echo } setmenuheight () { let width=$(stty size|cut -f2 -d' ') let height2=$(stty size|cut -f1 -d' ')-1 let height=$height2-10 linecount=$(cat $TMPD|wc -l) [ $height -gt $linecount ] && height=$linecount } if [ -e $RAMDISKDIR/newconfig ]; then echo /shm/newconfig exists, please remove. exit 1 fi if [ ! -f /config/etc.tar.bz2 ]; then echo Cannot find file: /config/etc.tar.bz2 exit 1 fi for d in $RAMDISKDIR/etc $RAMDISKDIR/root do if [ ! -e "$d" ]; then echo Cannot find directory: $d exit 1 fi done rm -f $TMPD cd $RAMDISKDIR mkdir newconfig || exit 1 tar -xjf /config/etc.tar.bz2 -C newconfig for f in $(find etc root -type f -print) do echo -n "." [ $f = "etc/Devil-release" ] && continue [ $f = "etc/issue" ] && continue [ $f = "etc/issue.net" ] && continue [ $f = "etc/mtab" ] && continue [ $f = "etc/.pwd.lock" ] && continue cmp -s $f newconfig/$f || echo $f \"\" off \"$f\" >> $TMPD done while true do setmenuheight eval $DIALOG --title \"Select files to be copied to the new config\" --backtitle \"$BACKTITLE\" \ --item-help --help-button \ --checklist \"[un]select files to be kept with the SPACE BAR\" 0 $width $height \ $(sort $TMPD) 2> $RESULT RETURN=$? if [ $RETURN -eq 0 ]; then if [ "$(head -n1 $RESULT|cut -c1-4)" = "HELP" ]; then # Help button pressed for f in $(cat $RESULT|cut -c5-) do if [ -f "newconfig/$f" ]; then echo > $TMPF ls -l "$f" "newconfig/$f" >> $TMPF eval $DIALOG --title \"the files:\" \ --backtitle \"$BACKTITLE\" \ --item-help --help-button \ --textbox "$TMPF" $height2 $width echo > $TMPF diff -u "$f" "newconfig/$f" >> $TMPF eval $DIALOG --title \"running diff on the files:\" \ --backtitle \"$BACKTITLE\" \ --item-help --help-button \ --textbox "$TMPF" $height2 $width rm -f $TMPF eval $DIALOG --title \"the old/original file:\" \ --backtitle \"$BACKTITLE\" \ --item-help --help-button \ --textbox "$f" $height2 $width eval $DIALOG --title \"the NEW file:\" \ --backtitle \"$BACKTITLE\" \ --item-help --help-button \ --textbox "newconfig/$f" $height2 $width else echo > $TMPF ls -l "$f" >> $TMPF eval $DIALOG --title \"the old/original file:\" \ --backtitle \"$BACKTITLE\" \ --item-help --help-button \ --textbox "$TMPF" $height2 $width rm -f $TMPF eval $DIALOG --title \"the old/original file\" \ --backtitle \"$BACKTITLE\" \ --item-help --help-button \ --textbox "$f" $height2 $width fi done else # OK button pressed for f in $(cat $RESULT) do eval p=$f d="$(dirname newconfig/$p)" [ ! -d $d ] && mkdir -p $d # echo cp -af $p newconfig/$p echo "keeping file: $p" cp -af $p newconfig/$p done break fi else # Cancel button pressed break fi done rm -fr $TMPD $RESULT Index: pre_init =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/pre_init,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pre_init 9 Oct 2003 00:14:08 -0000 1.7 +++ pre_init 17 Oct 2003 21:00:51 -0000 1.8 @@ -46,9 +46,14 @@ mount -o remount,size=$CHANGE_SHMFS_SIZE /shm fi +# unpack /var to the shmfs +echo "Unpacking /var" +tar -C /shm/ -xjf /config/var.tar.bz2 + if [ -d /config/etc_files ]; then if ! cmp -s /shm/etc/Devil-release /config/etc_files/Devil-release then + cp -f /config/etc_files/issue* /etc RV1="$(cat /shm/etc/Devil-release | sed 's/Devil-Linux //')" RV2="$(cat /config/etc_files/Devil-release | sed 's/Devil-Linux //')" echo @@ -62,22 +67,54 @@ echo "Your media is version: $RV1" echo "Your cdrom is version: $RV2" $NORMAL + + #export LINES=$(stty size|cut -f1 -d' ') + #export COLUMNS=$(stty size|cut -f2 -d' ') + #export PS1='> ' + #export PS2='> ' + echo - echo 'Running "save-config" will eliminate this error message in future reboots,' - echo "but will NOT fix any problems caused by old configuration files." - echo - read -n 1 -t 60 -p "Press any key to continue ... (or timeout in 60 seconds)" + read -n 1 -t 300 -p 'Press "y" to upgrade now, or any key to skip ... (timeout in 5 minutes)' bs echo + if [ "$bs" = "y" ]; then + echo + echo -n "Comparing configurations, please wait " + /sbin/upgrade-config + echo + read -n 1 -t 300 -p 'Press "y" to switch to your new config ... (timeout in 5 minutes)' bs + echo + if [ "$bs" = "y" ]; then + cp -f /config/etc_files/* /shm/newconfig/etc/ + cp -f /shm/etc/mtab /shm/newconfig/etc/ + mv /shm/etc /shm/etc-old + mv /shm/newconfig/etc/ /shm/etc + $YELLOW + echo + echo 'You MUST run "save-config" after bootup to save your new config' + echo + $NORMAL + echo 'Your old etc directory will be saved until reboot at: /shm/etc-old' + echo + read -n 1 -t 300 -p 'Press any key to continue ... (timeout in 5 minutes)' + echo + else + rm -fr /shm/newconfig + $YELLOW + echo + echo + echo 'No changes made.' + echo + $NORMAL + read -n 1 -t 300 -p 'Press any key to continue ... (timeout in 5 minutes)' + echo + fi + fi + unset bs fi - cp -fdR /config/etc_files/* /etc fi # make sure, all the files in /etc are owned by root chown -R 0.0 /shm/etc/* - -# unpack /var to the shmfs -echo "Unpacking /var" -tar -C /shm/ -xjf /config/var.tar.bz2 echo "Initializing devfs" mount -t devfs none /dev |