summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/scripts/envsubst-html.sh
blob: 8ca12e8af5488390efdbb5b7dd0d553b393b458e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

set -e

# We can use simple version of envsubst execution as
# envsubst < /usr/share/nginx/html/index.html.template > /usr/share/nginx/html/index.html
# but it replaces everything that looks like environment variable substitution
# so it affects `default values` approach.
# we need to replace only provided environment variables.

auto_envsubst() {
  template_path="/usr/share/nginx/html/index.html.template"
  output_path="/usr/share/nginx/html/index.html"
  defined_envs=$(printf '${%s} ' $(env | cut -d= -f1))
  envsubst "$defined_envs" < "$template_path" > "$output_path"
}

auto_envsubst
exit 0