Skip to content

Commit b5ce12a

Browse files
committed
Cleanup the docker start.sh script
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent c867efe commit b5ce12a

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

docker/start.sh

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22

3-
# for Click library to work in satosa-saml-metadata
4-
export LC_ALL=C.UTF-8
5-
export LANG=C.UTF-8
6-
7-
# exit immediately on failure
83
set -e
94

10-
if [ -z "${DATA_DIR}" ]; then
11-
DATA_DIR=/opt/satosa/etc
12-
fi
5+
# for Click library to work in satosa-saml-metadata
6+
export LC_ALL="C.UTF-8"
7+
export LANG="C.UTF-8"
138

14-
if [ ! -d "${DATA_DIR}" ]; then
15-
mkdir -p "${DATA_DIR}"
9+
if [ -z "${DATA_DIR}" ]
10+
then DATA_DIR=/opt/satosa/etc
1611
fi
1712

18-
if [ -z "${PROXY_PORT}" ]; then
19-
PROXY_PORT="8000"
13+
if [ ! -d "${DATA_DIR}" ]
14+
then mkdir -p "${DATA_DIR}"
2015
fi
2116

22-
if [ -z "${METADATA_DIR}" ]; then
23-
METADATA_DIR="${DATA_DIR}"
17+
if [ -z "${PROXY_PORT}" ]
18+
then PROXY_PORT="8000"
2419
fi
2520

26-
cd ${DATA_DIR}
27-
28-
mkdir -p ${METADATA_DIR}
21+
if [ -z "${METADATA_DIR}" ]
22+
then METADATA_DIR="${DATA_DIR}"
23+
fi
2924

30-
if [ ! -d ${DATA_DIR}/attributemaps ]; then
31-
cp -pr /opt/satosa/attributemaps ${DATA_DIR}/attributemaps
25+
if [ ! -d "${DATA_DIR}/attributemaps" ]
26+
then cp -pr /opt/satosa/attributemaps "${DATA_DIR}/attributemaps"
3227
fi
3328

34-
# Activate virtualenv
29+
# activate virtualenv
3530
. /opt/satosa/bin/activate
3631

37-
# generate metadata for front- (IdP) and back-end (SP) and write it to mounted volume
38-
39-
satosa-saml-metadata proxy_conf.yaml ${DATA_DIR}/metadata.key ${DATA_DIR}/metadata.crt --dir ${METADATA_DIR}
32+
# generate metadata for frontend(IdP interface) and backend(SP interface)
33+
# write the result to mounted volume
34+
mkdir -p "${METADATA_DIR}"
35+
satosa-saml-metadata \
36+
"${DATA_DIR}/proxy_conf.yaml" \
37+
"${DATA_DIR}/metadata.key" \
38+
"${DATA_DIR}/metadata.crt" \
39+
--dir "${METADATA_DIR}"
4040

4141
# start the proxy
42-
if [[ -f https.key && -f https.crt ]]; then # if HTTPS cert is available, use it
43-
exec gunicorn -b0.0.0.0:${PROXY_PORT} --keyfile https.key --certfile https.crt satosa.wsgi:app
44-
else
45-
exec gunicorn -b0.0.0.0:${PROXY_PORT} satosa.wsgi:app
42+
# if HTTPS cert is available, use it
43+
https_key="${DATA_DIR}/https.key"
44+
https_crt="${DATA_DIR}/https.crt"
45+
if [ -f "$https_key" && -f "$https_crt" ]
46+
then exec gunicorn -b0.0.0.0:"${PROXY_PORT}" satosa.wsgi:app --keyfile "$https_key" --certfile "$https_crt"
47+
else exec gunicorn -b0.0.0.0:"${PROXY_PORT}" satosa.wsgi:app
4648
fi

0 commit comments

Comments
 (0)