#!/bin/sh
# Update Various System Files, Ports, etc.
# Copyright (c) 2006, TundraWare Inc, Des Plaines, IL USA
# All Rights Reserved
# $Id: sysupd,v 1.107 2006/02/17 22:45:39 root Exp $
#####
# Where To Put The Various Log Files Generated Here
#####
DIRCVS=/bku/LOGS
DIRMIRROR=/bku/LOGS
DIRNESSUS=/bku/LOGS
#####
# List Of Sets To Process By Default
#####
DEFAULTSETS='mirror nessus ports stable'
# ---------------- Support Functions ---------------- #
#####
# Enter Timestamp Into Current Log
# Args:
# $1 Name of logfile
#####
timestamp()
{
echo "" >> $1
echo "#####" >> $1
echo -n "# " >> $1
date >>$1
echo "#####" >> $1
echo "" >> $1
}
# End Of 'timestamp()'
#####
# Execute The Desired Update
# Args:
# $1 Update Name
# $2 Log Directory
# $3 Command String To Execute
#####
runupd()
{
log=$2/$1.log
timestamp $log
touch $2/.$1-begin && eval $3 >>$log 2>&1 && touch $2/.$1-end &
}
# End of 'runupd()'
# -------------------- Program Entry Point ---------------#
#####
# Command line args override default set
#####
if [ $*_ = _ ]
then
SETS=$DEFAULTSETS
else
SETS=$*
fi
#####
# Process The Requested Updates
#####
for SET in $SETS
do
case $SET
in
###
# Update Mirrored FreeBSD Files
###
mirror)
runupd $SET $DIRMIRROR "/root/bin/mirror-freebsd"
# runupd $SET $DIRMIRROR "/usr/local/bin/rsync --delete -vaz rsync://ftp13.freebsd.org:/pub/FreeBSD/ports/i386/packages-4-stable /usr1"
;;
###
# Update The Nessus Plugins
###
nessus)
runupd $SET $DIRNESSUS "/usr/local/sbin/nessus-update-plugins"
;;
###
# CVSUP Updates
###
ports)
runupd $SET $DIRCVS "/usr/local/bin/cvsup -h cvsup6.freebsd.org -g /root/cvsup/$SET-supfile && cd /usr/ports && make index"
;;
stable)
runupd $SET $DIRCVS "/usr/local/bin/cvsup -h cvsup5.freebsd.org -g /root/cvsup/$SET-supfile"
;;
*)
echo "Invalid sysupd Option Specified!"
;;
esac
done