From 071f2aa83a31248811720ec809c8d1b1d052fba3 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 20 Oct 2025 10:40:23 +0200 Subject: [PATCH] Update Dispatcharr defaults and improve install script Increased default RAM to 2048MB and updated default OS version to 13 in ct/dispatcharr.sh. Refactored update_script for improved readability. Modified install/dispatcharr-install.sh to use uv for Python package installation and clarified virtual environment creation comments. --- ct/dispatcharr.sh | 170 ++++++++++++++++----------------- install/dispatcharr-install.sh | 9 +- 2 files changed, 89 insertions(+), 90 deletions(-) diff --git a/ct/dispatcharr.sh b/ct/dispatcharr.sh index 11b0f4b6..9e032428 100644 --- a/ct/dispatcharr.sh +++ b/ct/dispatcharr.sh @@ -9,10 +9,10 @@ APP="Dispatcharr" APP_NAME=${APP,,} var_tags="${var_tags:-media;arr}" var_cpu="${var_cpu:-1}" -var_ram="${var_ram:-1024}" +var_ram="${var_ram:-2048}" var_disk="${var_disk:-8}" var_os="${var_os:-debian}" -var_version="${var_version:-12}" +var_version="${var_version:-13}" var_unprivileged="${var_unprivileged:-1}" header_info "$APP" @@ -21,91 +21,91 @@ color catch_errors function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -d "/opt/dispatcharr" ]]; then - msg_error "No ${APP} Installation Found!" - exit - fi - - RELEASE=$(curl -fsSL https://api.github.com/repos/Dispatcharr/Dispatcharr/releases/latest | jq -r '.tag_name' | sed 's/^v//') - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then - msg_ok "Starting update" - APP_DIR="/opt/dispatcharr" - APP_USER="dispatcharr" - APP_GROUP="dispatcharr" - - msg_info "Stopping $APP" - systemctl stop dispatcharr-celery - systemctl stop dispatcharr-celerybeat - systemctl stop dispatcharr-daphne - systemctl stop dispatcharr - msg_ok "Stopped $APP" - - msg_info "Creating Backup" - BACKUP_FILE="/opt/dispatcharr_$(date +%F).tar.gz" - msg_info "Source and Database backup" - set -o allexport - source /etc/$APP_NAME/$APP_NAME.env - set +o allexport - PGPASSWORD=$POSTGRES_PASSWORD pg_dump -U $POSTGRES_USER -h $POSTGRES_HOST $POSTGRES_DB >/opt/$POSTGRES_DB-$(date +%F).sql - $STD tar -czf "$BACKUP_FILE" /opt/dispatcharr /opt/Dispatcharr_version.txt /opt/$POSTGRES_DB-$(date +%F).sql &>/dev/null - msg_ok "Backup Created" - - msg_info "Updating $APP to v${RELEASE}" - rm -rf /opt/dispatcharr - fetch_and_deploy_gh_release "dispatcharr" "Dispatcharr/Dispatcharr" - chown -R "$APP_USER:$APP_GROUP" "$APP_DIR" - sed -i 's/program\[\x27channel_id\x27\]/program["channel_id"]/g' "${APP_DIR}/apps/output/views.py" - - msg_ok "Dispatcharr Updated to $RELEASE" - - msg_info "Creating Python Virtual Environment" - cd $APP_DIR - python3 -m venv env - source env/bin/activate - $STD pip install --upgrade pip - $STD pip install -r requirements.txt - $STD pip install gunicorn - ln -sf /usr/bin/ffmpeg $APP_DIR/env/bin/ffmpeg - msg_ok "Python Environment Setup" - - msg_info "Building Frontend" - cd $APP_DIR/frontend - $STD npm install --legacy-peer-deps - $STD npm run build - msg_ok "Built Frontend" - - msg_info "Running Django Migrations" - cd $APP_DIR - source env/bin/activate - set -o allexport - source /etc/$APP_NAME/$APP_NAME.env - set +o allexport - $STD python manage.py migrate --noinput - $STD python manage.py collectstatic --noinput - msg_ok "Migrations Complete" - - msg_info "Starting $APP" - systemctl start dispatcharr-celery - systemctl start dispatcharr-celerybeat - systemctl start dispatcharr-daphne - systemctl start dispatcharr - msg_ok "Started $APP" - echo "${RELEASE}" >"/opt/${APP}_version.txt" - - msg_info "Cleaning Up" - rm -rf /opt/$POSTGRES_DB-$(date +%F).sql - msg_ok "Cleanup Completed" - - msg_ok "Update Successful, Backup saved to $BACKUP_FILE" - - else - msg_ok "No update required. ${APP} is already at v${RELEASE}" - fi + if [[ ! -d "/opt/dispatcharr" ]]; then + msg_error "No ${APP} Installation Found!" exit + fi + + RELEASE=$(curl -fsSL https://api.github.com/repos/Dispatcharr/Dispatcharr/releases/latest | jq -r '.tag_name' | sed 's/^v//') + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_ok "Starting update" + APP_DIR="/opt/dispatcharr" + APP_USER="dispatcharr" + APP_GROUP="dispatcharr" + + msg_info "Stopping $APP" + systemctl stop dispatcharr-celery + systemctl stop dispatcharr-celerybeat + systemctl stop dispatcharr-daphne + systemctl stop dispatcharr + msg_ok "Stopped $APP" + + msg_info "Creating Backup" + BACKUP_FILE="/opt/dispatcharr_$(date +%F).tar.gz" + msg_info "Source and Database backup" + set -o allexport + source /etc/$APP_NAME/$APP_NAME.env + set +o allexport + PGPASSWORD=$POSTGRES_PASSWORD pg_dump -U $POSTGRES_USER -h $POSTGRES_HOST $POSTGRES_DB >/opt/$POSTGRES_DB-$(date +%F).sql + $STD tar -czf "$BACKUP_FILE" /opt/dispatcharr /opt/Dispatcharr_version.txt /opt/$POSTGRES_DB-$(date +%F).sql &>/dev/null + msg_ok "Backup Created" + + msg_info "Updating $APP to v${RELEASE}" + rm -rf /opt/dispatcharr + fetch_and_deploy_gh_release "dispatcharr" "Dispatcharr/Dispatcharr" + chown -R "$APP_USER:$APP_GROUP" "$APP_DIR" + sed -i 's/program\[\x27channel_id\x27\]/program["channel_id"]/g' "${APP_DIR}/apps/output/views.py" + + msg_ok "Dispatcharr Updated to $RELEASE" + + msg_info "Creating Python Virtual Environment" + cd $APP_DIR + python3 -m venv env + source env/bin/activate + $STD pip install --upgrade pip + $STD pip install -r requirements.txt + $STD pip install gunicorn + ln -sf /usr/bin/ffmpeg $APP_DIR/env/bin/ffmpeg + msg_ok "Python Environment Setup" + + msg_info "Building Frontend" + cd $APP_DIR/frontend + $STD npm install --legacy-peer-deps + $STD npm run build + msg_ok "Built Frontend" + + msg_info "Running Django Migrations" + cd $APP_DIR + source env/bin/activate + set -o allexport + source /etc/$APP_NAME/$APP_NAME.env + set +o allexport + $STD python manage.py migrate --noinput + $STD python manage.py collectstatic --noinput + msg_ok "Migrations Complete" + + msg_info "Starting $APP" + systemctl start dispatcharr-celery + systemctl start dispatcharr-celerybeat + systemctl start dispatcharr-daphne + systemctl start dispatcharr + msg_ok "Started $APP" + echo "${RELEASE}" >"/opt/${APP}_version.txt" + + msg_info "Cleaning Up" + rm -rf /opt/$POSTGRES_DB-$(date +%F).sql + msg_ok "Cleanup Completed" + + msg_ok "Update Successful, Backup saved to $BACKUP_FILE" + + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi + exit } start diff --git a/install/dispatcharr-install.sh b/install/dispatcharr-install.sh index 3d53e916..e4ac7bac 100644 --- a/install/dispatcharr-install.sh +++ b/install/dispatcharr-install.sh @@ -51,7 +51,7 @@ fetch_and_deploy_gh_release "dispatcharr" "Dispatcharr/Dispatcharr" msg_info "Setup Python virtual environment" cd /opt/dispatcharr -# WICHTIG: Erstelle ein echtes venv statt --system +# uv venv erstellt ein minimales venv - wir nutzen uv zum Installieren $STD uv venv env msg_ok "Virtual environment created" @@ -63,11 +63,11 @@ UV_INDEX_ARGS=(--index-url "$PYPI_URL" --index-strategy unsafe-best-match) for u in "${EXTRA_INDEX_URLS[@]}"; do [[ -n "$u" && "$u" != "$PYPI_URL" ]] && UV_INDEX_ARGS+=(--extra-index-url "$u") done + if [[ -f requirements.txt ]]; then - $STD /opt/dispatcharr/env/bin/python -m pip install --upgrade pip setuptools wheel - $STD /opt/dispatcharr/env/bin/pip install "${UV_INDEX_ARGS[@]}" -r requirements.txt + $STD uv pip install --python /opt/dispatcharr/env/bin/python "${UV_INDEX_ARGS[@]}" -r requirements.txt fi -$STD /opt/dispatcharr/env/bin/pip install "${UV_INDEX_ARGS[@]}" gunicorn gevent celery daphne +$STD uv pip install --python /opt/dispatcharr/env/bin/python "${UV_INDEX_ARGS[@]}" gunicorn gevent celery daphne ln -sf /usr/bin/ffmpeg /opt/dispatcharr/env/bin/ffmpeg msg_ok "Python Requirements Installed" @@ -79,7 +79,6 @@ msg_ok "Built Frontend" msg_info "Running Django Migrations" cd /opt/dispatcharr -# WICHTIG: Setze Umgebungsvariablen für Django/PostgreSQL export POSTGRES_DB="$DB_NAME" export POSTGRES_USER="$DB_USER" export POSTGRES_PASSWORD="$DB_PASS"