summaryrefslogtreecommitdiff
path: root/start.sh
blob: f0d0a0d623ae30aa9741e90e2642079233f5b405 (plain)
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
#!/bin/sh

set -e

[ -n "$DEBUG" ] && set -x

oidc_scheme=$(echo "$OIDC_ISSUER" | awk -F[/:] '{print $1}')
oidc_host=$(echo "$OIDC_ISSUER" | awk -F[/:] '{print $4}')
yaml=$(sed -e "s/OAUTH_CLIENT_ID/$OAUTH_CLIENT_ID/" /etc/envoy/envoy.yaml)
yaml=$(echo "$yaml" | sed -e "s,https://example.com,$OIDC_ISSUER,")
yaml=$(echo "$yaml" | sed -e "s/example.com/$oidc_host/")

# For http://gdk.test:3000
if [ "$oidc_scheme" = "http" ]; then
  yaml=$(echo "$yaml" | sed -e '/transport_socket:/,+4d')
  oidc_port=$(echo "$OIDC_ISSUER" | awk -F[/:] '{print $5}')
  yaml=$(echo "$yaml" | sed -e "s/port_value: 443/port_value: $oidc_port/")
fi

if [ -z "$HMAC_SESSION_SECRET" ]; then
  export HMAC_SESSION_SECRET="$OAUTH_CLIENT_SECRET"
fi

echo "[$(date "+%H:%M:%S")] ==> Starting…"
/usr/local/bin/sparkled & /usr/local/bin/envoy --config-yaml "$yaml" --log-level warn --component-log-level oauth2:trace