#!/bin/sh
# -------------------
# Global settings.
# -------------------
rep=/usr/ports
yplog=/var/log/yplog.log
nplog=/var/log/nplog.log
# --------------------
# Functions.
# --------------------
nostop () {
echo `date '+%a %b %d %T'` "ports: failed /usr/ports doesnt seem to exist" >> $nplog
}
ohyes () {
echo `date '+%a %b %d %T'` "ports: the port tree is up-to-date" >> $yplog
}
# --------------------
# Signals.
# --------------------
trap 'echo -n "error occured with signal [1]: Hangup from: " >> $nplog ; \
awk "NR==$LINENO" $0 | sed "s/^[ \t]*//" >> $nplog ; exit 1' 1
trap 'echo -n "error occured with signal [2]: Interrupt from: " >> $nplog ; \
awk "NR==$LINENO" $0 | sed "s/^[ \t]*//" >> $nplog ; exit 2' 2
trap 'echo -n "error occured with signal [3]: Quit from: " >> $nplog ; \
awk "NR==$LINENO" $0 | sed "s/^[ \t]*//" >> $nplog ; exit 3' 3
trap 'echo -n "error occured with signal [6]: Abort from: " >> $nplog ; \
awk "NR==$LINENO" $0 | sed "s/^[ \t]*//" >> $nplog ; exit 6' 6
trap 'echo -n "error occured with signal [9]: Killed from: " >> $nplog ; \
awk "NR==$LINENO" $0 | sed "s/^[ \t]*//" >> $nplog ; exit 9' 9
trap 'echo -n "error occured with signal [15]: Dying on signal from: " >> $nplog ; \
awk "NR==$LINENO" $0 | sed "s/^[ \t]*//" >> $nplog ; exit 15' 15
# --------------------
# Program.
# --------------------
if [ -d $rep ]; then
/usr/local/bin/cvsup -g -L 2 /root/cvsup/ports-supfile
cd /usr/ports && make fetchindex
cd /usr/ports && make index
/usr/local/sbin/portsdb -Uu
ohyes
else
nostop
fi
# End of file
Partager