/[CCFs]/bin/autobuild
ViewVC logotype

Annotation of /bin/autobuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (hide annotations)
Tue Jul 27 15:36:35 2021 UTC (3 years, 3 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 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.13 # $Id: autobuild,v 1.12 2021/06/28 15:44:20 ccflib Exp $
8 ccflib 1.3 #
9 ccflib 1.7
10 ccflib 1.9 # 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 ccflib 1.10 cat $HEAD_MESSAGE >> $MESSAGE
30 ccflib 1.9
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 ccflib 1.2 . $HOME/bin/ccflib.cfg
49 ccflib 1.5
50 ccflib 1.9 # Add $HOME/bin to $PATH
51    
52 ccflib 1.1 export PATH=$HOME/bin:$PATH
53 ccflib 1.9
54     # Name the lock file and define function unlock
55 ccflib 1.1
56     LOCK=$HOME/autobuild.lck
57     unlock () {
58     rm -f $LOCK
59     }
60 ccflib 1.5
61 ccflib 1.9 # Do the work
62    
63 ccflib 1.1 count=0
64     maxcount=10
65 ccflib 1.7 trap unlock EXIT
66    
67 ccflib 1.1 while [ -e $LOCK -a $count -lt $maxcount ] ; do
68     count=$[count + 1]
69 ccflib 1.7 echo $me: $LOCK exists. Sleeping 60s [$count]
70     sleep 60
71 ccflib 1.1 done
72 ccflib 1.9
73 ccflib 1.1 if [ $count -lt $maxcount ] ; then
74     touch $LOCK
75 ccflib 1.7 # trap unlock EXIT
76 ccflib 1.9 # Get nay new CCF from incoming
77 ccflib 1.1 getdeliveries
78 ccflib 1.9 # 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 ccflib 1.1 buildlatest && acceptbuild
84     else
85     echo $me: $LOCK exists, and slept enough. Giving up.
86     exit 1
87     fi
88    
89 ccflib 1.9 # Reset redicrections to avoid unexpected results
90    
91     exec 1>&2 2>&-
92    
93    
94 ccflib 1.13 # 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 ccflib 1.9
102     nothingtobuild=`cat $LOG | grep -c "Nothing to build"`
103    
104 ccflib 1.10 cat $LOG >> $MESSAGE
105 ccflib 1.6
106 ccflib 1.7
107 ccflib 1.9 # Define mail subject
108 ccflib 1.7
109 ccflib 1.9 subject="CCF autobuild run at `date` on `hostname`"
110 ccflib 1.1
111 ccflib 1.9 # Use mailx to send messages instead of sendmail
112 ccflib 1.1
113 ccflib 1.9 if [ "$nothingtobuild" != "0" ] ; then
114     mailx -s "$subject" eduardo.ojero@sciops.esa.int < $MESSAGE
115 ccflib 1.1 fi

  ViewVC Help
Powered by ViewVC 1.1.27