diff --git a/README.md b/README.md index 6a36c26..475f469 100644 --- a/README.md +++ b/README.md @@ -6,32 +6,28 @@ This script was designed to be used in a Self Service policy to ensure specific Requirements: * Jamf Pro -* Latest Version of macOS Sierra Installer - - -Written by: Joshua Roskos | Professional Services Engineer | Jamf - -Created On: January 5th, 2017 | Updated On: April 5th, 2017 +* macOS Sierra 10.12.4 or later +* Look over the USER VARIABLES and configure as needed. ___ **Why is this needed?** -Starting with macOS Sierra, Apple has begun enforcing the way in which you can silently call for the OS upgrade process to happen in the background. Because of this change, many common ways that have been used and worked in the past no longer do. This script was created to adhear to Apple's requirements of the startosinstall binary. +Starting with macOS Sierra, Apple has begun enforcing the way in which you can silently call for the OS upgrade process to happen in the background. Because of this change, many common ways that have been used and worked in the past no longer do. This script was created to adhear to Apple's requirements of the startosinstall binary. -This script has been tested on OS X 10.11.5 upgrading to macOS Sierra 10.12.2 without issue. If the machine is FileVault encrypted, it will complete the authenticated restart to the OS Installer and automatically perform the upgrade with no user interaction. Upon completion the machine will again reboot to the macOS Sierra Login Window. +This script has been tested on OS X 10.11.5 upgrading to macOS Sierra 10.12.5 without issue. If the machine is FileVault encrypted, it will complete the authenticated restart to the OS Installer and automatically perform the upgrade with no user interaction. Upon completion the machine will again reboot to the macOS Sierra Login Window. +* Note: Authenticated login is broken with 10.12.4+. See https://github.com/kc9wwh/macOSUpgrade/issues/13 -**Configuring the Script** -When you open the script you will find some user variables defined on lines 57-73. Here you can specify the message that is displayed to the end user while the script is running and preparing the computer to upgrade to macOS Sierra. +**Configuring the Script** -Also, if you decide not to stage the macOS Sierra Installer in /Users/Shared/, you will need to update the paths on lines 73, 114 and 173. +When you open the script you will find some user variables defined on lines 59-91. Here you can specify the message that is displayed to the end user while the script is running and preparing the computer to upgrade to macOS Sierra, as well as the varibles used to determine the version and path for the macOS Installer. Also, don't forget to setup a policy with a custom trigger specified as defined in the user variables. **Stagging macOS Sierra Installer** -In order for this script to work, you will have to have a copy of the macOS Sierra Installer that is available from the Mac App Store located in /Users/Shared/. One of the easiest ways to achieve this is to package the installer with composer as seen below and deploy the package via Jamf Pro. +In order for this script to work, you will have to have a copy of the macOS Sierra Installer that is available from the Mac App Store located in /Applications. One of the easiest ways to achieve this is to package the installer with composer as seen below and deploy the package via Jamf Pro. ![alt text](/imgs/composer.png) diff --git a/imgs/composer.png b/imgs/composer.png index db2b4ed..0583b16 100644 Binary files a/imgs/composer.png and b/imgs/composer.png differ diff --git a/macOS10.12Upgrade.sh b/macOS10.12Upgrade.sh index 630d098..e3f54a0 100644 --- a/macOS10.12Upgrade.sh +++ b/macOS10.12Upgrade.sh @@ -1,6 +1,6 @@ #!/bin/bash -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Copyright (c) 2017 Jamf. All rights reserved. # @@ -12,7 +12,7 @@ # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the Jamf nor the names of its contributors may be -# used to endorse or promote products derived from this software without +# used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY @@ -26,18 +26,19 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # 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, -# as well as to address changes Apple has made to the ability to complete macOS upgrades -# silently. +# requirements have been met before proceeding with an inplace upgrade to macOS Sierra, +# as well as to address changes Apple has made to the ability to complete macOS upgrades +# silently. # # REQUIREMENTS: # - Jamf Pro -# - Latest Version of macOS Sierra Installer +# - Latest Version of the macOS Installer (must be 10.12.4 or later) +# - Look over the USER VARIABLES and configure as needed. # # # For more information, visit https://github.com/kc9wwh/macOSUpgrade @@ -46,13 +47,13 @@ # Written by: Joshua Roskos | Professional Services Engineer | Jamf # # Created On: January 5th, 2017 -# Updated On: April 5th, 2017 -# -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Updated On: May 25th, 2017 +# +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # USER VARIABLES -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ##Enter 0 for Full Screen, 1 for Utility window (screenshots available on GitHub) userDialog=0 @@ -63,18 +64,35 @@ title="macOS Sierra Upgrade" ##Heading to be used for userDialog heading="Please wait as we prepare your computer for macOS Sierra..." +#Specify path to OS installer. Use Parameter 4 in the JSS, or specify here +#Example: /Applications/Install macOS Sierra.app +OSInstaller="$4" + +##Version of OS. Use Parameter 5 in the JSS, or specify here. +#Example: 10.12.5 +version="$5" + +#Trigger used for download. Use Parameter 6 in the JSS, or specify here. +#This should match a custom trigger for a policy that contains an installer +#Example: download-sierra-install +download_trigger="$6" + ##Title to be used for userDialog description=" -This process will take approximately 5-10 minutes. +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 \ +take several minutes." + ##Icon to be used for userDialog ##Default is macOS Sierra Installer logo which is included in the staged installer package -icon=/Users/Shared/Install\ macOS\ Sierra.app/Contents/Resources/InstallAssistant.icns +icon="$OSInstaller/Contents/Resources/InstallAssistant.icns" -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # SYSTEM CHECKS -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ##Check if device is on battery or ac power pwrAdapter=$( /usr/bin/pmset -g ps ) @@ -102,16 +120,44 @@ else /bin/echo "Disk Check: ERROR - ${freeSpace%.*}GB Free Space Detected" fi -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +##Check for existing Sierra 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" + else + downloadSierra="Yes" + ##Delete old version. + /bin/echo "Installer found, but old. Deleting..." + /bin/rm -rf "$OSInstaller" + fi +else + downloadSierra="Yes" +fi + +##Download Sierra if needed +if [ $downloadSierra = "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 "$icon" -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..." +fi + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # CREATE FIRST BOOT SCRIPT -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /bin/mkdir /usr/local/jamfps /bin/echo "#!/bin/bash ## First Run Script to remove the installer. ## Clean up files -/bin/rm -fdr /Users/Shared/Install\ macOS\ Sierra.app +/bin/rm -fdr "$OSInstaller" /bin/sleep 2 ## Update Device Inventory /usr/local/jamf/bin/jamf recon @@ -124,18 +170,18 @@ exit 0" > /usr/local/jamfps/finishOSInstall.sh /usr/sbin/chown root:admin /usr/local/jamfps/finishOSInstall.sh /bin/chmod 755 /usr/local/jamfps/finishOSInstall.sh -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # LAUNCH DAEMON -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # cat << EOF > /Library/LaunchDaemons/com.jamfps.cleanupOSInstall.plist - - - + + + - Label - com.jamfps.cleanupOSInstall - ProgramArguments + Label + com.jamfps.cleanupOSInstall + ProgramArguments /bin/bash -c @@ -143,7 +189,7 @@ cat << EOF > /Library/LaunchDaemons/com.jamfps.cleanupOSInstall.plist RunAtLoad - + EOF @@ -151,9 +197,9 @@ EOF /usr/sbin/chown root:wheel /Library/LaunchDaemons/com.jamfps.cleanupOSInstall.plist /bin/chmod 644 /Library/LaunchDaemons/com.jamfps.cleanupOSInstall.plist -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # APPLICATION -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # if [[ ${pwrStatus} == "OK" ]] && [[ ${spaceStatus} == "OK" ]]; then ##Launch jamfHelper @@ -170,13 +216,18 @@ if [[ ${pwrStatus} == "OK" ]] && [[ ${spaceStatus} == "OK" ]]; then ##Begin Upgrade /bin/echo "Launching startosinstall..." - /Users/Shared/Install\ macOS\ Sierra.app/Contents/Resources/startosinstall --applicationpath /Users/Shared/Install\ macOS\ Sierra.app --nointeraction --pidtosignal $jamfHelperPID & + "$OSInstaller/Contents/Resources/startosinstall" --applicationpath "$OSInstaller" --nointeraction --pidtosignal $jamfHelperPID & /bin/sleep 3 else + ## Remove Script + /bin/rm -f /usr/local/jamfps/finishOSInstall.sh + /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 macOS Sierra. 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 -exit 0 \ No newline at end of file +exit 0