From 539578c9658b6908100da0980e7bb8b67d140b65 Mon Sep 17 00:00:00 2001 From: MaxJa4 <74194322+MaxJa4@users.noreply.github.com> Date: Wed, 16 Feb 2022 18:57:25 +0100 Subject: [PATCH] Add check for SECRET_KEY and POSTGRES_PASSWORD --- boot.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/boot.sh b/boot.sh index 91b436f7..313fbd42 100644 --- a/boot.sh +++ b/boot.sh @@ -4,11 +4,26 @@ source venv/bin/activate TANDOOR_PORT="${TANDOOR_PORT:-8080}" NGINX_CONF_FILE=/opt/recipes/nginx/conf.d/Recipes.conf +display_warning() { + echo "[WARNING]" + echo -e "$1" +} + echo "Checking configuration..." +# Nginx config file must exist if gunicorn is not active if [ ! -f "$NGINX_CONF_FILE" ] && [ $GUNICORN_MEDIA -eq 0 ]; then - echo -e "\n[WARNING]\nNginx configuration file could not be found at the default location!" - echo -e "Path: ${NGINX_CONF_FILE}\n" + display_warning "Nginx configuration file could not be found at the default location!\nPath: ${NGINX_CONF_FILE}" +fi + +# SECRET_KEY must be set in .env file +if [ -z "${SECRET_KEY}" ]; then + display_warning "The environment variable 'SECRET_KEY' is not set but REQUIRED for running Tandoor!" +fi + +# POSTGRES_PASSWORD must be set in .env file +if [ -z "${POSTGRES_PASSWORD}" ]; then + display_warning "The environment variable 'POSTGRES_PASSWORD' is not set but REQUIRED for running Tandoor!" fi echo "Waiting for database to be ready..." @@ -43,4 +58,4 @@ echo "Done" chmod -R 755 /opt/recipes/mediafiles -exec gunicorn -b :$TANDOOR_PORT --access-logfile - --error-logfile - --log-level INFO recipes.wsgi +exec gunicorn -b :$TANDOOR_PORT --access-logfile - --error-logfile - --log-level INFO recipes.wsgi \ No newline at end of file