Skip to main content
Question

Script to check OS version and to install necessary updates for Safari


Forum|alt.badge.img+1

Hello, Jamf community. I am trying to create a script which I can deploy via Jamf to a number of clients. The script should check the OS version and push the installation of Security Update for Safari 13.1.1. Unfortunately it returns a error " text.txt: line 15: syntax error: unexpected end of file" and i am not able to understand why is this happening.
Here is the script:

!/bin/bash

sw_vers

if [[ "$ProductVersion" == "10.13.6" ]]; then
softwareupdate -i 'Safari13.1.1HighSierraAuto-13.1.1'
elif [[ "$ProductVersion" == "10.14.6" ]]; then softwareupdate -i 'Safari13.1.1MojaveAuto-13.1.1'

sleep 1

exit 0

4 replies

Chris_Hafner
Forum|alt.badge.img+23
  • Jamf Heroes
  • 1718 replies
  • June 10, 2020

I am not the expert here... but don't you need another else statement to cover all other conditions?


Forum|alt.badge.img+6
  • Contributor
  • 45 replies
  • June 10, 2020

we used softwareupdate to check and install patches on all of our devices.


Mauricio11
Forum|alt.badge.img+11
  • Valued Contributor
  • 173 replies
  • June 11, 2020

Why not use smart groups to scope the macOS versions you want to target and apply that to the policy?


Forum|alt.badge.img+3
  • New Contributor
  • 4 replies
  • June 11, 2020

Add "fi" after "elif" and "#" before anything on first line. Should work then.

#!/bin/bash
sw_vers

if [[ "$ProductVersion" == "10.13.6" ]]; then
softwareupdate -i 'Safari13.1.1HighSierraAuto-13.1.1'
elif [[ "$ProductVersion" == "10.14.6" ]]; then softwareupdate -i 'Safari13.1.1MojaveAuto-13.1.1'
fi
sleep 1

exit 0

Also can't find any variable defined, so I guess this script below is something you're looking for -

#!/bin/bash
ProductVersion=$(sw_vers | grep "ProductVersion" | awk '{ print $2; }')
​
if [[ "$ProductVersion" == "10.13.6" ]]; then
softwareupdate -i 'Safari13.1.1HighSierraAuto-13.1.1'
elif [[ "$ProductVersion" == "10.14.6" ]]; then softwareupdate -i 'Safari13.1.1MojaveAuto-13.1.1'
fi
sleep 1exit 0

Also it would be good to add "else" to get some output as well if none of defined OS versions doesn't match in if statement, e.g. -

#!/bin/bash
ProductVersion=$(sw_vers | grep "ProductVersion" | awk '{ print $2; }')
​
if [[ "$ProductVersion" == "10.13.6" ]]; then
softwareupdate -i 'Safari13.1.1HighSierraAuto-13.1.1'
elif [[ "$ProductVersion" == "10.14.6" ]]; then softwareupdate -i 'Safari13.1.1MojaveAuto-13.1.1'
else
echo "OS version didn't match"
fi
sleep 1exit 0

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings