From fe76ba1709517f887f4b1727ec03c93770c0098c Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 29 Apr 2025 15:52:59 +0200 Subject: [PATCH] Update sabnzbd.sh --- ct/sabnzbd.sh | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ct/sabnzbd.sh b/ct/sabnzbd.sh index 8f0c8585..838c57ab 100644 --- a/ct/sabnzbd.sh +++ b/ct/sabnzbd.sh @@ -28,11 +28,14 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + RELEASE=$(curl -fsSL https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" = "$(cat /opt/${APP}_version.txt)" ]]; then + + if [[ -f /opt/${APP}_version.txt ]] && [[ "${RELEASE}" == "$(cat /opt/${APP}_version.txt)" ]]; then msg_ok "No update required. ${APP} is already at ${RELEASE}" exit fi + msg_info "Updating $APP to ${RELEASE}" systemctl stop sabnzbd cp -r /opt/sabnzbd /opt/sabnzbd_backup_$(date +%s) @@ -42,28 +45,22 @@ function update_script() { cp -rf "${tmpdir}/SABnzbd-${RELEASE}/"* /opt/sabnzbd/ rm -rf "$tmpdir" + # Check if venv exists, else create with uv if [[ ! -d /opt/sabnzbd/venv ]]; then - msg_info "Migrating SABnzbd to venv installation" - $STD python3 -m venv /opt/sabnzbd/venv - source /opt/sabnzbd/venv/bin/activate - $STD pip install --upgrade pip - if [[ -f /opt/sabnzbd/requirements.txt ]]; then - $STD pip install -r /opt/sabnzbd/requirements.txt - fi - deactivate + msg_info "Migrating SABnzbd to uv virtual environment" + $STD uv venv /opt/sabnzbd/venv + msg_ok "Created uv venv at /opt/sabnzbd/venv" if grep -q "ExecStart=python3 SABnzbd.py" /etc/systemd/system/sabnzbd.service; then sed -i "s|ExecStart=python3 SABnzbd.py|ExecStart=/opt/sabnzbd/venv/bin/python SABnzbd.py|" /etc/systemd/system/sabnzbd.service systemctl daemon-reload - msg_ok "Migrated SABnzbd to venv installation and updated Service" + msg_ok "Updated SABnzbd service to use uv venv" fi - else - source /opt/sabnzbd/venv/bin/activate - $STD pip install --upgrade pip - $STD pip install -r /opt/sabnzbd/requirements.txt - deactivate fi + $STD uv pip install --upgrade pip --python=/opt/sabnzbd/venv/bin/python + $STD uv pip install -r /opt/sabnzbd/requirements.txt --python=/opt/sabnzbd/venv/bin/python + echo "${RELEASE}" >/opt/${APP}_version.txt systemctl start sabnzbd msg_ok "Updated ${APP} to ${RELEASE}"