|
From: Bruce S. <bl...@us...> - 2008-04-16 13:19:20
|
Update of /cvsroot/devil-linux/build/scripts/scripts In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv16884/scripts/scripts Modified Files: pre_init save-config upgrade-config Log Message: /etc is now "aufs"! Index: pre_init =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/pre_init,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- pre_init 6 Jul 2007 03:59:33 -0000 1.28 +++ pre_init 16 Apr 2008 13:19:16 -0000 1.29 @@ -11,6 +11,17 @@ # used to initialize the devfs # +# mount /etc/ as a union/aufs directory +mount -n -t proc proc /proc # aufs needs /proc/mounts +mount -n --bind /shm/dev/ /dev/ # aufs needs /dev/null +mkdir -p /shm/var/tmp # aufs needs /tmp + +# select either aufs or unionfs mount below: +mount -n -t aufs -o br:/shm/etc-mods:/etc-cd=rr none /shm/etc +#mount -n -t unionfs -o dirs=/shm/etc-mods:/etc-cd=ro none /shm/etc + +umount -n /proc + # settings source /etc/sysconfig/config @@ -30,7 +41,7 @@ echo "Changed Root" $NORMAL -mount --bind /shm/dev/ /dev/ +#mount --bind /shm/dev/ /dev/ echo "Un-Mounting old Filesystems" umount /initrd/dev &> /dev/null @@ -67,64 +78,45 @@ echo "Unpacking /var" bunzip2 -s -c /config/var.tar.bz2 | tar -C /shm/ -x -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 //')" +if [ -d /shm/oldconfig ]; then + echo "Devil-Linux pre-UnionfS" > /shm/etc/Devil-release +fi + +if ! cmp -s /shm/etc/Devil-release /etc-cd/Devil-release +then + cp -f /etc-cd/issue* /etc + RV1="$(cat /shm/etc/Devil-release | sed 's/Devil-Linux //')" + RV2="$(cat /etc-cd/Devil-release | sed 's/Devil-Linux //')" + echo + $RED + echo "*** WARNING ***" + echo + $YELLOW + echo "You are running a configuration media for a different release CD!" + echo "You should update your floppy/USB to prevent potential problems." + echo + echo "Your media is version: $RV1" + echo "Your cdrom is version: $RV2" + $NORMAL + echo + bs="n" + read -n 1 -t 300 -p 'Press any key to upgrade, or "n" to skip. (timeout in 5 minutes)' bs + echo + if [ "$bs" != "n" ]; then echo - $RED - echo "*** WARNING ***" + echo -n "Comparing configurations, please wait " + /sbin/upgrade-config echo $YELLOW - echo "You are running a configuration media for a different release CD!" - echo "You should update your floppy/USB to prevent potential problems." echo - echo "Your media is version: $RV1" - echo "Your cdrom is version: $RV2" + echo 'You MUST run "save-config" after bootup to save your new config' + echo $NORMAL echo - read -n 1 -t 300 -p 'Press any key to upgrade, or "n" to skip. (timeout in 5 minutes)' bs + read -n 1 -t 300 -p 'Press any key to continue ... (timeout in 5 minutes)' echo - if [ "$bs" != "n" ]; then - echo - echo -n "Comparing configurations, please wait " - /sbin/upgrade-config - echo - read -n 1 -t 300 -p 'Press any key to switch to your new config, or "n" to skip. (timeout in 5 min)' bs - echo - if [ "$bs" != "n" ]; 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 "Your old config file has been saved as: /etc/sysconfig/config.old" - echo "A log of all changes is available at: /etc/sysconfig/upgrade.log" - - 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 + unset bs fi # call custom Pre_init Index: save-config =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/save-config,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- save-config 3 Nov 2007 19:56:01 -0000 1.36 +++ save-config 16 Apr 2008 13:19:16 -0000 1.37 @@ -231,7 +231,7 @@ $SUCCESS echo "listing difference" $NORMAL - ( cd / ; tar -djf $CONFIG_MOUNT/$DL_CONFIG_FILE etc ) + ( cd /shm ; tar -djf $CONFIG_MOUNT/$DL_CONFIG_FILE etc-mods ) umount $CONFIG_MOUNT @@ -276,7 +276,7 @@ --exclude=lvm/cache \ -j \ -f $CONFIG_MOUNT/$DL_CONFIG_FILE \ - etc root + etc-mods root error=$? Index: upgrade-config =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/upgrade-config,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- upgrade-config 27 Mar 2008 14:27:04 -0000 1.31 +++ upgrade-config 16 Apr 2008 13:19:16 -0000 1.32 @@ -9,12 +9,17 @@ # # Written by: Bruce Smith <dev...@re...> +DL_CONFIG_DIR="/floppy" +DL_CONFIG_SOURCE="$(cat /shm/DL_CONFIG_SOURCE)" +DL_CONFIG_FILE="$(cat /shm/DL_CONFIG_FILE)" + TMPC=/shm/var/tmp/upd-config.$$ TMPD=/shm/var/tmp/upd-etc.$$ TMPF=/shm/var/tmp/upd-tmp.$$ +CMPF=/shm/var/tmp/upd-cmpf.$$ RESULT=/shm/var/tmp/upd-res.$$ RAMDISKDIR="/shm" -LOGF="newconfig/etc/sysconfig/upgrade.log" +LOGF="/shm/upgrade.log" #DIALOG="dialog --clear --aspect 76 --no-shadow" DIALOG="dialog --clear --no-shadow" @@ -75,58 +80,57 @@ [ "$(expr substr "$1" 1 $(expr length "$2"))" = "$2" ] && return 0 || return 1 } -echo -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 +bailout () { + rm -fr $RAMDISKDIR/oldconfig + exit $1 +} -for d in $RAMDISKDIR/etc -do - if [ ! -e "$d" ]; then - echo Cannot find directory: $d - exit 1 - fi -done +echo rm -f $TMPD -cd $RAMDISKDIR -mkdir newconfig || exit 1 -tar -xjf /config/etc.tar.bz2 -C newconfig -for f in $(find etc -type f -mtime -3650 -print) +if [ -d $RAMDISKDIR/oldconfig ]; then + cd $RAMDISKDIR/oldconfig + PREUFS="yes" + FINDDIR="etc" + CMPDIR=".." +else + cd $RAMDISKDIR || bailout 1 + PREUFS="" + FINDDIR="etc-mods" + CMPDIR="/etc-cd" +fi +echo > $CMPF + +for f in $(find $FINDDIR -type f -mtime -3650 -print) do onoff="on" echo -n "." - [ $f = "etc/Devil-release" ] && continue - [ $f = "etc/issue" ] && continue - [ $f = "etc/issue.net" ] && continue - [ $f = "etc/sysconfig/upgrade.log" ] && continue - [ $f = "etc/sysconfig/software" ] && continue - [ $f = "etc/mtab" ] && continue - [ $f = "etc/.pwd.lock" ] && continue - [ $f = "etc/passwd" ] && continue - [ $f = "etc/passwd-" ] && continue - [ $f = "etc/group" ] && continue - [ $f = "etc/group-" ] && continue - [ $f = "etc/shadow" ] && continue - [ $f = "etc/shadow-" ] && continue - [ $f = "etc/gshadow" ] && continue - [ $f = "etc/gshadow-" ] && continue - comparesubstr "$f" "etc/modules/" && continue - comparesubstr "$f" "etc/sysconfig/config" && continue -# comparesubstr "$f" "etc/ssh/ssh_host_" && onoff="on" - comparesubstr "$f" "etc/init.d/" && onoff="off" - comparesubstr "$f" "etc/pam.d/" && onoff="off" - comparesubstr "$f" "etc/init.d/firewall.rules" && onoff="on" - comparesubstr "$f" "etc/init.d/boot.local" && onoff="on" - finfo=$(ls -a $f) - cmp -s $f newconfig/$f || echo $f \"\" $onoff \"$finfo\" >> $TMPD + [ $f = "$FINDDIR/Devil-release" ] && continue + [ $f = "$FINDDIR/issue" ] && continue + [ $f = "$FINDDIR/issue.net" ] && continue + [ $f = "$FINDDIR/sysconfig/upgrade.log" ] && continue + [ $f = "$FINDDIR/sysconfig/software" ] && continue + [ $f = "$FINDDIR/mtab" ] && continue + [ $f = "$FINDDIR/.pwd.lock" ] && continue + [ $f = "$FINDDIR/passwd" ] && continue + [ $f = "$FINDDIR/passwd-" ] && continue + [ $f = "$FINDDIR/group" ] && continue + [ $f = "$FINDDIR/group-" ] && continue + [ $f = "$FINDDIR/shadow" ] && continue + [ $f = "$FINDDIR/shadow-" ] && continue + [ $f = "$FINDDIR/gshadow" ] && continue + [ $f = "$FINDDIR/gshadow-" ] && continue + comparesubstr "$f" "$FINDDIR/modules/" && continue + comparesubstr "$f" "$FINDDIR/sysconfig/config" && continue + comparesubstr "$f" "$FINDDIR/init.d/" && onoff="off" + comparesubstr "$f" "$FINDDIR/pam.d/" && onoff="off" + comparesubstr "$f" "$FINDDIR/init.d/firewall.rules" && onoff="on" + comparesubstr "$f" "$FINDDIR/init.d/boot.local" && onoff="on" + comparesubstr "$f" "$FINDDIR/my.cnf" && onoff="off" + comparesubstr "$f" "$FINDDIR/udev/" && onoff="off" + cmp -s "/etc/$f" "$CMPDIR/$f" || echo $f \"\" $onoff \"$f\" >> $TMPD + echo $f >> $CMPF done msgbox "Please read:" "The next screen will let you select which of your old config files you want to copy to your new configuration \n\nBe VERY CAREFUL to only copy files you have customized. Copying other files could cause severe problems.\n\nNote: Selecting \"Help\" will display info about the current file, but upon return you will lose all selections made." @@ -145,15 +149,15 @@ # Help button pressed for f in $(cat $RESULT|cut -c5-) do - if [ -f "newconfig/$f" ]; then + if [ -f "$CMPDIR/$f" ]; then echo > $TMPF - ls -l "$f" "newconfig/$f" >> $TMPF + ls -l "$f" "$CMPDIR/$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 + diff -u "$f" "$CMPDIR/$f" >> $TMPF eval $DIALOG --title \"running diff on the files:\" \ --backtitle \"$BACKTITLE\" \ --item-help --help-button \ @@ -166,7 +170,7 @@ eval $DIALOG --title \"the NEW file:\" \ --backtitle \"$BACKTITLE\" \ --item-help --help-button \ - --textbox "newconfig/$f" $height2 $width + --textbox "$CMPDIR/$f" $height2 $width else echo > $TMPF ls -l "$f" >> $TMPF @@ -187,43 +191,57 @@ echo "************************************************************" >> $LOGF date >> $LOGF echo >> $LOGF - echo "Files saved from old config:" >> $LOGF - echo "----------------------------" >> $LOGF - echo >> $LOGF - for f in $(cat $RESULT) - do - eval p=$f - d="$(dirname $p)" - if [ ! -d newconfig/$d ]; then - mkdir -p newconfig/$d - chmod --reference /$d newconfig/$d - chown --reference /$d newconfig/$d - fi - if [ "$p" = "etc/modules.conf" ]; then - echo "migrating file: $p" | tee -a $LOGF - grep -v "file=/" $p > newconfig/$p - else - echo "keeping file: $p" | tee -a $LOGF - cp -af $p newconfig/$p - fi - done + if [ -n "$PREUFS" ]; then + echo "Files copied from old config:" >> $LOGF + echo "----------------------------" >> $LOGF + echo >> $LOGF + for f in $(cat $RESULT) + do + eval p=$f + d="$(dirname $p)" + if [ ! -d $CMPDIR/$d ]; then + mkdir -p $CMPDIR/$d + chmod --reference /$d $CMPDIR/$d + chown --reference /$d $CMPDIR/$d + fi + if [ "$p" = "$CMPDIR/modules.conf" ]; then + echo "migrating file: $p" | tee -a $LOGF + grep -v "file=/" $p > $CMPDIR/$p + else + echo "copying file: $p" | tee -a $LOGF + cp -af $p $CMPDIR/$p + fi + done + else + echo "Files not kept from old config:" >> $LOGF + echo "-------------------------------" >> $LOGF + echo >> $LOGF + for f in $(cat $CMPF) + do + if [ $(grep -xc "$f" $RESULT) -eq 1 ]; then + echo "not keeping: $p" | tee -a $LOGF + rm -f $FINDDIR/$p + fi + done + fi + cp -f /etc-cd/{Devil-release,issue,issue.net} /shm/etc/ - echo >> $LOGF - echo "Symlinks preserved from old config:" >> $LOGF - echo "-----------------------------------" >> $LOGF - echo >> $LOGF - for f in $(find /etc/ -type l | grep -v "init.d/rc" | grep -v "init.d/boot.d") - do - eval p=$f - d="$(dirname $p)" - if [ ! -d newconfig/$d ]; then - mkdir -p newconfig/$d - chmod --reference /$d newconfig/$d - chown --reference /$d newconfig/$d - fi - echo "preserving link: $f" | tee -a $LOGF - cp -dpf $f newconfig/$f - done +# echo >> $LOGF +# echo "Symlinks preserved from old config:" >> $LOGF +# echo "-----------------------------------" >> $LOGF +# echo >> $LOGF +# for f in $(find /etc/ -type l | grep -v "init.d/rc" | grep -v "init.d/boot.d") +# do +# eval p=$f +# d="$(dirname $p)" +# if [ ! -d $CMPDIR/$d ]; then +# mkdir -p $CMPDIR/$d +# chmod --reference /$d $CMPDIR/$d +# chown --reference /$d $CMPDIR/$d +# fi +# echo "preserving link: $f" | tee -a $LOGF +# cp -dpf $f $CMPDIR/$f +# done pause break fi @@ -236,43 +254,45 @@ echo if askyesno "/etc/sysconfig/config migration" "Do you want to migrate old values to your new /etc/sysconfig/config ?" yes then - echo >> $LOGF - echo >> $LOGF - echo "/etc/sysconfig/config migration:" >> $LOGF - echo "--------------------------------" >> $LOGF - echo >> $LOGF - cp -f etc/sysconfig/config newconfig/etc/sysconfig/config.old - cp -f newconfig/etc/sysconfig/config newconfig/etc/sysconfig/config.default - . etc/sysconfig/config - echo "Migrating /etc/sysconfig/config values ..." - echo - for bs in $(grep -v -e '^ *#' -e '^ *$' etc/sysconfig/config|cut -f1 -d'=') - do - eval mod_config newconfig/etc/sysconfig/config ${bs} \"\$${bs}\" - done - pause + echo >> $LOGF + echo >> $LOGF + echo "/etc/sysconfig/config migration:" >> $LOGF + echo "--------------------------------" >> $LOGF + echo >> $LOGF + if [ -n "$PREUFS" ]; then + cp -f $FINDDIR/sysconfig/config $CMPDIR/etc/sysconfig/config.old + else + cp -f /etc/sysconfig/config /etc/sysconfig/config.old + cp -f /etc-cd/sysconfig/config /etc/sysconfig/config + fi + . /etc/sysconfig/config.old + echo "Migrating /etc/sysconfig/config values ..." + echo + for bs in $(grep -v -e '^ *#' -e '^ *$' /etc/sysconfig/config|cut -f1 -d'=') + do + eval mod_config /etc/sysconfig/config ${bs} \"\$${bs}\" + done + pause fi if askyesno "User and Group migration" "Do you want to migrate your old users, groups and passwords?" yes ; then migrateid () { - cp -f newconfig/${1} newconfig/${1}.dl - cp -f newconfig/${2} newconfig/${2}.dl - cp -f ${1} newconfig/${1} - cp -f ${2} newconfig/${2} - cp -f ${1} newconfig/${1}- - cp -f ${2} newconfig/${2}- + if [ -n "${PREUFS}" ]; then + cp -f $FINDDIR/${1} /etc/${1} + cp -f $FINDDIR/${2} /etc/${2} + fi + cp -f /etc/${1} /etc/${1}- + cp -f /etc/${2} /etc/${2}- # Add all non-existing users/groups to new config while read id ; do name="$(echo $id|cut -d: -f1)" - [ "$(grep -c "^${name}:" newconfig/${1})" -gt 0 ] && continue - grep "^${name}:" newconfig/${1}.dl >> newconfig/${1} - grep "^${name}:" newconfig/${2}.dl >> newconfig/${2} + [ "$(grep -c "^${name}:" /etc/${1})" -gt 0 ] && continue + grep "^${name}:" /etc-cd/${1} >> /etc/${1} + grep "^${name}:" /etc-cd/${2} >> /etc/${2} echo ${name} - created. | tee -a $LOGF - done < newconfig/${1}.dl - rm -f newconfig/${1}.dl - rm -f newconfig/${2}.dl + done < /etc-cd/${1} } echo >> $LOGF @@ -281,7 +301,8 @@ echo "---------------" >> $LOGF echo | tee -a $LOGF - migrateid etc/passwd etc/shadow + migrateid passwd shadow + migrateid passwd shadow echo >> $LOGF echo | tee -a $LOGF @@ -289,26 +310,27 @@ echo "----------------" >> $LOGF echo | tee -a $LOGF - migrateid etc/group etc/gshadow + migrateid group gshadow + migrateid group gshadow fi # make sure the init system is configured correctly -rm -rf newconfig/etc/init.d/rc{S,0,1,2,3,4,5,6}.d -rm -rf newconfig/etc/init.d/boot.d -mkdir -p newconfig/etc/init.d/rc{S,0,1,2,3,4,5,6}.d -mkdir -p newconfig/etc/init.d/boot.d - -insserv -f -d $(grep -l "### BEGIN INIT INFO" newconfig/etc/init.d/* | grep -v "skeleton") +#rm -rf $CMPDIR/etc/init.d/rc{S,0,1,2,3,4,5,6}.d +#rm -rf $CMPDIR/etc/init.d/boot.d +#mkdir -p $CMPDIR/etc/init.d/rc{S,0,1,2,3,4,5,6}.d +#mkdir -p $CMPDIR/etc/init.d/boot.d +# +#insserv -f -d $(grep -l "### BEGIN INIT INFO" $CMPDIR/etc/init.d/* | grep -v "skeleton") # make sure we use the correct system initialization -sed -e s%"si::sysinit:/etc/init.d/boot"%"si::sysinit:/etc/init.d/rc boot"% newconfig/etc/inittab > newconfig/etc/inittab.new -mv -f newconfig/etc/inittab.new newconfig/etc/inittab +sed -e s%"si::sysinit:/etc/init.d/boot"%"si::sysinit:/etc/init.d/rc boot"% /etc/inittab > /etc/inittab.new +mv -f /etc/inittab.new /etc/inittab # syslog-ng # remove all chroot jail entries and replace stream with dgram sed -e 's|unix-stream *( *"/jail[^;]*;||g' \ -e 's|unix-stream *( *"/dev/log"|unix-dgram("/dev/log"|' \ - < newconfig/etc/syslog-ng/syslog-ng.conf > $TMPD -mv $TMPD newconfig/etc/syslog-ng/syslog-ng.conf + < /etc/syslog-ng/syslog-ng.conf > $TMPD +mv $TMPD /etc/syslog-ng/syslog-ng.conf -rm -fr $TMPD $RESULT +rm -fr $TMPD $RESULT $RAMDISKDIR/oldconfig |