From 58de656fe713609d859bb178a7b430376e34ece5 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:46:19 +0200 Subject: [PATCH] Update sabnzbd.sh --- ct/sabnzbd.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ct/sabnzbd.sh b/ct/sabnzbd.sh index a29ef5d..b46356c 100644 --- a/ct/sabnzbd.sh +++ b/ct/sabnzbd.sh @@ -29,6 +29,23 @@ function update_script() { 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 [[ ! -d /opt/sabnzbd/venv ]]; then + msg_info "Migrating SABnzbd to venv installation" + python3 -m venv /opt/sabnzbd/venv + source /opt/sabnzbd/venv/bin/activate + pip install --upgrade pip + if [[ -f /opt/sabnzbd/requirements.txt ]]; then + pip install -r /opt/sabnzbd/requirements.txt + fi + deactivate + 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 + systemctl restart sabnzbd.service + msg_ok "Migrated SABnzbd to venv installation and updated Service" + fi + fi + msg_info "Updating $APP to ${RELEASE}" systemctl stop sabnzbd.service tar zxvf <(curl -fsSL https://github.com/sabnzbd/sabnzbd/releases/download/$RELEASE/SABnzbd-${RELEASE}-src.tar.gz)