diff --git a/Jamf Pro/Extension Attributes/jamf_ea_LatestOSSupported.sh b/Jamf Pro/Extension Attributes/jamf_ea_LatestOSSupported.sh index 40344d5..c161e10 100644 --- a/Jamf Pro/Extension Attributes/jamf_ea_LatestOSSupported.sh +++ b/Jamf Pro/Extension Attributes/jamf_ea_LatestOSSupported.sh @@ -3,11 +3,12 @@ ################################################################################################### # Script Name: jamf_ea_LatestOSSupported.sh # By: Zack Thompson / Created: 9/26/2017 -# Version: 1.7.0 / Updated: 3/23/2020 / By: ZT +# Version: 1.8.0 / Updated: 10/21/2020 / By: ZT # # Description: A Jamf Extension Attribute to check the latest compatible version of macOS. # # System Requirements can be found here: +# Big Sur - https://www.apple.com/macos/big-sur-preview/ # Catalina - https://support.apple.com/en-us/HT201475 # Mojave - https://support.apple.com/en-us/HT210190 # * MacPro5,1's = https://support.apple.com/en-us/HT208898 @@ -30,10 +31,14 @@ requiredRAMCatalina=$(($minimumRAMCatalina * $convertToGigabytes)) requiredFreeSpace=$(($minimumFreeSpace * $convertToGigabytes)) # Get the OS Version - osVersion=$( /usr/bin/sw_vers -productVersion | /usr/bin/awk -F '.' '{print $2"."$3}' ) + osVersion=$( /usr/bin/sw_vers -productVersion ) + osMajorVersion=$( echo "${osVersion}" | /usr/bin/awk -F '.' '{print $1}' ) + osMinorPatchVersion=$( echo "${osVersion}" | /usr/bin/awk -F '.' '{print $2"."$3}' ) # Get the Model Type and Major Version modelType=$( /usr/sbin/sysctl -n hw.model | /usr/bin/sed 's/[^a-zA-Z]//g' ) - modelMajorVersion=$( /usr/sbin/sysctl -n hw.model | /usr/bin/sed 's/[^0-9,]//g' | /usr/bin/awk -F ',' '{print $1}' ) + modelVersion=$( /usr/sbin/sysctl -n hw.model | /usr/bin/sed 's/[^0-9,]//g' ) + modelMajorVersion=$( echo "${modelVersion}" | /usr/bin/awk -F ',' '{print $1}' ) + modelMinorVersion=$( echo "${modelVersion}" | /usr/bin/awk -F ',' '{print $2}' ) # Get RAM Info systemRAM=$( /usr/sbin/sysctl -n hw.memsize ) RAMUpgradeable=$( /usr/sbin/system_profiler SPMemoryDataType | /usr/bin/awk -F "Upgradeable Memory: " '{print $2}' | /usr/bin/xargs ) @@ -45,21 +50,45 @@ modelCheck() { - if [[ $modelMajorVersion -ge $5 && $(/usr/bin/bc <<< "${osVersion} >= 8") -eq 1 ]]; then + if [[ $modelMajorVersion -ge $5 && ( $(/usr/bin/bc <<< "${osMajorVersion} >= 11") -eq 1 || $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 9") -eq 1 ) ]]; then echo "Big Sur" - elif [[ $modelMajorVersion -ge $4 && $(/usr/bin/bc <<< "${osVersion} >= 8") -eq 1 ]]; then + elif [[ $modelMajorVersion -ge $4 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 9") -eq 1 ]]; then echo "Catalina" - elif [[ $modelMajorVersion -ge $3 && $(/usr/bin/bc <<< "${osVersion} >= 8") -eq 1 ]]; then + elif [[ $modelMajorVersion -ge $4 && $(/usr/bin/bc <<< "${osMinorPatchVersion} <= 8") -eq 1 ]]; then + echo "Mojave / OS Limitation" # (Current OS Limitation, 10.15 Catalina) + elif [[ $modelMajorVersion -ge $3 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 8") -eq 1 ]]; then echo "Mojave" - elif [[ $modelMajorVersion -ge $2 && $(/usr/bin/bc <<< "${osVersion} >= 8") -eq 1 ]]; then + elif [[ $modelMajorVersion -ge $2 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 8") -eq 1 ]]; then echo "High Sierra" - elif [[ $modelMajorVersion -ge $2 && $(/usr/bin/bc <<< "${osVersion} >= 7.5") -eq 1 ]]; then + elif [[ $modelMajorVersion -ge $2 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 7.5") -eq 1 ]]; then echo "Sierra / OS Limitation" # (Current OS Limitation, 10.13 Compatible) - elif [[ $modelMajorVersion -ge $1 && $(/usr/bin/bc <<< "${osVersion} >= 6.8") -eq 1 ]]; then + elif [[ $modelMajorVersion -ge $1 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 6.8") -eq 1 ]]; then echo "El Capitan" else - echo "Current OS Not Supported" - exit 0 + echo "Current OS Not Supported" + fi + +} + +# Apple just had to make one iMac model (14,4) support Big Sur... +iMacModelCheck() { + + if [[ $modelMajorVersion -ge $5 && $modelMinorVersion -ge 4 && ( $(/usr/bin/bc <<< "${osMajorVersion} >= 11") -eq 1 || $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 9") -eq 1 ) ]]; then + echo "Big Sur" + elif [[ $modelMajorVersion -ge $4 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 9") -eq 1 ]]; then + echo "Catalina" + elif [[ $modelMajorVersion -ge $4 && $(/usr/bin/bc <<< "${osMinorPatchVersion} <= 8") -eq 1 ]]; then + echo "Mojave / OS Limitation" # (Current OS Limitation, 10.15 Catalina) + elif [[ $modelMajorVersion -ge $3 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 8") -eq 1 ]]; then + echo "Mojave" + elif [[ $modelMajorVersion -ge $2 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 8") -eq 1 ]]; then + echo "High Sierra" + elif [[ $modelMajorVersion -ge $2 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 7.5") -eq 1 ]]; then + echo "Sierra / OS Limitation" # (Current OS Limitation, 10.13 Compatible) + elif [[ $modelMajorVersion -ge $1 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 6.8") -eq 1 ]]; then + echo "El Capitan" + else + echo "Current OS Not Supported" fi } @@ -67,12 +96,12 @@ modelCheck() { # Because Apple had to make Mojave support for MacPro's difficult... I have to add complexity to the original "simplistic" logic in this script. macProModelCheck() { - if [[ $modelMajorVersion -ge $4 ]]; then - # For MacPro 6,1 (2013/Trash Cans), these should be supported no matter the existing state, since they wouldn't be compatible with any OS that is old, nor have incompatible hardware. - echo "Catalina" + if [[ $modelMajorVersion -ge $5 ]]; then + # For MacPro 6,1 (2013/Trash Cans) and newer, these should be supported no matter the existing state, since they wouldn't be compatible with any OS that is old, nor have incompatible hardware. + echo "Big Sur" - elif [[ $modelMajorVersion -ge $3 && $(/usr/bin/bc <<< "${osVersion} >= 13.6") -eq 1 ]]; then - # Supports Mojave, but required Metal Capabable Graphics Cards and FileVault must be disabled. + elif [[ $modelMajorVersion -ge $3 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 13.6") -eq 1 ]]; then + # Supports Mojave, but required Metal Capable Graphics Cards and FileVault must be disabled. macProResult="Mojave" # Check if the Graphics Card supports Metal @@ -87,15 +116,14 @@ macProModelCheck() { echo "${macProResult}" - elif [[ $modelMajorVersion -ge $3 && $(/usr/bin/bc <<< "${osVersion} <= 13.6") -eq 1 ]]; then - # Supports Mojave or newer, but requires a stepped upgrade path . + elif [[ $modelMajorVersion -ge $3 && $(/usr/bin/bc <<< "${osMinorPatchVersion} <= 13.5") -eq 1 ]]; then - echo "High Sierra / OS Limitation" + echo "High Sierra / OS Limitation" # Supports Mojave or newer, but requires a stepped upgrade path - elif [[ $modelMajorVersion -ge $2 && $(/usr/bin/bc <<< "${osVersion} >= 7.5") -eq 1 ]]; then + elif [[ $modelMajorVersion -ge $2 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 7.5") -eq 1 ]]; then echo "Sierra / OS Limitation" # (Current OS Limitation, 10.13 Compatible) - elif [[ $modelMajorVersion -ge $1 && $(/usr/bin/bc <<< "${osVersion} >= 6.8") -eq 1 ]]; then + elif [[ $modelMajorVersion -ge $1 && $(/usr/bin/bc <<< "${osMinorPatchVersion} >= 6.8") -eq 1 ]]; then echo "El Capitan" fi @@ -104,12 +132,12 @@ macProModelCheck() { ################################################## # Check for compatibility... -# Each number passed to the below functions is the major model version for the model type. -# The first parameter is for El Capitan, the second is for High Sierra, the third is for Mojave, and the forth is for Catalina. +# Each number passed to the below functions is the minimum major model version for the model type. +# The first parameter is for El Capitan, the second is for High Sierra, the third is for Mojave, the forth is for Catalina, and the fifth is for Big Sur. case $modelType in "iMac" ) - # Function modelCheck - latestOSSupport=$( modelCheck 7 10 13 13 15 ) + # Function iMacModelCheck + latestOSSupport=$( iMacModelCheck 7 10 13 13 14 ) ;; "MacBook" ) # Function modelCheck @@ -128,7 +156,7 @@ case $modelType in latestOSSupport=$( modelCheck 3 4 6 6 7 ) ;; "MacPro" ) - # Function modelCheck + # Function macProModelCheck latestOSSupport=$( macProModelCheck 3 5 5 6 6 ) ;; "iMacPro" ) @@ -158,13 +186,13 @@ if [[ "${latestOSSupport}" == "Catalina" ]]; then latestOSSupport="Mojave" else # Device does not have enough RAM to support any upgrade!? - echo "Not Upgrableable" + echo "Not Upgradable" exit 0 fi else # Device does not have enough RAM to upgrade currently, but RAM capacity can be increased. - finalResult+="Insufficient RAM" + finalResult+=" / Insufficient RAM" fi fi @@ -177,7 +205,7 @@ else if [[ "${RAMUpgradeable}" == "No" ]]; then # Device does not have enough RAM to support any upgrade!? - echo "Not Upgrableable" + echo "Not Upgradable" exit 0 else