Compare commits

...

6 Commits

Author SHA1 Message Date
root
22c0627298 fix cron 2 2025-08-12 00:32:04 +02:00
5ac85d6f1c docker/entrypoint.sh aktualisiert 2025-08-11 21:15:24 +00:00
df02a9db5e fix cron 2025-08-11 22:34:24 +02:00
79156f35c8 README.md aktualisiert 2025-08-11 13:19:39 +00:00
9f4c5c72b3 README.md aktualisiert 2025-08-11 10:58:37 +00:00
root
7470c2d3d0 fix CSRF 2025-08-11 12:57:08 +02:00
6 changed files with 43 additions and 15 deletions

View File

@@ -61,10 +61,15 @@ services:
environment: environment:
# Django # Django
- DJANGO_DEBUG=true - DJANGO_DEBUG=true
- USE_X_FORWARDED_HOST=true
- DJANGO_SECURE_PROXY_SSL_HEADER=true
- DJANGO_CSRF_COOKIE_SECURE=true
- DJANGO_SESSION_COOKIE_SECURE=true
- DJANGO_ALLOWED_HOSTS=* - DJANGO_ALLOWED_HOSTS=*
- DJANGO_SECRET_KEY=change-me - DJANGO_SECRET_KEY=change-me
- DB_PATH=/app/data/db.sqlite3 - DB_PATH=/app/data/db.sqlite3
- NOTIFICATIONS_ALLOW_DUPLICATES=false - NOTIFICATIONS_ALLOW_DUPLICATES=false
- DJANGO_CSRF_TRUSTED_ORIGINS="https://subscribarr.local.js-devop.de"
# App Settings (optional, otherwise use first-run setup) # App Settings (optional, otherwise use first-run setup)
#- JELLYFIN_URL= #- JELLYFIN_URL=
#- JELLYFIN_API_KEY= #- JELLYFIN_API_KEY=
@@ -85,11 +90,8 @@ services:
# Cron schedule (default every 30min) # Cron schedule (default every 30min)
- CRON_SCHEDULE=*/30 * * * * - CRON_SCHEDULE=*/30 * * * *
volumes: volumes:
- subscribarr-data:/app/data - ./data:/app/data
restart: unless-stopped restart: unless-stopped
volumes:
subscribarr-data:
``` ```
--- ---
@@ -115,7 +117,7 @@ volumes:
## First Run ## First Run
1. Start the container (or dev server) and open `http://<host>:8000`. 1. Start the container (or dev server) and open `http://<host>:8081`.
2. Complete the **first-time setup**: Jellyfin URL/API key (required), optional Sonarr/Radarr, SMTP. 2. Complete the **first-time setup**: Jellyfin URL/API key (required), optional Sonarr/Radarr, SMTP.
3. **Sign in** with Jellyfin credentials (admin users in Jellyfin become admins in Subscribarr). 3. **Sign in** with Jellyfin credentials (admin users in Jellyfin become admins in Subscribarr).
4. Adjust settings later at `/settings/`. 4. Adjust settings later at `/settings/`.

View File

@@ -6,7 +6,7 @@ class Command(BaseCommand):
help = 'Checks for new media and sends notifications' help = 'Checks for new media and sends notifications'
def handle(self, *args, **kwargs): def handle(self, *args, **kwargs):
self.stdout.write(f'[{timezone.now()}] Starting media check...') self.stdout.write(f'[{timezone.now()}] Starting media check...')
try: try:
check_and_notify_users() check_and_notify_users()
self.stdout.write(self.style.SUCCESS(f'[{timezone.now()}] Media check finished successfully')) self.stdout.write(self.style.SUCCESS(f'[{timezone.now()}] Media check finished successfully'))

BIN
data/db.sqlite3 Normal file

Binary file not shown.

View File

