#!/bin/sh # Update Various System Files, Ports, etc. # Copyright (c) 2006-2016, TundraWare Inc, Des Plaines, IL USA # All Rights Reserved # $Id$ ##### # Where To Put The Various Log Files Generated Here ##### LOGDIR=/var/log ##### # Some Program Locations Vary By OS ### ECHO=$(which echo) ##### # List Of Sets To Process By Default ##### #ALL='debian freebsd_doc freebsd_ports freebsd_src freebsd_sys macports redhat texlive' # !!! # !!! Edit this or the program will do nothing without CLI args # !!! DEFAULTSETS=${SYSUPD:-""} # Allow setting this from the environment # ---------------- 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/sysupd-$1.log timestamp $log touch $2/.sysupd-$1-begin && eval $3 >>$log 2>&1 && touch $2/.sysupd-$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 ### # Debian Linux Updates ### debian) runupd $SET $LOGDIR "/usr/bin/apt-get -y update && /usr/bin/apt-get -y dist-upgrade && /usr/bin/apt-get -y upgrade" ;; ### # FreeBSD Documentation Updates ### freebsd_doc) runupd $SET $LOGDIR "/usr/local/bin/svn update /usr/doc" ;; ### # Freebsd Ports Updates ### freebsd_ports) runupd $SET $LOGDIR "/usr/sbin/portsnap cron update" ;; ### # FreeBSD Source Code Updates ### freebsd_src) runupd $SET $LOGDIR "/usr/local/bin/svn update /usr/src" ;; ### # FreeBSD Rebuild OS & Kernels ### freebsd_sys) rm -f $LOGDIR/sysupd-${SET}.log # Only keep latest run log cd /usr/src runupd $SET $LOGDIR "make -j4 clean buildworld buildkernel" ;; ### # MacPorts ### macports) runupd $SET $LOGDIR "/opt/local/bin/port selfupdate && /opt/local/bin/port upgrade outdated" ;; ### # RedHat YUM Updates ### redhat) runupd $SET $LOGDIR "/usr/bin/yum -y clean all && /usr/bin/yum -y upgrade" ;; ### # TeX Live Updates ### texlive) runupd $SET $LOGDIR "/usr/local/bin/tlmgr update --self && /usr/local/bin/tlmgr update --all" ;; ##### # Catch Errors ##### *) ${ECHO} "Invalid sysupd Option Specified!" ;; esac done