From 5204ad7e16cd9c7cbed5850e89a04ea8e52c07cb Mon Sep 17 00:00:00 2001 From: tteckster Date: Wed, 8 May 2024 13:34:01 -0400 Subject: [PATCH] Update paperless-ngx.sh add version check --- ct/paperless-ngx.sh | 52 ++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/ct/paperless-ngx.sh b/ct/paperless-ngx.sh index fdb49961..0e3b90d5 100644 --- a/ct/paperless-ngx.sh +++ b/ct/paperless-ngx.sh @@ -66,33 +66,37 @@ function update_script() { 3>&1 1>&2 2>&3) header_info if [ "$UPD" == "1" ]; then - msg_info "Stopping all Paperless-ngx Services" - systemctl stop paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service - msg_ok "Stopped all Paperless-ngx Services" + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping all Paperless-ngx Services" + systemctl stop paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service + msg_ok "Stopped all Paperless-ngx Services" - msg_info "Updating to ${RELEASE}" - cd ~ - wget -q https://github.com/paperless-ngx/paperless-ngx/releases/download/$RELEASE/paperless-ngx-$RELEASE.tar.xz - tar -xf paperless-ngx-$RELEASE.tar.xz - cp -r /opt/paperless/paperless.conf paperless-ngx/ - cp -r paperless-ngx/* /opt/paperless/ - cd /opt/paperless - pip install -r requirements.txt &>/dev/null - cd /opt/paperless/src - /usr/bin/python3 manage.py migrate &>/dev/null - msg_ok "Updated to ${RELEASE}" + msg_info "Updating to ${RELEASE}" + cd ~ + wget -q https://github.com/paperless-ngx/paperless-ngx/releases/download/$RELEASE/paperless-ngx-$RELEASE.tar.xz + tar -xf paperless-ngx-$RELEASE.tar.xz + cp -r /opt/paperless/paperless.conf paperless-ngx/ + cp -r paperless-ngx/* /opt/paperless/ + cd /opt/paperless + pip install -r requirements.txt &>/dev/null + cd /opt/paperless/src + /usr/bin/python3 manage.py migrate &>/dev/null + msg_ok "Updated to ${RELEASE}" - msg_info "Cleaning up" - cd ~ - rm paperless-ngx-$RELEASE.tar.xz - rm -rf paperless-ngx - msg_ok "Cleaned" + msg_info "Cleaning up" + cd ~ + rm paperless-ngx-$RELEASE.tar.xz + rm -rf paperless-ngx + msg_ok "Cleaned" - msg_info "Starting all Paperless-ngx Services" - systemctl start paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service - sleep 1 - msg_ok "Started all Paperless-ngx Services" - msg_ok "Updated Successfully!\n" + msg_info "Starting all Paperless-ngx Services" + systemctl start paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service + sleep 1 + msg_ok "Started all Paperless-ngx Services" + msg_ok "Updated Successfully!\n" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi exit fi if [ "$UPD" == "2" ]; then