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.7 |
# $Id: autobuild,v 1.6 2014/12/03 14:46:22 ccflib Exp $ |
8 |
ccflib |
1.3 |
# |
9 |
ccflib |
1.7 |
|
10 |
ccflib |
1.2 |
. $HOME/bin/ccflib.cfg |
11 |
ccflib |
1.5 |
|
12 |
ccflib |
1.1 |
##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 |
ccflib |
1.5 |
|
24 |
ccflib |
1.1 |
count=0 |
25 |
|
|
maxcount=10 |
26 |
ccflib |
1.7 |
trap unlock EXIT |
27 |
|
|
|
28 |
ccflib |
1.1 |
while [ -e $LOCK -a $count -lt $maxcount ] ; do |
29 |
|
|
count=$[count + 1] |
30 |
ccflib |
1.7 |
echo $me: $LOCK exists. Sleeping 60s [$count] |
31 |
|
|
sleep 60 |
32 |
ccflib |
1.1 |
done |
33 |
|
|
if [ $count -lt $maxcount ] ; then |
34 |
|
|
touch $LOCK |
35 |
ccflib |
1.7 |
# trap unlock EXIT |
36 |
ccflib |
1.1 |
getdeliveries |
37 |
|
|
buildlatest && acceptbuild |
38 |
|
|
else |
39 |
|
|
echo $me: $LOCK exists, and slept enough. Giving up. |
40 |
|
|
exit 1 |
41 |
|
|
fi |
42 |
|
|
|
43 |
ccflib |
1.6 |
# Notify by email using sendmail instead of via the cron job, so that |
44 |
|
|
# it is possible to get a meaningful subject line |
45 |
|
|
# |
46 |
|
|
# The email initially went to ccflib@xmm.esac.esa.int where the procmailrc file |
47 |
|
|
# copied it to xmm-it mailman mail list and stored it into a mailbox under ccflib |
48 |
|
|
# directory ($HOME/Mail/....). However, this mail is only telling that autobuild was |
49 |
ccflib |
1.7 |
# executed, in fact not even that but buildlatest. So, a change has been made in the |
50 |
ccflib |
1.6 |
# ccflib procmailrc file to filter out these messages and sent only to the |
51 |
|
|
# CCF Building system administrator (eduardo.ojero@esa.int). |
52 |
|
|
|
53 |
ccflib |
1.1 |
if [ -s $LOG ] ; then |
54 |
|
|
/usr/lib/sendmail -t <<EOF |
55 |
ccflib |
1.4 |
To: ccflib@xmm.esac.esa.int |
56 |
ccflib |
1.7 |
Subject: Run of autobuild@sasbld01 - CCF build at `date` |
57 |
|
|
|
58 |
|
|
Only for the ccflib administrator eyes. |
59 |
|
|
|
60 |
|
|
The following log was produced during the last build of autobuild: |
61 |
ccflib |
1.1 |
|
62 |
|
|
`cat $LOG` |
63 |
|
|
|
64 |
|
|
EOF |
65 |
|
|
fi |