-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·81 lines (71 loc) · 1.78 KB
/
build.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
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
81
#!/bin/bash
NAME=`basename $( dirname ${BASH_SOURCE[0]} )`
if [ "${NAME}" == "." ]; then
NAME=`basename $(pwd)`
fi
DIRNAME=`dirname ${BASH_SOURCE[0]}`
DIRNAME=`readlink -f ${DIRNAME}`
if [ "${DIRNAME}" == "." ]; then
DIRNAME=`pwd`
fi
INSTANCECOUNT=0
for i in ${DIRNAME}/print-instance-args_*.sh ; do
INSTANCE=`basename $i ` #Just the file
INSTANCE=${INSTANCE:20} #Remove the first 20 chars (print-instance-args_)
INSTANCE="_"${INSTANCE:0:-3} #Remove the last 3 chars (.sh)
if [ "${1}" == "main" ]; then
set -- "" "${@:2}"
fi
if [ "${INSTANCE:1}" == "main" ]; then
INSTANCE=""
fi
if [ "${INSTANCE:1}" == "*" ]; then
break;
else
INSTANCECOUNT=` expr ${INSTANCECOUNT} + 1 `
fi
if [ "${1}" == "${INSTANCE:1}" -o "${1}" == "" ]; then
if [ "${MATCHED}" == "1" ]; then
break
fi
if [ "${1}" == "${INSTANCE:1}" ]; then
MATCHED=1
fi
#Do this for each of them (or the match)
#echo Name: ${NAME}, DirName: ${DIRNAME}, Instance: ${INSTANCE:1}, Counter: ${INSTANCECOUNT}.
#For builds, we don't actually do anything.
fi
done
if [ "${INSTANCECOUNT}" == "0" ]; then
echo ${0}: No instances found, nothing was done. > /dev/null
fi
cd /var/scripts/docker/${NAME}
if [ -f already-disabled ]; then
touch already-already-disabled
else
touch already-disabled
fi
if [ -f disabled ]; then
touch already-disabled
else
touch disabled
fi
if [ -f $(dirname ${BASH_SOURCE[0]})/build-extra.sh ]; then
$(dirname ${BASH_SOURCE[0]})/build-extra.sh ${1}
fi
if [ "${1}" == "--no-cache" ]; then
NOCACHE="--no-cache"
else
NOCACHE=""
fi
docker build $NOCACHE -t gadjet/${NAME}:latest -t gadjet/${NAME}:`date +%s` .
if [ -f already-disabled ]; then
rm already-disabled
else
rm disabled
fi
if [ -f already-already-disabled ]; then
rm already-already-disabled
touch already-disabled
fi
cd -