I have a macOS Big Sur upgrade script that has worked perfectly in my testing on dummy machines but when I have it pushed via policy, everything works, except for the part after they click upgrade. It's as if the script just halts and exits. However, when I run it through self-service as that same user on their machine, it works normally and begins the upgrade! Any ideas on why they are different? Apologies for the caveman script
Below is my script; after the user accepts the upgrade, is when it stops (line 77 or ## Upgrade Here ##):
#!/bin/bash
if ! [[ $(sw_vers | grep ProductVersion | awk -F ":" '{print $2}' | awk '{$1=$1};1' | awk -F "." '{print $1}') == 11 ]]
then
if [ -e "/Users/Shared/deferrals_MacOSUpgrade.txt" ]
then
deferralsleft=$(cat /Users/Shared/deferrals_MacOSUpgrade.txt)
else
echo 3 > /Users/Shared/deferrals_MacOSUpgrade.txt
deferralsleft=$(cat /Users/Shared/deferrals_MacOSUpgrade.txt)
fi
if [[ $(sudo find /Users -name "Install macOS Big Sur.app") ]] || [[ $(sudo find /Applications -name "Install macOS Big Sur.app") ]]
then
## Find where Installer is located
testpath=$(sudo find /Users -name "Install macOS Big Sur.app")
if [ -z "${testpath}" ]
then
echo "Not in Users"
else
echo "Found in $testpath"
path=$(sudo find /Users -name "Install macOS Big Sur.app")
fi
testpath=$(sudo find /Applications -name "Install macOS Big Sur.app")
if [ -z "${testpath}" ]
then
echo "Not in Applications"
else
echo "Found in $testpath"
path=$(sudo find /Applications -name "Install macOS Big Sur.app")
fi
## Set Install Args ##
install_args=()
install_args+=("--forcequitapps")
## Set Prompt Icon Location ##
iconpath=$path$"/Contents/Resources"
iconpathHFS=$(/usr/bin/osascript -e "return POSIX file \\"$iconpath\\"" | awk -F "file" '{print $2}' | awk '{$1=$1};1')
## Fix Icon HFS Path for Mojave ##
if [[ $(sw_vers | grep ProductVersion | awk -F ":" '{print $2}' | awk '{$1=$1};1' | awk 'BEGIN{FS="."} {print $1 "." $2}') == 10.14 ]]
then
iconpathHFS=$iconpathHFS$":"
fi
echo $iconpathHFS
## Set jamfHelper Info ##
heading="Please wait as we prepare your computer for macOS Big Sur..."
description="
This process will take approximately 5-10 minutes.
Once completed your computer will reboot and begin the upgrade."
jamfIcon=$iconpath$"/InstallAssistant.icns"
## Prompt User to Begin Installation
if [ $deferralsleft -gt 0 ]
then
currentdeferrals=$(echo $deferralsleft)
((deferralsleft--))
echo $deferralsleft > /Users/Shared/deferrals_MacOSUpgrade.txt
response=$(/usr/bin/osascript -e 'tell application "Finder"' -e "with timeout of 3600 seconds" -e 'activate' -e "display dialog \\"A New MacOS upgrade is required!\\n\\nYou are receiving this prompt because your machine is currently on an out-of-date MacOS version. We need to get you updated to MacOS Big Sur for compliance with Security policies. This upgrade will not affect any of your files or applications.\\n\\nWe understand this may not be a good time and have allowed up to 3 deferrals. After these two deferrals are used up, the MacOS Upgrade will begin. We recommend you find 30 Minutes to an Hour for the upgrade to avoid inconveniences.\\n\\nDeferrals Remaining: $currentdeferrals\\n\\nIf you have any questions or concerns, please contact IT calling x#### or submitting a Ticket!\\" with icon file ((\\"$iconpathHFS\\") & \\"InstallAssistant.icns\\") buttons {\\"Defer\\", \\"Upgrade\\"} default button \\"Upgrade\\" with title \\"MacOS Big Sur Upgrade\\" with hidden answer" -e 'end timeout' -e 'end tell')
if [[ $(echo "$response" | /usr/bin/awk -F "button returned:" '{print $2}' | /usr/bin/awk -F "," '{print $1}') = *Upgrade* ]]
then
echo "Upgrade Selected"
## Upgrade HERE ##
/Library/Application\\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -title "" -icon "$jamfIcon" -heading "$heading" -description "$description" &
jamfHelperPID=$!
"$iconpath/startosinstall" "${install_args[@]}" --agreetolicense --nointeraction --pidtosignal $jamfHelperPID >> /var/log/startosinstall.log 2>&1 &
else
echo "User Deferred. Deferrals remaining: $deferralsleft"
fi
else
echo "Defer Limit Reached"
response=$(/usr/bin/osascript -e 'tell application "Finder"' -e "with timeout of 3600 seconds" -e 'activate' -e "display dialog \\"A New MacOS upgrade is required!\\n\\nYou are receiving this prompt because your machine is currently on an out-of-date MacOS version. We need to get you updated to MacOS Big Sur for compliance with Security policies. This upgrade will not affect any of your files or applications.\\n\\nDEFERRALS LIMIT REACHED!\\n\\nYou have reached your deferral limit and MacOS will force the upgrade upon closer of this window OR on reboot.\\" with icon file ((\\"$iconpathHFS\\") & \\"InstallAssistant.icns\\") buttons {\\"Upgrade\\"} default button \\"Upgrade\\" with title \\"MacOS Big Sur Upgrade\\" with hidden answer" -e 'end timeout' -e 'end tell')
## Force Upgrade HERE ##
/Library/Application\\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -title "" -icon "$jamfIcon" -heading "$heading" -description "$description" &
jamfHelperPID=$!
"$iconpath/startosinstall" "${install_args[@]}" --agreetolicense --nointeraction --pidtosignal $jamfHelperPID >> /var/log/startosinstall.log 2>&1 &
fi
else
echo "MacOS Big Sur Installer has not been located. Initiating Download..."
curl "http://swcdn.apple.com/content/downloads/04/42/002-42341-A_4PL6G0S8GN/cs65avpi1aelh133lc36fy0ste3lihe71n/InstallAssistant.pkg" --output "/Users/Shared/BigSur_11_6_Installer.pkg"
sudo installer -pkg "/Users/Shared/BigSur_11_6_Installer.pkg" -target /
fi
else
echo "Already on Big Sur!"
fi
Here is an image of the policy log after it's been pushed; there should be steps after: