mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 02:12:49 +00:00 
			
		
		
		
	Update SABnzbd. Include par2cmdline-turbo (#8648)
* Fix non-free sources - Don't delete after use - Use trixie instead of bookworm - deb822 style * Add par2cmdline-turbo to sabnzbd * Remove duplicate setup_uv * Remove duplicated msg around setup_uv * Update sabnzbd to use fetch_and_deploy * switch fetch_deploy outside of msg Added virtual environment setup and package installation for SABnzbd. --------- Co-authored-by: CanbiZ <47820557+MickLesk@users.noreply.github.com>
This commit is contained in:
		@@ -24,40 +24,38 @@ function update_script() {
 | 
				
			|||||||
    check_container_storage
 | 
					    check_container_storage
 | 
				
			||||||
    check_container_resources
 | 
					    check_container_resources
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if par2 --version | grep -q "par2cmdline-turbo"; then
 | 
				
			||||||
 | 
					        fetch_and_deploy_gh_release "par2cmdline-turbo" "animetosho/par2cmdline-turbo" "prebuild" "latest" "/usr/bin/" "*-linux-amd64.zip"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    if [[ ! -d /opt/sabnzbd ]]; then
 | 
					    if [[ ! -d /opt/sabnzbd ]]; then
 | 
				
			||||||
        msg_error "No ${APP} Installation Found!"
 | 
					        msg_error "No ${APP} Installation Found!"
 | 
				
			||||||
        exit
 | 
					        exit
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    setup_uv
 | 
					    if check_for_gh_release "sabnzbd-org" "sabnzbd/sabnzbd"; then
 | 
				
			||||||
    RELEASE=$(curl -fsSL https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
 | 
					        PYTHON_VERSION="3.13" setup_uv
 | 
				
			||||||
    if [[ -f /opt/${APP}_version.txt ]] && [[ "${RELEASE}" == "$(cat /opt/${APP}_version.txt)" ]]; then
 | 
					        systemctl stop sabnzbd
 | 
				
			||||||
        msg_ok "No update required. ${APP} is already at ${RELEASE}"
 | 
					        cp -r /opt/sabnzbd /opt/sabnzbd_backup_$(date +%s)
 | 
				
			||||||
        exit
 | 
					        fetch_and_deploy_gh_release "sabnzbd-org" "sabnzbd/sabnzbd" "prebuild" "latest" "/opt/sabnzbd" "SABnzbd-*-src.tar.gz"
 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
    setup_uv
 | 
					 | 
				
			||||||
    msg_info "Updating $APP to ${RELEASE}"
 | 
					 | 
				
			||||||
    systemctl stop sabnzbd
 | 
					 | 
				
			||||||
    cp -r /opt/sabnzbd /opt/sabnzbd_backup_$(date +%s)
 | 
					 | 
				
			||||||
    temp_file=$(mktemp)
 | 
					 | 
				
			||||||
    curl -fsSL "https://github.com/sabnzbd/sabnzbd/releases/download/${RELEASE}/SABnzbd-${RELEASE}-src.tar.gz" -o "$temp_file"
 | 
					 | 
				
			||||||
    tar -xzf "$temp_file" -C /opt/sabnzbd --strip-components=1
 | 
					 | 
				
			||||||
    rm -f "$temp_file"
 | 
					 | 
				
			||||||
    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"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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
 | 
					        if [[ ! -d /opt/sabnzbd/venv ]]; then
 | 
				
			||||||
            systemctl daemon-reload
 | 
					            msg_info "Migrating SABnzbd to uv virtual environment"
 | 
				
			||||||
            msg_ok "Updated SABnzbd service to use uv venv"
 | 
					            $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 "Updated SABnzbd service to use uv venv"
 | 
				
			||||||
 | 
					            fi
 | 
				
			||||||
        fi
 | 
					        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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        systemctl start sabnzbd
 | 
				
			||||||
 | 
					        msg_ok "Updated Successfully"
 | 
				
			||||||
    fi
 | 
					    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}"
 | 
					 | 
				
			||||||
    exit
 | 
					    exit
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,30 +19,33 @@ $STD apt install -y \
 | 
				
			|||||||
    p7zip-full
 | 
					    p7zip-full
 | 
				
			||||||
msg_ok "Installed Dependencies"
 | 
					msg_ok "Installed Dependencies"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Setup uv"
 | 
					PYTHON_VERSION="3.13" setup_uv
 | 
				
			||||||
setup_uv
 | 
					 | 
				
			||||||
msg_ok "Setup uv"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Setup Unrar"
 | 
					msg_info "Setup Unrar"
 | 
				
			||||||
cat <<EOF >/etc/apt/sources.list.d/non-free.list
 | 
					cat <<EOF >/etc/apt/sources.list.d/non-free.sources
 | 
				
			||||||
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
 | 
					Types: deb
 | 
				
			||||||
 | 
					URIs: http://deb.debian.org/debian/
 | 
				
			||||||
 | 
					Suites: trixie
 | 
				
			||||||
 | 
					Components: non-free 
 | 
				
			||||||
 | 
					Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
$STD apt update
 | 
					$STD apt update
 | 
				
			||||||
$STD apt install -y unrar
 | 
					$STD apt install -y unrar
 | 
				
			||||||
rm /etc/apt/sources.list.d/non-free.list
 | 
					 | 
				
			||||||
msg_ok "Setup Unrar"
 | 
					msg_ok "Setup Unrar"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fetch_and_deploy_gh_release "sabnzbd-org" "sabnzbd/sabnzbd" "prebuild" "latest" "/opt/sabnzbd" "SABnzbd-*-src.tar.gz"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Installing SABnzbd"
 | 
					msg_info "Installing SABnzbd"
 | 
				
			||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
 | 
					 | 
				
			||||||
mkdir -p /opt/sabnzbd
 | 
					 | 
				
			||||||
$STD uv venv /opt/sabnzbd/venv
 | 
					$STD uv venv /opt/sabnzbd/venv
 | 
				
			||||||
temp_file=$(mktemp)
 | 
					 | 
				
			||||||
curl -fsSL "https://github.com/sabnzbd/sabnzbd/releases/download/${RELEASE}/SABnzbd-${RELEASE}-src.tar.gz" -o "$temp_file"
 | 
					 | 
				
			||||||
tar -xzf "$temp_file" -C /opt/sabnzbd --strip-components=1
 | 
					 | 
				
			||||||
$STD uv pip install -r /opt/sabnzbd/requirements.txt --python=/opt/sabnzbd/venv/bin/python
 | 
					$STD uv pip install -r /opt/sabnzbd/requirements.txt --python=/opt/sabnzbd/venv/bin/python
 | 
				
			||||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
 | 
					 | 
				
			||||||
msg_ok "Installed SABnzbd"
 | 
					msg_ok "Installed SABnzbd"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					read -r -p "Would you like to install par2cmdline-turbo? <y/N> " prompt
 | 
				
			||||||
 | 
					if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
 | 
				
			||||||
 | 
					  mv /usr/bin/par2 /usr/bin/par2.old
 | 
				
			||||||
 | 
					  fetch_and_deploy_gh_release "par2cmdline-turbo" "animetosho/par2cmdline-turbo" "prebuild" "latest" "/usr/bin/" "*-linux-amd64.zip"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Creating Service"
 | 
					msg_info "Creating Service"
 | 
				
			||||||
cat <<EOF >/etc/systemd/system/sabnzbd.service
 | 
					cat <<EOF >/etc/systemd/system/sabnzbd.service
 | 
				
			||||||
[Unit]
 | 
					[Unit]
 | 
				
			||||||
@@ -65,7 +68,6 @@ motd_ssh
 | 
				
			|||||||
customize
 | 
					customize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Cleaning up"
 | 
					msg_info "Cleaning up"
 | 
				
			||||||
rm -f "$temp_file"
 | 
					 | 
				
			||||||
$STD apt -y autoremove
 | 
					$STD apt -y autoremove
 | 
				
			||||||
$STD apt -y autoclean
 | 
					$STD apt -y autoclean
 | 
				
			||||||
$STD apt -y clean
 | 
					$STD apt -y clean
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user