-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild-and-start.sh
executable file
·77 lines (60 loc) · 2.21 KB
/
build-and-start.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
#!/bin/bash
# build Docker images or not
DOCKER_BUILD=1
if [ $1 = "SKIPBUILD" ]
then
DOCKER_BUILD=0
fi
# assemble date and a salt as image version
DATE=`date +"%Y%m%d"`
SALT="1"
# version a la 20200701_1
DATE_TAG=$DATE"_"$SALT
# tag for the docker images (default "master" for latest stage in master branch)
TAG="${TAG:-master}"
echo "USING THE FOLLOWING TAG FOR IMAGE BUILD "$TAG
echo "USING THE FOLLOWING TAG FOR IMAGE BUILD "$DATE_TAG
docker network create sauber-network
if [ $DOCKER_BUILD -eq 1 ]
then
echo "Building Docker Images ..."
TAG="$TAG" /bin/sh ./build-images.sh
echo "... DONE Building Docker Images"
fi
# create mount directory for GeoServer
echo
echo "Creating mount directory for GeoServer ... "
mkdir \
--parents \
geoserver_mnt/geoserver_data \
geoserver_mnt/raster_data
echo "... DONE Creating mount directory for GeoServer"
echo
# create mount directory for database backups
echo
echo "Creating mount directory for database backups"
mkdir \
db_backups
echo "... DONE Creating mount directory for database backups"
echo
docker stack deploy -c docker-stack.yml sauber-stack
echo 'Waiting 60 seconds for stack to deploy...'
# This avoids the following scripts binding to an existing UM Server instance
# that is shut down shortly after due to re-deployment.
sleep 60
until [ ! -z "$UM_SERVER_ID" ]; do
UM_SERVER_ID=$(docker ps | grep um_server | cut -c1-5) ## Get all running containers. Search for UM Server container name. Get UM-Server ID by first 5 digits of response.
sleep 5;
((cnt++)) && ((cnt==6)) && \
echo 'Error: Universal Messaging Server Container not found.' && \
exit # Exit if UM Server not found in given amount of tries
echo 'Searching for UM Container. Attempt' $cnt;
done;
CHANNELS=("HeartbeatChannel raster_data station_data") ## Add additional channels to be created
for channel in $CHANNELS; do
echo 'Creating channel' $channel
until [[ $(docker exec $UM_SERVER_ID runUMTool.sh ListChannels -rname=nsp://localhost:9000 | grep "$channel") ]]; do # Until channel exists on UM Server:
docker exec $UM_SERVER_ID runUMTool.sh CreateChannel -rname=nsp://localhost:9000 -channelname="$channel" # Create channel on UM Server
sleep 1
done;
done