diff --git a/ct/sabnzbd.sh b/ct/sabnzbd.sh index b69bf77a5..d111fc1c1 100644 --- a/ct/sabnzbd.sh +++ b/ct/sabnzbd.sh @@ -38,16 +38,18 @@ function update_script() { cp -r /opt/sabnzbd /opt/sabnzbd_backup_$(date +%s) fetch_and_deploy_gh_release "sabnzbd-org" "sabnzbd/sabnzbd" "prebuild" "latest" "/opt/sabnzbd" "SABnzbd-*-src.tar.gz" + # Always ensure venv exists if [[ ! -d /opt/sabnzbd/venv ]]; then msg_info "Migrating SABnzbd to uv virtual environment" $STD uv venv /opt/sabnzbd/venv msg_ok "Created uv venv at /opt/sabnzbd/venv" + fi - 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 "Updated SABnzbd service to use uv venv" - fi + # Always check and fix service file if needed + if [[ -f /etc/systemd/system/sabnzbd.service ]] && 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 "Updated SABnzbd service to use uv venv" 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