2020-05-05 23:31:01 +02:00
#!/bin/bash
# This shell script sets the api url based on an environment variable and starts nginx in foreground.
2021-09-29 21:12:22 +02:00
VIKUNJA_API_URL = " ${ VIKUNJA_API_URL :- "/api/v1" } "
2021-10-26 20:53:17 +02:00
VIKUNJA_SENTRY_ENABLED = " ${ VIKUNJA_SENTRY_ENABLED :- "false" } "
VIKUNJA_SENTRY_DSN = " ${ VIKUNJA_SENTRY_DSN :- "https://7e684483a06a4225b3e05cc47cae7a11@sentry.kolaente.de/2" } "
2021-09-29 21:12:22 +02:00
VIKUNJA_HTTP_PORT = " ${ VIKUNJA_HTTP_PORT :- 80 } "
2021-10-04 20:43:43 +02:00
VIKUNJA_HTTPS_PORT = " ${ VIKUNJA_HTTPS_PORT :- 443 } "
2020-05-05 23:31:01 +02:00
2021-10-04 20:44:45 +02:00
echo " Using $VIKUNJA_API_URL as default api url "
2020-05-05 23:31:01 +02:00
# Escape the variable to prevent sed from complaining
VIKUNJA_API_URL = $( echo $VIKUNJA_API_URL | sed 's/\//\\\//g' )
2021-10-04 20:55:05 +02:00
sed -i "s/http\:\/\/localhost\:3456//g" /usr/share/nginx/html/index.html # replacing in two steps to make sure api urls from releases are properly replaced as well
sed -i " s/'\/api\/v1/' $VIKUNJA_API_URL /g " /usr/share/nginx/html/index.html
2021-10-26 20:53:17 +02:00
sed -i " s/\.SENTRY_ENABLED = false/\.SENTRY_ENABLED = $VIKUNJA_SENTRY_ENABLED /g " /usr/share/nginx/html/index.html
sed -i " s/\.SENTRY_DSN = '.*'/\.SENTRY_DSN = ' $VIKUNJA_SENTRY_DSN '/g " /usr/share/nginx/html/index.html
2020-05-05 23:31:01 +02:00
2021-10-04 20:43:43 +02:00
sed -i " s/listen 80/listen $VIKUNJA_HTTP_PORT /g " /etc/nginx/nginx.conf
sed -i " s/listen 443/listen $VIKUNJA_HTTPS_PORT /g " /etc/nginx/nginx.conf
2021-09-29 21:12:22 +02:00
2020-05-22 18:11:20 +02:00
# Set the uid and gid of the nginx run user
usermod --non-unique --uid ${ PUID } nginx
groupmod --non-unique --gid ${ PGID } nginx
2020-05-05 23:31:01 +02:00
nginx -g "daemon off;"