-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.sh
executable file
·37 lines (33 loc) · 1012 Bytes
/
deploy.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
#!/bin/bash
function healthCheck() {
echo "Waiting for Structr to be ready for deployment"
for i in $(seq 1 30)
do
STATUS_CODE=$(curl --write-out %{http_code} --silent localhost:8082/structr/health/ready)
if [ "$STATUS_CODE" -ne 200 ] ; then
echo "Status is $STATUS_CODE. Still waiting for Structr to start..."
sleep 5
else
echo "Running Structr instance found"
return 0
fi
done
echo "Structr failed to start. Exiting..."
exit 1
}
function deploy() {
echo "Starting deployment..."
exec 3>&1
STATUS_CODE=$(curl --write-out %{http_code} \
-HX-User:superadmin -HX-Password:superuser \
--silent -XPOST http://localhost:8082/structr/rest/maintenance/deploy -d '{mode:"import", source:"/repository"}' \
-o >(cat >&3))
if [ "$STATUS_CODE" -ne 200 ] ; then
echo "$STATUS_CODE Deployment failed!"
exit 1
else
echo "$STATUS_CODE: Deployment successfull!"
fi
}
healthCheck
deploy