diff --git a/ct/alpine.sh b/ct/alpine.sh index ea946a60..4940d6fc 100644 --- a/ct/alpine.sh +++ b/ct/alpine.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/debian.sh b/ct/debian.sh index c41a2a3d..dad59683 100644 --- a/ct/debian.sh +++ b/ct/debian.sh @@ -19,21 +19,21 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /var ]]; then - msg_error "No ${APP} Installation Found!" + header_info + check_container_storage + check_container_resources + if [[ ! -d /var ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_info "Updating $APP LXC" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated $APP LXC" exit - fi - msg_info "Updating $APP LXC" - $STD apt-get update - $STD apt-get -y upgrade - msg_ok "Updated $APP LXC" - exit } start diff --git a/ct/deferred/alpine-homarr.sh b/ct/deferred/alpine-homarr.sh index c78398d6..def7cca2 100644 --- a/ct/deferred/alpine-homarr.sh +++ b/ct/deferred/alpine-homarr.sh @@ -18,7 +18,7 @@ header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/ampache.sh b/ct/deferred/ampache.sh index ada18f09..ccf300e2 100644 --- a/ct/deferred/ampache.sh +++ b/ct/deferred/ampache.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/ghostfolio.sh b/ct/deferred/ghostfolio.sh index 56002d40..36039092 100644 --- a/ct/deferred/ghostfolio.sh +++ b/ct/deferred/ghostfolio.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/hoodik.sh b/ct/deferred/hoodik.sh index 0e7597b1..1fee14b1 100644 --- a/ct/deferred/hoodik.sh +++ b/ct/deferred/hoodik.sh @@ -18,7 +18,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/jumpserver.sh b/ct/deferred/jumpserver.sh index a8784733..1658a368 100644 --- a/ct/deferred/jumpserver.sh +++ b/ct/deferred/jumpserver.sh @@ -17,42 +17,42 @@ var_unprivileged="1" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -d /opt/jumpserver ]]; then - msg_error "No ${APP} Installation Found!" + if [[ ! -d /opt/jumpserver ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -fsSL https://api.github.com/repos/jumpserver/installer/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/') + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Updating ${APP} to ${RELEASE}" + if [[ -d /opt/jumpserver/config ]]; then + cp -r /opt/jumpserver/config /opt/jumpserver_config_backup + fi + echo "${RELEASE}" >/opt/${APP}_version.txt + rm -rf /opt/jumpserver + cd /opt + curl -fsSL "https://github.com/jumpserver/installer/releases/download/${RELEASE}/jumpserver-installer-${RELEASE}.tar.gz" -o jumpserver-installer-${RELEASE}.tar.gz + mkdir -p /opt/jumpserver + $STD tar -xzvf jumpserver-installer-${RELEASE}.tar.gz -C /opt/jumpserver --strip-components=1 + if [[ -d /opt/jumpserver_config_backup ]]; then + cp -r /opt/jumpserver_config_backup /opt/jumpserver/config + rm -rf /opt/jumpserver_config_backup + fi + cd /opt/jumpserver + yes y | head -n 3 | $STD ./jmsctl.sh upgrade + $STD ./jmsctl.sh start + rm -rf /opt/jumpserver-installer-${RELEASE}.tar.gz + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}." + fi exit - fi - RELEASE=$(curl -fsSL https://api.github.com/repos/jumpserver/installer/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/') - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then - msg_info "Updating ${APP} to ${RELEASE}" - if [[ -d /opt/jumpserver/config ]]; then - cp -r /opt/jumpserver/config /opt/jumpserver_config_backup - fi - echo "${RELEASE}" >/opt/${APP}_version.txt - rm -rf /opt/jumpserver - cd /opt - curl -fsSL "https://github.com/jumpserver/installer/releases/download/${RELEASE}/jumpserver-installer-${RELEASE}.tar.gz" -o jumpserver-installer-${RELEASE}.tar.gz - mkdir -p /opt/jumpserver - $STD tar -xzvf jumpserver-installer-${RELEASE}.tar.gz -C /opt/jumpserver --strip-components=1 - if [[ -d /opt/jumpserver_config_backup ]]; then - cp -r /opt/jumpserver_config_backup /opt/jumpserver/config - rm -rf /opt/jumpserver_config_backup - fi - cd /opt/jumpserver - yes y | head -n 3 | $STD ./jmsctl.sh upgrade - $STD ./jmsctl.sh start - rm -rf /opt/jumpserver-installer-${RELEASE}.tar.gz - msg_ok "Updated Successfully" - else - msg_ok "No update required. ${APP} is already at ${RELEASE}." - fi - exit } start diff --git a/ct/deferred/kasm.sh b/ct/deferred/kasm.sh index 6ee3bb93..ba78e8d5 100644 --- a/ct/deferred/kasm.sh +++ b/ct/deferred/kasm.sh @@ -19,41 +19,41 @@ var_tun="${var_tun:-yes}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -d /opt/kasm ]]; then - msg_error "No ${APP} Installation Found!" + if [[ ! -d /opt/kasm ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -fsSL 'https://www.kasmweb.com/downloads' | grep -o 'https://kasm-static-content.s3.amazonaws.com/kasm_release_[^"]*\.tar\.gz' | head -n 1 | sed -E 's/.*release_(.*)\.tar\.gz/\1/') + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Updating ${APP} to v${RELEASE}" + temp_file=$(mktemp) + curl -fsSL "https://kasm-static-content.s3.amazonaws.com/kasm_release_${RELEASE}.tar.gz" -o "$temp_file" + tar zxf "$temp_file" + mkdir -p /opt/kasm/backups/ + chmod 777 /opt/kasm/backups/ + mv /opt/kasm/1.*/certs/kasm_nginx.crt /opt/kasm/kasm_nginx.crt_bak + printf 'y\n' | $STD sudo bash /tmp/kasm_release/upgrade.sh + $STD sudo bash /tmp/kasm_release/upgrade.sh + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to v${RELEASE}" + + msg_info "Cleaning up" + rm -f "$temp_file" + rm -rf /tmp/kasm_release + $STD apt-get -y autoremove + $STD apt-get -y autoclean + msg_ok "Cleaned" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi exit - fi - RELEASE=$(curl -fsSL 'https://www.kasmweb.com/downloads' | grep -o 'https://kasm-static-content.s3.amazonaws.com/kasm_release_[^"]*\.tar\.gz' | head -n 1 | sed -E 's/.*release_(.*)\.tar\.gz/\1/') - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then - msg_info "Updating ${APP} to v${RELEASE}" - temp_file=$(mktemp) - curl -fsSL "https://kasm-static-content.s3.amazonaws.com/kasm_release_${RELEASE}.tar.gz" -o "$temp_file" - tar zxf "$temp_file" - mkdir -p /opt/kasm/backups/ - chmod 777 /opt/kasm/backups/ - mv /opt/kasm/1.*/certs/kasm_nginx.crt /opt/kasm/kasm_nginx.crt_bak - printf 'y\n' | $STD sudo bash /tmp/kasm_release/upgrade.sh - $STD sudo bash /tmp/kasm_release/upgrade.sh - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated ${APP} to v${RELEASE}" - - msg_info "Cleaning up" - rm -f "$temp_file" - rm -rf /tmp/kasm_release - $STD apt-get -y autoremove - $STD apt-get -y autoclean - msg_ok "Cleaned" - else - msg_ok "No update required. ${APP} is already at v${RELEASE}" - fi - exit } start diff --git a/ct/deferred/koel.sh b/ct/deferred/koel.sh index a4b6ea7e..b0c12d86 100644 --- a/ct/deferred/koel.sh +++ b/ct/deferred/koel.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/librespeed.sh b/ct/deferred/librespeed.sh index 931248cd..4861a568 100644 --- a/ct/deferred/librespeed.sh +++ b/ct/deferred/librespeed.sh @@ -17,34 +17,34 @@ var_unprivileged="1" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -f /opt/librespeed/index.html ]]; then - msg_error "No ${APP} Installation Found!" + if [[ ! -f /opt/librespeed/index.html ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -fsSL https://api.github.com/repos/librespeed/speedtest/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') + if [[ ! -f /opt/librespeed/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt//librespeed/${APP}_version.txt)" ]]; then + msg_info "Updating $APP..." + temp_file=$(mktemp) + curl -fsSL "https://github.com/librespeed/speedtest/archive/refs/tags/${RELEASE}.zip" -o "$temp_file" + mkdir -p /temp + unzip -qu "$temp_file" -d /temp + cd /temp/speedtest-"${RELEASE}" + cp -u favicon.ico index.html speedtest.js speedtest_worker.js /opt/librespeed/ + cp -ru backend /opt/librespeed/ + echo "${RELEASE}" >/opt/"${APP}"_version.txt + systemctl restart caddy + msg_ok "$APP has been updated." + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi exit - fi - RELEASE=$(curl -fsSL https://api.github.com/repos/librespeed/speedtest/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') - if [[ ! -f /opt/librespeed/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt//librespeed/${APP}_version.txt)" ]]; then - msg_info "Updating $APP..." - temp_file=$(mktemp) - curl -fsSL "https://github.com/librespeed/speedtest/archive/refs/tags/${RELEASE}.zip" -o "$temp_file" - mkdir -p /temp - unzip -qu "$temp_file" -d /temp - cd /temp/speedtest-"${RELEASE}" - cp -u favicon.ico index.html speedtest.js speedtest_worker.js /opt/librespeed/ - cp -ru backend /opt/librespeed/ - echo "${RELEASE}" >/opt/"${APP}"_version.txt - systemctl restart caddy - msg_ok "$APP has been updated." - else - msg_ok "No update required. ${APP} is already at ${RELEASE}" - fi - exit } start build_container diff --git a/ct/deferred/netbootxyz.sh b/ct/deferred/netbootxyz.sh index 201073af..60832ff4 100644 --- a/ct/deferred/netbootxyz.sh +++ b/ct/deferred/netbootxyz.sh @@ -26,7 +26,7 @@ var_os="${var_os:-debian}" var_version="${var_version:-12}" variables color -catch_errors +init_error_traps function default_settings() { CT_TYPE="1" diff --git a/ct/deferred/nginxproxymanager.sh b/ct/deferred/nginxproxymanager.sh index b1ff024d..41f1aecd 100644 --- a/ct/deferred/nginxproxymanager.sh +++ b/ct/deferred/nginxproxymanager.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/ocis.sh b/ct/deferred/ocis.sh index 167b4593..44f5f1ae 100644 --- a/ct/deferred/ocis.sh +++ b/ct/deferred/ocis.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/openwebui.sh b/ct/deferred/openwebui.sh index 85341bd9..47a9e74a 100644 --- a/ct/deferred/openwebui.sh +++ b/ct/deferred/openwebui.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/pixelfed.sh b/ct/deferred/pixelfed.sh index 8ddab519..44ac53b3 100644 --- a/ct/deferred/pixelfed.sh +++ b/ct/deferred/pixelfed.sh @@ -16,7 +16,7 @@ var_version="${var_version:-12}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/polaris.sh b/ct/deferred/polaris.sh index c290d770..c43b57de 100644 --- a/ct/deferred/polaris.sh +++ b/ct/deferred/polaris.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/roundcubemail.sh b/ct/deferred/roundcubemail.sh index 75d0e3bc..6f65e527 100644 --- a/ct/deferred/roundcubemail.sh +++ b/ct/deferred/roundcubemail.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/squirrelserversmanager.sh b/ct/deferred/squirrelserversmanager.sh index 4403ab5f..751a6026 100644 --- a/ct/deferred/squirrelserversmanager.sh +++ b/ct/deferred/squirrelserversmanager.sh @@ -16,7 +16,7 @@ var_unprivileged="${var_unprivileged:-1}" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/deferred/vikunja.sh b/ct/deferred/vikunja.sh index 792e3b1e..687d4700 100644 --- a/ct/deferred/vikunja.sh +++ b/ct/deferred/vikunja.sh @@ -17,55 +17,54 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /opt/vikunja ]]; then - msg_error "No ${APP} Installation Found!" - exit - fi + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/vikunja ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi - if whiptail --backtitle "Vikunja Update" --title "🔄 VERSION SELECTION" --yesno \ - "Choose the version type to update to:\n\n• STABLE: Recommended for production use\n• UNSTABLE: Latest development version\n\n⚠️ WARNING: Unstable versions may contain bugs,\nbe incomplete, or cause system instability.\nOnly use for testing purposes.\n\nDo you want to use the UNSTABLE version?\n(No = Stable, Yes = Unstable)" 16 70 --defaultno - then - msg_info "Selecting version" - RELEASE="unstable" - FILENAME="vikunja-${RELEASE}-x86_64.deb" - msg_ok "Selected UNSTABLE version" - else - msg_info "Selecting version" - RELEASE=$(curl -fsSL https://dl.vikunja.io/vikunja/ | grep -oP 'href="/vikunja/\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1) - FILENAME="vikunja-${RELEASE}-amd64.deb" - msg_ok "Selected STABLE version: ${RELEASE}" - fi - - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then - msg_info "Stopping ${APP}" - systemctl stop vikunja - msg_ok "Stopped ${APP}" - msg_info "Updating ${APP} to ${RELEASE}" - cd /opt - rm -rf /opt/vikunja/vikunja - rm -rf "/opt/$FILENAME" - curl -fsSL "https://dl.vikunja.io/vikunja/$RELEASE/$FILENAME" -o $(basename "https://dl.vikunja.io/vikunja/$RELEASE/$FILENAME") - export DEBIAN_FRONTEND=noninteractive - $STD dpkg -i $FILENAME - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated ${APP}" - msg_info "Starting ${APP}" - systemctl start vikunja - msg_ok "Started ${APP}" - msg_info "Cleaning Up" - rm -rf /opt/$FILENAME - msg_ok "Cleaned" - msg_ok "Updated Successfully" - else - msg_ok "No update required. ${APP} is already at ${RELEASE}" - fi - exit + if whiptail --backtitle "Vikunja Update" --title "🔄 VERSION SELECTION" --yesno \ + "Choose the version type to update to:\n\n• STABLE: Recommended for production use\n• UNSTABLE: Latest development version\n\n⚠️ WARNING: Unstable versions may contain bugs,\nbe incomplete, or cause system instability.\nOnly use for testing purposes.\n\nDo you want to use the UNSTABLE version?\n(No = Stable, Yes = Unstable)" 16 70 --defaultno; then + msg_info "Selecting version" + RELEASE="unstable" + FILENAME="vikunja-${RELEASE}-x86_64.deb" + msg_ok "Selected UNSTABLE version" + else + msg_info "Selecting version" + RELEASE=$(curl -fsSL https://dl.vikunja.io/vikunja/ | grep -oP 'href="/vikunja/\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1) + FILENAME="vikunja-${RELEASE}-amd64.deb" + msg_ok "Selected STABLE version: ${RELEASE}" + fi + + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping ${APP}" + systemctl stop vikunja + msg_ok "Stopped ${APP}" + msg_info "Updating ${APP} to ${RELEASE}" + cd /opt + rm -rf /opt/vikunja/vikunja + rm -rf "/opt/$FILENAME" + curl -fsSL "https://dl.vikunja.io/vikunja/$RELEASE/$FILENAME" -o $(basename "https://dl.vikunja.io/vikunja/$RELEASE/$FILENAME") + export DEBIAN_FRONTEND=noninteractive + $STD dpkg -i $FILENAME + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP}" + msg_info "Starting ${APP}" + systemctl start vikunja + msg_ok "Started ${APP}" + msg_info "Cleaning Up" + rm -rf /opt/$FILENAME + msg_ok "Cleaned" + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + exit } start diff --git a/ct/dispatcharr.sh b/ct/dispatcharr.sh index 49285859..979cd3d0 100644 --- a/ct/dispatcharr.sh +++ b/ct/dispatcharr.sh @@ -18,96 +18,94 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps 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!" + 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 - 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/ct/docspell.sh b/ct/docspell.sh index 93eb6806..a9667cea 100644 --- a/ct/docspell.sh +++ b/ct/docspell.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/ente.sh b/ct/ente.sh index 3074d79b..7f8b3132 100644 --- a/ct/ente.sh +++ b/ct/ente.sh @@ -17,21 +17,21 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /var ]]; then - msg_error "No ${APP} Installation Found!" + header_info + check_container_storage + check_container_resources + if [[ ! -d /var ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_info "Updating $APP LXC" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated $APP LXC" exit - fi - msg_info "Updating $APP LXC" - $STD apt-get update - $STD apt-get -y upgrade - msg_ok "Updated $APP LXC" - exit } start diff --git a/ct/freepbx.sh b/ct/freepbx.sh index d7526bcd..96f8dd02 100644 --- a/ct/freepbx.sh +++ b/ct/freepbx.sh @@ -18,44 +18,44 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources + + if [[ ! -f /lib/systemd/system/freepbx.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Updating $APP LXC" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated $APP LXC" + + msg_info "Updating $APP Modules" + $STD fwconsole ma updateall + $STD fwconsole reload + msg_ok "Updated $APP Modules" - if [[ ! -f /lib/systemd/system/freepbx.service ]]; then - msg_error "No ${APP} Installation Found!" exit - fi - - msg_info "Updating $APP LXC" - $STD apt-get update - $STD apt-get -y upgrade - msg_ok "Updated $APP LXC" - - msg_info "Updating $APP Modules" - $STD fwconsole ma updateall - $STD fwconsole reload - msg_ok "Updated $APP Modules" - - exit } start if whiptail --title "Commercial Modules" --yesno "Remove Commercial modules?" --defaultno 10 50; then - export ONLY_OPENSOURCE="yes" + export ONLY_OPENSOURCE="yes" - if whiptail --title "Firewall Module" --yesno "Do you want to KEEP the Firewall module (and sysadmin)?" 10 50; then - export REMOVE_FIREWALL="no" - else - export REMOVE_FIREWALL="yes" - fi + if whiptail --title "Firewall Module" --yesno "Do you want to KEEP the Firewall module (and sysadmin)?" 10 50; then + export REMOVE_FIREWALL="no" + else + export REMOVE_FIREWALL="yes" + fi else - export ONLY_OPENSOURCE="no" - export REMOVE_FIREWALL="no" + export ONLY_OPENSOURCE="no" + export REMOVE_FIREWALL="no" fi build_container diff --git a/ct/frigate.sh b/ct/frigate.sh index 479c6b98..2cc5d113 100644 --- a/ct/frigate.sh +++ b/ct/frigate.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-0}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/garmin-grafana.sh b/ct/garmin-grafana.sh index 7351ad00..f34fec36 100644 --- a/ct/garmin-grafana.sh +++ b/ct/garmin-grafana.sh @@ -17,78 +17,78 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps # this only updates garmin-grafana, not influxdb or grafana, which are upgraded with apt function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -d /opt/garmin-grafana/ ]]; then - msg_error "No ${APP} Installation Found!" + if [[ ! -d /opt/garmin-grafana/ ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + RELEASE=$(curl -fsSL https://api.github.com/repos/arpanghosh8453/garmin-grafana/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + if [[ ! -d /opt/garmin-grafana/ ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping $APP" + systemctl stop garmin-grafana + systemctl stop grafana-server + systemctl stop influxdb + msg_ok "Stopped $APP" + + if [[ ! -f /opt/garmin-grafana/.env ]]; then + msg_error "No .env file found in /opt/garmin-grafana/.env" + exit + fi + source /opt/garmin-grafana/.env + if [[ -z "${INFLUXDB_USER}" || -z "${INFLUXDB_PASSWORD}" || -z "${INFLUXDB_NAME}" ]]; then + msg_error "INFLUXDB_USER, INFLUXDB_PASSWORD, or INFLUXDB_NAME not set in .env file" + exit + fi + + msg_info "Creating Backup" + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/garmin-grafana/.garminconnect /opt/garmin-grafana/.env + mv /opt/garmin-grafana/ /opt/garmin-grafana-backup/ + msg_ok "Backup Created" + + msg_info "Updating $APP to v${RELEASE}" + curl -fsSL -o "${RELEASE}.zip" "https://github.com/arpanghosh8453/garmin-grafana/archive/refs/tags/${RELEASE}.zip" + unzip -q "${RELEASE}.zip" + mv "garmin-grafana-${RELEASE}/" "/opt/garmin-grafana" + rm -f "${RELEASE}.zip" + $STD uv sync --locked --project /opt/garmin-grafana/ + # shellcheck disable=SC2016 + sed -i 's/\${DS_GARMIN_STATS}/garmin_influxdb/g' /opt/garmin-grafana/Grafana_Dashboard/Garmin-Grafana-Dashboard.json + sed -i 's/influxdb:8086/localhost:8086/' /opt/garmin-grafana/Grafana_Datasource/influxdb.yaml + sed -i "s/influxdb_user/${INFLUXDB_USER}/" /opt/garmin-grafana/Grafana_Datasource/influxdb.yaml + sed -i "s/influxdb_secret_password/${INFLUXDB_PASSWORD}/" /opt/garmin-grafana/Grafana_Datasource/influxdb.yaml + sed -i "s/GarminStats/${INFLUXDB_NAME}/" /opt/garmin-grafana/Grafana_Datasource/influxdb.yaml + # Copy across grafana data + cp -r /opt/garmin-grafana/Grafana_Datasource/* /etc/grafana/provisioning/datasources + cp -r /opt/garmin-grafana/Grafana_Dashboard/* /etc/grafana/provisioning/dashboards + # Copy back the env and token files + cp /opt/garmin-grafana-backup/.env /opt/garmin-grafana/.env + cp -r /opt/garmin-grafana-backup/.garminconnect /opt/garmin-grafana/.garminconnect + msg_ok "Updated $APP to v${RELEASE}" + + msg_info "Starting $APP" + systemctl start garmin-grafana + systemctl start grafana-server + systemctl start influxdb + msg_ok "Started $APP" + + msg_info "Cleaning Up" + rm -rf /opt/garmin-grafana-backup + msg_ok "Cleanup Completed" + + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi exit - fi - - RELEASE=$(curl -fsSL https://api.github.com/repos/arpanghosh8453/garmin-grafana/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - if [[ ! -d /opt/garmin-grafana/ ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then - msg_info "Stopping $APP" - systemctl stop garmin-grafana - systemctl stop grafana-server - systemctl stop influxdb - msg_ok "Stopped $APP" - - if [[ ! -f /opt/garmin-grafana/.env ]]; then - msg_error "No .env file found in /opt/garmin-grafana/.env" - exit - fi - source /opt/garmin-grafana/.env - if [[ -z "${INFLUXDB_USER}" || -z "${INFLUXDB_PASSWORD}" || -z "${INFLUXDB_NAME}" ]]; then - msg_error "INFLUXDB_USER, INFLUXDB_PASSWORD, or INFLUXDB_NAME not set in .env file" - exit - fi - - msg_info "Creating Backup" - tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/garmin-grafana/.garminconnect /opt/garmin-grafana/.env - mv /opt/garmin-grafana/ /opt/garmin-grafana-backup/ - msg_ok "Backup Created" - - msg_info "Updating $APP to v${RELEASE}" - curl -fsSL -o "${RELEASE}.zip" "https://github.com/arpanghosh8453/garmin-grafana/archive/refs/tags/${RELEASE}.zip" - unzip -q "${RELEASE}.zip" - mv "garmin-grafana-${RELEASE}/" "/opt/garmin-grafana" - rm -f "${RELEASE}.zip" - $STD uv sync --locked --project /opt/garmin-grafana/ - # shellcheck disable=SC2016 - sed -i 's/\${DS_GARMIN_STATS}/garmin_influxdb/g' /opt/garmin-grafana/Grafana_Dashboard/Garmin-Grafana-Dashboard.json - sed -i 's/influxdb:8086/localhost:8086/' /opt/garmin-grafana/Grafana_Datasource/influxdb.yaml - sed -i "s/influxdb_user/${INFLUXDB_USER}/" /opt/garmin-grafana/Grafana_Datasource/influxdb.yaml - sed -i "s/influxdb_secret_password/${INFLUXDB_PASSWORD}/" /opt/garmin-grafana/Grafana_Datasource/influxdb.yaml - sed -i "s/GarminStats/${INFLUXDB_NAME}/" /opt/garmin-grafana/Grafana_Datasource/influxdb.yaml - # Copy across grafana data - cp -r /opt/garmin-grafana/Grafana_Datasource/* /etc/grafana/provisioning/datasources - cp -r /opt/garmin-grafana/Grafana_Dashboard/* /etc/grafana/provisioning/dashboards - # Copy back the env and token files - cp /opt/garmin-grafana-backup/.env /opt/garmin-grafana/.env - cp -r /opt/garmin-grafana-backup/.garminconnect /opt/garmin-grafana/.garminconnect - msg_ok "Updated $APP to v${RELEASE}" - - msg_info "Starting $APP" - systemctl start garmin-grafana - systemctl start grafana-server - systemctl start influxdb - msg_ok "Started $APP" - - msg_info "Cleaning Up" - rm -rf /opt/garmin-grafana-backup - msg_ok "Cleanup Completed" - - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Update Successful" - else - msg_ok "No update required. ${APP} is already at v${RELEASE}" - fi - exit } start diff --git a/ct/ghostfolio.sh b/ct/ghostfolio.sh index 6595d5f7..d74aead6 100644 --- a/ct/ghostfolio.sh +++ b/ct/ghostfolio.sh @@ -17,56 +17,56 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -f /opt/ghostfolio/dist/apps/api/main.js ]]; then - msg_error "No ${APP} Installation Found!" - exit - fi - - msg_info "Stopping $APP" - systemctl stop ghostfolio - msg_ok "Stopped $APP" - - msg_info "Creating Backup" - tar -czf "/opt/ghostfolio_backup_$(date +%F).tar.gz" /opt/ghostfolio - msg_ok "Backup Created" - - msg_info "Updating $APP" - systemctl stop ghostfolio - - if [[ -d /opt/ghostfolio ]]; then - rm -rf /opt/ghostfolio_backup - mv /opt/ghostfolio /opt/ghostfolio_backup - fi - - if fetch_and_deploy_gh_release "ghostfolio" "ghostfolio/ghostfolio" "tarball" "latest" "/opt/ghostfolio"; then - cd /opt/ghostfolio - npm ci - npm run build:production - npx prisma migrate deploy - msg_ok "Updated $APP" - else - if [[ -d /opt/ghostfolio_backup ]]; then - rm -rf /opt/ghostfolio - mv /opt/ghostfolio_backup /opt/ghostfolio + if [[ ! -f /opt/ghostfolio/dist/apps/api/main.js ]]; then + msg_error "No ${APP} Installation Found!" + exit fi - msg_ok "No update required or update failed. ${APP} is up to date" - fi - msg_info "Starting $APP" - systemctl start ghostfolio - msg_ok "Started $APP" + msg_info "Stopping $APP" + systemctl stop ghostfolio + msg_ok "Stopped $APP" - msg_info "Cleaning Up" - npm cache clean --force - msg_ok "Cleanup Completed" - exit + msg_info "Creating Backup" + tar -czf "/opt/ghostfolio_backup_$(date +%F).tar.gz" /opt/ghostfolio + msg_ok "Backup Created" + + msg_info "Updating $APP" + systemctl stop ghostfolio + + if [[ -d /opt/ghostfolio ]]; then + rm -rf /opt/ghostfolio_backup + mv /opt/ghostfolio /opt/ghostfolio_backup + fi + + if fetch_and_deploy_gh_release "ghostfolio" "ghostfolio/ghostfolio" "tarball" "latest" "/opt/ghostfolio"; then + cd /opt/ghostfolio + npm ci + npm run build:production + npx prisma migrate deploy + msg_ok "Updated $APP" + else + if [[ -d /opt/ghostfolio_backup ]]; then + rm -rf /opt/ghostfolio + mv /opt/ghostfolio_backup /opt/ghostfolio + fi + msg_ok "No update required or update failed. ${APP} is up to date" + fi + + msg_info "Starting $APP" + systemctl start ghostfolio + msg_ok "Started $APP" + + msg_info "Cleaning Up" + npm cache clean --force + msg_ok "Cleanup Completed" + exit } start diff --git a/ct/globaleaks.sh b/ct/globaleaks.sh index f6c7a43b..16e60b1a 100644 --- a/ct/globaleaks.sh +++ b/ct/globaleaks.sh @@ -16,21 +16,21 @@ var_version="${var_version:-12}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -f /usr/sbin/globaleaks ]]; then - msg_error "No ${APP} installation found!" - exit - fi + header_info + check_container_storage + check_container_resources + if [[ ! -f /usr/sbin/globaleaks ]]; then + msg_error "No ${APP} installation found!" + exit + fi - msg_info "Updating $APP LXC" - $STD apt-get update - $STD apt-get -y upgrade - msg_ok "Updated $APP LXC" + msg_info "Updating $APP LXC" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated $APP LXC" } start diff --git a/ct/hanko.sh b/ct/hanko.sh index de3079c2..53e295d2 100644 --- a/ct/hanko.sh +++ b/ct/hanko.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/joplin-server.sh b/ct/joplin-server.sh index fb6969cf..02983e10 100644 --- a/ct/joplin-server.sh +++ b/ct/joplin-server.sh @@ -17,39 +17,39 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /opt/joplin-server ]]; then - msg_error "No ${APP} Installation Found!" + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/joplin-server ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "joplin-server" "laurent22/joplin"; then + msg_info "Stopping Services" + systemctl stop joplin-server + msg_ok "Stopped Services" + + fetch_and_deploy_gh_release "joplin-server" "laurent22/joplin" "tarball" "latest" + + msg_info "Updating ${APP}" + cd /opt/joplin-server + sed -i "/onenote-converter/d" packages/lib/package.json + $STD yarn config set --home enableTelemetry 0 + export BUILD_SEQUENCIAL=1 + $STD yarn install --inline-builds + msg_ok "Updated $APP" + + msg_info "Starting Services" + systemctl start joplin-server + msg_ok "Started Services" + + msg_ok "Updated Successfully" + fi exit - fi - - if check_for_gh_release "joplin-server" "laurent22/joplin"; then - msg_info "Stopping Services" - systemctl stop joplin-server - msg_ok "Stopped Services" - - fetch_and_deploy_gh_release "joplin-server" "laurent22/joplin" "tarball" "latest" - - msg_info "Updating ${APP}" - cd /opt/joplin-server - sed -i "/onenote-converter/d" packages/lib/package.json - $STD yarn config set --home enableTelemetry 0 - export BUILD_SEQUENCIAL=1 - $STD yarn install --inline-builds - msg_ok "Updated $APP" - - msg_info "Starting Services" - systemctl start joplin-server - msg_ok "Started Services" - - msg_ok "Updated Successfully" - fi - exit } start diff --git a/ct/kanba.sh b/ct/kanba.sh index 270f5e00..04f85ace 100644 --- a/ct/kanba.sh +++ b/ct/kanba.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/leantime.sh b/ct/leantime.sh index 6a029571..e6fe9864 100644 --- a/ct/leantime.sh +++ b/ct/leantime.sh @@ -17,39 +17,39 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -d /opt/leantime ]]; then - msg_error "No ${APP} Installation Found!" + if [[ ! -d /opt/leantime ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "leantime" "Leantime/leantime"; then + msg_info "Creating Backup" + mariadb-dump leantime >"/opt/${APP}_db_backup_$(date +%F).sql" + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" "/opt/${APP}" + mv /opt/leantime /opt/leantime_bak + msg_ok "Backup Created" + + fetch_and_deploy_gh_release "leantime" "Leantime/leantime" "prebuild" "latest" "/opt/leantime" Leantime*.tar.gz + + msg_info "Restoring Config & Permissions" + mv /opt/leantime_bak/config/.env /opt/leantime/config/.env + chown -R www-data:www-data "/opt/leantime" + chmod -R 750 "/opt/leantime" + msg_ok "Restored Config & Permissions" + + msg_info "Removing Backup" + rm -rf /opt/leantime_bak + msg_ok "Removed Backup" + msg_ok "Updated Successfully" + fi exit - fi - - if check_for_gh_release "leantime" "Leantime/leantime"; then - msg_info "Creating Backup" - mariadb-dump leantime >"/opt/${APP}_db_backup_$(date +%F).sql" - tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" "/opt/${APP}" - mv /opt/leantime /opt/leantime_bak - msg_ok "Backup Created" - - fetch_and_deploy_gh_release "leantime" "Leantime/leantime" "prebuild" "latest" "/opt/leantime" Leantime*.tar.gz - - msg_info "Restoring Config & Permissions" - mv /opt/leantime_bak/config/.env /opt/leantime/config/.env - chown -R www-data:www-data "/opt/leantime" - chmod -R 750 "/opt/leantime" - msg_ok "Restored Config & Permissions" - - msg_info "Removing Backup" - rm -rf /opt/leantime_bak - msg_ok "Removed Backup" - msg_ok "Updated Successfully" - fi - exit } start diff --git a/ct/librenms.sh b/ct/librenms.sh index aaa71a1a..3acd3812 100644 --- a/ct/librenms.sh +++ b/ct/librenms.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/livebook.sh b/ct/livebook.sh index 438c14f4..7c8f3276 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -17,38 +17,38 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -f /opt/livebook/.mix/escripts/livebook ]]; then - msg_error "No ${APP} Installation Found!" + if [[ ! -f /opt/livebook/.mix/escripts/livebook ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "livebook" "livebook-dev/livebook"; then + msg_info "Stopping ${APP}" + systemctl stop livebook + msg_info "Service stopped" + + msg_info "Updating container" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated container" + + msg_info "Updating ${APP}" + source /opt/livebook/.env + cd /opt/livebook + $STD mix escript.install hex livebook --force + + chown -R livebook:livebook /opt/livebook /data + systemctl start livebook + msg_ok "Updated ${APP}" + fi exit - fi - - if check_for_gh_release "livebook" "livebook-dev/livebook"; then - msg_info "Stopping ${APP}" - systemctl stop livebook - msg_info "Service stopped" - - msg_info "Updating container" - $STD apt-get update - $STD apt-get -y upgrade - msg_ok "Updated container" - - msg_info "Updating ${APP}" - source /opt/livebook/.env - cd /opt/livebook - $STD mix escript.install hex livebook --force - - chown -R livebook:livebook /opt/livebook /data - systemctl start livebook - msg_ok "Updated ${APP}" - fi - exit } start diff --git a/ct/manyfold.sh b/ct/manyfold.sh index 2d782d55..d5b46484 100644 --- a/ct/manyfold.sh +++ b/ct/manyfold.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/maxun.sh b/ct/maxun.sh index a5561dc5..78a865fa 100644 --- a/ct/maxun.sh +++ b/ct/maxun.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/notesnook.sh b/ct/notesnook.sh index 3d1fbb3c..ddb87f82 100644 --- a/ct/notesnook.sh +++ b/ct/notesnook.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/npmplus.sh b/ct/npmplus.sh index 10a2fe4e..e6bb0b98 100644 --- a/ct/npmplus.sh +++ b/ct/npmplus.sh @@ -17,35 +17,35 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE MODE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 14 60 2 \ - "1" "Check for Alpine Updates" OFF \ - "2" "Update NPMplus Docker Container" ON \ - 3>&1 1>&2 2>&3) + UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE MODE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 14 60 2 \ + "1" "Check for Alpine Updates" OFF \ + "2" "Update NPMplus Docker Container" ON \ + 3>&1 1>&2 2>&3) - header_info "$APP" + header_info "$APP" - case "$UPD" in - "1") - msg_info "Updating Alpine OS" - $STD apk -U upgrade - msg_ok "System updated" - exit - ;; - "2") - msg_info "Updating NPMplus Container" - cd /opt - msg_info "Pulling latest container image" - $STD docker compose pull - msg_info "Recreating container" - $STD docker compose up -d - msg_ok "NPMplus container updated" - exit - ;; - esac - exit 0 + case "$UPD" in + "1") + msg_info "Updating Alpine OS" + $STD apk -U upgrade + msg_ok "System updated" + exit + ;; + "2") + msg_info "Updating NPMplus Container" + cd /opt + msg_info "Pulling latest container image" + $STD docker compose pull + msg_info "Recreating container" + $STD docker compose up -d + msg_ok "NPMplus container updated" + exit + ;; + esac + exit 0 } start diff --git a/ct/opencloud.sh b/ct/opencloud.sh index 2c428f93..e97c3af3 100644 --- a/ct/opencloud.sh +++ b/ct/opencloud.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/postiz.sh b/ct/postiz.sh index e5355367..32ec0ac3 100644 --- a/ct/postiz.sh +++ b/ct/postiz.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/proxmox-datacenter-manager.sh b/ct/proxmox-datacenter-manager.sh index 19cf1328..57796383 100644 --- a/ct/proxmox-datacenter-manager.sh +++ b/ct/proxmox-datacenter-manager.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info @@ -30,7 +30,7 @@ function update_script() { if grep -q 'Debian GNU/Linux 12' /etc/os-release && [ -f /etc/apt/sources.list.d/proxmox-release-bookworm.list ] && [ -f /etc/apt/sources.list.d/pdm-test.list ]; then msg_info "Updating outdated outdated source formats" - echo "deb [signed-by=/usr/share/keyrings/proxmox-archive-keyring.gpg] http://download.proxmox.com/debian/pdm bookworm pdm-test" > /etc/apt/sources.list.d/pdm-test.list + echo "deb [signed-by=/usr/share/keyrings/proxmox-archive-keyring.gpg] http://download.proxmox.com/debian/pdm bookworm pdm-test" >/etc/apt/sources.list.d/pdm-test.list curl -fsSL https://enterprise.proxmox.com/debian/proxmox-archive-keyring-trixie.gpg -o /usr/share/keyrings/proxmox-archive-keyring.gpg rm -f /etc/apt/keyrings/proxmox-release-bookworm.gpg /etc/apt/sources.list.d/proxmox-release-bookworm.list $STD apt-get update diff --git a/ct/romm.sh b/ct/romm.sh index 8dc95b58..771aed1d 100644 --- a/ct/romm.sh +++ b/ct/romm.sh @@ -18,48 +18,48 @@ var_fuse="${var_fuse:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -d /opt/romm ]]; then - msg_error "No ${APP} Installation Found!" + if [[ ! -d /opt/romm ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Stopping $APP" + systemctl stop romm + systemctl stop nginx + msg_ok "Stopped $APP" + + msg_info "Updating $APP" + cd /opt/romm/app + git pull + + # Update backend + cd /opt/romm/app + source /opt/romm/venv/bin/activate + pip install --upgrade pip + pip install poetry + poetry install + + # Update frontend + cd /opt/romm/app/frontend + npm install + npm run build + + echo "Updated on $(date)" >/opt/romm/version.txt + msg_ok "Updated $APP" + + msg_info "Starting $APP" + systemctl start romm + systemctl start nginx + msg_ok "Started $APP" + msg_ok "Update Successful" exit - fi - - msg_info "Stopping $APP" - systemctl stop romm - systemctl stop nginx - msg_ok "Stopped $APP" - - msg_info "Updating $APP" - cd /opt/romm/app - git pull - - # Update backend - cd /opt/romm/app - source /opt/romm/venv/bin/activate - pip install --upgrade pip - pip install poetry - poetry install - - # Update frontend - cd /opt/romm/app/frontend - npm install - npm run build - - echo "Updated on $(date)" >/opt/romm/version.txt - msg_ok "Updated $APP" - - msg_info "Starting $APP" - systemctl start romm - systemctl start nginx - msg_ok "Started $APP" - msg_ok "Update Successful" - exit } start diff --git a/ct/rybbit.sh b/ct/rybbit.sh index e523bde2..6e3caddd 100644 --- a/ct/rybbit.sh +++ b/ct/rybbit.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/scraparr.sh b/ct/scraparr.sh index e5ba622a..bca478df 100644 --- a/ct/scraparr.sh +++ b/ct/scraparr.sh @@ -17,40 +17,40 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -d /opt/scraparr/ ]]; then - msg_error "No ${APP} Installation Found!" + if [[ ! -d /opt/scraparr/ ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + if check_for_gh_release "scraparr" "thecfu/scraparr"; then + msg_info "Stopping Services" + systemctl stop scraparr + msg_ok "Services Stopped" + + PYTHON_VERSION="3.12" setup_uv + fetch_and_deploy_gh_release "scrappar" "thecfu/scraparr" "tarball" "latest" "/opt/scraparr" + + msg_info "Updating Scraparr" + cd /opt/scraparr + $STD uv venv /opt/scraparr/.venv + $STD /opt/scraparr/.venv/bin/python -m ensurepip --upgrade + $STD /opt/scraparr/.venv/bin/python -m pip install --upgrade pip + $STD /opt/scraparr/.venv/bin/python -m pip install -r /opt/scraparr/src/scraparr/requirements.txt + chmod -R 755 /opt/scraparr + msg_ok "Updated Scraparr" + + msg_info "Starting Services" + systemctl start scraparr + msg_ok "Services Started" + msg_ok "Updated Successfully" + fi exit - fi - if check_for_gh_release "scraparr" "thecfu/scraparr"; then - msg_info "Stopping Services" - systemctl stop scraparr - msg_ok "Services Stopped" - - PYTHON_VERSION="3.12" setup_uv - fetch_and_deploy_gh_release "scrappar" "thecfu/scraparr" "tarball" "latest" "/opt/scraparr" - - msg_info "Updating Scraparr" - cd /opt/scraparr - $STD uv venv /opt/scraparr/.venv - $STD /opt/scraparr/.venv/bin/python -m ensurepip --upgrade - $STD /opt/scraparr/.venv/bin/python -m pip install --upgrade pip - $STD /opt/scraparr/.venv/bin/python -m pip install -r /opt/scraparr/src/scraparr/requirements.txt - chmod -R 755 /opt/scraparr - msg_ok "Updated Scraparr" - - msg_info "Starting Services" - systemctl start scraparr - msg_ok "Services Started" - msg_ok "Updated Successfully" - fi - exit } start diff --git a/ct/signoz.sh b/ct/signoz.sh index 936ac4cc..3e7d5bcc 100644 --- a/ct/signoz.sh +++ b/ct/signoz.sh @@ -17,41 +17,41 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /opt/signoz ]]; then - msg_error "No ${APP} Installation Found!" + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/signoz ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "signoz" "SigNoz/signoz"; then + msg_info "Stopping Services" + systemctl stop signoz + systemctl stop signoz-otel-collector + msg_ok "Stopped Services" + + fetch_and_deploy_gh_release "signoz" "SigNoz/signoz" "prebuild" "latest" "/opt/signoz" "signoz-community_linux_amd64.tar.gz" + fetch_and_deploy_gh_release "signoz-otel-collector" "SigNoz/signoz-otel-collector" "prebuild" "latest" "/opt/signoz-otel-collector" "signoz-otel-collector_linux_amd64.tar.gz" + fetch_and_deploy_gh_release "signoz-schema-migrator" "SigNoz/signoz-otel-collector" "prebuild" "latest" "/opt/signoz-schema-migrator" "signoz-schema-migrator_linux_amd64.tar.gz" + + msg_info "Updating ${APP}" + cd /opt/signoz-schema-migrator/bin + $STD ./signoz-schema-migrator sync --dsn="tcp://localhost:9000?password=" --replication=true --up= + $STD ./signoz-schema-migrator async --dsn="tcp://localhost:9000?password=" --replication=true --up= + msg_ok "Updated $APP" + + msg_info "Starting Services" + systemctl start signoz-otel-collector + systemctl start signoz + msg_ok "Started Services" + + msg_ok "Updated Successfully" + fi exit - fi - - if check_for_gh_release "signoz" "SigNoz/signoz"; then - msg_info "Stopping Services" - systemctl stop signoz - systemctl stop signoz-otel-collector - msg_ok "Stopped Services" - - fetch_and_deploy_gh_release "signoz" "SigNoz/signoz" "prebuild" "latest" "/opt/signoz" "signoz-community_linux_amd64.tar.gz" - fetch_and_deploy_gh_release "signoz-otel-collector" "SigNoz/signoz-otel-collector" "prebuild" "latest" "/opt/signoz-otel-collector" "signoz-otel-collector_linux_amd64.tar.gz" - fetch_and_deploy_gh_release "signoz-schema-migrator" "SigNoz/signoz-otel-collector" "prebuild" "latest" "/opt/signoz-schema-migrator" "signoz-schema-migrator_linux_amd64.tar.gz" - - msg_info "Updating ${APP}" - cd /opt/signoz-schema-migrator/bin - $STD ./signoz-schema-migrator sync --dsn="tcp://localhost:9000?password=" --replication=true --up= - $STD ./signoz-schema-migrator async --dsn="tcp://localhost:9000?password=" --replication=true --up= - msg_ok "Updated $APP" - - msg_info "Starting Services" - systemctl start signoz-otel-collector - systemctl start signoz - msg_ok "Started Services" - - msg_ok "Updated Successfully" - fi - exit } start diff --git a/ct/tunarr.sh b/ct/tunarr.sh index a3941b1d..9af3bebc 100644 --- a/ct/tunarr.sh +++ b/ct/tunarr.sh @@ -17,53 +17,53 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /opt/tunarr ]]; then - msg_error "No ${APP} Installation Found!" + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/tunarr ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + if check_for_gh_release "tunarr" "chrisbenincasa/tunarr"; then + msg_info "Stopping ${APP}" + systemctl stop tunarr + msg_ok "Stopped ${APP}" + + msg_info "Creating Backup" + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /usr/.local/share/tunarr + msg_ok "Backup Created" + + fetch_and_deploy_gh_release "tunarr" "chrisbenincasa/tunarr" "singlefile" "latest" "/opt/tunarr" "*linux-x64" + + msg_info "Starting ${APP}" + systemctl start tunarr + msg_ok "Started ${APP}" + + msg_ok "Updated Successfully" + fi + + if check_for_gh_release "ersatztv-ffmpeg" "ErsatzTV/ErsatzTV-ffmpeg"; then + msg_info "Stopping ${APP}" + systemctl stop tunarr + msg_ok "Stopped ${APP}" + + fetch_and_deploy_gh_release "ersatztv-ffmpeg" "ErsatzTV/ErsatzTV-ffmpeg" "prebuild" "latest" "/opt/ErsatzTV-ffmpeg" "*-linux64-gpl-7.1.tar.xz" + + msg_info "Set ErsatzTV-ffmpeg links" + chmod +x /opt/ErsatzTV-ffmpeg/bin/* + ln -sf /opt/ErsatzTV-ffmpeg/bin/ffmpeg /usr/local/bin/ffmpeg + ln -sf /opt/ErsatzTV-ffmpeg/bin/ffplay /usr/local/bin/ffplay + ln -sf /opt/ErsatzTV-ffmpeg/bin/ffprobe /usr/local/bin/ffprobe + msg_ok "ffmpeg links set" + + msg_info "Starting ${APP}" + systemctl start tunarr + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" + fi exit - fi - if check_for_gh_release "tunarr" "chrisbenincasa/tunarr"; then - msg_info "Stopping ${APP}" - systemctl stop tunarr - msg_ok "Stopped ${APP}" - - msg_info "Creating Backup" - tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /usr/.local/share/tunarr - msg_ok "Backup Created" - - fetch_and_deploy_gh_release "tunarr" "chrisbenincasa/tunarr" "singlefile" "latest" "/opt/tunarr" "*linux-x64" - - msg_info "Starting ${APP}" - systemctl start tunarr - msg_ok "Started ${APP}" - - msg_ok "Updated Successfully" - fi - - if check_for_gh_release "ersatztv-ffmpeg" "ErsatzTV/ErsatzTV-ffmpeg"; then - msg_info "Stopping ${APP}" - systemctl stop tunarr - msg_ok "Stopped ${APP}" - - fetch_and_deploy_gh_release "ersatztv-ffmpeg" "ErsatzTV/ErsatzTV-ffmpeg" "prebuild" "latest" "/opt/ErsatzTV-ffmpeg" "*-linux64-gpl-7.1.tar.xz" - - msg_info "Set ErsatzTV-ffmpeg links" - chmod +x /opt/ErsatzTV-ffmpeg/bin/* - ln -sf /opt/ErsatzTV-ffmpeg/bin/ffmpeg /usr/local/bin/ffmpeg - ln -sf /opt/ErsatzTV-ffmpeg/bin/ffplay /usr/local/bin/ffplay - ln -sf /opt/ErsatzTV-ffmpeg/bin/ffprobe /usr/local/bin/ffprobe - msg_ok "ffmpeg links set" - - msg_info "Starting ${APP}" - systemctl start tunarr - msg_ok "Started ${APP}" - msg_ok "Updated Successfully" - fi - exit } start diff --git a/ct/ubuntu.sh b/ct/ubuntu.sh index f208d7d0..5bae645b 100644 --- a/ct/ubuntu.sh +++ b/ct/ubuntu.sh @@ -19,7 +19,7 @@ var_unprivileged="${var_unprivileged:-0}" header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { header_info diff --git a/ct/viseron.sh b/ct/viseron.sh index ef0f4a98..6534ff2e 100644 --- a/ct/viseron.sh +++ b/ct/viseron.sh @@ -14,18 +14,18 @@ header_info "$APP" variables color -catch_errors +init_error_traps function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -f /etc/systemd/system/viseron.service ]]; then - msg_error "No ${APP} Installation Found!" + header_info + check_container_storage + check_container_resources + if [[ ! -f /etc/systemd/system/viseron.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_error "To update Viseron, create a new container and transfer your configuration." exit - fi - msg_error "To update Viseron, create a new container and transfer your configuration." - exit } start diff --git a/ct/wallabag.sh b/ct/wallabag.sh index 9325189a..910948ff 100644 --- a/ct/wallabag.sh +++ b/ct/wallabag.sh @@ -22,7 +22,7 @@ base_settings # Core variables color -catch_errors +init_error_traps function update_script() { header_info