Skip to content

Commit

Permalink
Make OS agnostic
Browse files Browse the repository at this point in the history
Changed instances of “macOS Sierra” to $macOSname, which is specified
with $7 in the JSS.
  • Loading branch information
Patrick Gallagher committed Sep 21, 2017
1 parent daa03df commit 7e45c7b
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions macOSUpgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This script was designed to be used in a Self Service policy to ensure specific
# requirements have been met before proceeding with an inplace upgrade to macOS Sierra,
# requirements have been met before proceeding with an inplace upgrade of the macOS,
# as well as to address changes Apple has made to the ability to complete macOS upgrades
# silently.
#
Expand All @@ -47,7 +47,7 @@
# Written by: Joshua Roskos | Professional Services Engineer | Jamf
#
# Created On: January 5th, 2017
# Updated On: September 8th, 2017
# Updated On: September 16th, 2017
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Expand All @@ -59,13 +59,13 @@
userDialog=0

##Title to be used for userDialog (only applies to Utility Window)
title="macOS Sierra Upgrade"
title="$7 Upgrade"

##Heading to be used for userDialog
heading="Please wait as we prepare your computer for macOS Sierra..."
heading="Please wait as we prepare your computer for $macOSname..."

#Specify path to OS installer. Use Parameter 4 in the JSS, or specify here
#Example: /Applications/Install macOS Sierra.app
#Example: /Applications/Install macOS High Sierra.app
OSInstaller="$4"

##Version of OS. Use Parameter 5 in the JSS, or specify here.
Expand All @@ -77,17 +77,21 @@ version="$5"
#Example: download-sierra-install
download_trigger="$6"

#Title of OS
#Example: macOS High Sierra
macOSname="$7"

##Title to be used for userDialog
description="
This process will take approximately 5-10 minutes.
Once completed your computer will reboot and begin the upgrade."

#Description to be used prior to downloading Sierra
dldescription="We need to download macOS Sierra to your computer, this will \
#Description to be used prior to downloading the OS installer
dldescription="We need to download $macOSname to your computer, this will \
take several minutes."

##Icon to be used for userDialog
##Default is macOS Sierra Installer logo which is included in the staged installer package
##Default is macOS Installer logo which is included in the staged installer package
icon="$OSInstaller/Contents/Resources/InstallAssistant.icns"

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand Down Expand Up @@ -120,32 +124,32 @@ else
/bin/echo "Disk Check: ERROR - ${freeSpace%.*} Bytes Free Space Detected"
fi

##Check for existing Sierra installer
##Check for existing OS installer
if [ -e "$OSInstaller" ]; then
/bin/echo "$OSInstaller found, checking version."
OSVersion=`/usr/libexec/PlistBuddy -c 'Print :"System Image Info":version' "$OSInstaller/Contents/SharedSupport/InstallInfo.plist"`
/bin/echo "OSVersion is $OSVersion"
if [ $OSVersion = $version ]; then
downloadSierra="No"
downloadOS="No"
else
downloadSierra="Yes"
downloadOS="Yes"
##Delete old version.
/bin/echo "Installer found, but old. Deleting..."
/bin/rm -rf "$OSInstaller"
fi
else
downloadSierra="Yes"
downloadOS="Yes"
fi

##Download Sierra if needed
if [ $downloadSierra = "Yes" ]; then
##Download OS installer if needed
if [ $downloadOS = "Yes" ]; then
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper \
-windowType utility -title "$title" -alignHeading center -alignDescription left -description "$dldescription" \
-button1 Ok -defaultButton 1 -icon "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SidebarDownloadsFolder.icns" -iconSize 100
##Run policy to cache installer
/usr/local/jamf/bin/jamf policy -event $download_trigger
else
/bin/echo "macOS Sierra installer with $version was already present, continuing..."
/bin/echo "$macOSname installer with $version was already present, continuing..."
fi

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand Down Expand Up @@ -202,7 +206,7 @@ EOF
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

##Caffeinate
/usr/bin/caffeinate -dis &
/usr/bin/caffeinate -dis &
caffeinatePID=$(echo $!)

if [[ ${pwrStatus} == "OK" ]] && [[ ${spaceStatus} == "OK" ]]; then
Expand All @@ -228,8 +232,8 @@ else
/bin/rm -f /Library/LaunchDaemons/com.jamfps.cleanupOSInstall.plist

/bin/echo "Launching jamfHelper Dialog (Requirements Not Met)..."
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "$title" -icon "$icon" -heading "Requirements Not Met" -description "We were unable to prepare your computer for macOS Sierra. Please ensure you are connected to power and that you have at least 15GB of Free Space.
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "$title" -icon "$icon" -heading "Requirements Not Met" -description "We were unable to prepare your computer for $macOSname. Please ensure you are connected to power and that you have at least 15GB of Free Space.
If you continue to experience this issue, please contact the IT Support Center." -iconSize 100 -button1 "OK" -defaultButton 1

fi
Expand Down

0 comments on commit 7e45c7b

Please sign in to comment.