mpanighetti / install-or-defer

A framework for prompting users of Jamf Pro-managed Macs to install Apple software updates.
Apache License 2.0
148 stars 28 forks source link

Software Update Action: restart Restarted but didn't install #47

Closed master-vodawagner closed 3 years ago

master-vodawagner commented 3 years ago

Granted I'm on the Apple Customer Seed program but the install mechanisms are the same.

My device is on Big Sur 11.0.1

To me it seems like line 208 no longer works on Big Sur as the output capture of /usr/sbin/softwareupdate --install --$INSTALL_WHICH --no-scan doesn't display the text "select Shut Down from the Apple menu"

test@testuser ~ % /usr/sbin/softwareupdate --list Finding available software Software Update found the following new or updated software:

Finding available software Downloading macOS Big Sur 11.1 Beta 2 Downloaded: macOS Big Sur 11.1 Beta 2 test@testuser ~ %

master-vodawagner commented 3 years ago

I just modified your code locally to try this method which includes the --restart argument onto the softwareupdate command which worked fine except it didn't close my open terminal elevated to root without prompting to close it

# Determine whether any critical updates are available, and if any require
    # a restart. If no updates need to be installed, bail out.
    if [[ "$UPDATE_CHECK" =~ (Action: restart|\[restart\]) ]]; then
        INSTALL_WHICH="all"
        echo "$(date): Update requires a restart / shutdown..." >> /var/log/ACLogs/install_or_defer.log
        ((RESTART_DETECTED++))

run_updates () {

    clean_up

    if [[ "$RESTART_DETECTED" = "1" ]]; then
        echo "$(date): Triggering update with restart argument..." >> /var/log/ACLogs/install_or_defer.log
        # Display HUD with updating message.
        echo "$(date): Running $INSTALL_WHICH system updates..." >> /var/log/ACLogs/install_or_defer.log
        "$JAMFHELPER" -windowType "hud" -windowPosition "ur" -icon "$LOGO" -title "$MSG_UPDATING_HEADING" -description "$MSG_UPDATING" -lockHUD &

        # Run Apple system updates.
        echo "$(date): Running $INSTALL_WHICH Apple system updates..." >> /var/log/ACLogs/install_or_defer.log
        UPDATE_OUTPUT_CAPTURE="$(/usr/sbin/softwareupdate --install --$INSTALL_WHICH --restart --no-scan 2>&1)" >> /var/log/ACLogs/install_or_defer.log
        echo "$(date): Finished running Apple updates." >> /var/log/ACLogs/install_or_defer.log
    else
        echo "$(date): Triggering update without restart argument..." >> /var/log/ACLogs/install_or_defer.log
        # Display HUD with updating message.
        echo "$(date): Running $INSTALL_WHICH system updates..." >> /var/log/ACLogs/install_or_defer.log
        "$JAMFHELPER" -windowType "hud" -windowPosition "ur" -icon "$LOGO" -title "$MSG_UPDATING_HEADING" -description "$MSG_UPDATING" -lockHUD &

        # Run Apple system updates.
        echo "$(date): Running $INSTALL_WHICH Apple system updates..." >> /var/log/ACLogs/install_or_defer.log
        UPDATE_OUTPUT_CAPTURE="$(/usr/sbin/softwareupdate --install --$INSTALL_WHICH --no-scan 2>&1)" >> /var/log/ACLogs/install_or_defer.log
        echo "$(date): Finished running Apple updates." >> /var/log/ACLogs/install_or_defer.log
    fi
mpanighetti commented 3 years ago

Thanks for digging into this. I wasn't able to reproduce it on my Big Sur Beta test Mac, but it has a T1 chip and thus isn't subject to the shutdown-vs-restart requirement that necessitated the output parsing originally. We should be able to make that parsing only happen in pre-Big Sur Macs, and just run softwareupdate --install --all --restart at the end of the script for Big Sur and later. It'll miss out on a proper cleanup at the end of the script run, but that will be handled the next time the script runs after the update is applied (assuming no secondary updates pop up afterward).

I'll update #44 with the necessary changes.

mpanighetti commented 3 years ago

Fixed in #44 and included in v4.0 release.