The opinions on this site are my own, and are not necessarily shared by my employer.
Return of the Yo notifications
05 Sep 2016
Last time, took our first steps to notify our users about updates in a slight nicer way. This time we are going to modify our script so that our users are only bugged once a day, and also not promoted to install 10.11 if they’re already running it.
Unfortunately for some, whilst this will be possible if we stuck to using bash, it would drive me insane, so we are switching to Python. Don’t be scared! Python makes a lot of sense once you get your head around it, and you’ll be a much happier mac admin once you leave the 1500 line bash scripts behind.
First off, let’s get to the point we were at last time in python. Replace payload/opt/grahamgilbert/bin/updatenotifier with this (remember you can test your script as you’re going along by calling the script manually: $ payload/opt/grahamgilbert/bin/updatenotifier):
So the first thing we’re going to change is adding in a method to track when the user has seen our notification. We’re going to use macOS’ built in method for storing preferences - whilst not technically a preference, we are storing a value we want to persist across reboots, so a preferences makes perfect sense. Make payload/opt/grahamgilbert/bin/updatenotifier look the the code below.
The final step is to only limit this to machines that need it - those under 10.11. We would usually use Munki to restrict who gets this, but just in case it gets manually installed somehow, let’s protect ourselves.