-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloop.sh
executable file
·49 lines (43 loc) · 1.17 KB
/
loop.sh
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
#!/bin/sh
set -e
# Load configuration
. build.conf
# Loop until we fail or the looping is stopped administratively
while ! [ -f failed ] && ! [ -f adminlock ]; do
# Figure out if this is the first build of a new day
touch -t `date "+%Y%m%d0000"` ${STATEDIR}/midnight
if ! [ ${STATEDIR}/lastsnap -nt ${STATEDIR}/midnight ]; then
BUILDTYPE=snap
touch ${STATEDIR}/lastsnap
else
BUILDTYPE=update
fi
rm ${STATEDIR}/midnight
# Send an email
(
echo "From: ${BUILDMAIL_FROM}"
for ADDR in ${BUILDMAIL_TO}; do
echo "To: ${ADDR}"
done
echo "Subject: `hostname` Portsnap build.sh ${BUILDTYPE}"
echo
# Do the build
if ! sh -e build.sh ${BUILDTYPE} 2>&1; then
touch failed;
else
# Upload if the build succeeded
sh upload.sh 2>&1 || true
fi
# Once a day, clean up portsnap-master
if [ ${BUILDTYPE} = "snap" ]; then
echo "`date`: Cleaning bits on portsnap-master"
ssh -i ${UPLOAD_KEY} ${UPLOAD_ACCT} \
sh portsnap-clean.sh 2>&1
fi
) | sendmail -t >/dev/null 2>/dev/null
done
# Send a warning if builds stop running
for ADDR in ${BUILDMAIL_TO}; do
echo "Subject: `hostname` Portsnap builds no longer running!" |
sendmail ${ADDR}
done