#!/bin/sh # ## Script for a cronjob to update the ports-tree automatically ## ## (c) 2004 Arvid Warnecke ## ## Released under the terms of the FreeBSD Copyright. ## ## Description: This script updates the system from CVS and refreshes ## the INDEX. It also updates the ports databases. ## At last it checks which ports needs to be upgraded and ## sends a list of those ports by email. ## If you like to execute that script by cron add something ## like that in your crontab: ## ## 0 6 * * * /path/where/the/script/is/cvs-cvsup.sh >>/dev/null 2>&1 ## ## ## Disclaimer: I wrote this script for my own use. Feel free to use it. ## But I do not ensure that it will work without errors. ## ## ## Version: 0.7.1 ## Settings ## ## You probably want to change those SUPFILE=/usr/local/etc/complete-supfile SUPSERVER=cvsup2.freebsd.org MAILADDR=madhatter@localhost ## You may change these if you want to CVSUP_LOG=/var/log/cvsup/cvs-cvsup.log PORTV_LOG=/var/log/cvsup/portversion.log DOC_LOG=/var/log/cvsup/documentation.log ## let's check something first ## if [ ! -r $SUPFILE ]; then echo "Supfile $SUPFILE is not available." | /usr/bin/mail -s "Error while CVS Update." $MAILADDR exit 127 fi ## then we move the old logfile apart ## ( /bin/mv -f $CVSUP_LOG $CVSUP_LOG.old ) >> /dev/null 2>&1 ( /bin/mv -f $DOC_LOG $DOC_LOG.old ) >> /dev/null 2>&1 ## next we get the new stuff ## echo "--------------------------------------------------------------------" >> $CVSUP_LOG ( echo -n " Script startet: " && /bin/date ) >> $CVSUP_LOG echo "--------------------------------------------------------------------" >> $CVSUP_LOG echo "Pulling updates from CVS: " >> $CVSUP_LOG /usr/local/bin/cvsup -L 2 -g -h $SUPSERVER $SUPFILE >> $CVSUP_LOG echo "--------------------------------------------------------------------" >> $CVSUP_LOG ## update the INDEX and the ports databases for pkgdb and portsdb ## echo "Updating the INDEX: " >> $CVSUP_LOG echo "------------------- " >> $CVSUP_LOG ( cd /usr/ports && make index ) >> $CVSUP_LOG 2>&1 echo "" >> $CVSUP_LOG echo "Updating the databases: " >> $CVSUP_LOG echo "----------------------- " >> $CVSUP_LOG ( /usr/local/sbin/portsdb -u && /usr/local/sbin/pkgdb -fu ) >> $CVSUP_LOG 2>&1 echo "--------------------------------------------------------------------" >> $CVSUP_LOG ( echo -n " Script ended: " && /bin/date ) >> $CVSUP_LOG echo "--------------------------------------------------------------------" >> $CVSUP_LOG ## now we'd like to know what we have to update ## echo "--------------------------------------------------------------------" >> $PORTV_LOG ( echo -n " " && /bin/date ) >> $PORTV_LOG echo "--------------------------------------------------------------------" >> $PORTV_LOG echo "" >> $PORTV_LOG ( /usr/local/sbin/portversion -v -l \< ) >> $PORTV_LOG 2>&1 echo "" >> $PORTV_LOG echo "--------------------------------------------------------------------" >> $PORTV_LOG ## i really need to have the documentation echo "--------------------------------------------------------------------" >> $DOC_LOG echo "" >> $DOC_LOG ( cd /usr/doc && make install clean ) >> $DOC_LOG 2>&1 echo "" >> $DOC_LOG ## send me an email, please ## if [ -r $PORTV_LOG ]; then /bin/cat $PORTV_LOG | /usr/bin/mail -s "Update the ports" $MAILADDR else /bin/cat $CVSUP_LOG | /usr/bin/mail -s "Probably something went wrong!" $MAILADDR fi ## clean up ## ( /bin/rm -f $PORTV_LOG ) >> /dev/null 2>&1