@@ -40,6 +40,7 @@ Description=Notify in NC when a NextCloudPi update is available
40
40
[Service]
41
41
Type=simple
42
42
ExecStart=/usr/local/bin/ncp-notify-update
43
+ ExecStartPost=/usr/local/bin/ncp-notify-unattended-upgrade
43
44
44
45
[Install]
45
46
WantedBy=default.target
@@ -76,13 +77,41 @@ IFACE=\$( ip r | grep "default via" | awk '{ print \$5 }' )
76
77
IP=\$ ( ip a | grep "global \$ IFACE" | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 )
77
78
78
79
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
79
- $USER_ "NextCloudPi \$ ( cat \$ VERFILE ) " \
80
- -l "NextCloudPi \$ ( cat \$ LATEST ) is available. Update from https://\$ IP:4443"
80
+ $USER_ "NextCloudPi update " \
81
+ -l "Update from \$ ( cat \$ VERFILE ) to \$ ( cat \$ LATEST ) is available. Update from https://\$ IP:4443"
81
82
82
83
cat \$ LATEST > \$ NOTIFIED
83
84
EOF
84
85
chmod +x /usr/local/bin/ncp-notify-update
85
86
87
+ cat > /usr/local/bin/ncp-notify-unattended-upgrade << EOF
88
+ #!/bin/bash
89
+ LOGFILE=/var/log/unattended-upgrades/unattended-upgrades.log
90
+ STAMPFILE=/var/run/.ncp-notify-unattended-upgrades
91
+ VERFILE=/usr/local/etc/ncp-version
92
+
93
+ test -e "\$ LOGFILE" || { echo "\$ LOGFILE not found"; exit 1; }
94
+
95
+ test -e "\$ STAMPFILE" || touch "\$ STAMPFILE"
96
+
97
+ [ \$ ( 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; }
98
+
99
+ LINE=\$ ( grep "INFO Packages that will be upgraded" "\$ LOGFILE" )
100
+
101
+ [[ "\$ LINE" == "" ]] && { echo "no new upgrades"; touch "\$ STAMPFILE"; exit 0; }
102
+
103
+ PKGS=\$ ( sed 's|^.*Packages that will be upgraded: ||' <<< "\$ LINE" )
104
+
105
+ echo "Packages automatically upgraded: \$ PKGS"
106
+
107
+ touch "\$ STAMPFILE"
108
+
109
+ sudo -u www-data php /var/www/nextcloud/occ notification:generate \
110
+ $USER_ "NextCloudPi Unattended Upgrades" \
111
+ -l "Packages automatically upgraded \$ PKGS"
112
+ EOF
113
+ chmod +x /usr/local/bin/ncp-notify-unattended-upgrade
114
+
86
115
# timer
87
116
cat > /etc/systemd/system/nc-notify-updates.timer << EOF
88
117
[Unit]
0 commit comments