Hi Everyone,
I have written a script to download the Mac OS update in background but its suck on admin password and followed by the user interaction to save all file and click on restart button to install the update.
but somehow script works till popup message display. below is the script
to update update os
#!/bin/bash
loggedInUser=$(stat -f%Su /dev/console)
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
windowType="hud"
description="There is a critical security update available for your Company issued computer.
To perform the update, Click on 'UPDATE' below and the security update will begin to run.
This update can take upwards of 45 minutes.
NOTE: Before clicking on 'UPDATE', save all working documents and Connected the Charger.
If you require assistance, please contact ********** on Slack or by email at."
button1="MacOS update"
icon="/Library/Application Support/JAMF/logs/**********.png"
title="Critical: Apple Security Update Available"
alignDescription="left"
alignHeading="center"
defaultButton="2"
timeout="900"
# JAMF Helper window as it appears for targeted computers
userChoice=$("$jamfHelper" -windowType "$windowType" -lockHUD -title "$title" -timeout "$timeout" -defaultButton "$defaultButton" -icon "$icon" -description "$description" -alignDescription "$alignDescription" -alignHeading "$alignHeading" -button1 "$button1")
# If user selects "UPDATE"
if [ "$userChoice" == "0" ]; then
echo "User clicked UPDATE;
# Trigger Mac OS update
softwareupdate -i -a
osascript -e 'tell app "loginwindow" to «event aevtrrst»'
echo "Dialog dismissed. Beginning install"
exit 0
fi
___
2. Restart system
#!/bin/bash
# Display a popup message to the user using AppleScript
osascript -e 'display dialog "A system update is ready to install. Please save your work, connect the charger, and click OK to restart." buttons {"OK"} default button "OK"'
# Check if the user clicked OK in the popup
if [ $? -eq 0 ]; then
# Restart the system
sudo reboot
# Restart the system with the charger connected
jamf policy -trigger restart_with_charger
echo "Dialog dismissed. Beginning install"
exit 0
fi
Need your expertise to automate the process.
Thank you