Hire me if you like: blake.irvin@gmail.com

Monday, May 15, 2006

Script to Install OS X Security Updates

This script can be run from remote (ssh) login or via cron or launchd jobs. It notifies the user of what's about to happen via System Events: 
 
 
#!/bin/bash 
 
INSTALLSTRING=`softwareupdate -l -r | grep -B 1 Security | grep ! | awk '{print $1 $2}' | tr -d '\n' | tr '!' ' '` 
UPDATESNEEDED=`softwareupdate -l -r | grep Security | wc -l` 
 
if [ "$UPDATESNEEDED" -ge "1" ] 
 
then 
 
 
 
osascript -e 'tell app "System Events" to display dialog "Critical security updates are being added to your machine. Your applications may run a bit slowly during this process. You will be notified when the updates are complete." buttons "OK" default button 1 with icon caution giving up after 60' 
 
 
 
softwareupdate -i $INSTALLSTRING 
 
 
 
osascript -e 'tell app "System Events" to display dialog "Critical security updates have been installed. Please restart your computer as soon as possible." buttons "OK" default button 1 with icon stop' 
 
 
 
elif [ "$UPDATESNEEDED" -lt "1" ] 
 
then 
exit 
 
fi

No comments:

Archive