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-09-01 13:20:57 +0300
committernachoparker <nacho@ownyourbits.com>2017-09-02 00:32:24 +0300
commitee748758713a746863d6936e65bb1051d82507ef (patch)
tree3f6f1908d180c76d08bc4094e58033a1b42984ed
parentbb58ac7501d717e04c30e3f5267429f50e06ba02 (diff)
nc-notify-updates: notify also of unattended upgradesv0.25.1
-rw-r--r--etc/nextcloudpi-config.d/nc-notify-updates.sh33
-rwxr-xr-xupdate.sh14
2 files changed, 45 insertions, 2 deletions
diff --git a/etc/nextcloudpi-config.d/nc-notify-updates.sh b/etc/nextcloudpi-config.d/nc-notify-updates.sh
index 147f346e..f96436cb 100644
--- a/etc/nextcloudpi-config.d/nc-notify-updates.sh
+++ b/etc/nextcloudpi-config.d/nc-notify-updates.sh
@@ -40,6 +40,7 @@ Description=Notify in NC when a NextCloudPi update is available
[Service]
Type=simple
ExecStart=/usr/local/bin/ncp-notify-update
+ExecStartPost=/usr/local/bin/ncp-notify-unattended-upgrade
[Install]
WantedBy=default.target
@@ -76,13 +77,41 @@ IFACE=\$( ip r | grep "default via" | awk '{ print \$5 }' )
IP=\$( ip a | grep "global \$IFACE" | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 )
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
- $USER_ "NextCloudPi \$( cat \$VERFILE )" \
- -l "NextCloudPi \$( cat \$LATEST ) is available. Update from https://\$IP:4443"
+ $USER_ "NextCloudPi update" \
+ -l "Update from \$( cat \$VERFILE ) to \$( cat \$LATEST ) is available. Update from https://\$IP:4443"
cat \$LATEST > \$NOTIFIED
EOF
chmod +x /usr/local/bin/ncp-notify-update
+ 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; }
+
+LINE=\$( grep "INFO Packages that will be upgraded" "\$LOGFILE" )
+
+[[ "\$LINE" == "" ]] && { echo "no new upgrades"; touch "\$STAMPFILE"; exit 0; }
+
+PKGS=\$( sed 's|^.*Packages that will be upgraded: ||' <<< "\$LINE" )
+
+echo "Packages automatically upgraded: \$PKGS"
+
+touch "\$STAMPFILE"
+
+sudo -u www-data php /var/www/nextcloud/occ notification:generate \
+ $USER_ "NextCloudPi Unattended Upgrades" \
+ -l "Packages automatically upgraded \$PKGS"
+EOF
+ chmod +x /usr/local/bin/ncp-notify-unattended-upgrade
+
# timer
cat > /etc/systemd/system/nc-notify-updates.timer <<EOF
[Unit]
diff --git a/update.sh b/update.sh
index 88f1f3e5..fc58ed67 100755
--- a/update.sh
+++ b/update.sh
@@ -86,6 +86,20 @@ launch_script $1 &> /run/ncp.log
EOF
chmod 700 /home/www/ncp-launcher.sh
+# update notify-updates to also notify about unattended upgrades
+cat > /etc/systemd/system/nc-notify-updates.service <<EOF
+[Unit]
+Description=Notify in NC when a NextCloudPi update is available
+
+[Service]
+Type=simple
+ExecStart=/usr/local/bin/ncp-notify-update
+ExecStartPost=/usr/local/bin/ncp-notify-unattended-upgrade
+
+[Install]
+WantedBy=default.target
+EOF
+
# adjust max PHP processes so Apps don't overload the board (#146)
sed -i 's|pm.max_children =.*|pm.max_children = 3|' /etc/php/7.0/fpm/pool.d/www.conf