|
This script was written because while updating
an OpenBSD installation is not really that
hard, there is no automated tool such as
Debian's apt to do so. Therefore I wrote
this script in an attempt to come up with
a semi-automatic method of updating an OpenBSD
box. There are other scripts available via
Google if this one does not meet your needs.
The error checking on this particular script is
non-existent, so be sure to check the OpenBSD
web site (particularly the upgrade mini-faq)
if things don't run smoothly or your kernel build
finishes after only a few seconds.
The ability to build an arbitrary port would
be useful, but is not included. (I don't
use many of the ports.) If you build and
install userland, you will need to take a
look at customizations you've made to your
system such as replacing sendmail with postfix.
The script uses sh instead of csh,
as I am
more familiar with bash scripting.
#!/bin/sh
##############################################################################
# System Upgrade
# James Zuelow
# Modified 02 September 2004
# Automates source code update & system rebuild for i386 OpenBSD 3.5
# Install /usr/src and /usr/ports from CD No. 3 before updating via cvs.
##############################################################################
updatesource()
{
export CVSROOT=anoncvs@anoncvs1.usa.openbsd.org:/cvs
cd /usr/src
# Update the next line to track the current version:
cvs up -t -rOPENBSD_3_5 -Pd
# Comment out the next 2 lines if you are not tracking ports:
cd /usr/ports
cvs -t up -rOPENBSD_3_5 -Pd
mainmenu
}
compilekernel()
{
# Check the upgrade mini-faq if things go wrong.
# If you are upgrading a stock 3.5 kernel the 1st time,
# uncomment the blocks below.
# cd /usr/src/gnu/usr.bin/binutils
# make -f Makefile.bsd-wrapper cleandir || exit
# make -f Makefile.bsd-wrapper obj || exit
# make -f Makefile.bsd-wrapper depend || exit
# make -f Makefile.bsd-wrapper || exit
# make -f Makefile.bsd-wrapper install || exit
cd /usr/src/sys/arch/i386/conf
/usr/sbin/config GENERIC
cd /usr/src/sys/arch/i386/compile/GENERIC
make clean || exit
make depend || exit
make bsd || exit
mainmenu
}
compileuserland()
{
# Sample exclusion line:
# export SKIPDIR="sendmail"
# The above line ensures make build doesn't clobber postfix
cd /usr/src
rm -rf /usr/obj/*
make obj || exit
make build || exit
mainmenu
}
changekernel()
{
# Uses cp instead of mv to make sure that a kernel build failure doesn't
# kill your box. If you need to, you can boot to the old copy.
DTE=`date +%y%m%d`
cd /usr/src/sys/arch/i386/compile/GENERIC
cp /bsd /bsd.${DTE}
cp bsd /bsd
chown root:wheel /bsd
reboot
}
mergeetc()
{
# Build mergemaster from ports to use this.
if [ -e /usr/local/sbin/mergemaster ]
then
/usr/local/sbin/mergemaster
mainmenu
else
echo " Not found - please install the mergemaster package."
read WT
mainmenu
fi
}
mainmenu()
{
clear
echo "System update, OpenBSD 3.5"
echo " Check the OpenBSD upgrade mini-faq if you have any problems"
echo ""
echo " Please choose an update option:"
echo ""
echo " 1) Update Source 2) Compile Kernel"
echo " 3) Replace Kernel & Reboot 4) Compile Userland"
echo " 5) Merge new /etc files 6) Exit"
echo ""
echo -n " Option (1-6): "
read UPDT
case $UPDT in
1) updatesource;;
2) compilekernel;;
3) changekernel;;
4) compileuserland;;
5) mergeetc;;
6) exit 0;;
*) echo "" && echo "Please enter a number between one and six."
echo -n "Press enter to continue." && read WT && mainmenu;;
esac
}
#main body
if [ $# == 0 ]
then
mainmenu
fi
case $1 in
source) updatesource;;
kernel) compilekernel;;
userland) compileuserland;;
newkernel) replacekernel;;
merge) mergeetc;;
*) echo "Usage:"
echo "sysupdate [source|kernel|newkernel|userland|merge]"
echo ""
echo "source - update /usr/src/ via cvs"
echo "kernel - build a new kernel"
echo "newkernel - install a previously built kernel"
echo "userland - build and install userland from source"
echo "merge - update /etc with new config files"
echo ""
echo "no options - opens selection menu"
echo "";;
esac
exit 2
|
|