Date: Sat, 25 Sep 2004 00:04:54 -0700 From: Joshua Tinnin <krinklyfig@spymac.com> To: freebsd-questions@freebsd.org Subject: Re: Port upgrading - my way Message-ID: <200409250004.55134.krinklyfig@spymac.com> In-Reply-To: <5.1.0.14.2.20040924173912.06169ce0@209.152.117.178> References: <C25FD1D7-0D97-11D9-9B5C-000393934006@npc-usa.com> <5.1.0.14.2.20040924173912.06169ce0@209.152.117.178>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 24 September 2004 03:55 pm, "W. D." <WD@us-webmasters.com> wrote: <snip> > OK, how about adding a cron job by root like this? > > (Line will wrap. Everything between '===' on one line) > ========================================================== > 15 3 * * * /usr/local/bin/cvsup -h cvsup7.FreeBSD.org /usr/share/examples/cvsup/ports-supfile && portsdb -Uu && pkgdb -fu && cd /usr/ports && make index > ========================================================== > > > Then in the morning running: > > portversion -l "<" > > Would this automate things without causing problems? > Any other safe ways to automate the process? I run a script in a cron job every day (I changed the name of the user in the script to username - just use whatever path points to your ports supfile). I am new at scripting, so the out to /dev/null on every command might be redundant or unnecessary, and some of it probably isn't coded efficiently, but it works. Also, I still use portindex, which has been removed from ports, but the script can easily be modified to use portsdb -Uu. The script also depends on fastest_cvsup to pick the fastest server (/usr/ports/sysutils/fastest_cvsup). Here's root's crontab: # mail any output to username, no matter whose crontab this is MAILTO=username # # run 4am, every day 1 4 * * * /bin/sh /home/username/supfiles/sup > /var/log/crontab.log 2&>1 Here's the script: #!/bin/sh # modified from script found: # http://www.freebsdforums.org/forums/showthread.php?s=&threadid=1162 # posted by ajr TODAY=$(date +"%d-%m-%y") touch /var/log/supscript-$TODAY SERVER=`/usr/local/bin/fastest_cvsup -q -c us` if [ "${SERVER}" != "" ]; then # update ports, for cvsup-without-gui /usr/local/bin/cvsup -L 2 -h $SERVER /home/username/supfiles/ports-supfile 2>&1 | tee -a /var/log/supscript-$TODAY > /dev/null # update /usr/ports/INDEX and create INDEX.db; machines with lots # of RAM (>64Mb) and swap can use 'portsdb -Uu' as one command, # but portindex is faster # !!! portindex is no longer in ports /usr/local/bin/portindex 2>&1 | tee -a /var/log/supscript-$TODAY > /dev/null && /usr/local/sbin/portsdb -u 2>&1 | tee -a /var/log/supscript-$TODAY > /dev/null # check to see if we need any ports upgrading BODY=`/usr/local/sbin/portversion -v | grep needs` if [ "${BODY}" != "" ]; then echo "$BODY" | mail -s "Ports that need upgrading" username | tee -a /var/log/supscript-$TODAY > /dev/null fi # clean out /usr/ports/*/*/work and any outdated distfiles # prefer to run this manually # /usr/local/sbin/portsclean -CD 2>&1 | tee -a /var/log/supscript-$TODAY > /dev/null fi Here's my ports-supfile: #*default host=cvsup10.freebsd.org # sup script uses output of fastest-cvsup to determine host *default base=/usr/local/etc/cvsup *default prefix=/usr *default release=cvs tag=. *default delete use-rel-suffix *default compress ports-all I get two emails every day, one of which is the output of the the cron job, and the other is a verbose list of ports which have newer versions available. Everything is logged to /var/log/supscript-$TODAY (date on the end in dd-mm-yy). I run portupgrade manually, as I want to be able to choose what to upgrade first (and, depending on the changes, it might not be necessary to upgrade at all). - jt
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200409250004.55134.krinklyfig>