Install the admin_notifications app (Note: this is not needed anymore with Nextcloud 14)
Create system-notifications.sh with the following content on your system, and make sure to adjust the path to your nextcloud /var/www/nextcloud/occ as well as your admin account name:
#!/usr/bin/env bash
#
# @license MIT
# @copyright 2017 Joas Schilling coding@schilljs.com
ADMIN="admin"
OCC_PATH="/var/www/nextcloud/occ"
PACKAGES=$(/usr/lib/update-notifier/apt-check -p 2>&1)
NUM_PACKAGES=$(echo "$PACKAGES" | wc -l)
if [ "$PACKAGES" != "" ]; then
UPDATE_MESSAGE=$(echo "Packages to update: $PACKAGES" | sed -r ':a;N;$!ba;s/\n/, /g')
$OCC_PATH notification:generate $ADMIN "$NUM_PACKAGES packages require to be updated" -l "$UPDATE_MESSAGE"
elif [ -f /var/run/reboot-required ]; then
$OCC_PATH notification:generate $ADMIN "System requires a reboot"
fi
3. Add the script to the cronjob crontab -u www-data -e:
0 10 * * * /path/to/file/system-notifications.sh
[Update] Raspbian and other systems
If your operating system does not support apt-check, you can also try to replace the line:
Thanks a lot! I’d love to have that feature.
But i cant seem to get it working.
I installed admin-notifications,
the cron task (space at the end of the line, empty line at eof),
and changed the path and admin vars in the script.
I can see that cron was running in syslog and i can manually set a notification
(sudo -u www-data php /path/to/nextcloud/occ notification:generate admin “test”).
And i checked that apt-check works for www-data.
Nonetheless they wont show up
Any idea what i might be missing?
System is Nextcloud 12.0.3; Ubuntu 14.04; php 7.1.9
If i mark it as executable i get “not authorized” on line 15
($OCC_PATH notification:generate $ADMIN “$NUM_PACKAGES packages require to be updated” -l “$UPDATE_MESSAGE”).
But as i know it shouldnt be necessary to mark it as such?!
(due to #! )
ps.: owner of the file is www-data as i use apache
pss: copypasted the wrong line, now its right
No, you have to added it. I correct this issue and added check if user is the same as OCC owner. Also will create Log line with status. Works good under debian and ubuntu.