-
Notifications
You must be signed in to change notification settings - Fork 15
/
checkStagingURLs.sh
executable file
·364 lines (331 loc) · 16.6 KB
/
checkStagingURLs.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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
#!/bin/bash
# verify staging/development/stable URLs are present and not 404'd
version_jbt=""
version_ds=""
devstudioReleaseVersion=10.0
eclipseReleaseName=neon
quals=""
static=""
quiet=0
skipdiscovery=0; # flag to skip discovery sites check
onlydiscovery=0; # flag to only check discovery sites
OPTIONS="" # container for options so we can dump them into the console for logging
logn ()
{
if [[ $quiet == 0 ]]; then echo -n -e "$1"; fi
}
log ()
{
if [[ $quiet == 0 ]]; then echo -e "$1"; fi
}
logerr ()
{
if [[ $quiet == 0 ]]; then
echo -e "$2"
else
echo -e "$1$2"
fi
}
usage ()
{
log "Usage : $0 -vrjbt [version_jbt] -vrds [version_ds] -dsrv [devstudioReleaseVersion] -ern [eclipseReleaseName]"
log "Example: $0 -vrjbt 4.4.1.Final -ern neon -qual development"
log "Example: $0 -vrds 10.1.0.GA -dsrv 10.0 -qual stable"
log "Example: $0 -vrjbt 4.4.1.Final -vrds 10.1.0.GA -dsrv 10.0 -ern neon -quals \"development stable\""
log ""
exit 1
}
if [[ $# -lt 1 ]]; then usage; fi
# read commandline args
while [[ "$#" -gt 0 ]]; do
case $1 in
'-vrjbt') version_jbt="$2"; shift 1;;
'-vrds') version_ds="$2"; shift 1;;
'-dsrv') devstudioReleaseVersion="$2"; shift 1;;
'-ern') eclipseReleaseName="$2"; shift 1;;
'-qual'|'-quals') quals="${quals} $2"; shift 1;;
'-q') quiet="1"; shift 0;;
'-skipdiscovery') skipdiscovery=1; OPTIONS="${OPTIONS} skipdiscovery"; shift 0;;
'-onlydiscovery') onlydiscovery=1; OPTIONS="${OPTIONS} onlydiscovery"; shift 0;;
esac
shift 1
done
# default
if [[ ! ${quals} ]]; then
quals=staging # or snapshots or development or stable
fi
tmpdir=`mktemp -d`
mkdir -p $tmpdir
checkCompositeXML ()
{
url=$1
# echo "Check children of $url ..."
# parse the file for <child location="" URLs>
urls=$(wget -q --no-check-certificate ${url} -O - | grep "<child location" | sed -e "s#.*location=.\(.\+\).\/>.*#\1#")
for a in ${urls}; do
if [[ ${a} != "http"* ]]; then # relative path
a=${url%/composite*xml}/${a}
fi
logn " > ${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
}
norm="\033[0;39m"
green="\033[1;32m"
yellow='\e[0;30m\e[1;43m' # yellow reversed
red="\033[1;31m"
OK=0
notOK=0
version_ds_latest=${version_ds%.*}.latest
for qual in $quals; do
# when not staging, check for static/ URLs and don't check for .latest symlinks but actual files
if [[ ${qual} == "development" ]] || [[ ${qual} == "stable" ]]; then
static="static/"
fi
if [[ ${version_jbt} ]]; then
# discovery sites
if [[ ${skipdiscovery} -lt 1 ]] || [[ ${onlydiscovery} -gt 0 ]]; then
for u in https://download.jboss.org/jbosstools/${static}${eclipseReleaseName}/${qual}/builds \
https://download.jboss.org/jbosstools/${static}${eclipseReleaseName}/${qual}/updates; do
for f in discovery.central ; do
for ff in compositeContent.xml compositeArtifacts.xml jbosstools-earlyaccess.properties jbosstools-directory.xml plugins/; do
if [[ ${f} == "discovery.central" ]] && [[ ${ff/earlyaccess.properties/} != ${ff} ]]; then continue; fi # skip check for central + earlyaccess.properties
if [[ ${u/builds/} != ${u} ]]; then
if [[ ${qual} == "snapshots" ]]; then
b=${u}/jbosstools-${f}_${version_jbt}/latest/all/repo/${ff} # builds
else
b=${u}/jbosstools-${version_jbt}-build-${f}/latest/all/repo/${ff} # builds
fi
else
b="${u}/${f}/${version_jbt}/${ff} ${u}/${f}/${ff}" # updates
fi
for a in ${b}; do
# skip checks for staging/updates/discovery.*/composite*.xml
if [[ ${a} == *"/staging/updates/discovery.central/composite"*".xml" ]] || [[ ${a} == *"/staging/updates/discovery.earlyaccess/composite"*".xml" ]]; then
continue
fi
if [[ ${ff} == "composite"*".xml" ]] || [[ ${a} == ${u}/${f}/${version_jbt}/${ff} ]] || [[ ${u/builds/} != ${u} ]]; then
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
fi
if [[ ${ff} == "composite"*".xml" ]]; then
checkCompositeXML ${a}
elif [[ ${a} == ${u}/${f}/${version_jbt}/${ff} ]] || [[ ${u/builds/} != ${u} ]]; then
if [[ ${ff} == "plugins/" ]]; then
jars=$(curl -s ${a} | grep ".jar" | sed -e "s#.\+href=\"\([^\"]\+\)\".\+#\1#")
# check jar 404s
for j in ${jars}; do
logn " + ${j} : "; stat=$(curl -I -s ${a}${j} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr " + ${j} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
elif [[ ${ff/directory.xml} != ${ff} ]]; then
jars=$(curl -s ${a} | grep "url" | sed -e "s#.\+url=\"\([^\"]\+\)\".\+#\1#")
# check jar 404s
for j in ${jars}; do
logn " + ${j} : "; stat=$(curl -I -s ${j}} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr " + ${j} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
fi
fi
done
done
done
log ""
done
fi
if [[ ${onlydiscovery} -lt 1 ]]; then
# build folders
for u in https://download.jboss.org/jbosstools/${static}${eclipseReleaseName}/${qual}/builds; do
for f in coretests central integration-tests core; do
for ff in repo/artifacts.xml.xz repo/content.xml.xz repo/category.xml repo/buildinfo.json repository.zip repository.zip.sha256; do
a=${u}/jbosstools-${version_jbt}-build-${f}/latest/all/${ff}
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
log ""
done
done
for u in https://download.jboss.org/jbosstools/${static}${eclipseReleaseName}/${qual}/builds; do
for f in fuse-extras; do
for ff in repo/artifacts.xml.xz repo/content.xml.xz repo/category.xml repo/buildinfo.json; do # no repo zip to check here
a=${u}/jbosstools-${version_jbt}-build-${f}/latest/all/${ff}
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
log ""
done
done
# update sites
for u in https://download.jboss.org/jbosstools/${static}${eclipseReleaseName}/${qual}/updates; do
for f in fuse-extras coretests central integration-tests core; do
for ff in artifacts.xml.xz content.xml.xz category.xml buildinfo.json; do
a=${u}/${f}/${version_jbt}/${ff}
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
log ""
done
done
# released artifacts linked from tools.jboss.org
if [[ $qual != "staging" ]]; then
for u in https://download.jboss.org/jbosstools/${static}${eclipseReleaseName}/${qual}/updates/core; do
for f in src updatesite-core; do
for ff in jbosstools-${version_jbt}-${f}.zip jbosstools-${version_jbt}-${f}.zip.sha256; do
a=${u}/${ff}
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
done
done
fi
fi
fi
##################################
if [[ ${version_ds} ]]; then
# check installer build folder [INTERNAL]
version_ds_latest_actual=${version_ds_latest} # normally this is a .latest filename
if [[ ${qual} == "stable" ]]; then
version_ds_latest_actual=${version_ds} # but for stable, look for .GA
fi
# discovery sites
if [[ ${skipdiscovery} -lt 1 ]] || [[ ${onlydiscovery} -gt 0 ]]; then
for u in https://devstudio.redhat.com/${static}${devstudioReleaseVersion}/${qual}/builds \
https://devstudio.redhat.com/${static}${devstudioReleaseVersion}/${qual}/updates; do
for f in discovery.central ; do
for ff in compositeContent.xml compositeArtifacts.xml devstudio-earlyaccess.properties devstudio-directory.xml plugins/; do
if [[ ${f} == "discovery.central" ]] && [[ ${ff/earlyaccess.properties/} != ${ff} ]]; then continue; fi # skip check for central + earlyaccess.properties
if [[ ${u/builds/} != ${u} ]]; then
if [[ ${qual} == "snapshots" ]]; then
b=${u}/jbosstools-${f}_${version_jbt}/latest/all/repo/${ff} # builds
else
b=${u}/devstudio-${version_ds}-build-${f}/latest/all/repo/${ff} # builds
fi
else
b="${u}/${f}/${version_ds}/${ff} ${u}/${f}/${ff}" # updates
fi
for a in ${b}; do
# skip checks for staging/updates/discovery.*/composite*.xml
if [[ ${a} == *"/staging/updates/discovery.central/composite"*".xml" ]] || [[ ${a} == *"/staging/updates/discovery.earlyaccess/composite"*".xml" ]]; then
continue
fi
if [[ ${ff} == "composite"*".xml" ]] || [[ ${a} == ${u}/${f}/${version_ds}/${ff} ]] || [[ ${u/builds/} != ${u} ]]; then
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
fi
if [[ ${ff} == "composite"*".xml" ]]; then
checkCompositeXML ${a}
elif [[ ${a} == ${u}/${f}/${version_ds}/${ff} ]] || [[ ${u/builds/} != ${u} ]]; then
if [[ ${ff} == "plugins/" ]]; then
jars=$(curl -s ${a} | grep ".jar" | sed -e "s#.\+href=\"\([^\"]\+\)\".\+#\1#")
# check jar 404s
for j in ${jars}; do
logn " + ${j} : "; stat=$(curl -I -s ${a}${j} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr " + ${j} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
elif [[ ${ff/directory.xml} != ${ff} ]]; then
jars=$(curl -s ${a} | grep "url" | sed -e "s#.\+url=\"\([^\"]\+\)\".\+#\1#")
# check jar 404s
for j in ${jars}; do
logn " + ${j} : "; stat=$(curl -I -s ${a/${ff}/${j}} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr " + ${j} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
fi
fi
done
done
done
log ""
done
fi
if [[ ${onlydiscovery} -lt 1 ]]; then
# no longer publishing to wonka
# zips: only if /stable/ or /staging/
# if [[ ${qual} != "development" ]]; then
# for u in http://wonka.mw.lab.eng.bos.redhat.com/rhd/devstudio/${devstudioReleaseVersion}/${qual}/builds/devstudio-${versionWithRespin_ds}-build-product/latest/all; do
# for f in devstudio-${versionWithRespin_ds_latest_actual}-installer-standalone.jar \
# devstudio-${versionWithRespin_ds_latest_actual}-updatesite-central.zip devstudio-${versionWithRespin_ds_latest_actual}-updatesite-core.zip; do
# for ff in $f ${f}.sha256; do
# a=${u}/${ff}
# logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
# if [[ $stat ]]; then # try backup URL (.latest or .GA)
# #logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"
# log ""
# a=${u}/${ff/.latest/.GA}
# logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
# fi
# if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
# done
# done
# done
# fi
# log ""
# installer build folder [EXTERNAL]
for u in https://devstudio.redhat.com/${static}${devstudioReleaseVersion}/${qual}/builds/devstudio-${version_ds}-build-product/latest/all; do
for f in codereadystudio-${version_ds_latest_actual}-installer-standalone.jar \
codereadystudio-${version_ds_latest_actual}-updatesite-central.zip codereadystudio-${version_ds_latest_actual}-updatesite-core.zip; do
for ff in $f ${f}.sha256; do
a=${u}/${ff}
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ $stat ]]; then # try backup URL (.latest or .GA)
#logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"
log ""
a=${u}/${ff/.latest/.GA}
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
fi
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${u}/${ff} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
done
done
log ""
# build folders
for u in https://devstudio.redhat.com/${static}${devstudioReleaseVersion}/${qual}/builds; do
for f in central; do
for ff in repo/artifacts.xml.xz repo/content.xml.xz repo/category.xml repo/buildinfo.json repository.zip repository.zip.sha256; do
a=${u}/devstudio-${version_ds}-build-${f}/latest/all/${ff}
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
log ""
done
done
for u in https://devstudio.redhat.com/${static}${devstudioReleaseVersion}/${qual}/builds; do
for f in fuse-extras; do
for ff in repo/artifacts.xml.xz repo/content.xml.xz repo/category.xml repo/buildinfo.json; do # no repo zip to check here
a=${u}/devstudio-${version_ds}-build-${f}/latest/all/${ff}
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
log ""
done
done
# zips
for u in https://devstudio.redhat.com/${static}${devstudioReleaseVersion}/${qual}/updates; do
for f in core/codereadystudio-${version_ds}-updatesite-core.zip core/devstudio-${version_ds}-target-platform.zip \
central/codereadystudio-${version_ds}-updatesite-central.zip core/devstudio-${version_ds}-target-platform-central.zip; do
for ff in $f ${f}.sha256; do
logn "${u}/${ff} : "; stat=$(curl -I -s ${u}/${ff} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${u}/${ff} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
done
done
log ""
# check update sites
for u in https://devstudio.redhat.com/${static}${devstudioReleaseVersion}/${qual}/updates; do
for f in fuse-extras core central; do
for ff in artifacts.xml.xz content.xml.xz category.xml buildinfo.json; do
a=${u}/${f}/${version_ds}/${ff}
logn "${a} : "; stat=$(curl -I -s ${a} | egrep "404 Not Found")
if [[ ! $stat ]]; then log "${green}OK${norm}"; let OK+=1; else logerr "${a} : " "${red}NO${norm} \n$(curl -I -s ${a})"; let notOK+=1; fi
done
log ""
done
done
fi
fi
done
##################################
log "[INFO] [${quals} ] URLs found: ${OK} (${OPTIONS})"
if [[ ${notOK} -gt 0 ]]; then
logerr "" "[ERROR] [${quals} ] URLs missing: ${notOK} (${OPTIONS})"
exit $notOK
fi