bp88 / JSS-Scripts

Random scripts for use in the Jamf Pro
188 stars 61 forks source link

Recommended updates do not install silently on Catalina (10.15.6) with AppleSoftwareUpdate.sh #15

Closed jmahlman closed 3 years ago

jmahlman commented 3 years ago

Came across this issue with the Safari 14 update. macOS 10.15.6 uses a different software update readout than 10.14.6 (not sure if it's new but this is when I noticed it). When readingsoftwareupdate -l into ListOfSoftwareUpdates the following is the output:

10.14.6:

Software Update Tool

Finding available software Software Update found the following new or updated software:

  • Safari14.0MojaveAuto-14.0 Safari (14.0), 67309K [recommended] Software Update Tool

10.15.6:

Software Update Tool

Finding available software Software Update found the following new or updated software:

  • Label: Safari14.0CatalinaAuto-14.0 Title: Safari, Version: 14.0, Size: 65417K, Recommended: YES,

The issue is, the 2 lines that set UpdatesNoRestart and RestartRequired use grep:

UpdatesNoRestart=$(/bin/cat "$ListOfSoftwareUpdates" | /usr/bin/grep recommended | /usr/bin/grep -v restart | /usr/bin/cut -d , -f 1 | /usr/bin/sed -e 's/^[[:space:]]*//' | /usr/bin/sed -e 's/^Title:\ *//')
RestartRequired=$(/bin/cat "$ListOfSoftwareUpdates" | /usr/bin/grep restart | /usr/bin/grep -v '\*' | /usr/bin/cut -d , -f 1 | /usr/bin/sed -e 's/^[[:space:]]*//' | /usr/bin/sed -e 's/^Title:\ *//')

This will work on 10.14 but not 10.15 because of casing. Adding -i to the grep commands for finding "restart" and "recommended" resolves this:


UpdatesNoRestart=$(/bin/cat "$ListOfSoftwareUpdates" | /usr/bin/grep -i recommended | /usr/bin/grep -v -i restart | /usr/bin/cut -d , -f 1 | /usr/bin/sed -e 's/^[[:space:]]*//' | /usr/bin/sed -e 's/^Title:\ *//')
RestartRequired=$(/bin/cat "$ListOfSoftwareUpdates" | /usr/bin/grep -i restart | /usr/bin/grep -v '\*' | /usr/bin/cut -d , -f 1 | /usr/bin/sed -e 's/^[[:space:]]*//' | /usr/bin/sed -e 's/^Title:\ *//')