Benches Uncategorized

2

Rebooting with Status - this works

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

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

2 replies

Sign in or join Beachball Help to reply.

  1. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    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. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    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 #