Catalina script not updating policy, but policy is succesful

beeboo
Contributor

have a script that checks if "/Applications/Install macOS Catalina.app" is installed.

eventually after my checks, it calls a function that uses jamfHelper to provide some visuals and dialog boxes for the user.

FUNCTION BELOW (installCATALINAprompt)

popup=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -title "$title" -description "$message" -button1 "Update" -button2 "Cancel" -defaultButton 1 -cancelButton 2 -timeout 3600 -countdown -alignCountdown center -icon "$icon"` #"$icon"` #> /dev/null 2>&1 &
                    # 0 means default so if a user doesnt respond OR clicks "update" then the process will start
                    if [[ "$popup" == "0" ]]; then
                        # Caffeinate to ensure machine is running without sleeping/hibernating/etc
                        /usr/bin/caffeinate -dis &
                        caffeinatePID=$!
                        disown
                        /bin/echo "Commence upgrade"
                        #Launch jamfHelper - second screen - full screen
                        catalinaICON="/Applications/Install macOS Catalina.app/Contents/Resources/InstallAssistant.icns"
                        /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -description "$description" -heading "Please wait as we prepare your computer for macOS Catalina" -icon "/Applications/Install macOS Catalina.app/Contents/Resources/InstallAssistant.icns" &
                        # /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -description "$description" -heading "Please wait as we prepare your computer for the macOS Catalina" -icon "$catalinaICON" &
                        # Command to start the OS upgrade
                        /Applications/Install macOS Catalina.app/Contents/Resources/startosinstall --agreetolicense --forcequitapps
                        sleep 10
                        { /bin/kill "${caffeinatePID}"; } 2>/dev/null
                        { /usr/bin/killall jamfHelper; } 2>/dev/null
                        /bin/echo "Upgrade complete"
                        description2="macOS Catalina upgrade complete.
Please click Restart Now to reboot your machine now otherwise your machine will automatically reboot in one hour."
                        popup2=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -description "$description2" -heading "LendingClub IT" -icon "/Library/LC/logo.icns" -button1 "Restart Now" -defaultButton 1 -timeout 3600 -countdown -lockHUD -alignCountdown center`
                        if [[ "$popup2" == "0" ]]; then
                            /bin/echo "kicking off restart now"
                            shutdown -r +1 &
                        fi   
                    # 2 means quit, which is the cancel button
                    else [[ "popup" == "2" ]]
                        /bin/echo "User cancelled upgrade"
                        exit 0
                    fi

thats the part that does it as im calling that particular function

this is the part that runs the script itself

if [[ $deploymentTYPE = "prompt" ]]; then
    /bin/echo "Prompting user about policy"
    installCATALINAprompt
    /bin/echo "macOS Catalina installed.  Rebooting"
    { /usr/bin/killall jamfHelper; } 2>/dev/null
fi

problem is, machine does the installer for catalina with no issues, however, theres nothing in the logs for my policy.

id like to see the logs if nothing else than to see that it went through properly, but all it does it update the machine then removes it from the policy due to the smart group

@mm2270 cuz i know ure a superstar πŸ™‚

3 REPLIES 3

sdagley
Honored Contributor II

@beeboo When you run the macOS Catalina installer the Mac restarts which terminates the script, so it never logs completion with your Jamf Pro server. Rather than re-inventing the wheel to install Catalina, take a look at the macOSUpgrade script which spawns the installer as a separate process than the script so it can complete and update the policy status that the installer was started. It also sets up a recon call after the restart so the Mac reports its new OS version.

beeboo
Contributor

@sdagley thats fair - I just different controls and needs but I mightve seen that script before.
plus, the addition of jamfhelper means i gotta do a lot of editing in the script anyways.

I pose this as a thought process - the only glaring difference in the scripts (in relation to the command) is that there is an ampersand attached to the end of the command to install Catalina (along with spitting out logs) which makes its own progress, correct?

i mean, im so close, giving on this script that works except for submitting logs seems like an awful waste of time and learning for me 😞

EDIT:

ill note that this works for softwareupdates eg doing a 10.15.5 > 10.15.6 update.
no ampersand for that process and it updates my logs properly while also updating the machine as expected.

maybe there is something inherent in the OS update that causes this specific issue?

im thinking it could be a few things:
1. something at the end of the update process (that isnt easily visible) that does a force reboot after its installed
2. forcequit flag for the installer maybe its quitting an app that is negatively affecting the process? eg maybe it quits terminal or something and as such it doesnt have a chance to write to JSS?
3. maybe the shutdown -r should be outside the function to prevent any timeouts during the process running therefore rebooting computer before it could write to JSS (even with the 1 min i give it)
4. maybe i need to add an & to the installer line too and do a check to see if a file/process is complete (im assuming thats what eval is for? i havent used eval before)

sdagley
Honored Contributor II

@beeboo The & at the end of the startosinstall command means run it as a background process, and don't wait for it to complete.

When you're doing a softwareupdate and set the Policy option to restart the jamf binary is smart enough to defer the restart until the policy has completed.

One of the biggest advantages of Jamf Nation is the ability to make use of the work others have already done so you don't have to recreate the wheel. You really should look at macOSUpgrade, it does a lot of pre-flight and error handling to try and make sure an upgrade is going to work. To use it you only have to upload the script, create and upload a .pkg for the Install macOS Catalina.app, and create 2 policies (one to install the Install macOS Catalina.pkg you created, and one to run the macOSUpgrade script). It really doesn't take that much time to set it up.

If you're determined to roll your own script, then macOSUpgrade should show you all the things you need to do to get your script to complete and report in while also running startosinstall. That will probably take longer.