-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinit.sh
executable file
·188 lines (120 loc) · 5.91 KB
/
init.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
#! /bin/bash
############################
# set environment variables
############################
export NGINX_PORT=8001
export SKYPORT_NETWORK_NAME="skyport2_default"
if [[ $_ == $0 ]]; then
echo "Error: please use command \"source ./init.sh\""
exit 1
fi
docker -v > /dev/null
if [[ $? -ne 0 ]]; then
echo "docker is missing. Follow instructions at https://docs.docker.com/compose/install/ to install"
return 1
fi
docker-compose -v > /dev/null
if [[ $? -ne 0 ]]; then
echo "docker-compose is missing or not configured. Follow instructions at https://docs.docker.com/compose/install/ to install"
return 1
fi
if [[ "$(docker-compose -v)" == "docker-compose version 1.8.0"* ]] ; then
echo "Version of docker-compose is out of date, follow instructions at https://docs.docker.com/compose/install/"
echo "Note: the default ubuntu repositories will not help you here."
return 1
fi
export REPO_DIR=`pwd`
if [ $(basename `pwd`) != "Skyport2" ] ; then
echo "Please run \"source ./init.sh\" inside the Skyport2 repository directory"
return
fi
source ./scripts/init-directories.sh
if [ $(cat /etc/hosts | grep "skyport" | wc -l) -eq 0 ] ; then
echo ""
echo "skyport entry in your /etc/hosts file is missing. Please execute:"
echo "> sudo ./scripts/add_etc_hosts_entry.sh"
echo ""
echo "Afterwards execute \"source ./init.sh\" again."
return 1
fi
# we create this docker network to get its IP address
if [ $(docker network list --filter name=${SKYPORT_NETWORK_NAME} -q | wc -l ) -eq 0 ] ; then
docker network create ${SKYPORT_NETWORK_NAME}
fi
export SKYPORT_DOCKER_GATEWAY=$(docker network inspect ${SKYPORT_NETWORK_NAME} -f '{{(index .IPAM.Config 0).Gateway}}')
if [ ${SKYPORT_DOCKER_GATEWAY}x == x ] ; then
# try another method of extracting ip address
export SKYPORT_DOCKER_GATEWAY=$(docker network inspect skyport2_default | grep Gateway | cut -d : -f 2 | cut -d '"' -f 2)
fi
if [ ${SKYPORT_DOCKER_GATEWAY}x == x ] ; then
echo "SKYPORT_DOCKER_GATEWAY could not be obtained."
exit 1
fi
# Docker image tag , used by Dockerfiles and Compose file
export TAG=demo
source ./scripts/get_docker_binary.sh
# This script van be used to determine the IP address
#source ./scripts/get_ip_address.sh
#if [ $? -ne 0 ] ; then
# return 1
#fi
export SKYPORT_HOST="skyport.local" # The suffix .local is needed as some older go libraries e.g. as used in the awe-worker cannot handle a domain names without suffix
export SKYPORT_URL=http://${SKYPORT_HOST}:${NGINX_PORT}
export AWE_SERVER_URL=${SKYPORT_URL}/awe/api/
export SHOCK_SERVER_URL=${SKYPORT_URL}/shock/api/
export AUTH_URL=${SKYPORT_URL}/auth/
export AWE_SERVER_URL_INTERNAL=${SKYPORT_DOCKER_GATEWAY}/awe/api/
# create variuos config files from templates
#awe-monitor
sed -e "s;\${AWE_SERVER_URL};${AWE_SERVER_URL};g" -e "s;\${AUTH_URL};${AUTH_URL};g" ${CONFIGDIR}/awe-monitor/config.js_template > ${CONFIGDIR}/awe-monitor/config.js
#ShockBrowser
sed -e "s;\${AWE_SERVER_URL};${AWE_SERVER_URL};g" -e "s;\${SHOCK_SERVER_URL};${SHOCK_SERVER_URL};g" -e "s;\${AUTH_URL};${AUTH_URL};g" ${CONFIGDIR}/ShockBrowser/config.js_template > ${CONFIGDIR}/ShockBrowser/config.js
#AWE server
sed -e "s;\${AWE_SERVER_URL};${AWE_SERVER_URL};g" -e "s;\${AUTH_URL};${AUTH_URL};g" -e "s;\${SKYPORT_URL};${SKYPORT_URL};g" ${CONFIGDIR}/AWE/awe-server.conf_template > ${CONFIGDIR}/AWE/awe-server.conf
# AWE worker
sed -e "s;\${SKYPORT_URL};${SKYPORT_URL};g" ${CONFIGDIR}/AWE/awe-worker.cfg_template > ${CONFIGDIR}/AWE/awe-worker.cfg
# auth
sed -e "s;\${SKYPORT_HOST};${SKYPORT_HOST};g" Config/authServer/httpd.conf_template > Config/authServer/httpd.conf
sed -e "s;\${AUTH_URL};${AUTH_URL};g" -e "s;\${SKYPORT_URL};${SKYPORT_URL};g" Config/authServer/perl/ClientConfigShock.pm_template > Config/authServer/perl/ClientConfigShock.pm
sed -e "s;\${AUTH_URL};${AUTH_URL};g" -e "s;\${SKYPORT_URL};${SKYPORT_URL};g" Config/authServer/perl/ClientConfigDemoApp.pm_template > Config/authServer/perl/ClientConfigDemoApp.pm
sed -e "s;\${AUTH_URL};${AUTH_URL};g" -e "s;\${SKYPORT_URL};${SKYPORT_URL};g" Config/authServer/perl/ClientConfigSkyport.pm_template > Config/authServer/perl/ClientConfigSkyport.pm
sed -e "s;\${AUTH_URL};${AUTH_URL};g" Config/authServer/perl/OAuthConfig.pm_template > Config/authServer/perl/OAuthConfig.pm
sed -e "s;\${AUTH_URL};${AUTH_URL};g" Config/authServer/dbsetup.demo.mysql_template > Config/authServer/dbsetup.demo.mysql
#DemoApp
sed -e "s;\${AUTH_URL};${AUTH_URL};g" -e "s;\${SKYPORT_URL};${SKYPORT_URL};g" -e "s;\${SHOCK_SERVER_URL};${SHOCK_SERVER_URL};g" Config/DemoApp/index.html_template > Config/DemoApp/index.html
sed -e "s;\${AUTH_URL};${AUTH_URL};g" -e "s;\${SKYPORT_URL};${SKYPORT_URL};g" -e "s;\${SHOCK_SERVER_URL};${SHOCK_SERVER_URL};g" Config/DemoApp/config.js_template > Config/DemoApp/config.js
#nginx
sed -e "s;\${AUTH_URL};${AUTH_URL};g" -e "s;\${SKYPORT_URL};${SKYPORT_URL};g" Config/nginx/index.html_template > Config/nginx/index.html
sed -e "s;\${AUTH_URL};${AUTH_URL};g" -e "s;\${SKYPORT_URL};${SKYPORT_URL};g" -e "s;\${SHOCK_SERVER_URL};${SHOCK_SERVER_URL};g" -e "s;\${AWE_SERVER_URL};${AWE_SERVER_URL};g" Config/nginx/services.html_template > Config/nginx/services.html
#echo "updating docker images"
#./scripts/update.sh
cat <<EOF > .env
TAG=${TAG}
CONFIGDIR=${CONFIGDIR}
SHOCKDIR=${SHOCKDIR}
DATADIR=${DATADIR}
LOGDIR=${LOGDIR}
SKYPORT_HOST=${SKYPORT_HOST}
NGINX_PORT=${NGINX_PORT}
SKYPORT_URL=${SKYPORT_URL}
AWE_SERVER_URL=${AWE_SERVER_URL}
SHOCK_SERVER_URL=${SHOCK_SERVER_URL}
AUTH_URL=${AUTH_URL}
SKYPORT_DOCKER_GATEWAY=${SKYPORT_DOCKER_GATEWAY}
DOCKER_VERSION=${DOCKER_VERSION}
DOCKER_BINARY=${DOCKER_BINARY}
CWL_DIR=${CWL_DIR}
DOCSDIR=${DOCSDIR}
EOF
cat .env
# this directory can be mounted by other containers
mkdir -p ${DATADIR}/env/
cp .env ${DATADIR}/env/skyport2.env
echo ".env has been written"
echo ""
echo ""
echo ""
echo "Next step: docker-compose up"
echo ""
echo "...then open http://localhost:${NGINX_PORT} (or ${SKYPORT_URL}) in your browser."
echo ""