Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Jun 2007 16:51:39 +0200
From:      Olivier Regnier <oregnier@oregnier.net>
To:        freebsd-questions@freebsd.org
Subject:   script to update my ports tree
Message-ID:  <467FD67B.9070604@oregnier.net>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------090304030508070909000707
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi everyone,

I made a shell script in /etc/periodic/daily/610.update-ports-tree and 
in my /etc/periodic.conf, this line : daily_update_ports_tree_enable="YES".

The problem is simple, my script doesn't start at all.

Can you help me please ?

Thank you :)



--------------090304030508070909000707
Content-Type: text/plain;
 name="610.update-ports-tree"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="610.update-ports-tree"

#!/bin/sh

# if there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
	. /etc/defaults/periodic.conf
	source_periodic_confs
fi

COUNTRIE=us
RETVAL=0
DATE=`date +%d/%m/%Y`
LOGFILE=/var/log/system-update-report.log

selectserver() {
	# Checking fastest cvs server
	server=`/usr/local/bin/fastest_cvsup -c $COUNTRIE | grep "1st" | \
	awk {'print $3'}`

	# Creating supfile
	sed "s/*default host=.*/*default host=$server/" \
	/usr/share/examples/cvsup/ports-supfile > /etc/ports-supfile
}

case "$daily_update_ports_tree_enable" in
	[Yy][Ee][Ss])

	# Begin
	selectserver

	# Fetching sources files
	/usr/bin/csup /etc/ports-supfile
	RETVAL=$?
	if [ $RETVAL != 0 ]
	then
		echo "-> $DATE - Ports tree: error while fetching sources files." \
		>> $LOGFILE
		exit 0
	fi

	# Creating INDEX.db file
	/usr/local/sbin/portsdb -Fu
	RETVAL=$?
	if [ $RETVAL != 0 ]
	then
		echo "-> $DATE - Ports tree: error while creating INDEX.db file" \
		>> $LOGFILE
		exit 0
	fi

	# Checking if applications needs to be updated
	LIST=`/usr/local/sbin/portversion -l "<"`
	RETVAL=$?
	if [ $RETVAL != 0 ]
	then
		echo "-> $DATE - Ports tree: error while checking updates" \
		>> $LOGFILE
		exit 0
	fi

	# Result
	if [ "$LIST" = "" ]
	then
		echo "-> $DATE - Ports tree: Up-To-Date" >> $LOGFILE
	else
		echo -e "-> $DATE - Ports tree: Up-To-Date. Here is list of \
		applications needs to be updated.\n\n$LIST" >> $LOGFILE
	fi
	*) rc=0;;
esac

exit $rc

--------------090304030508070909000707--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?467FD67B.9070604>