Posted on 08-15-2019 07:56 AM
Hello everyone,
I downloaded the script below and uploaded to JAMF Pro. When I run sudo jamf policy, I get a message back saying parameters 4 is missing. I don't know what I need to put there. Does anyone know? Also, being that I'm running Mojave 10.14.5, do I need to make a change on the script?
formatInput() { # Arrays that contain multiple variations of each item to ensure it gets formatted correctly RemoteDesktop=("rdp" "RDP" "remote desktop" "remote" "Remote" "Remote Desktop") iTunes=("itunes" "Itunes" "iTunes") macOS=("macos" "MacOS" "MACOS" "osx" "OSX") appStore=("app" "appstore" "App Store" "App store" "Appstore") security=("Security" "security" "security update" "Security Update") safari=("safari" "Safari")
# Formats the item name
if [[ "${iTunes[@]}" =~ "$itemUpdate" ]]; then
itemUpdate="iTunes"
elif [[ "${macOS[@]}" =~ "$itemUpdate" ]]; then
itemUpdate="macOS"
elif [[ "${RemoteDesktop[@]}" =~ "$itemUpdate" ]]; then
itemUpdate="RemoteDesktop"
elif [[ "${appStore[@]}" =~ "$itemUpdate" ]]; then
itemUpdate="App Store"
elif [[ "${security[@]}" =~ "$itemUpdate" ]]; then
itemUpdate="Security"
elif [[ "${safari[@]}" =~ "$itemUpdate" ]]; then
itemUpdate="Safari"
fi
}
updateList=()
if [[ ! -z "$4" ]]; then
itemUpdate="$4"
formatInput
updateList+=($itemUpdate)
else
echo "Parameter 4 is missing and is required."
exit 0
fi
if [[ ! -z "$5" ]]; then
itemUpdate="$5"
formatInput
updateList+=($itemUpdate)
else
echo "Parameter 5 is empty."
fi
if [[ ! -z "$6" ]]; then
itemUpdate="$6"
formatInput
updateList+=($itemUpdate)
else
echo "Parameter 6 is empty."
fi
if [[ ! -z "$7" ]]; then
itemUpdate="$7"
formatInput
updateList+=($itemUpdate)
else
echo "Parameter 7 is empty."
fi
updateCount="0"
for i in "${updateList[@]}"; do
echo "Searching for an update for ${updateList[$updateCount]} .."
# Variable that searches for available software updates for the item
searchUpdate=$(/usr/sbin/softwareupdate -l | grep -w "" | sed 's/^[[:space:]]//' | grep -y "${updateList[$updateCount]}" | sed 's/[]//g' | sed 's/^[[:space:]]//')
# Checks to see if there is an update available, if not it will return No Update Found and continue to the next item
if [[ -z "$searchUpdate" ]]; then
echo "No update found for ${updateList[$updateCount]} .."
else
echo "Update found for ${updateList[$updateCount]} .. Starting download."
installList+=("$searchUpdate")
/usr/sbin/softwareupdate -d "$searchUpdate"
echo "Download of "${updateList[$updateCount]}" finished"
fi
let updateCount+=1
done
installCount="0"
for i in "${installList[@]}"; do
echo "Installing the update for "${installList[$installCount]}" ..."
/usr/sbin/softwareupdate -i "${installList[$installCount]}"
echo "Installation of "${installList[$installCount]}" is complete."
let installCount+=1
done
sudo /usr/local/bin/jamf recon
echo "The following updates have been installed:"
echo "${installList[@]}"
if [[ "${installList[@]}" =~ Security ]]; then
echo "A restart is required for this update"
restartRequired="yes"
else
restartRequired="no"
fi
if [[ "$restartRequired" == "yes" ]]; then
echo "Restart is Required"
# Edit the line below to match the policy in the Jamf Pro server
sudo /usr/local/bin/jamf policy -event securityReboot
else
echo "No Restart Required"
fi
Posted on 11-21-2019 10:44 AM
you need to set up as parameter 4 the name of the update you what to make.
for mac os
macOS - macOS Software Update (Restart Required)
Posted on 12-18-2019 12:42 AM
For Delayed authenticated reboot how to create a policy with a custom trigger Set to Ongoing
When i run above mention script at the end i got message-No policies were found for the "securityReboot" trigger.
Posted on 01-22-2020 12:31 AM
Thanks for the update,script is now working with mac os 10.13,10.14,However it do not works with mac os 10.15 any help on this?
Posted on 10-09-2020 09:22 AM
The script mentions " This section currently only looks for the "security" label" . Is there anything else on the body of the script I need to update if I want it to look for macOS - macOS Software Update (Restart Required) on Parameter 4 instead of Security?
Posted on 10-13-2020 11:37 AM
Still having very hit-or-miss results on 10.15... anyone have any pointers?