Newer
Older
sysupd / sysupd
@tundra tundra on 26 Mar 2013 1 KB Corrected path to tlmgr.
#!/bin/sh
# Update Various System Files, Ports, etc.
# Copyright (c) 2006-2013, TundraWare Inc, Des Plaines, IL USA
# All Rights Reserved
# $Id: sysupd,v 1.135 2013/03/26 17:02:32 tundra Exp $


#####
# Where To Put The Various Log Files Generated Here
#####

LOGDIR=/var/log


#####
# List Of Sets To Process By Default
#####

DEFAULTSETS='doc ports src texlive'


# ---------------- 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

    ###
    # 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"
    ;;

    ###
    # SVN Updates
    ###

    doc | src)
      runupd $SET $LOGDIR "/usr/local/bin/svn update /usr/${SET}"
    ;;


    ###
    # Ports Updates
    ###

    ports)
      runupd $SET $LOGDIR "/usr/sbin/portsnap cron update"
    ;;


    ###
    # Update TeX Live
    ###

    texlive)
       runupd $SET $LOGDIR "/usr/local/bin/tlmgr update --self && /usr/local/texlive/bin/tlmgr update --all"
    ;;

 
   #####
    # Catch Errors
    #####

    *)
     echo "Invalid sysupd Option Specified!"
    ;;

  esac

done