This build.sh is for FreeBSD stable. It runs buildworld, installword, buildkernel and so on. I have used it for several years to upgrade my FreeBSD computers without problems, but please look at it carefully if you are considering running it as it will make system changes. It does not change to single user, which has never caused me issues, but your system may require that. Pasting the code here has mangled the license, so it would be safest to download the link above. This can also be used for FreeBSD 5.* but you need to remove the dostand() function and where it is called.
#!/usr/local/bin/bash
# Copyright (c) June 2000 Shaun Branden
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS “AS IS” AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
SUPFILE=”/home/shaun/cvs/stable-supfile”
KERN=”SAGAN”
if [ -z $1 ]
then
echo “Usage: `basename $0` {-a(ll includes cvs)|-m(ost)}” >&2
exit 42
fi
if [ "$UID" != "0" ]
then
echo “You do not have permission to use this script”
exit 42
fi
docvs ()
{
echo “updating cvs”
cvsup -g $SUPFILE
if [ $? -ne "0" ]
then
echo “cvs failed, perhaps we are offline”
exit 42
fi
}
#remove the working files from last time
doremove ()
{
echo “Removing old /usr/obj:”
cd /usr/obj
if [ $? -eq "0" ]
then
rm -rf *
chflags -R noschg *
rm -rf *
else
echo “Did not change to /usr/obj so rm -rf not run”
exit 42
fi
}
#compiles all system sources
dobuild ()
{
echo “Compiling the sources:”
cd /usr/src
make buildworld
if [ $? -ne "0" ]
then
echo “make buildworld failed, exiting”
exit 42
fi
}
#compile and installs the kernel
dokernel ()
{
echo “Compiling the kernel called $KERN ”
echo “running make buildkernel”
make buildkernel KERNCONF=$KERN
if [ $? -ne "0" ]
then
echo “make buildkernel failed, exiting”
exit 42
fi
echo “running make installkernel”
make installkernel KERNCONF=$KERN
if [ $? -ne "0" ]
then
echo “make installkernel failed, exiting”
exit 42
fi
}
#installs new system
doinstall ()
{
#install it all
echo “running make installworld”
make installworld
if [ $? -ne "0" ]
then
echo “ERROR: make installworld failed, exiting”
exit 42
fi
}
#update stand
dostand ()
{
echo “Updating stand”
cd /usr/src/release/sysinstall
make clean
make all install
if [ $? -ne "0" ]
then
echo “ERROR: updating stand failed, exiting”
echo “Try to update stand manually”
fi
}
#Now run Mergemaster, this will also run MAKEDEV”
domerge ()
{
echo “Would you like me to run mergemaster? (y/n)”
read answer
if [ $answer = "y" ]
then
cp -Rp /etc /etc.old
mergemaster
if [ $? -ne "0" ]
then
echo “make installkernel failed, exiting”
exit 42
fi
else
echo “Run cp -Rp /etc /etc.old
mergemaster
manually”
exit
fi
}
#calls from here
case “$1″ in
-a)
docvs
doremove
dobuild
dokernel
doinstall
dostand
domerge
;;
-m)
doremove
dobuild
dokernel
doinstall
dostand
domerge
;;
*)
echo “Usage: `basename $0` {-a(ll includes cvs)|-m(ost)}” >&2
;;
esac
echo “Now that mergemaster is complete you can reboot to the new system:)”








