forked from CZERTAINLY/CZERTAINLY-FE-Administrator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-nginx.sh
26 lines (21 loc) · 934 Bytes
/
start-nginx.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
#!/bin/sh
export EXISTING_VARS=$(printenv | awk -F= '{print $1}' | sed 's/^/\$/g' | paste -sd,);
configFile=/usr/share/nginx/html/config.js
tmpConfigFile=/usr/share/nginx/html/config.js.tmp
envsubst $EXISTING_VARS < $configFile > $tmpConfigFile
mv $tmpConfigFile $configFile
nginxFile=/etc/nginx/conf.d/default.conf
tmpNginxFile=/etc/nginx/conf.d/default.conf.tmp
envsubst $EXISTING_VARS < $nginxFile > $tmpNginxFile
mv $tmpNginxFile $nginxFile
indexFile=/usr/share/nginx/html/index.html
tmpIndexFile=/usr/share/nginx/html/index.html.tmp
sed 's/"\/administrator/"\'"$BASE_URL"'/g' $indexFile > $tmpIndexFile
mv $tmpIndexFile $indexFile
sed 's/"\/api/"\'"$API_URL"'/g' $indexFile > $tmpIndexFile
mv $tmpIndexFile $indexFile
sed 's/"\/login/"\'"$LOGIN_URL"'/g' $indexFile > $tmpIndexFile
mv $tmpIndexFile $indexFile
sed 's/"\/logout/"\'"$LOGOUT_URL"'/g' $indexFile > $tmpIndexFile
mv $tmpIndexFile $indexFile
nginx -g 'daemon off;'