Created
November 17, 2011 21:13
-
-
Save rustymyers/1374544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Script credit: Jeremy Reichman <[email protected]> | |
# VolumeCheck Exit Statuses are calculated by subtracting 32 | |
# E.G. exit 48 matches 16, exit 50 matches 18 in the VolumeCheck.strings file | |
# Check for minimum Mac OS X major version on the volume | |
SCRIPT_PATH="$0" | |
VOLUME_PATH="$1" | |
echo "\$0 = $0" | |
echo "\$1 = $1" | |
if [ ! -e "$VOLUME_PATH/System/Library/CoreServices/SystemVersion.plist" ];then | |
echo "ERROR: This volume $VOLUME_PATH does not have OS X installed" | |
exit 50 | |
fi | |
# Get the version of Mac OS X on the target volume | |
VOLUME_VERSION=`/usr/bin/defaults read "$VOLUME_PATH/System/Library/CoreServices/SystemVersion" ProductVersion` | |
echo "Install volume has OS X $VOLUME_VERSION" | |
# Get the major version of Mac OS X from the full version string | |
# Corresponds to y in x.y.z | |
VOLUME_VERSION_MAJOR=`/bin/echo "$VOLUME_VERSION" | /usr/bin/cut -f 2 -d '.'` | |
VOLUME_VERSION_MINOR=`/bin/echo "$VOLUME_VERSION" | /usr/bin/cut -f 3 -d '.'` | |
echo "The install volume has the Major OS version: $VOLUME_VERSION_MAJOR" | |
echo "The install volume has the Minor OS version: $VOLUME_VERSION_MINOR" | |
# Set the minimum Mac OS X major and minor version required on the volume | |
MINIMUM_VERSION_MAJOR="7" | |
MINIMUM_VERSION_MINOR="2" | |
if [ "$VOLUME_VERSION_MAJOR" -ge "$MINIMUM_VERSION_MAJOR" ] && [ "$VOLUME_VERSION_MINOR" -ge "$MINIMUM_VERSION_MINOR" ] ; then | |
# Success | |
echo "Success: OS X $VOLUME_VERSION can be used" | |
exit 0 | |
else | |
# Corresponds to failure code "16" in VolumeCheck.strings | |
echo "ERROR: OS X $VOLUME_VERSION can NOT be used. Exiting..." | |
exit 48 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment