From owner-freebsd-questions@FreeBSD.ORG Sat Sep 25 07:04:54 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1A8B316A4CE for ; Sat, 25 Sep 2004 07:04:54 +0000 (GMT) Received: from smtp807.mail.sc5.yahoo.com (smtp807.mail.sc5.yahoo.com [66.163.168.186]) by mx1.FreeBSD.org (Postfix) with SMTP id CCB2643D46 for ; Sat, 25 Sep 2004 07:04:53 +0000 (GMT) (envelope-from krinklyfig@spymac.com) Received: from unknown (HELO smogmonster.com) (krinklyfig@pacbell.net@64.171.1.210 with plain) by smtp807.mail.sc5.yahoo.com with SMTP; 25 Sep 2004 07:04:53 -0000 From: Joshua Tinnin To: freebsd-questions@freebsd.org Date: Sat, 25 Sep 2004 00:04:54 -0700 User-Agent: KMail/1.7 References: <5.1.0.14.2.20040924173912.06169ce0@209.152.117.178> In-Reply-To: <5.1.0.14.2.20040924173912.06169ce0@209.152.117.178> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200409250004.55134.krinklyfig@spymac.com> Subject: Re: Port upgrading - my way X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: krinklyfig@spymac.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Sep 2004 07:04:54 -0000 On Friday 24 September 2004 03:55 pm, "W. D." wrote: > 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