diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 33786ef5..724b5bb8 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -82,6 +82,16 @@ echo "Environment DISPATCHARR_LOG_LEVEL set to: '${DISPATCHARR_LOG_LEVEL}'" # READ-ONLY - don't let users change these export POSTGRES_DIR=/data/db +# Run init scripts +echo "Starting user setup..." +. /app/docker/init/01-user-setup.sh +echo "Setting up PostgreSQL..." +. /app/docker/init/02-postgres.sh +echo "Starting init process..." +. /app/docker/init/03-init-dispatcharr.sh + +export DJANGO_SECRET_KEY="$(cat "$SECRET_FILE")" + # Global variables, stored so other users inherit them if [[ ! -f /etc/profile.d/dispatcharr.sh ]]; then # Define all variables to process @@ -91,7 +101,7 @@ if [[ ! -f /etc/profile.d/dispatcharr.sh ]]; then DISPATCHARR_ENV DISPATCHARR_DEBUG DISPATCHARR_LOG_LEVEL REDIS_HOST REDIS_DB POSTGRES_DIR DISPATCHARR_PORT DISPATCHARR_VERSION DISPATCHARR_TIMESTAMP LIBVA_DRIVERS_PATH LIBVA_DRIVER_NAME LD_LIBRARY_PATH - CELERY_NICE_LEVEL UWSGI_NICE_LEVEL + CELERY_NICE_LEVEL UWSGI_NICE_LEVEL DJANGO_SECRET_KEY ) # Process each variable for both profile.d and environment @@ -121,16 +131,6 @@ fi EOF fi -# Run init scripts -echo "Starting user setup..." -. /app/docker/init/01-user-setup.sh -echo "Setting up PostgreSQL..." -. /app/docker/init/02-postgres.sh -echo "Starting init process..." -. /app/docker/init/03-init-dispatcharr.sh - -export DJANGO_SECRET_KEY="$(cat "$SECRET_FILE")" - # Start PostgreSQL echo "Starting Postgres..." su - postgres -c "$PG_BINDIR/pg_ctl -D ${POSTGRES_DIR} start -w -t 300 -o '-c port=${POSTGRES_PORT}'" diff --git a/docker/init/03-init-dispatcharr.sh b/docker/init/03-init-dispatcharr.sh index 4ca42e17..a808cedd 100644 --- a/docker/init/03-init-dispatcharr.sh +++ b/docker/init/03-init-dispatcharr.sh @@ -40,6 +40,7 @@ PY mv -f "$tmpfile" "$SECRET_FILE" || { echo "move failed"; rm -f "$tmpfile"; exit 1; } fi +chown $PUID:$PGID "$SECRET_FILE" || true chmod 600 "$SECRET_FILE" || true # Export for app start (read the file)