|
1 |
| -#!/usr/bin/env bash |
| 1 | +#!/usr/bin/env sh |
2 | 2 |
|
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 |
8 | 3 | set -e
|
9 | 4 |
|
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" |
13 | 8 |
|
14 |
| -if [ ! -d "${DATA_DIR}" ]; then |
15 |
| - mkdir -p "${DATA_DIR}" |
| 9 | +if [ -z "${DATA_DIR}" ] |
| 10 | +then DATA_DIR=/opt/satosa/etc |
16 | 11 | fi
|
17 | 12 |
|
18 |
| -if [ -z "${PROXY_PORT}" ]; then |
19 |
| - PROXY_PORT="8000" |
| 13 | +if [ ! -d "${DATA_DIR}" ] |
| 14 | +then mkdir -p "${DATA_DIR}" |
20 | 15 | fi
|
21 | 16 |
|
22 |
| -if [ -z "${METADATA_DIR}" ]; then |
23 |
| - METADATA_DIR="${DATA_DIR}" |
| 17 | +if [ -z "${PROXY_PORT}" ] |
| 18 | +then PROXY_PORT="8000" |
24 | 19 | fi
|
25 | 20 |
|
26 |
| -cd ${DATA_DIR} |
27 |
| - |
28 |
| -mkdir -p ${METADATA_DIR} |
| 21 | +if [ -z "${METADATA_DIR}" ] |
| 22 | +then METADATA_DIR="${DATA_DIR}" |
| 23 | +fi |
29 | 24 |
|
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" |
32 | 27 | fi
|
33 | 28 |
|
34 |
| -# Activate virtualenv |
| 29 | +# activate virtualenv |
35 | 30 | . /opt/satosa/bin/activate
|
36 | 31 |
|
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}" |
40 | 40 |
|
41 | 41 | # 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 |
46 | 48 | fi
|
0 commit comments