1 |
#! /usr/local/bin/bash |
2 |
# |
3 |
# Giuseppe Vacanti, January 2000 |
4 |
# |
5 |
# + fetch new CCF deliveries |
6 |
# + build latest files |
7 |
# + move new files to CCF repository |
8 |
# |
9 |
# $Id: autobuild,v 1.3 2003/11/26 10:51:18 ccflib Exp $ |
10 |
# |
11 |
. $HOME/bin/ccflib.cfg |
12 |
##echo $me running on `date` |
13 |
export PATH=$HOME/bin:$PATH |
14 |
me=`basename $0` |
15 |
LOG=$HOME/autobuild.log |
16 |
exec 2>&1 |
17 |
exec 1>$LOG |
18 |
|
19 |
LOCK=$HOME/autobuild.lck |
20 |
unlock () { |
21 |
rm -f $LOCK |
22 |
} |
23 |
count=0 |
24 |
maxcount=10 |
25 |
while [ -e $LOCK -a $count -lt $maxcount ] ; do |
26 |
count=$[count + 1] |
27 |
echo $me: $LOCK exists. Sleeping 300s [$count] |
28 |
sleep 300 |
29 |
done |
30 |
if [ $count -lt $maxcount ] ; then |
31 |
touch $LOCK |
32 |
trap unlock EXIT |
33 |
getdeliveries |
34 |
buildlatest && acceptbuild |
35 |
else |
36 |
echo $me: $LOCK exists, and slept enough. Giving up. |
37 |
exit 1 |
38 |
fi |
39 |
|
40 |
# send email instead of using the cron output, so that it is possible to |
41 |
# get a meaningful subject line. |
42 |
if [ -s $LOG ] ; then |
43 |
/usr/lib/sendmail -t <<EOF |
44 |
To: ccflib@xmm.esac.esa.int |
45 |
Subject: CCF build `date` |
46 |
|
47 |
`cat $LOG` |
48 |
|
49 |
EOF |
50 |
fi |