-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.sh
executable file
·268 lines (230 loc) · 6.29 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#!/bin/bash
source bin/include/utils.sh
mkdir -p build
PLUGINS=()
PATCHES=()
HOTFIXES=()
TRUSTEDCERTS=()
OBJECTS=()
while getopts ":b:t:z:w:m:e:p:s:o:l:" opt; do
case ${opt} in
l ) LABEL=${OPTARG}
;;
b ) SSB=${OPTARG}
;;
t ) SPTARGET=${OPTARG}
;;
z ) IIQ_ZIP=${OPTARG}
;;
c )
TRUSTEDCERTS+=("${OPTARG}")
;;
m )
PLUGINS+=("${OPTARG}")
;;
p )
PATCHES+=("${OPTARG}")
;;
e )
HOTFIXES+=("${OPTARG}")
;;
o )
OBJECTS+=("${OPTARG}")
;;
s ) SKIP_DEMO_COMPANY_DATA=y
;;
w ) IIQ_WAR=${OPTARG}
;;
\? ) echo "Usage: ./start.sh [-b <existing SSB build directory>] [-t SPTARGET] [-z <identityIQ zip>] [-w <existing WAR file>]"
;;
esac
done
if [[ ! -z $TAG ]]; then
greenecho " => Using image tag ${LABEL}"
fi
# Validate WAR locator inputs
if [[ -z $SSB ]] && [[ -z $IIQ_ZIP ]] && [[ -z $IIQ_WAR ]]; then
echo "You must specify an IIQ zip (-z), an IIQ war (-w), or an SSB build directory (-b)"
exit 5
fi
# Validate incompatible inputs
if [[ ! -z $SSB ]] && [[ ! -z $IIQ_ZIP ]]; then
echo "The zip (-z) and build (-b) options are mutually exclusive and you specified both"
exit 5
fi
# Validate specified locations
if [[ ! -z "$IIQ_ZIP" ]] && [[ ! -e "$IIQ_ZIP" ]]; then
redecho "IIQ zip file $IIQ_ZIP does not exist"
exit 5
fi
if [[ ! -z $IIQ_WAR ]] && [[ ! -e $IIQ_WAR ]]; then
redecho "IIQ war file $IIQ_WAR does not exist"
exit 5
fi
for plugin in "${PLUGINS[@]}"
do
if [[ ! -e $plugin ]]; then
redecho "Cannot find plugin $plugin"
exit 5
fi
done
COMPOSE_PATH=$(which docker-compose)
if [[ ! -z $(echo "$COMPOSE_PATH" | grep "not found") ]]; then
redecho "Cannot find the docker-compose command"
exit 5
fi
greenecho " => Creating and cleaning build directory"
HERE=`pwd`
mkdir -p ${HERE}/build/tmp
BUILD="${HERE}/build"
if [ -e "${BUILD}/identityiq.war" ]; then
rm "${BUILD}/identityiq.war"
fi
greenecho " => Build directory is ${BUILD}"
IIQ_VERSION=
IIQ_PATCH=
# Sanity checking for optional SSB build
if [[ ! -z $SSB ]]; then
if [[ ! -z $(echo "${SSB}" | grep "git\\.") ]]; then
greenecho " => SSB looks like a Git repo, checking it out to the 'build/tmp/ssb' folder..."
pushd "${BUILD}/tmp"
# This operation is expensive, see if the repo is the same as last time and don't delete if it is
if [[ -e ./repo ]]; then
OLDREPO=`cat ./repo`
if [[ -e ssb ]] && [[ "${SSB}" != "${OLDREPO}" ]]; then
# Refresh
rm -rf ssb/*
git clone "${SSB}" ssb
else
# Update
pushd ssb
git pull
popd
fi
else
# New
git clone "${SSB}" ssb
fi
echo ${SSB} > ./repo
SSB=${BUILD}/tmp/ssb
popd
greenecho " => SSB checked out from Git"
fi
SSB=${SSB%/}
if [[ ! -f "${SSB}/build.xml" ]]; then
redecho "Option -b directory '${SSB}' does not contain a build.xml"
exit 1
fi
if [[ -z "${SPTARGET}" ]]; then
redecho " !! SSB specified but no SPTARGET defined; using 'sandbox' by default"
SPTARGET=sandbox
fi
BUILD_PROPERTIES=${SSB}/build.properties
if [[ ! -e ${BUILD_PROPERTIES} ]]; then
BUILD_PROPERTIES=${SSB}/${SPTARGET}.build.properties
if [[ ! -e ${BUILD_PROPERTIES} ]]; then
redecho "No build.properties or ${SPTARGET}.build.properties found"
exit 1
fi
fi
# This goofy construct is needed to compensate for DOS-formatted files with a \r in them
IIQ_VERSION=`grep IIQVersion ${BUILD_PROPERTIES} | head -1 | awk -F "=" '{print $2}' | tr -d '\r'`
IIQ_PATCHLEVEL=`grep IIQPatchLevel ${BUILD_PROPERTIES} | awk -F "=" '{print $2}' | tr -d '\r'`
if [[ ! -z ${IIQ_PATCHLEVEL} ]]; then
IIQ_PATCH="$IIQ_VERSION$IIQ_PATCHLEVEL"
greenecho " => Identified IIQ patch $IIQ_PATCH"
fi
fi
ANT=`which ant`
if [[ -z ${ANT} ]]; then
redecho "The 'ant' executable is not available on your path"
exit 2
fi
JAVA=`which java`
if [[ -z ${JAVA} ]]; then
redecho "The 'java' executable is not available on your path"
exit 3
fi
if [[ ! -z ${SSB} ]]; then
greenecho " => SSB configuration -- "
echo " SSB build: ${SSB}/build.xml"
echo " SSB SPTARGET: ${SPTARGET}"
fi
if [[ ! -z $IIQ_ZIP ]]; then
IIQ_ZIP=`realname "${IIQ_ZIP}"`
fi
# Start building
if [[ ! -z ${SSB} ]]; then
greenecho " => Building SSB..."
export SPTARGET
pushd ${SSB}
mkdir -p build
ant clean war >> ${BUILD}/build.log 2>&1
if [[ ! -e build/deploy/identityiq.war ]]; then
redecho "The SSB build does not appear to have produced an identityiq.war; please see the build.log for details"
exit 9
fi
cp build/deploy/identityiq.war ${BUILD} 2> /dev/null
popd
else
if [[ ! -z "$IIQ_ZIP" ]]; then
greenecho " => No SSB; extracting WAR from identityiq ZIP file"
pushd ${BUILD}
unzip -qo "$IIQ_ZIP"
popd
else
cp "${IIQ_WAR}" "${BUILD}/identityiq.war"
fi
fi
if [[ ! -e ${BUILD}/identityiq.war ]]; then
redecho "The build directory does not contain an identityiq.war"
exit 9
fi
cp ${BUILD}/identityiq.war iiq-build/sailpoint/
mkdir -p iiq-build/src/patch
mkdir -p iiq-build/src/efix
mkdir -p iiq-build/src/plugins
mkdir -p iiq-build/src/certs
mkdir -p iiq-build/src/objects
rm -f iiq-build/src/plugins/*.zip
rm -f iiq-build/src/patch/*.jar
rm -f iiq-build/src/efix/*.zip
rm -f iiq-build/src/efix/*.jar
rm -rf iiq-build/src/objects/*
touch iiq-build/src/efix/.keep
touch iiq-build/src/patch/.keep
touch iiq-build/src/plugins/.keep
touch iiq-build/src/certs/.keep
touch iiq-build/src/objects/.keep
for patch in "${PATCHES[@]}"
do
greenecho " => Including patch archive $patch"
cp "$patch" "iiq-build/src/patch"
done
for efix in "${HOTFIXES[@]}"
do
greenecho " => Including efix archive $efix"
cp "$efix" "iiq-build/src/efix"
done
for plugin in "${PLUGINS[@]}"
do
greenecho " => Including plugin archive $plugin"
cp "$plugin" "iiq-build/src/plugins"
done
for cert in "${TRUSTEDCERTS[@]}"
do
greenecho " => Including trusted SSL certificate $cert"
cp "$cert" "iiq-build/src/certs"
done
for object in "${OBJECTS[@]}"
do
greenecho " => Including object $object"
cp -rf "$object" "iiq-build/src/objects"
done
greenecho " => Building Docker containers, please wait a minute or two..."
docker-compose --progress quiet build
if [[ ! -z "${LABEL}" ]]; then
greenecho " => Tagging image 'latest' with $LABEL"
docker tag git.identityworksllc.com:5005/idw/idw-sailpoint/sailpoint-docker:latest "git.identityworksllc.com:5005/idw/idw-sailpoint/sailpoint-docker:$LABEL"
fi
greenecho " => All done!"