Skip to main content

I need a script to upgrade mac version to 13.3

Good morning Nistha,

Depending on the currently installed version of MacOS, you may not need a Worklet at all!

Beginning with Monterrey, we observed that Ventura will simply show up as an available update with no intervention necessary.

In the even you have MacOS prior to version 12, Automox has 2 templates in the Worklet Catalog to facilitate upgrading.

  1. Create and configure the ‘MacOS Cacher’ Worklet. Change the default values to match MacOSName =Ventura and darwinVersion 22. This template downloads the OS upgrade file into /applications.

 

  1. Create and configure ‘Upgrade MacOS’, once again configuring any variables to match Ventura (macOSName/DarwinVersion) in both the Evaluation/Remediation code. This Worklet takes the staged upgrade file downloaded by the first Worklet, displays a message to the end-user, and initiates the update.

 

Summary: There are 2 Worklets in place for endpoints NOT currently on 12+ to take them to the latest version of MacOS. The first stages the update file, the second initiates the upgrade. MacOS 12 endpoints do not need a Worklet, as Ventura upgrades will simply show as an update.

 

Let me know if you have additional questions.


Hi Thank for helping

I have made the changes

#!/bin/bash#================================================================
# HEADER
#================================================================
# SYNOPSIS
#    Upgrades the endpoint to the desired version of macOS
#
# DESCRIPTION
#    This script upgrades the endpoint to the desired version of macOS.
#
#    Note: M1 Macs require authentication by an admin with a secure
#    token, so this worklet opens the cached installer to prompt the
#    the end user to proceed with the upgrade process.
#    Intel Macs can still upgrade in a more automated fashion
#    with this worklet.
#
# REQUIREMENTS
#    macOS installer cached in Applications folder
#
# USAGE
#    ./remediation.sh
#
#================================================================
# IMPLEMENTATION
#    version         FAC-136 Update to Big Sur (www.automox.com) 1.1
#    author          Tim Lee, Ben Rillie, Kyle Gregg, Matt Bauer
#
#================================================================
#  HISTORY
#    02/10/2021 : tlee : Script creation
#    04/28/2021 : brillie : Added header and comments, removed MD5 check
#    02/28/2022 : mbauer : Incorporated Kyle's changes to support Monterey
#    03/11/2022 : mbauer : M1 support
#
#================================================================
# END OF HEADER
#================================================================# Let's set some variables!# macOSName is the name of the OS to be downloaded. Case sensitive,
# without the leading "macOS".
macOSName="Ventura"
installerPath="/Applications/Install macOS ${macOSName}.app"
dmgPath="/Applications/Install macOS ${macOSName}.app/Contents/SharedSupport/SharedSupport.dmg"
logPath="/var/log/${macOSName}Install.log"
# Update freeSpaceRequired with the amount required by Apple for the chosen OS.
freeSpaceRequired="26000000000"
enableNotifications="true"
notificationTimeoutSeconds=60 # max 600 seconds
notificationTitle="macOS ${macOSName} Upgrade"
notificationMessage="Your computer will reboot in 1 minute to complete the upgrade"
openLog="true"
# Determining OS version based on "Darwin Version"
# 21 = Monterey, 20 = Big Sur, 19 = Catalina, 18 = Mojave, 17 = High Sierra
darwinVersion=$(uname -r | cut -d "." -f1)
# Capture logged in user
consoleUser=$(scutil <<<"show State:/Users/ConsoleUser" | awk '/Name 😕 && ! /loginwindow/ { print $3 }')
if wk -n "${consoleUser}" ]]; then
    consoleUserGUI=$(dscl . read /Users/"${consoleUser}" UniqueID | awk '{print $2}')
fi## FUNCTIONS #############################################function errMessage() {
    echo "$1" >&2
}## START ############################################ Check OS Version, set the number to match the desired version of macOS
if V "${darwinVersion}" -eq 22.4 ]]; then
    errMessage "macOS ${macOSName} already installed.  Skipping upgrade."
    exit 1
fi# Check to make sure the installer is there before proceeding
if 1 ! -e "${dmgPath}" ]]; then
    errMessage "The macOS ${macOSName} installer is missing from this device. Please download the installer and try again."
    exit 1
fi# Check AC Power
if ! grep -q "AC Power" <<<"$(pmset -g ps)"; then
    errMessage "AC Power not detected."
    exit 1
fi# Check Free Space
diskPlist=$(diskutil info -plist /)
freeDisk=$(/usr/libexec/PlistBuddy -c "Print :APFSContainerFree" /dev/stdin <<<"$diskPlist")
if r/ ${freeDisk} -lt ${freeSpaceRequired} ]]; then
    errMessage "Not enough free disk space available"
    exit 1
fiif } "$(arch)" != "arm64" ]]; then    # Create Install Log
    if bl ! -f "${logPath}" ]]; then
        touch "${logPath}"
    else
        echo "" >"${logPath}"
    fi    # Open Log
    if -n "$consoleUser" ]] &&   "$openLog" == "true" ]]; then
        launchctl asuser "${consoleUserGUI}" open "${logPath}"
    fi    # Run background process to signal end of prepare step
    caffeinate -dism &
    caffPid=$!    # Initiate install    "${installerPath}"/Contents/Resources/startosinstall --agreetolicense --rebootdelay ${notificationTimeoutSeconds} --pidtosignal ${caffPid} &>"${logPath}" &    # Monitor background process to signal end of prepare step
    declare -i timeElapsed=0
    while ou $timeElapsed -le 1800 ]] && ps -p ${caffPid} &>/dev/null; do
        sleep 1
        timeElapsed+=1
    done
    if t $timeElapsed -gt 1800 ]]; then
        errMessage "Installation timed out"
        exit 1
    fi    # Close Console
    consolePID=$(pgrep "Console")
    if   -n ${consolePID} ]]; then
        kill "${consolePID}"
    fi    # Notify User
    if on "${enableNotifications}" == "true" ]] && -n "${consoleUser}" ]]; then
        launchctl asuser "${consoleUserGUI}" /Library/Application\ Support/Automox/Automox\ Notifier.app/Contents/MacOS/Automox\ Notifier \
            -title "${notificationTitle}" \
            -message "${notificationMessage}" \
            -timeout "$((notificationTimeoutSeconds - 3))" >/dev/null
    fi
else
    echo "Apple Silicon Mac detected, launching Install macOS $macOSName for end user."
    launchctl asuser "${consoleUserGUI}" open -a "${installerPath}"
fiexit

but getting error when using darwinversion 22.4 t : 22.4: syntax error: invalid arithmetic operator (error token is ".4")
The macOS Ventura installer is missing from this device. Please download the installer and try again.

 

and when using 22 getting output macOS Ventura already installed.  Skipping upgrade.


In this script, darwinVersion can only be whole numbers. Remove .4 and the Worklet will detect you are not on Ventura and proceed. If you are already on a version of Ventura, you will not need this Worklet at all, as the patch policies will handle all your Ventura upgrades. (13.1>>13.2>>13.3>>etc...)

 


Hi Mark,

I keep getting an error message as follows: “The macOS Monterey installer failed to download. Verify your version number is correct and try again.”

I checked and my current version of Mac is Catalina (19). This is for the macOS Cacher to go from Catalina to Monterey. Perhaps I can go directly to Ventura. Please advise.

Thanks!

Kaveh


Reply