I've been playing with some more robust ways to run softwareupdate than the built in implementation in Casper and came up with this. Modify as you like to make it work for your environment, it currently only works with 10.8 because 10.7 uses a slightly different structure for index.plist (and I just didn't have time to modify for it). Basically it checks if you are on 10.8, then if you have any updates, and if you do and they requires a restart, download them all and modify the proper files so that when someone does go to Apple - Restart, it'll bring up the built in Apple environment to show them a pretty progress bar on how their updates are going, and if there are updates but none of them require a restart, install them silently. This can be used in conjunction with a Policy so that you can warn users that it's running, that if it finds updates that require restart that it'll install those updates when they restart the computer, etc. etc. etc.
Enjoy!
#!/bin/bash SWUL=/usr/sbin/softwareupdate -l | /usr/bin/awk '{printf "%s", $0}'
SWULER=/usr/sbin/softwareupdate -l 2>&1 | /usr/bin/head -1
NoRestartUpdates=/usr/sbin/softwareupdate -l | /usr/bin/grep -v restart | /usr/bin/grep -B1 recommended | /usr/bin/grep -v recommended | /usr/bin/awk '{print $2}' | /usr/bin/awk '{printf "%s ", $0}'
osvers=sw_vers -productVersion | awk -F. '{print $2}'
if [[ $osvers -eq 7 ]]; then /bin/echo "Script only for 10.8 ONLY" exit 1 elif [ "$SWULER" == "No new software available." ]; then /bin/echo "$SWULER" exit 1 elif [[ "$SWUL" == *"[restart]"* ]]; then echo "Installing Updates that require Restart" /usr/bin/sudo /usr/sbin/softwareupdate -d -a /usr/libexec/PListBuddy -c "Copy CompletedProducts InstallAtLogout" /Library/Updates/index.plist /usr/bin/touch /var/db/.SoftwareUpdateAtLogout /bin/chmod og-r /var/db/.SoftwareUpdateAtLogout /usr/libexec/PListBuddy -c "Add -RootInstallMode STRING YES" /var/db/.SoftwareUpdateOptions /usr/libexec/PListBuddy -c "Add -SkipConfirm STRING YES" /var/db/.SoftwareUpdateOptions /bin/chmod og-r /var/db/.SoftwareUpdateOptions elif [[ "$SWUL" == *"[recommended]"* ]]; then /bin/echo "Installing Updates that does not require Restart" /usr/bin/sudo /usr/sbin/softwareupdate -i $NoRestartUpdates fi exit 0