-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabtrigger
executable file
·81 lines (68 loc) · 2.52 KB
/
abtrigger
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# This is a simple cron job to serve as an autobuild trigger.
# This is meant to run as a cron job every five minutes, and
# will trigger the build system based on a trigger file.
# If the trigger file contains a list of routers, it will
# run that list. Otherwise, it will trigger a full catalog
# build.
# This trigger system is meant to be used with autobuild when
# running on a standalone bare-metal system. For use within
# the docker-rooterbuilder system, use abtrigger.docker as a
# wrapper for this script instead of trying to set up cron
# within a docker container.
######
#
# IMPORTANT: you MUST edit the following line to point to the
# config file you want to use for this instance of the script.
#
source /build/autobuild/autobuild19.conf
#
######
splitout() {
# Used to output the same text to both log and standard output.
# If running in a Docker container, will send all output to
# stdout instead.
if [ -f /.dockerenv ] ; then
echo "$*" >> /proc/1/fd/1
if [ "$(readlink -f /proc/$$/fd/1)" != "$(readlink -f /proc/1/fd/1)" ] ; then echo "$*" >> /proc/$$/fd/1 ; fi
else
logger -t autobuilder "$*"
echo "$*"
fi
}
splitecho() {
# Used to output the same text to standard output.
# If running in a Docker container, will send all output to
# stdout of #1 process instead.
if [ -f /.dockerenv ] ; then
echo "$*" >> /proc/1/fd/1
if [ "$(readlink -f /proc/$$/fd/1)" != "$(readlink -f /proc/1/fd/1)" ] ; then echo "$*" >> /proc/$$/fd/1 ; fi
else
echo "$*"
fi
}
if [ -f $TRIGGERFILE ] ; then
# User has requested an autobuild run.
# Check if sequence file exists; if not, start at 1.
if [ ! -f $SEQFILE ] ; then
splitout "abtrigger: Creating sequence file."
echo "1" > $SEQFILE
fi
# Grab the sequence number
SEQNO=`cat $SEQFILE`
SEQNEXT="$SEQNO"
let SEQNEXT++
echo $SEQNEXT > $SEQFILE
LIST=`tr '\n' ' ' < $TRIGGERFILE`
LIST=`echo ${LIST^^} | tr -d '\r'`
rm -f $TRIGGERFILE && splitout "abtrigger: Trigger file found and removed"
# Above will import contents of the trigger file as a
# single space delimited line.
splitout "abtrigger: Sequence $SEQNO, trigger file list: $LIST"
# Check if autobuilder running; if so, wait.
while [ -f $PIDFILE ] ; do
sleep 30
done
$AUTODIR/autobuild19 $SEQNO $LIST &>$AUTODIR/output/$SEQNO.build.txt &
splitout "abtrigger: autobuild19 sequence $SEQNO triggered with list: $LIST"
fi