From 311ccc76ab487ba98b3c62b67af0992c479aed3d Mon Sep 17 00:00:00 2001 From: nachoparker Date: Wed, 13 Mar 2019 19:58:53 -0600 Subject: nc-update-nc-apps-auto: notify user --- bin/ncp/CONFIG/nc-notify-updates.sh | 4 ++-- bin/ncp/CONFIG/nc-update-nc-apps-auto.sh | 18 ++++++++++++------ changelog.md | 4 +++- etc/ncp-config.d/nc-update-nc-apps-auto.cfg | 6 ++++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/bin/ncp/CONFIG/nc-notify-updates.sh b/bin/ncp/CONFIG/nc-notify-updates.sh index 0ae1799b..ab3983f2 100644 --- a/bin/ncp/CONFIG/nc-notify-updates.sh +++ b/bin/ncp/CONFIG/nc-notify-updates.sh @@ -43,7 +43,7 @@ echo "Found update from \$( cat \$VERFILE ) to \$( cat \$LATEST ). Sending notif IFACE=\$( ip r | grep "default via" | awk '{ print \$5 }' | head -1 ) IP=\$( ip a show dev "\$IFACE" | grep global | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 ) -sudo -u www-data php /var/www/nextcloud/occ notification:generate \ +ncc notification:generate \ $USER "NextCloudPi update" \ -l "Update from \$( cat \$VERFILE ) to \$( cat \$LATEST ) is available. Update from https://\$IP:4443" @@ -74,7 +74,7 @@ sed -i 's|INFO Packages that will be upgraded:|INFO Packages that will be upgrad echo -e "Packages automatically upgraded: \$PKGS\\n" # notify -sudo -u www-data php /var/www/nextcloud/occ notification:generate \ +ncc notification:generate \ $USER "NextCloudPi Unattended Upgrades" \ -l "Packages automatically upgraded \$PKGS" EOF diff --git a/bin/ncp/CONFIG/nc-update-nc-apps-auto.sh b/bin/ncp/CONFIG/nc-update-nc-apps-auto.sh index 95466161..0097e8dd 100644 --- a/bin/ncp/CONFIG/nc-update-nc-apps-auto.sh +++ b/bin/ncp/CONFIG/nc-update-nc-apps-auto.sh @@ -8,21 +8,27 @@ # More at: https://ownyourbits.com # -cronfile=/etc/cron.daily/ncp-autoupdate-apps - configure() { + local cronfile=/etc/cron.daily/ncp-autoupdate-apps + [[ "$ACTIVE" != "yes" ]] && { rm -f "$cronfile" echo "automatic app updates disabled" return 0 } - cat > "$cronfile" <<'EOF' + cat > "$cronfile" <> /var/log/ncp.log -echo "checking for updates..." >> /var/log/ncp.log -ncc app:update --all -n >> /var/log/ncp.log +OUT="\$( +echo "[ nc-update-nc-apps-auto ]" +echo "checking for updates..." +ncc app:update --all -n +)" +echo "\$OUT" >> /var/log/ncp.log + +APPS=\$( echo "\$OUT" | grep 'updated\$' | awk '{ print \$1 }') +ncc notification:generate "$USER" "Apps updated" -l "\$APPS" EOF chmod 755 "$cronfile" echo "automatic app updates enabled" diff --git a/changelog.md b/changelog.md index 43c6b750..3ac97dc9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ -[v1.10.0](https://github.com/nextcloud/nextcloudpi/commit/b00c5f1) (2019-03-13) add nc-previews-auto +[v1.10.1](https://github.com/nextcloud/nextcloudpi/commit/9003eb0) (2019-03-13) nc-update-nc-apps-auto: notify user + +[v1.10.0 ](https://github.com/nextcloud/nextcloudpi/commit/06073ed) (2019-03-13) add nc-previews-auto [v1.9.8 ](https://github.com/nextcloud/nextcloudpi/commit/d7bbe25) (2019-03-13) nc-scan: improvements diff --git a/etc/ncp-config.d/nc-update-nc-apps-auto.cfg b/etc/ncp-config.d/nc-update-nc-apps-auto.cfg index 8e859a18..c5d59407 100644 --- a/etc/ncp-config.d/nc-update-nc-apps-auto.cfg +++ b/etc/ncp-config.d/nc-update-nc-apps-auto.cfg @@ -11,6 +11,12 @@ "name": "Active", "value": "no", "type": "bool" + }, + { + "id": "USER", + "name": "Notify user", + "value": "ncp", + "suggest": "ncp" } ] } -- cgit v1.2.3