Update sabnzbd.sh
This commit is contained in:
parent
1d0cd6c446
commit
fe76ba1709
@ -28,11 +28,14 @@ function update_script() {
|
|||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
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}"
|
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_info "Updating $APP to ${RELEASE}"
|
msg_info "Updating $APP to ${RELEASE}"
|
||||||
systemctl stop sabnzbd
|
systemctl stop sabnzbd
|
||||||
cp -r /opt/sabnzbd /opt/sabnzbd_backup_$(date +%s)
|
cp -r /opt/sabnzbd /opt/sabnzbd_backup_$(date +%s)
|
||||||
@ -42,28 +45,22 @@ function update_script() {
|
|||||||
cp -rf "${tmpdir}/SABnzbd-${RELEASE}/"* /opt/sabnzbd/
|
cp -rf "${tmpdir}/SABnzbd-${RELEASE}/"* /opt/sabnzbd/
|
||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
|
|
||||||
|
# Check if venv exists, else create with uv
|
||||||
if [[ ! -d /opt/sabnzbd/venv ]]; then
|
if [[ ! -d /opt/sabnzbd/venv ]]; then
|
||||||
msg_info "Migrating SABnzbd to venv installation"
|
msg_info "Migrating SABnzbd to uv virtual environment"
|
||||||
$STD python3 -m venv /opt/sabnzbd/venv
|
$STD uv venv /opt/sabnzbd/venv
|
||||||
source /opt/sabnzbd/venv/bin/activate
|
msg_ok "Created uv venv at /opt/sabnzbd/venv"
|
||||||
$STD pip install --upgrade pip
|
|
||||||
if [[ -f /opt/sabnzbd/requirements.txt ]]; then
|
|
||||||
$STD pip install -r /opt/sabnzbd/requirements.txt
|
|
||||||
fi
|
|
||||||
deactivate
|
|
||||||
|
|
||||||
if grep -q "ExecStart=python3 SABnzbd.py" /etc/systemd/system/sabnzbd.service; then
|
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
|
sed -i "s|ExecStart=python3 SABnzbd.py|ExecStart=/opt/sabnzbd/venv/bin/python SABnzbd.py|" /etc/systemd/system/sabnzbd.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
msg_ok "Migrated SABnzbd to venv installation and updated Service"
|
msg_ok "Updated SABnzbd service to use uv venv"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
source /opt/sabnzbd/venv/bin/activate
|
|
||||||
$STD pip install --upgrade pip
|
|
||||||
$STD pip install -r /opt/sabnzbd/requirements.txt
|
|
||||||
deactivate
|
|
||||||
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
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||||
systemctl start sabnzbd
|
systemctl start sabnzbd
|
||||||
msg_ok "Updated ${APP} to ${RELEASE}"
|
msg_ok "Updated ${APP} to ${RELEASE}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user