1 |
ccflib |
1.5 |
#! /bin/bash |
2 |
ccflib |
1.1 |
# |
3 |
|
|
# + fetch new CCF deliveries |
4 |
|
|
# + build latest files |
5 |
|
|
# + move new files to CCF repository |
6 |
|
|
# |
7 |
ccflib |
1.6 |
# $Id: autobuild,v 1.5 2014/12/02 15:57:10 ccflib Exp $ |
8 |
ccflib |
1.3 |
# |
9 |
ccflib |
1.2 |
. $HOME/bin/ccflib.cfg |
10 |
ccflib |
1.5 |
|
11 |
ccflib |
1.1 |
##echo $me running on `date` |
12 |
|
|
export PATH=$HOME/bin:$PATH |
13 |
|
|
me=`basename $0` |
14 |
|
|
LOG=$HOME/autobuild.log |
15 |
|
|
exec 2>&1 |
16 |
|
|
exec 1>$LOG |
17 |
|
|
|
18 |
|
|
LOCK=$HOME/autobuild.lck |
19 |
|
|
unlock () { |
20 |
|
|
rm -f $LOCK |
21 |
|
|
} |
22 |
ccflib |
1.5 |
|
23 |
ccflib |
1.1 |
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 |
ccflib |
1.6 |
# Notify by email using sendmail instead of via the cron job, so that |
41 |
|
|
# it is possible to get a meaningful subject line |
42 |
|
|
# |
43 |
|
|
# The email initially went to ccflib@xmm.esac.esa.int where the procmailrc file |
44 |
|
|
# copied it to xmm-it mailman mail list and stored it into a mailbox under ccflib |
45 |
|
|
# directory ($HOME/Mail/....). However, this mail is only telling that autobuild was |
46 |
|
|
# executed, in fact not evn that but buildlatest. So, a change has been made in the |
47 |
|
|
# ccflib procmailrc file to filter out these messages and sent only to the |
48 |
|
|
# CCF Building system administrator (eduardo.ojero@esa.int). |
49 |
|
|
|
50 |
ccflib |
1.1 |
if [ -s $LOG ] ; then |
51 |
|
|
/usr/lib/sendmail -t <<EOF |
52 |
ccflib |
1.4 |
To: ccflib@xmm.esac.esa.int |
53 |
ccflib |
1.1 |
Subject: CCF build `date` |
54 |
|
|
|
55 |
|
|
`cat $LOG` |
56 |
|
|
|
57 |
|
|
EOF |
58 |
|
|
fi |