|
| 1 | +#!/usr/bin/env bash |
| 2 | +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: ekke85 | MickLesk |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/Dispatcharr/Dispatcharr |
| 7 | + |
| 8 | +APP="Dispatcharr" |
| 9 | +var_tags="${var_tags:-media;arr}" |
| 10 | +var_cpu="${var_cpu:-1}" |
| 11 | +var_ram="${var_ram:-2048}" |
| 12 | +var_disk="${var_disk:-8}" |
| 13 | +var_os="${var_os:-debian}" |
| 14 | +var_version="${var_version:-13}" |
| 15 | +var_unprivileged="${var_unprivileged:-1}" |
| 16 | + |
| 17 | +header_info "$APP" |
| 18 | +variables |
| 19 | +color |
| 20 | +catch_errors |
| 21 | + |
| 22 | +function update_script() { |
| 23 | + header_info |
| 24 | + check_container_storage |
| 25 | + check_container_resources |
| 26 | + if [[ ! -d "/opt/dispatcharr" ]]; then |
| 27 | + msg_error "No ${APP} Installation Found!" |
| 28 | + exit |
| 29 | + fi |
| 30 | + |
| 31 | + setup_uv |
| 32 | + NODE_VERSION="24" setup_nodejs |
| 33 | + |
| 34 | + if check_for_gh_release "Dispatcharr" "Dispatcharr/Dispatcharr"; then |
| 35 | + msg_info "Stopping Services" |
| 36 | + systemctl stop dispatcharr-celery |
| 37 | + systemctl stop dispatcharr-celerybeat |
| 38 | + systemctl stop dispatcharr-daphne |
| 39 | + systemctl stop dispatcharr |
| 40 | + msg_ok "Stopped Services" |
| 41 | + |
| 42 | + msg_info "Creating Backup" |
| 43 | + BACKUP_FILE="/opt/dispatcharr_backup_$(date +%F_%H-%M-%S).tar.gz" |
| 44 | + if [[ -f /opt/dispatcharr/.env ]]; then |
| 45 | + cp /opt/dispatcharr/.env /tmp/dispatcharr.env.backup |
| 46 | + fi |
| 47 | + if [[ -f /opt/dispatcharr/start-gunicorn.sh ]]; then |
| 48 | + cp /opt/dispatcharr/start-gunicorn.sh /tmp/start-gunicorn.sh.backup |
| 49 | + fi |
| 50 | + if [[ -f /opt/dispatcharr/start-celery.sh ]]; then |
| 51 | + cp /opt/dispatcharr/start-celery.sh /tmp/start-celery.sh.backup |
| 52 | + fi |
| 53 | + if [[ -f /opt/dispatcharr/start-celerybeat.sh ]]; then |
| 54 | + cp /opt/dispatcharr/start-celerybeat.sh /tmp/start-celerybeat.sh.backup |
| 55 | + fi |
| 56 | + if [[ -f /opt/dispatcharr/start-daphne.sh ]]; then |
| 57 | + cp /opt/dispatcharr/start-daphne.sh /tmp/start-daphne.sh.backup |
| 58 | + fi |
| 59 | + if [[ -f /opt/dispatcharr/.env ]]; then |
| 60 | + set -o allexport |
| 61 | + source /opt/dispatcharr/.env |
| 62 | + set +o allexport |
| 63 | + if [[ -n "$POSTGRES_DB" ]] && [[ -n "$POSTGRES_USER" ]] && [[ -n "$POSTGRES_PASSWORD" ]]; then |
| 64 | + PGPASSWORD=$POSTGRES_PASSWORD pg_dump -U $POSTGRES_USER -h ${POSTGRES_HOST:-localhost} $POSTGRES_DB >/tmp/dispatcharr_db_$(date +%F).sql |
| 65 | + msg_info "Database backup created" |
| 66 | + fi |
| 67 | + fi |
| 68 | + $STD tar -czf "$BACKUP_FILE" -C /opt dispatcharr /tmp/dispatcharr_db_*.sql |
| 69 | + msg_ok "Backup created: $BACKUP_FILE" |
| 70 | + |
| 71 | + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "dispatcharr" "Dispatcharr/Dispatcharr" |
| 72 | + |
| 73 | + msg_info "Updating Dispatcharr Backend" |
| 74 | + if [[ -f /tmp/dispatcharr.env.backup ]]; then |
| 75 | + mv /tmp/dispatcharr.env.backup /opt/dispatcharr/.env |
| 76 | + fi |
| 77 | + if [[ -f /tmp/start-gunicorn.sh.backup ]]; then |
| 78 | + mv /tmp/start-gunicorn.sh.backup /opt/dispatcharr/start-gunicorn.sh |
| 79 | + fi |
| 80 | + if [[ -f /tmp/start-celery.sh.backup ]]; then |
| 81 | + mv /tmp/start-celery.sh.backup /opt/dispatcharr/start-celery.sh |
| 82 | + fi |
| 83 | + if [[ -f /tmp/start-celerybeat.sh.backup ]]; then |
| 84 | + mv /tmp/start-celerybeat.sh.backup /opt/dispatcharr/start-celerybeat.sh |
| 85 | + fi |
| 86 | + if [[ -f /tmp/start-daphne.sh.backup ]]; then |
| 87 | + mv /tmp/start-daphne.sh.backup /opt/dispatcharr/start-daphne.sh |
| 88 | + fi |
| 89 | + |
| 90 | + cd /opt/dispatcharr |
| 91 | + rm -rf .venv |
| 92 | + $STD uv venv |
| 93 | + $STD uv pip install -r requirements.txt --index-strategy unsafe-best-match |
| 94 | + $STD uv pip install gunicorn gevent celery redis daphne |
| 95 | + msg_ok "Updated Dispatcharr Backend" |
| 96 | + |
| 97 | + msg_info "Building Frontend" |
| 98 | + cd /opt/dispatcharr/frontend |
| 99 | + $STD npm install --legacy-peer-deps |
| 100 | + $STD npm run build |
| 101 | + msg_ok "Built Frontend" |
| 102 | + |
| 103 | + msg_info "Running Django Migrations" |
| 104 | + cd /opt/dispatcharr |
| 105 | + if [[ -f .env ]]; then |
| 106 | + set -o allexport |
| 107 | + source .env |
| 108 | + set +o allexport |
| 109 | + fi |
| 110 | + $STD uv run python manage.py migrate --noinput |
| 111 | + $STD uv run python manage.py collectstatic --noinput |
| 112 | + msg_ok "Migrations Complete" |
| 113 | + |
| 114 | + msg_info "Starting Services" |
| 115 | + systemctl start dispatcharr |
| 116 | + systemctl start dispatcharr-celery |
| 117 | + systemctl start dispatcharr-celerybeat |
| 118 | + systemctl start dispatcharr-daphne |
| 119 | + msg_ok "Started Services" |
| 120 | + |
| 121 | + msg_info "Cleaning up" |
| 122 | + rm -f /tmp/dispatcharr_db_*.sql |
| 123 | + msg_ok "Cleanup completed" |
| 124 | + msg_ok "Update Successfully!" |
| 125 | + fi |
| 126 | + exit |
| 127 | +} |
| 128 | + |
| 129 | +start |
| 130 | +build_container |
| 131 | +description |
| 132 | + |
| 133 | +msg_ok "Completed Successfully!\n" |
| 134 | +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" |
| 135 | +echo -e "${INFO}${YW} Access it using the following URL:${CL}" |
| 136 | +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}" |
0 commit comments