diff options
author | nachoparker <nacho@ownyourbits.com> | 2021-10-06 21:08:55 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2021-10-07 22:28:50 +0300 |
commit | 8a6c1c08a21629c048f8ec31bf5707c0875d5705 (patch) | |
tree | 51327b7c5911e4594a8c4efaefc996735039c830 | |
parent | 9e276600e62272f98de50eb7d8fa40c2041fe1b0 (diff) |
ncp-check-nc-version: dont notify the same version more than oncev1.40.3
Signed-off-by: nachoparker <nacho@ownyourbits.com>
-rwxr-xr-x | bin/ncp-check-nc-version | 9 | ||||
-rw-r--r-- | bin/ncp/UPDATES/nc-notify-updates.sh | 16 | ||||
-rw-r--r-- | updates/1.41.0.sh | 40 |
3 files changed, 56 insertions, 9 deletions
diff --git a/bin/ncp-check-nc-version b/bin/ncp-check-nc-version index 97ed40f9..49318789 100755 --- a/bin/ncp-check-nc-version +++ b/bin/ncp-check-nc-version @@ -8,9 +8,16 @@ source /usr/local/etc/library.sh # sets NCLATESTVER CURRENT="$(ncc status | grep "version:" | awk '{ print $3 }')" LATEST="$(wget -qO- https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/etc/ncp.cfg | jq -r .nextcloud_version)" +NOTIFIED=/var/run/.nc-version-notified + +test -e "${NOTIFIED}" && [[ "${LATEST}" == "$( cat "${NOTIFIED}" )" ]] && { + echo "Found update from ${CURRENT} to ${LATEST}. Already notified" + exit 0 +} if is_more_recent_than "${LATEST}" "${CURRENT}"; then notify_admin \ "Nextcloud update" \ - "Update from ${CURRENT} to "${LATEST}" is available. Update from https://$(get_ip):4443" + "Update from ${CURRENT} to ${LATEST} is available. Update from https://$(get_ip):4443" + echo "${LATEST}" > "${NOTIFIED}" fi diff --git a/bin/ncp/UPDATES/nc-notify-updates.sh b/bin/ncp/UPDATES/nc-notify-updates.sh index 501d2fee..95670238 100644 --- a/bin/ncp/UPDATES/nc-notify-updates.sh +++ b/bin/ncp/UPDATES/nc-notify-updates.sh @@ -50,7 +50,7 @@ cat $LATEST > $NOTIFIED EOF chmod +x /usr/local/bin/ncp-notify-update - cat > /usr/local/bin/ncp-notify-unattended-upgrade <<EOF + cat > /usr/local/bin/ncp-notify-unattended-upgrade <<'EOF' #!/bin/bash source /usr/local/etc/library.sh @@ -58,25 +58,25 @@ LOGFILE=/var/log/unattended-upgrades/unattended-upgrades.log STAMPFILE=/var/run/.ncp-notify-unattended-upgrades VERFILE=/usr/local/etc/ncp-version -test -e "\$LOGFILE" || { echo "\$LOGFILE not found"; exit 1; } +test -e "$LOGFILE" || { echo "$LOGFILE not found"; exit 1; } # find lines with package updates -LINE=\$( grep "INFO Packages that will be upgraded:" "\$LOGFILE" ) +LINE=$( grep "INFO Packages that will be upgraded:" "$LOGFILE" ) -[[ "\$LINE" == "" ]] && { echo "no new upgrades"; exit 0; } +[[ "$LINE" == "" ]] && { echo "no new upgrades"; exit 0; } # extract package names -PKGS=\$( sed 's|^.*Packages that will be upgraded: ||' <<< "\$LINE" | tr '\\n' ' ' ) +PKGS=$( sed 's|^.*Packages that will be upgraded: ||' <<< "$LINE" | tr '\n' ' ' ) # mark lines as read -sed -i 's|INFO Packages that will be upgraded:|INFO Packages that will be upgraded :|' \$LOGFILE +sed -i 's|INFO Packages that will be upgraded:|INFO Packages that will be upgraded :|' \LOGFILE -echo -e "Packages automatically upgraded: \$PKGS\\n" +echo -e "Packages automatically upgraded: $PKGS\n" # notify notify_admin \ "NextCloudPi Unattended Upgrades" \ - "Packages automatically upgraded \$PKGS" + "Packages automatically upgraded $PKGS" EOF chmod +x /usr/local/bin/ncp-notify-unattended-upgrade diff --git a/updates/1.41.0.sh b/updates/1.41.0.sh new file mode 100644 index 00000000..4a8f5375 --- /dev/null +++ b/updates/1.41.0.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -e + +## BACKWARD FIXES ( for older images ) + +source /usr/local/etc/library.sh # sets NCLATESTVER PHPVER RELEASE + +# all images + +# we handle this ourselves now +ncc app:disable updatenotification +run_app nc-notify-updates + +# docker images only +[[ -f /.docker-image ]] && { + : +} + +# for non docker images +[[ ! -f /.docker-image ]] && { + + # make sure redis is up before running nextclud-domain + cat > /usr/lib/systemd/system/nextcloud-domain.service <<'EOF' +[Unit] +Description=Register Current IP as Nextcloud trusted domain +Requires=network.target +After=mysql.service redis.service + +[Service] +ExecStart=/bin/bash /usr/local/bin/nextcloud-domain.sh +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target +EOF +} + +exit 0 |