From 6d89c2de129de2189ca9d8f5435b5cfb2d6ae8e0 Mon Sep 17 00:00:00 2001 From: towerhand <42445253+towerhand@users.noreply.github.com> Date: Fri, 6 Sep 2024 02:05:57 -0500 Subject: [PATCH] Update sabnzbd only if a new version is available. (#3664) --- ct/sabnzbd.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ct/sabnzbd.sh b/ct/sabnzbd.sh index c6d0aa26..d0656d6b 100644 --- a/ct/sabnzbd.sh +++ b/ct/sabnzbd.sh @@ -55,16 +55,21 @@ function default_settings() { function update_script() { header_info if [[ ! -d /opt/sabnzbd ]]; then msg_error "No ${APP} Installation Found!"; exit; fi -msg_info "Updating $APP" -systemctl stop sabnzbd.service RELEASE=$(curl -s https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -tar zxvf <(curl -fsSL https://github.com/sabnzbd/sabnzbd/releases/download/$RELEASE/SABnzbd-${RELEASE}-src.tar.gz) &>/dev/null -\cp -r SABnzbd-${RELEASE}/* /opt/sabnzbd &>/dev/null -rm -rf SABnzbd-${RELEASE} -cd /opt/sabnzbd -python3 -m pip install -r requirements.txt &>/dev/null -systemctl start sabnzbd.service -msg_ok "Updated $APP" +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + 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) &>/dev/null + \cp -r SABnzbd-${RELEASE}/* /opt/sabnzbd &>/dev/null + rm -rf SABnzbd-${RELEASE} + cd /opt/sabnzbd + python3 -m pip install -r requirements.txt &>/dev/null + echo "${RELEASE}" >/opt/${APP}_version.txt + systemctl start sabnzbd.service + msg_ok "Updated ${APP} to ${RELEASE}" +else + msg_info "No update required. ${APP} is already at ${RELEASE}" +fi exit }