This is a script that I use to update my ports tree. Just change the supfile variable to point to yours and run it as ports.sh -c or ports.sh -a (change the rather odd switches yourself). There are a few lines commented out from past revisions/ experiments, just ignore them or use them, or abuse me. The license should be completely commented out, but pasting it here changed things, so use the link above. This changes system stuff, so is run as root, so by all means don’t trust me, please read it first and make sure you know what you are doing.
#!/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/ports-supfile”
if [ "$UID" != "0" ]
then
echo “You do not have permission to use this script”
exit 42
fi
docvs ()
{
#if [ `netstat -rn|grep default|awk {'print $6'}` == "tun0" ]
#then
echo “updating ports tree using cvsup”
cvsup -g $SUPFILE
if [ $? -ne "0" ]
then
echo “cvsup failed, not sure why”
exit 42
fi
#else
# echo “we are not online”
# exit 42
#fi
}
doportsdb ()
{
echo “running portsdb -Uu”
/usr/local/sbin/portsdb -Uu
if [ $? -ne "0" ]
then
echo “ERROR: portsdb failed to run”
exit 42
fi
}
#calls from here
case “$1″ in
-a)
docvs
doportsdb
;;
-c)
docvs
;;
*)
echo “Usage: `basename $0` {-a(ll includes portsdb)|-c(vs)}” >&2
;;
esac








