I use a script to check the uptime of a machine and display a dialog using growlnotify. It's something I threw together three years ago, but it worked great. It would alert users when they had not restarted for more than 5 days. After 10 days it would alert them via Growl and also send an email to them from the system.
You could have a script that checked machine uptime and if greater than 5 days, checked for software updates and alerted the user that they had been up for more than 5 days. If there are also updates, you can alert them that there are updates that need to be applied. Two birds, one stone.
I need to re-write my script to use cocoaDialog now instead of Growl, but here is the original script using Growl and growlnotify:
#!/bin/sh
days=`uptime | awk '{ print $4 }' | sed 's/,//g'`
num=`uptime | awk '{ print $3 }'`
computername=$2
message1="Your computer has now been up for $num days. It is important for you to restart"
message2="your machine regularly to help it run efficiently and to apply any updates or changes"
message3="that have been pushed in the background. Please restart your machine ASAP. Thank you."
if [ $days = "days" ];
then
if [ $num -gt 5 ];
then
if [ $num -gt 9 ];
then
CurrentUser=`ls -l /dev/console | awk '{ print $3 }'`
email=`dscl /LDAPv3/your.ldapserver.com -read /Users/$CurrentUser | grep EMailAddress | awk '{ print $2 }'`
touch /Library/Application Support/JAMF/Receipts/UpTooLong.pkg
/usr/sbin/jamf displayMessage -message "Your computer has now been up for $num days. Please restart ASAP. Thank you"
echo -e "$message1
$message2
$message3" | mail -s "Machine Up Too Long" $email
else
touch /Library/Application Support/JAMF/Receipts/UpTooLong.pkg
/usr/local/bin/growlnotify -a "Finder" -t "Restart Required" -m "Your computer has been up for $num days. Please restart as soon as possible." -s
fi
else
if [ -e "/Library/Application Support/JAMF/Receipts/UpTooLong.pkg" ]
then
rm /Library/Application Support/JAMF/Receipts/UpTooLong.pkg
fi
fi
fi
/usr/sbin/jamf recon
exit 0
Hope that helps give you some ideas. I turned this off last year but need to re-enable it.
This might be an option:
http://code.google.com/p/munki/wiki/AppleSoftwareUpdatesWithMunki#Using_the_munki_tools_only_to_install_Apple_Software_Updates
Munki can be used to only install Apple updates. It will notify the user of available updates, allow the user to install them, and require a logout or restart if needed.
Steve,
Thank you for sharing that script.
Greg,
After testing just the updates with Munki, that looks like the easiest path. I'm looking forward to the extra features for updates in 0.8.4 when it is not a preview released.
@Brockma9 this is pretty slick - thank you! My concern from testing is the delay @ shutdown. WHen I shutdown the machine, it goes to a grey screen and sits there for about 60-70 seconds - then prompts.
My thought process would be - we already know from JAMF that the system needs updates (hence it's in the Software Update Smart Group). So why do another search? Would it be possible to take the search out and just skip straight to the - user prompt, and then yes/no to install or not?
Maybe it can't be done that way...
@stevewood - I'd be interested in that too if you get time.
EDIT: actually timed how long it took from hitting shutdown to the time the script prompted.
brockma9:
You can use Munki to install Apple Software Updates without having to set up a Munki server. But if you want to take advantage of the new features in 0.8.4 that allow you to cause some Apple updates to be installed in the background without bothering the user, or to "force install" some updates after a certain date, you do need a Munki server to store the additional data needed to support those operations.
-Greg