11#! /usr/bin/env bash
22source <( curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
33# Copyright (c) 2021-2025 tteck
4- # Author: tteck (tteckster)
4+ # Author: tteck (tteckster) | Co-Author: MickLesk (CanbiZ)
55# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
66# Source: https://sabnzbd.org/
77
88APP=" SABnzbd"
99var_tags=" ${var_tags:- downloader} "
1010var_cpu=" ${var_cpu:- 2} "
11- var_ram=" ${var_ram:- 4096 } "
12- var_disk=" ${var_disk:- 8 } "
11+ var_ram=" ${var_ram:- 2048 } "
12+ var_disk=" ${var_disk:- 5 } "
1313var_os=" ${var_os:- debian} "
1414var_version=" ${var_version:- 12} "
1515var_unprivileged=" ${var_unprivileged:- 1} "
@@ -20,30 +20,43 @@ color
2020catch_errors
2121
2222function update_script() {
23- header_info
24- check_container_storage
25- check_container_resources
26- if [[ ! -d /opt/sabnzbd ]]; then
27- msg_error " No ${APP} Installation Found!"
28- exit
29- fi
30- RELEASE=$( curl -fsSL https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep " tag_name" | awk ' {print substr($2, 2, length($2)-3) }' )
31- if [[ ! -f /opt/${APP} _version.txt ]] || [[ " ${RELEASE} " != " $( cat /opt/${APP} _version.txt) " ]]; then
23+ header_info
24+ check_container_storage
25+ check_container_resources
26+
27+ if [[ ! -d /opt/sabnzbd ]]; then
28+ msg_error " No ${APP} Installation Found!"
29+ exit
30+ fi
31+ RELEASE=$( curl -fsSL https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep " tag_name" | awk ' {print substr($2, 2, length($2)-3) }' )
32+ if [[ -f /opt/${APP} _version.txt ]] && [[ " ${RELEASE} " == " $( cat /opt/${APP} _version.txt) " ]]; then
33+ msg_ok " No update required. ${APP} is already at ${RELEASE} "
34+ exit
35+ fi
3236 msg_info " Updating $APP to ${RELEASE} "
33- rm -rf /usr/lib/python3.* /EXTERNALLY-MANAGED
34- systemctl stop sabnzbd.service
35- tar zxvf <( curl -fsSL https://github.com/sabnzbd/sabnzbd/releases/download/$RELEASE /SABnzbd-${RELEASE} -src.tar.gz)
36- cp -rf SABnzbd-${RELEASE} /* /opt/sabnzbd
37- rm -rf SABnzbd-${RELEASE}
38- cd /opt/sabnzbd
39- $STD python3 -m pip install -r requirements.txt
37+ systemctl stop sabnzbd
38+ cp -r /opt/sabnzbd /opt/sabnzbd_backup_$( date +%s)
39+ temp_file=$( mktemp)
40+ curl -fsSL " https://github.com/sabnzbd/sabnzbd/releases/download/${RELEASE} /SABnzbd-${RELEASE} -src.tar.gz" -o " $temp_file "
41+ tar -xzf " $temp_file " -C /opt/sabnzbd --strip-components=1
42+ rm -f " $temp_file "
43+ if [[ ! -d /opt/sabnzbd/venv ]]; then
44+ msg_info " Migrating SABnzbd to uv virtual environment"
45+ $STD uv venv /opt/sabnzbd/venv
46+ msg_ok " Created uv venv at /opt/sabnzbd/venv"
47+
48+ if grep -q " ExecStart=python3 SABnzbd.py" /etc/systemd/system/sabnzbd.service; then
49+ sed -i " s|ExecStart=python3 SABnzbd.py|ExecStart=/opt/sabnzbd/venv/bin/python SABnzbd.py|" /etc/systemd/system/sabnzbd.service
50+ systemctl daemon-reload
51+ msg_ok " Updated SABnzbd service to use uv venv"
52+ fi
53+ fi
54+ $STD uv pip install --upgrade pip --python=/opt/sabnzbd/venv/bin/python
55+ $STD uv pip install -r /opt/sabnzbd/requirements.txt --python=/opt/sabnzbd/venv/bin/python
4056 echo " ${RELEASE} " > /opt/${APP} _version.txt
41- systemctl start sabnzbd.service
57+ systemctl start sabnzbd
4258 msg_ok " Updated ${APP} to ${RELEASE} "
43- else
44- msg_ok " No update required. ${APP} is already at ${RELEASE} "
45- fi
46- exit
59+ exit
4760}
4861
4962start
@@ -54,3 +67,4 @@ msg_ok "Completed Successfully!\n"
5467echo -e " ${CREATING}${GN}${APP} setup has been successfully initialized!${CL} "
5568echo -e " ${INFO}${YW} Access it using the following URL:${CL} "
5669echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :7777${CL} "
70+
0 commit comments