Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2017-11-06 17:17:50 +0300
committernachoparker <nacho@ownyourbits.com>2017-11-06 17:17:50 +0300
commit963542bd305fdbde0625e432f990c785efe27187 (patch)
treeaea2551e70d36a12a3b0d02bfd6cd402c1b9b23c
parent9212ecb09baf7d8975eb6c38bda735d19fd95a73 (diff)
nc-notify-updates: rework for more accuracyv0.32.3
-rw-r--r--etc/nextcloudpi-config.d/nc-notify-updates.sh23
1 files changed, 11 insertions, 12 deletions
diff --git a/etc/nextcloudpi-config.d/nc-notify-updates.sh b/etc/nextcloudpi-config.d/nc-notify-updates.sh
index f0a5428f..5a30ce72 100644
--- a/etc/nextcloudpi-config.d/nc-notify-updates.sh
+++ b/etc/nextcloudpi-config.d/nc-notify-updates.sh
@@ -86,29 +86,28 @@ EOF
cat > /usr/local/bin/ncp-notify-unattended-upgrade <<EOF
#!/bin/bash
+
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 "\$STAMPFILE" || touch "\$STAMPFILE"
-
-[ \$( date -r "\$LOGFILE" +'%y%m%d%H%M' ) -le \$( date -r "\$STAMPFILE" +'%y%m%d%H%M' ) ] && { echo "info is up to date"; exit 0; }
+# find lines with package updates
+LINE=\$( grep "INFO Packages that will be upgraded:" "\$LOGFILE" )
-LINE=\$( grep "INFO Packages that will be upgraded" "\$LOGFILE" | tail -1 )
+[[ "\$LINE" == "" ]] && { echo "no new upgrades"; exit 0; }
-[[ "\$LINE" == "" ]] && { echo "no new upgrades"; touch "\$STAMPFILE"; 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" )
+# mark lines as read
+sed -i 's|INFO Packages that will be upgraded:|INFO Packages that will be upgraded :|' \$LOGFILE
-echo "Packages automatically upgraded: \$PKGS"
+echo -e "Packages automatically upgraded: \$PKGS\\n"
-touch "\$STAMPFILE"
-
-sudo -u www-data php /var/www/nextcloud/occ notification:generate \
- $USER_ "NextCloudPi Unattended Upgrades" \
- -l "Packages automatically upgraded \$PKGS"
+# notify
+sudo -u www-data php /var/www/nextcloud/occ notification:generate "NextCloudPi Unattended Upgrades" -l "Packages automatically upgraded $PKGS"
EOF
chmod +x /usr/local/bin/ncp-notify-unattended-upgrade