/[CCFs]/bin/autobuild
ViewVC logotype

Contents of /bin/autobuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (show annotations)
Tue Jul 27 15:36:35 2021 UTC (3 years, 4 months ago) by ccflib
Branch: MAIN
CVS Tags: HEAD
Changes since 1.12: +8 -6 lines
removed any notification mail when something has been built

1 #! /bin/bash
2 #
3 # + fetch new CCF deliveries
4 # + build latest files
5 # + move new files to CCF repository
6 #
7 # $Id: autobuild,v 1.12 2021/06/28 15:44:20 ccflib Exp $
8 #
9
10 # Name and initialize $LOG file
11
12 LOG=$HOME/autobuild.log
13 [ -f "$LOG" ] && rm -f $LOG
14 touch $LOG
15
16 # Name and initialize HEAD_MESSAGE and MESSAGE to be sued for mail
17
18 HEAD_MESSAGE="$HOME/head_message"
19 MESSAGE="$HOME/MESSAGE"
20
21 [ -f "$HEAD_MESSAGE" ] && rm -f $HEAD_MESSAGE
22 [ -f "$MESSAGE" ] && rm -f $MESSAGE
23
24 touch $HEAD_MESSAGE $MESSAGE
25
26 echo "CCF autobuild run at `date` on `hostname`" >> $HEAD_MESSAGE
27 echo "-----------------------------------------------------------------------" >> $HEAD_MESSAGE
28
29 cat $HEAD_MESSAGE >> $MESSAGE
30
31 me=`basename $0`
32
33
34 # Redirects stderr (2) to stdout (1)
35
36 exec 2>&1
37
38 # Redirects the stdout to $LOG for the whole script
39
40 exec > $LOG
41
42 echo "-> $me running on "`date`
43 echo
44
45
46 # Source configuration settings
47
48 . $HOME/bin/ccflib.cfg
49
50 # Add $HOME/bin to $PATH
51
52 export PATH=$HOME/bin:$PATH
53
54 # Name the lock file and define function unlock
55
56 LOCK=$HOME/autobuild.lck
57 unlock () {
58 rm -f $LOCK
59 }
60
61 # Do the work
62
63 count=0
64 maxcount=10
65 trap unlock EXIT
66
67 while [ -e $LOCK -a $count -lt $maxcount ] ; do
68 count=$[count + 1]
69 echo $me: $LOCK exists. Sleeping 60s [$count]
70 sleep 60
71 done
72
73 if [ $count -lt $maxcount ] ; then
74 touch $LOCK
75 # trap unlock EXIT
76 # Get nay new CCF from incoming
77 getdeliveries
78 # Let do the two next steps in this way so as
79 # the acceptbuild will be done ONLY when buildlatest
80 # exits with return state 0. For example, if
81 # buildlatest has nothing to build the exit state is -1
82 # therefore acceptbuild is not executed.
83 buildlatest && acceptbuild
84 else
85 echo $me: $LOCK exists, and slept enough. Giving up.
86 exit 1
87 fi
88
89 # Reset redicrections to avoid unexpected results
90
91 exec 1>&2 2>&-
92
93
94 # Capture "Nothing to build" in nothingtobuild.
95 # If nothingtobuild = 0 there were builds.
96 # If nothingtobuild = 1, nothing was built.
97 # In case nothing was built, just simply inform the
98 # designated ccflib admin. Otherwise, do nothing until
99 # later on the do_checkupdates will report the proper
100 # mail distribution list.
101
102 nothingtobuild=`cat $LOG | grep -c "Nothing to build"`
103
104 cat $LOG >> $MESSAGE
105
106
107 # Define mail subject
108
109 subject="CCF autobuild run at `date` on `hostname`"
110
111 # Use mailx to send messages instead of sendmail
112
113 if [ "$nothingtobuild" != "0" ] ; then
114 mailx -s "$subject" eduardo.ojero@sciops.esa.int < $MESSAGE
115 fi

  ViewVC Help
Powered by ViewVC 1.1.27