From aaf75369435024b096a8c23301daded9f8209e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sun, 22 Sep 2024 21:17:34 +0200 Subject: [PATCH] nc-autoupdate-nc: Fix erroneous update/updated notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-check-nc-version | 5 ++- bin/ncp-update-nc | 11 ++++--- bin/ncp-update-nc.d/update-nc.sh | 2 +- bin/ncp/SECURITY/nc-encrypt.sh | 4 +-- bin/ncp/UPDATES/nc-autoupdate-nc.sh | 2 +- staged_rollouts/v1.55.2.txt | 50 +++++++++++++++++++++++++++++ updates/1.55.2.sh | 6 ++++ 7 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 staged_rollouts/v1.55.2.txt create mode 100644 updates/1.55.2.sh diff --git a/bin/ncp-check-nc-version b/bin/ncp-check-nc-version index 972a5b8a..1de2474d 100755 --- a/bin/ncp-check-nc-version +++ b/bin/ncp-check-nc-version @@ -8,7 +8,10 @@ source /usr/local/etc/library.sh # sets NCLATESTVER CURRENT="$(nc_version)" NEXT_VERSION="$(determine_nc_update_version "${CURRENT}" "${NCLATESTVER?}")" -[[ -n "$NEXT_VERSION" ]] || exit 0 +if [[ -z "$NEXT_VERSION" ]] || [[ "$NEXT_VERSION" == "${CURRENT}" ]] +then + exit 0 +fi NOTIFIED=/var/run/.nc-version-notified diff --git a/bin/ncp-update-nc b/bin/ncp-update-nc index 337cc8c8..001d438a 100755 --- a/bin/ncp-update-nc +++ b/bin/ncp-update-nc @@ -26,19 +26,19 @@ VER="$1" connect_to_nc_update() { tail -n 100 -f "/var/log/ncp-update-nc.log" & tail_pid=$! + trap "kill '$tail_pid'" EXIT while [[ "$(systemctl is-active ncp-update-nc ||:)" =~ ^(active|activating|deactivating)$ ]] do sleep 3 done - kill "$tail_pid" if [[ "$(systemctl is-active ncp-update-nc ||:)" == "inactive" ]] then echo "Nextcloud update finished successfully." return 0 elif [[ "$(systemctl is-active ncp-update-nc ||:)" == "failed" ]] then - echo "Nextcloud update failed." + echo "Nextcloud update failed (or was installed already)." return 1 else echo "Nextcloud update was not found or failed (unexpected status: '$(systemctl is-active ncp-update-nc ||:)')" @@ -52,15 +52,16 @@ then exit $? fi -systemctl reset-failed ncp-encrypt ||: -systemd-run -u 'ncp-update-nc' bash -c "DBG='${DBG:-}' /usr/local/bin/ncp-update-nc.d/update-nc.sh '${VER}' |& tee /var/log/ncp-update-nc.log" -sleep 5 +systemctl reset-failed ncp-encrypt 2>/dev/null ||: +systemd-run -u 'ncp-update-nc' bash -c "set -o pipefail; DBG='${DBG:-}' /usr/local/bin/ncp-update-nc.d/update-nc.sh '${VER}' |& tee /var/log/ncp-update-nc.log" +sleep 1 if ! [[ "$(systemctl is-active ncp-update-nc ||:)" =~ ^(active|inactive|activating|deactivating)$ ]] then echo "Failed to start ncp-update-nc" [[ -f /var/log/ncp-update-nc.log ]] && cat /var/log/ncp-update-nc.log systemctl status --no-pager ncp-update-nc ||: + exit 1 fi connect_to_nc_update diff --git a/bin/ncp-update-nc.d/update-nc.sh b/bin/ncp-update-nc.d/update-nc.sh index b8bdd18c..fd9e0d41 100755 --- a/bin/ncp-update-nc.d/update-nc.sh +++ b/bin/ncp-update-nc.d/update-nc.sh @@ -31,7 +31,7 @@ fi TARGET_VERSION="$(determine_nc_update_version "${CURRENT?}" "${NCLATESTVER}" "${REQUESTED_VERSION}")" [[ "$TARGET_VERSION" == "$CURRENT" ]] && { echo "Nextcloud version ${CURRENT} is already installed. Nothing to do." - exit 0 + exit 1 } [[ -n "$TARGET_VERSION" ]] || { echo "Could not find a valid upgrade path from '${CURRENT}' to '${TARGET_VERSION}'. Nothing to update." diff --git a/bin/ncp/SECURITY/nc-encrypt.sh b/bin/ncp/SECURITY/nc-encrypt.sh index efed4d9b..bde94e6b 100644 --- a/bin/ncp/SECURITY/nc-encrypt.sh +++ b/bin/ncp/SECURITY/nc-encrypt.sh @@ -58,7 +58,7 @@ configure() export PASSWORD # Just mount already encrypted data if [[ -f "${encdir?}"/gocryptfs.conf ]]; then - systemctl reset-failed ncp-encrypt ||: + systemctl reset-failed ncp-encrypt 2>/dev/null ||: systemd-run -u ncp-encrypt -E PASSWORD bash -c "gocryptfs -fg -allow_other -q '${encdir}' '${datadir}' <<<\"\${PASSWORD}\" 2>&1 | sed /^Switch/d |& tee /var/log/ncp-encrypt.log" # switch to the regular virtual hosts after we decrypt, so we can access NC and ncp-web @@ -88,7 +88,7 @@ configure() mv "${datadir?}" "${tmpdir?}" mkdir "${datadir}" - systemctl reset-failed ncp-encrypt ||: + systemctl reset-failed ncp-encrypt 2>/dev/null ||: systemd-run -u ncp-encrypt -E PASSWORD bash -c "gocryptfs -fg -allow_other -q '${encdir}' '${datadir}' <<<\"\${PASSWORD}\" 2>&1 | sed /^Switch/d |& tee /var/log/ncp-encrypt.log" maxtries=5 diff --git a/bin/ncp/UPDATES/nc-autoupdate-nc.sh b/bin/ncp/UPDATES/nc-autoupdate-nc.sh index ee95ee23..3a750988 100644 --- a/bin/ncp/UPDATES/nc-autoupdate-nc.sh +++ b/bin/ncp/UPDATES/nc-autoupdate-nc.sh @@ -23,7 +23,7 @@ configure() source /usr/local/etc/library.sh echo -e "[ncp-update-nc]" >> /var/log/ncp.log -/usr/local/bin/ncp-update-nc "$NCLATESTVER" 2>&1 | tee -a /var/log/ncp.log +/usr/local/bin/ncp-update-nc "latest" 2>&1 | tee -a /var/log/ncp.log if [[ \${PIPESTATUS[0]} -eq 0 ]]; then diff --git a/staged_rollouts/v1.55.2.txt b/staged_rollouts/v1.55.2.txt new file mode 100644 index 00000000..ebefaca7 --- /dev/null +++ b/staged_rollouts/v1.55.2.txt @@ -0,0 +1,50 @@ +0 +1 +2 +3 +4 +5 +6 +9 +10 +13 +15 +26 +29 +30 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +51 +54 +55 +59 +60 +62 +63 +64 +68 +69 +70 +73 +74 +75 +76 +84 +89 +92 +96 \ No newline at end of file diff --git a/updates/1.55.2.sh b/updates/1.55.2.sh new file mode 100644 index 00000000..3321c3bc --- /dev/null +++ b/updates/1.55.2.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +source /usr/local/etc/library.sh + +run_app nc-autoupdate-nc