2021-11-23 04:09:13 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
NGINX_SSL_CMNT="#"
|
|
|
|
|
|
2021-11-23 05:52:09 +00:00
|
|
|
TEMPLATE_DIR="/opt/appsmith/templates"
|
|
|
|
|
APP_TEMPLATE="$TEMPLATE_DIR/nginx-app-http.conf.template.sh"
|
|
|
|
|
|
|
|
|
|
# Check exist certificate with given custom domain
|
|
|
|
|
if [[ -n $APPSMITH_CUSTOM_DOMAIN ]]; then
|
|
|
|
|
APP_TEMPLATE="$TEMPLATE_DIR/nginx-app-https.conf.template.sh"
|
|
|
|
|
if ! [[ -e "/etc/letsencrypt/live/$APPSMITH_CUSTOM_DOMAIN" ]]; then
|
|
|
|
|
source "/opt/appsmith/init_ssl_cert.sh"
|
|
|
|
|
init_ssl_cert "$APPSMITH_CUSTOM_DOMAIN"
|
2021-12-07 10:07:51 +00:00
|
|
|
|
|
|
|
|
if (($? != 0)); then
|
|
|
|
|
echo $?
|
|
|
|
|
APP_TEMPLATE="$TEMPLATE_DIR/nginx-app-http.conf.template.sh"
|
|
|
|
|
fi
|
2021-11-23 05:52:09 +00:00
|
|
|
fi
|
2021-11-23 04:09:13 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Re-generating nginx config template"
|
2021-11-23 05:52:09 +00:00
|
|
|
bash "$APP_TEMPLATE" "$APPSMITH_CUSTOM_DOMAIN" >"/etc/nginx/conf.d/nginx_app.conf.template"
|
2021-11-23 04:09:13 +00:00
|
|
|
|
|
|
|
|
echo "Generating nginx configuration"
|
|
|
|
|
cat /etc/nginx/conf.d/nginx_app.conf.template | envsubst "$(printf '$%s,' $(env | grep -Eo '^APPSMITH_[A-Z0-9_]+'))" | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' >/etc/nginx/sites-available/default
|
|
|
|
|
|
2021-11-24 14:52:22 +00:00
|
|
|
exec nginx -g "daemon off;"
|