Skip to content

Commit c66fb80

Browse files
authored
Refactor: sabnzbd (#4127)
* Refactor: sabnzbd * update SABnzbd to uv * update to uv * Update sabnzbd.sh * Update sabnzbd.sh * Update sabnzbd-install.sh * Update sabnzbd.json * add .sabnzbd/ ini
1 parent 0356697 commit c66fb80

File tree

3 files changed

+70
-50
lines changed

3 files changed

+70
-50
lines changed

ct/sabnzbd.sh

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env bash
22
source <(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

88
APP="SABnzbd"
99
var_tags="${var_tags:-downloader}"
1010
var_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}"
1313
var_os="${var_os:-debian}"
1414
var_version="${var_version:-12}"
1515
var_unprivileged="${var_unprivileged:-1}"
@@ -20,30 +20,43 @@ color
2020
catch_errors
2121

2222
function 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

4962
start
@@ -54,3 +67,4 @@ msg_ok "Completed Successfully!\n"
5467
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
5568
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
5669
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:7777${CL}"
70+

frontend/public/json/sabnzbd.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
"updateable": true,
1010
"privileged": false,
1111
"interface_port": 7777,
12-
"documentation": null,
12+
"documentation": "https://sabnzbd.org/wiki/",
1313
"website": "https://sabnzbd.org/",
14-
"logo": "https://raw.githubusercontent.com/sabnzbd/sabnzbd/develop/icons/logo-arrow.svg",
15-
"config_path": "",
14+
"logo": "https://raw.githubusercontent.com/selfhst/icons/refs/heads/main/svg/sabnzbd.svg",
15+
"config_path": "/.sabnzbd/sabnzbd.ini",
1616
"description": "SABnzbd is a free, open-source software program for downloading binary files from Usenet newsgroups. It is designed to be easy to use, and provides a number of features to simplify the downloading process, such as automatic error detection and repair, download scheduling, and integration with other applications. SABnzbd is a binary newsreader, which means it is specifically designed for downloading binary files, such as images, music, and video, from Usenet newsgroups. With its user-friendly interface and powerful features, SABnzbd makes it easy to manage your Usenet downloads and keep your download queue organized.",
1717
"install_methods": [
1818
{
1919
"type": "default",
2020
"script": "ct/sabnzbd.sh",
2121
"resources": {
2222
"cpu": 2,
23-
"ram": 4096,
24-
"hdd": 8,
23+
"ram": 2048,
24+
"hdd": 5,
2525
"os": "debian",
2626
"version": "12"
2727
}

install/sabnzbd-install.sh

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

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

@@ -14,52 +14,58 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
$STD apt-get install -y par2
18-
$STD apt-get install -y p7zip-full
17+
$STD apt-get install -y \
18+
par2 \
19+
p7zip-full
20+
msg_ok "Installed Dependencies"
21+
22+
msg_info "Setup uv"
23+
setup_uv
24+
msg_ok "Setup uv"
25+
26+
msg_info "Setup Unrar"
1927
cat <<EOF >/etc/apt/sources.list.d/non-free.list
2028
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
2129
EOF
2230
$STD apt-get update
2331
$STD apt-get install -y unrar
2432
rm /etc/apt/sources.list.d/non-free.list
25-
msg_ok "Installed Dependencies"
26-
27-
msg_info "Setup Python3"
28-
$STD apt-get install -y \
29-
python3-dev \
30-
python3-pip
31-
$STD apt-get install -y python3-setuptools
32-
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
33-
msg_ok "Setup Python3"
33+
msg_ok "Setup Unrar"
3434

3535
msg_info "Installing SABnzbd"
3636
RELEASE=$(curl -fsSL https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
37-
$STD tar zxvf <(curl -fsSL https://github.com/sabnzbd/sabnzbd/releases/download/$RELEASE/SABnzbd-${RELEASE}-src.tar.gz)
38-
mv SABnzbd-${RELEASE} /opt/sabnzbd
39-
cd /opt/sabnzbd
40-
$STD python3 -m pip install -r requirements.txt
37+
mkdir -p /opt/sabnzbd
38+
$STD uv venv /opt/sabnzbd/venv
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+
$STD uv pip install -r /opt/sabnzbd/requirements.txt --python=/opt/sabnzbd/venv/bin/python
4143
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
4244
msg_ok "Installed SABnzbd"
4345

4446
msg_info "Creating Service"
45-
service_path="/etc/systemd/system/sabnzbd.service"
46-
echo "[Unit]
47+
cat <<EOF >/etc/systemd/system/sabnzbd.service
48+
[Unit]
4749
Description=SABnzbd
4850
After=network.target
51+
4952
[Service]
5053
WorkingDirectory=/opt/sabnzbd
51-
ExecStart=python3 SABnzbd.py -s 0.0.0.0:7777
54+
ExecStart=/opt/sabnzbd/venv/bin/python SABnzbd.py -s 0.0.0.0:7777
5255
Restart=always
5356
User=root
57+
5458
[Install]
55-
WantedBy=multi-user.target" >$service_path
56-
systemctl enable --now -q sabnzbd.service
59+
WantedBy=multi-user.target
60+
EOF
61+
systemctl enable -q --now sabnzbd
5762
msg_ok "Created Service"
5863

5964
motd_ssh
6065
customize
6166

6267
msg_info "Cleaning up"
68+
rm -f "$temp_file"
6369
$STD apt-get -y autoremove
6470
$STD apt-get -y autoclean
6571
msg_ok "Cleaned"

0 commit comments

Comments
 (0)