Added copyright information.
Refactored code to use a common execution function.
1 parent ad9507d commit 095d8e108d2f1f2a5145083083170a106a1da4f5
@root root authored on 10 Feb 2006
Showing 1 changed file
View
123
sysupd
#!/bin/sh
# Update Various System Files, Ports, etc.
# $Id: sysupd,v 1.1 2006/02/10 06:18:42 root Exp $
# Copyright (c) 2006, TundraWare Inc, Des Plaines, IL USA
# All Rights Reserved
# $Id: sysupd,v 1.101 2006/02/10 06:39:59 root Exp $
 
 
#####
# The CVSHOST To Use
#####
 
CVSHOST=cvsup5.freebsd.org
 
 
#####
# Where To Put The Various Log Files Generated Here
#####
 
DIRCVS=/bku/LOGS
DIRINDEX=/bku/LOGS
DIRMIRROR=/bku/LOGS
DIRNESSUS=/bku/LOGS
 
 
#####
# List Of Sets To Process By Default
# Always Do The Ports Index Rebuild *After* The Ports CVSUP
 
DEFAULTSETS='mirror nessus ports stable index'
 
 
# ---------------- Support Functions ---------------- #
 
#####
# Enter Timestamp Into Current Log
# Args:
# $1 Name of logfile
#####
 
timestamp()
{
echo "" >> $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 2>&1 >> $log
touch $2/.$1-end
}
 
# End of 'runupd()'
 
 
# -------------------- Program Entry Point ---------------#
 
 
 
#####
# Command line args override default set
#####
case $SET
in
 
# Rebuild Ports Index
###
# Rebuild Ports Index
###
 
index)
 
cd /usr/ports
make index
runupd $SET $DIRINDEX "cd /usr/ports && make index"
;;
 
 
###
# Update Mirrored FreeBSD Files
###
 
mirror)
 
LOGDIR=$DIRCVS
MYLOG=$LOGDIR/$SET.log
timestamp $MYLOG
touch $LOGDIR/.$SET-begin
/root/bin/mirror-freebsd 2>&1 >> $MYLOG
touch $LOGDIR/.$SET-end
 
runupd $SET $DIRCVS "/root/bin/mirror-freebsd"
;;
 
 
###
# Update The Nessus Plugins
###
 
nessus)
 
LOGDIR=$DIRNESSUS
MYLOG=$LOGDIR/$SET.log
timestamp $MYLOG
touch $LOGDIR/.$SET-begin
/usr/local/sbin/nessus-update-plugins -v 2>&1 >> $MYLOG
touch $LOGDIR/.$SET-end
runupd $SET $DIRNESSUS "/usr/local/sbin/nessus-update-plugins -v"
;;
 
 
###
# CVSUP Updates
###
 
ports|stable)
 
LOGDIR=$DIRCVS
MYLOG=$LOGDIR/cvsup-$SET.log
timestamp $MYLOG
touch $LOGDIR/.cvsup-$SET-begin
/usr/local/bin/cvsup -h $CVSHOST -g /root/cvsup/$SET-supfile 2>&1 >> $MYLOG
touch $LOGDIR/.cvsup-$SET-end
runupd $SET $DIRCVS "/usr/local/bin/cvsup -h $CVSHOST -g /root/cvsup/$SET-supfile"
;;
 
esac