@@ -8,11 +8,15 @@ services:
environment: environment:
# Django # Django
- DJANGO_DEBUG=true - DJANGO_DEBUG=true
- USE_X_FORWARDED_HOST=true
- DJANGO_SECURE_PROXY_SSL_HEADER=true
- DJANGO_CSRF_COOKIE_SECURE=true
- DJANGO_SESSION_COOKIE_SECURE=true
- DJANGO_ALLOWED_HOSTS=* - DJANGO_ALLOWED_HOSTS=*
- DJANGO_SECRET_KEY=change-me - DJANGO_SECRET_KEY=change-me
- DB_PATH=/app/data/db.sqlite3 - DB_PATH=/app/data/db.sqlite3
- NOTIFICATIONS_ALLOW_DUPLICATES=false - NOTIFICATIONS_ALLOW_DUPLICATES=false
- DJANGO_CSRF_TRUSTED_ORIGINS="https://subscribarr.example.com,https://app.example.org" - DJANGO_CSRF_TRUSTED_ORIGINS="https://subscribarr.local.js-devop.de"
# App Settings (optional, otherwise use first-run setup) # App Settings (optional, otherwise use first-run setup)
#- JELLYFIN_URL= #- JELLYFIN_URL=
#- JELLYFIN_API_KEY= #- JELLYFIN_API_KEY=
@@ -33,8 +37,5 @@ services:
# Cron schedule (default every 30min) # Cron schedule (default every 30min)
- CRON_SCHEDULE=*/30 * * * * - CRON_SCHEDULE=*/30 * * * *
volumes: volumes:
- subscribarr-data:/app/data - ./data:/app/data
restart: unless-stopped restart: unless-stopped
volumes:
subscribarr-data:

View File

@@ -2,6 +2,7 @@
set -euo pipefail set -euo pipefail
# Apply migrations # Apply migrations
python manage.py makemigrations
python manage.py migrate --noinput python manage.py migrate --noinput
# Create admin user if provided # Create admin user if provided
@@ -66,11 +67,20 @@ print("AppSettings seeded from environment (if provided)")
PY PY
# Setup cron if schedule provided # Setup cron if schedule provided
if [[ -n "${CRON_SCHEDULE:-}" ]]; then if [ -n "${CRON_SCHEDULE:-}" ]; then
echo "Configuring cron: ${CRON_SCHEDULE}" cat >/etc/cron.d/subscribarr <<EOF
echo "${CRON_SCHEDULE} cd /app && /usr/local/bin/python manage.py check_new_media >> /app/cron.log 2>&1" > /etc/cron.d/subscribarr SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# gleiche DB wie die App:
DB_PATH=${DB_PATH:-/app/data/db.sqlite3}
PYTHON=/usr/local/bin/python
# <m h dom mon dow> <user> <cmd>
${CRON_SCHEDULE} root cd /app && \$PYTHON manage.py migrate --noinput && \$PYTHON manage.py check_new_media >> /app/cron.log 2>&1
EOF
chmod 0644 /etc/cron.d/subscribarr chmod 0644 /etc/cron.d/subscribarr
crontab /etc/cron.d/subscribarr
/usr/sbin/cron /usr/sbin/cron
fi fi

View File

@@ -116,6 +116,21 @@ if not CSRF_TRUSTED_ORIGINS:
CSRF_TRUSTED_ORIGINS = ['https://subscribarr.local.js-devop.de'] CSRF_TRUSTED_ORIGINS = ['https://subscribarr.local.js-devop.de']
USE_X_FORWARDED_HOST = os.getenv('USE_X_FORWARDED_HOST', 'False').lower() == 'true'
if os.getenv('DJANGO_SECURE_PROXY_SSL_HEADER', '').lower() in ('1', 'true', 'yes'):
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Secure cookies when served over HTTPS (optional)
CSRF_COOKIE_SECURE = os.getenv('DJANGO_CSRF_COOKIE_SECURE', 'False').lower() == 'true'
SESSION_COOKIE_SECURE = os.getenv('DJANGO_SESSION_COOKIE_SECURE', 'False').lower() == 'true'
# Optional cookie domain override (for subdomain setups)
_cookie_domain = os.getenv('DJANGO_COOKIE_DOMAIN', '').strip()
if _cookie_domain:
CSRF_COOKIE_DOMAIN = _cookie_domain
SESSION_COOKIE_DOMAIN = _cookie_domain
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/5.2/topics/i18n/ # https://docs.djangoproject.com/en/5.2/topics/i18n/