2 Replies Latest reply: Aug 11, 2008 7:00 PM by UptimeJeff
UptimeJeff Level 4 Level 4 (3,390 points)
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
*COMMANDLINEINSTALL=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
  • 1. Re: Rebooting with Status - this works
    UptimeJeff Level 4 Level 4 (3,390 points)
    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
    COMMANDLINEINSTALL=1 softwareupdate -i -a
    echo "shutdown -r now" | at now +1 minute
  • 2. Re: Rebooting with Status - this works
    UptimeJeff Level 4 Level 4 (3,390 points)
    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

    COMMANDLINEINSTALL=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 #