Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Rebooting with Status - this works

First, a contribution...
I've seen a couple older threads related to performing 'softwareupdate -l -a' then rebooting after. Problem is, the shutdown command doesn't exit with a status and it leaves ARD hanging....
Here is one thread:
http://discussions.apple.com/thread.jspa?messageID=4270337&#4270337

Here is one solution (I am sure there are more)...
1. Enable the 'at' command with (Send Unix Command) this to all clients (as root):
*launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist*

2. Send the softwareupdate and reboot with Send Unix Command as root (two lines):
*softwareupdate -l -a*
*echo "shutdown -r now" | at now +1 minute*

ARD won't get stuck after the update when using this method...

To expand on this, you can add an option to only update if no user is logged in:

*if who | grep console; then*
* echo Machine is in use*
* exit 1*
fi
*COMMAND LINEINSTALL=1 softwareupdate -i -a*
*echo "shutdown -r now" | at now +1 minute*


To expand further... (I haven't gotten this far yet)...
I'd like to first run "diskutil verifyVolume /" and if a problem exists exit the script without running software update.

If anyone has code they would like to contribute towards this, please post.

Thanks
Jeff

Posted on Aug 11, 2008 3:01 PM

Reply
2 replies

Aug 11, 2008 3:24 PM in response to UptimeJeff

A few snafus in the last set of code... here it is again with the line to enable the 'at' command included:

Use Send Unix Command as root user (root user does not need to be enabled in the OS)


launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist
if who | grep console; then
echo Machine is in use
exit 1
fi
COMMAND LINEINSTALL=1 softwareupdate -i -a
echo "shutdown -r now" | at now +1 minute

Aug 11, 2008 7:00 PM in response to UptimeJeff

Current version of DiskUtilityVerify-SoftwareUpdate script optimized for ARD Send Unix Command:

if ! diskutil verifyVolume / | grep "appears to be OK"; then
echo " ******* DRIVE NEEDS REPAIR - UPDATES ABORTED ***********"
exit 1
fi

if ! launchctl list | grep atrun.plist; then
launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist
echo Enabled 'at' command
fi

if who | grep console; then
echo Machine is in use, updates aborted
exit 1
fi

COMMAND LINEINSTALL=1 softwareupdate -i -a
echo "shutdown -r now" | at now +1 minute

echo Done!



# the reboot should be skipped of no updates which require reboot are installed #

Rebooting with Status - this works

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.