Skip to content

Instantly share code, notes, and snippets.

@taniguti
Last active May 13, 2018 02:34
Show Gist options
  • Save taniguti/5d2b065d00c114da2020ac6b6fc5af0d to your computer and use it in GitHub Desktop.
Save taniguti/5d2b065d00c114da2020ac6b6fc5af0d to your computer and use it in GitHub Desktop.
grep -o 'OS X [0-9]\+.[0-9]\+' won't work for macOS 10.12 or later.
--- a/postinstall 2018-05-13 10:16:39.000000000 +0900
+++ b/postinstall 2018-05-13 11:33:10.000000000 +0900
@@ -1,14 +1,12 @@
#!/bin/sh
####################################################
-## Use the legacy binary if running on < 10.7
+## Use the legacy binary if running on < 10.9
####################################################
-os_version=$(system_profiler SPSoftwareDataType -xml | grep -A 2 'os_version</key>' | grep -o 'OS X [0-9]\+.[0-9]\+' | grep -o '[0-9]\+.[0-9]\+')
-major_version=$(echo $os_version | grep -o '[0-9]\+\.' | grep -o '[0-9]\+')
-minor_version=$(echo $os_version | grep -o '\.[0-9]\+' | grep -o '[0-9]\+')
+minor_version=$(sw_vers -productVersion | awk -F. '{print $2}')
/usr/bin/tar -xf /private/tmp/JAMFQuickAdd/Binaries.tar.gz -C /private/tmp/JAMFQuickAdd
/bin/mkdir -p /usr/local/bin
-if [ $major_version -lt 10 ] || [ $major_version -eq 10 -a $minor_version -lt 9 ];then
+if [ $minor_version -lt 9 ];then
jamfCLIPath=/usr/sbin/jamf
/bin/rm /private/tmp/JAMFQuickAdd/Binaries/jamf
/bin/mv /private/tmp/JAMFQuickAdd/Binaries/jamf2 $jamfCLIPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment