Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Sep 2003 13:13:02 -0500
From:      "Charles Howse" <chowse@charter.net>
To:        "'Kent Stewart'" <kstewart@owt.com>, "'ODHIAMBO Washington'" <wash@wananchi.com>
Cc:        freebsd-questions@freebsd.org
Subject:   RE: scripting the buildworld/installworld process
Message-ID:  <003301c370b4$af41b8d0$04fea8c0@moe>
In-Reply-To: <200308311745.03944.kstewart@owt.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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,=20
# 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 =3D 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 =3D 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 =3D n ] ; then
    diff -c /etc/master.passwd /usr/src/etc/master.passwd
    exit
fi

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

cmd=3D"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=3D"Clean out /usr/obj"
echo -n "Clean out /usr/obj? [y/n]: "
read d
if [ $d =3D y ] ; then
    cd /usr/obj
    chflags -R noschg *
    rm -rf *
fi
bailout

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

cmd=3D"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=3D"make buildkernel KERNCONF=3DGENERIC"
echo "Time for buildkernel GENERIC:" >> /var/log/build/build.log
\time -aho /var/log/build/build.log make buildkernel KERNCONF=3DGENERIC
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=3D"make installkernel KERNCONF=3DGENERIC"
echo "Time for installkernel GENERIC:" >> /var/log/build/build.log
\time -aho  /var/log/build/build.log make installkernel =
KERNCONF=3DGENERIC
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=3D"make buildkernel KERNCONF=3DCUSTOM"
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=3DCUSTOM
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=3D"make installkernel KERNCONF=3DCUSTOM"
echo "Time for installkernel CUSTOM:" >> /var/log/build/build.log
\time -aho /var/log/build/build.log make installkernel KERNCONF=3DCUSTOM
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=20
if [ $a =3D n ] ; then
    exit
fi

cmd=3D"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=3D"cp -Rp /etc /etc.old"
if [ -d /etc.old ] ; then
    rm -r /etc.old
fi   =20
cp -Rp /etc /etc.old
Bailout

Cmd=3D"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=3D"mergemaster -a"
/usr/sbin/mergemaster -a
bailout

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

cmd=3D"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=3D"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?"




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003301c370b4$af41b8d0$04fea8c0>