From 1ecb5bbeab8ff79fce107ff3e042f30fed02c769 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Dec 2025 12:38:37 +0100 Subject: [PATCH] Add DJANGO_SECRET_KEY support for Dispatcharr v0.13.1+ (#9730) * Initial plan * Add DJANGO_SECRET_KEY support for Dispatcharr v0.13.1+ Co-authored-by: MickLesk <47820557+MickLesk@users.noreply.github.com> * Improve DJANGO_SECRET_KEY generation to ensure consistent 50 character length Co-authored-by: MickLesk <47820557+MickLesk@users.noreply.github.com> * short --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MickLesk <47820557+MickLesk@users.noreply.github.com> --- ct/dispatcharr.sh | 5 +++++ install/dispatcharr-install.sh | 3 +++ 2 files changed, 8 insertions(+) diff --git a/ct/dispatcharr.sh b/ct/dispatcharr.sh index cf9bea3b3e..0cbc3b567c 100644 --- a/ct/dispatcharr.sh +++ b/ct/dispatcharr.sh @@ -87,6 +87,11 @@ function update_script() { mv /tmp/start-daphne.sh.backup /opt/dispatcharr/start-daphne.sh fi + if ! grep -q "DJANGO_SECRET_KEY" /opt/dispatcharr/.env; then + DJANGO_SECRET=$(openssl rand -base64 48 | tr -dc 'a-zA-Z0-9' | cut -c1-50) + echo "DJANGO_SECRET_KEY=$DJANGO_SECRET" >> /opt/dispatcharr/.env + fi + cd /opt/dispatcharr rm -rf .venv $STD uv venv diff --git a/install/dispatcharr-install.sh b/install/dispatcharr-install.sh index a968c86342..d5da5741f8 100644 --- a/install/dispatcharr-install.sh +++ b/install/dispatcharr-install.sh @@ -62,11 +62,13 @@ install -d -m 755 \ /data/uploads/{m3us,epgs} \ /data/{m3us,epgs} chown -R root:root /data +DJANGO_SECRET=$(openssl rand -base64 48 | tr -dc 'a-zA-Z0-9' | cut -c1-50) export DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:5432/${DB_NAME}" export POSTGRES_DB=$DB_NAME export POSTGRES_USER=$DB_USER export POSTGRES_PASSWORD=$DB_PASS export POSTGRES_HOST=localhost +export DJANGO_SECRET_KEY=$DJANGO_SECRET $STD uv run python manage.py migrate --noinput $STD uv run python manage.py collectstatic --noinput cat </opt/dispatcharr/.env @@ -76,6 +78,7 @@ POSTGRES_USER=$DB_USER POSTGRES_PASSWORD=$DB_PASS POSTGRES_HOST=localhost CELERY_BROKER_URL=redis://localhost:6379/0 +DJANGO_SECRET_KEY=$DJANGO_SECRET EOF cd /opt/dispatcharr/frontend $STD npm install --legacy-peer-deps