Well, here are my current versions of the update scripts.
I hope they are complicated enough for everyone. <grin>

Contrary to Kent's suggestion, I'm only logging the last 10 lines of the
important commands.  I defer to his experience and knowledge, but I
can't see the value in logging 7500 lines of code that executed
correctly.  Let's just get the last 10 lines, since that's where any
errors will be.

Comments, suggestions, flames?

------------------------------

#!/usr/local/bin/bash
#
# Update the system, run in multi-user mode.
#
# Checks the exit status of all important commands,
# Exits on exit status of anything other than 0, 
# Prints the name of the command that failed.
# Logs the last 10 lines of screen output for important commands.

bailout() {
if [ $? -ne 0 ] ; then
    echo "Update1 has bailed out on error $?"
    echo "The command that failed was..."
    echo $cmd
    exit
fi
}

echo -n "Have you read /usr/src/UPDATING? [y/n]: "
read a
if [ $a = n ] ; then
    less /usr/src/UPDATING
    exit
fi

echo -n "Have you merged /etc/group and /usr/src/etc/group? [y/n]: "
read b
if [ $b = n ] ; then
    diff -c /etc/group /usr/src/etc/group | less
    exit
fi

echo -n "Have you merged /etc/master.passwd and
/usr/src/etc/master.passwd? [y/n]: "
read c
if [ $c = n ] ; then
    diff -c /etc/master.passwd /usr/src/etc/master.passwd
    exit
fi

cmd="cp /disk2/larry/etc/make.conf /etc"
cp /disk2/larry/etc/make.conf /etc
bailout

cmd="cp /disk2/larry/usr/src/sys/i386/conf/CUSTOM
/usr/src/sys/i386/conf"
cp /disk2/larry/usr/src/sys/i386/conf/CUSTOM /usr/src/sys/i386/conf
bailout

cmd="Clean out /usr/obj"
echo -n "Clean out /usr/obj? [y/n]: "
read d
if [ $d = y ] ; then
    cd /usr/obj
    chflags -R noschg *
    rm -rf *
fi
bailout

echo -n "Continue with build? [y/n]: "
read e
if [ $e = n ] ; then
    exit
fi

cmd="make buildworld"
cd /usr/src
echo "Time for buildworld:" > /var/log/build/build.log
\time -aho /var/log/build/build.log make buildworld 2>&1 |
tee /var/log/build/tmp.log |
tail /var/log/build/tmp.log > /var/log/build/buildworld-`date
"+%Y%m%d-%H%M"`.log
bailout
echo >> /var/log/build/build.log
rm /var/log/build/tmp.log

cmd="make buildkernel KERNCONF=GENERIC"
echo "Time for buildkernel GENERIC:" >> /var/log/build/build.log
\time -aho /var/log/build/build.log make buildkernel KERNCONF=GENERIC
2>&1 |
tee /var/log/build/tmp.log |
tail /var/log/build/tmp.log > /var/log/build/buildkernG-`date
"+%Y%m%d-%H%M"`.log
bailout
echo >> /var/log/build/build.log
rm /var/log/build/tmp.log

cmd="make installkernel KERNCONF=GENERIC"
echo "Time for installkernel GENERIC:" >> /var/log/build/build.log
\time -aho  /var/log/build/build.log make installkernel KERNCONF=GENERIC
2>&1 |
tee /var/log/build/tmp.log |
tail /var/log/build/tmp.log > /var/log/build/installkernG-`date
"+%Y%m%d-%H%M"`.log
bailout
echo >> /var/log/build/build.log
rm /var/log/build/tmp.log

cmd="make buildkernel KERNCONF=CUSTOM"
cp /boot/kernel /boot/kernel.GENERIC
echo "Time for buildkernel CUSTOM:" >> /var/log/build/build.log
\time -aho /var/log/build/build.log make buildkernel KERNCONF=CUSTOM
2>&1 |
tee /var/log/build/tmp.log |
tail /var/log/build/tmp.log > /var/log/build/buildkernC-`date
"+%Y%m%d-%H%M"`.log
bailout
echo >> /var/log/build/build.log
rm /var/log/build/tmp.log

cmd="make installkernel KERNCONF=CUSTOM"
echo "Time for installkernel CUSTOM:" >> /var/log/build/build.log
\time -aho /var/log/build/build.log make installkernel KERNCONF=CUSTOM
2>&1 |
tee /var/log/build/tmp.log |
tail /var/log/build/tmp.log > /var/log/build/installkernC-`date
"+%Y%m%d-%H%M"`.log
bailout
echo >> /var/log/build/build.log
rm /var/log/build/tmp.log

echo "Reboot to single user mode and run /disk2/larry/bin/update2"

------------------------------

#!/usr/local/bin/bash
#
# Update the system. Run in single user mode.

bailout () {
if [ $? -ne 0 ] ; then
    echo "Update2 has bailed out on exit status $?"
    echo "The command that failed was..."
    echo $cmd
    exit
fi
}

echo -n "Continue with installworld? [y/n]: "
read a 
if [ $a = n ] ; then
    exit
fi

cmd="make installworld"
echo -n "Time for installworld:" >> /var/log/build/build.log
\time -aho /var/log/build/build.log make installworld |
tee /var/log/build/tmp.log |
tail /var/log/build/tmp.log > /var/log/build/instworld-`date
"+%Y%m%d-%H:%M"`.log
bailout
echo >> /var/log/build/build.log
rm /var/log/build/tmp.log

Cmd="cp -Rp /etc /etc.old"
if [ -d /etc.old ] ; then
    rm -r /etc.old
fi    
cp -Rp /etc /etc.old
Bailout

Cmd="rm -r /var/tmp/temproot"
if [ -d /var/tmp/temproot ] ; then
    cd /var/tmp/temproot
    chflags -R noschg *
    cd
    rm -r /var/tmp/temproot
Fi
bailout

Cmd="mergemaster -a"
/usr/sbin/mergemaster -a
bailout

Cmd="./MAKEDEV all"
cd /dev
./MAKEDEV all
bailout

cmd="make clean"
cd /usr/src/release/sysinstall
echo -n "Time for make clean:" >> /var/log/build/build.log
\time -aho /var/log/build/build.log make clean |
tee /var/log/build/tmp.log |
tail /var/log/build/tmp.log > /var/log/build/make_clean-`date
"+%Y%m%d-%H:%M"`.log
bailout
echo >> /var/log/build/build.log
rm /var/log/build/tmp.log

cmd="make all install"
echo "Time for make all install:" >> /var/log/build/build.log
\time -aho /var/log/build/build.log make all install |
tee /var/log/build/tmp.log |
tail /var/log/build/tmp.log > /var/log/build/make_all_install-`date
"+%Y%m%d-%H:%M"`.log
bailout
echo >> /var/log/build/build.log
rm /var/log/build/tmp.log

echo "Finished!  Do ps and top work?"


_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to