Skip to content

Instantly share code, notes, and snippets.

@nickvergessen
Last active March 29, 2017 15:48
Show Gist options
  • Save nickvergessen/b3c8b0bec050fbc0d62ef571f1f77a52 to your computer and use it in GitHub Desktop.
Save nickvergessen/b3c8b0bec050fbc0d62ef571f1f77a52 to your computer and use it in GitHub Desktop.

HowTo set it up

  1. Install the admin_notifications app
  2. Create system-notifications.sh with the content from below on your system
  3. Add the script to the cronjob crontab -u www-data -e:
0 10 * * * /path/to/file/system-notifications.sh
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment