/[CCFs]/bin/autobuild
ViewVC logotype

Annotation of /bin/autobuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (hide annotations)
Mon Jun 28 15:44:20 2021 UTC (3 years, 4 months ago) by ccflib
Branch: MAIN
Changes since 1.11: +2 -2 lines
replaced ccflib@sciops.esa.int by ccf@sciops.esa.int

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.12 # $Id: autobuild,v 1.11 2021/06/28 15:19:36 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     # Notify by email to all only if there is something to build
95     # Otherwise, notify only the ccflib administrator,
96     # by the time being: eduardo.ojero@sciops.esa.int
97    
98     nothingtobuild=`cat $LOG | grep -c "Nothing to build"`
99    
100 ccflib 1.10 cat $LOG >> $MESSAGE
101 ccflib 1.6
102 ccflib 1.7
103 ccflib 1.9 # Define mail subject
104 ccflib 1.7
105 ccflib 1.9 subject="CCF autobuild run at `date` on `hostname`"
106 ccflib 1.1
107 ccflib 1.9 # Use mailx to send messages instead of sendmail
108 ccflib 1.1
109 ccflib 1.9 if [ "$nothingtobuild" != "0" ] ; then
110     mailx -s "$subject" eduardo.ojero@sciops.esa.int < $MESSAGE
111     else
112 ccflib 1.12 mailx -s "$subject" ccf@sciops.esa.int < $MESSAGE
113 ccflib 1.1 fi

  ViewVC Help
Powered by ViewVC 1.1.27