Using startosinstall to install a macOS upgrade with Munki

Update: The instructions below will be obsolete once Munki 3 is released. More details on the Munki 3 implementation can be found on the Munki wiki.

createOSXinstallPkg is a great project for making an Apple macOS installer into a .pkg you can deploy with Munki.

Apple did some things to break that process for 10.12.4. People are in the process of finding workarounds for it.

One option is to use the built-in startosinstall tool that comes with the installer bundle.

If you import the bundle into Munki, you'll want to have both a preinstall_script and a postinstall_script.

The preinstall_script checks to make sure there aren't other updates pending, since startosinstall will run its own reboot independent of Munki. The pending updates should be 1 (it's the only 1) or 0 (it was part of a set of updates that did complete and then the pending updates cleared, and you're trying again):

#!/bin/bash

# Make sure there is only one pending update (this one)
pending_count=$(defaults read /Library/Preferences/ManagedInstalls PendingUpdateCount)

# If it's 1 or 0, we're good to go
if [ "$pending_count" == 1 ] || [ "$pending_count" == 0 ]; then

exit 0

else

# Otherwise, abort the installation
exit 1

fi
The postinstall_script does the actual install:
#!/bin/bash

sudo "/Applications/Install macOS Sierra.app/Contents/Resources/startosinstall" --applicationpath "/Applications/Install macOS Sierra.app" --agreetolicense --nointeraction
Just as you would with a normal OS upgrade item, you want the installs array to reflect the OS version (not the presence of the installer bundle in the /Applications folder), and you want to mark this as an Apple item. (Check the Munki wiki for more details about those two things.)

P.S. There is now a recommendation on the createOSXinstallPkg README to upgrade using 10.12.3 or investigate using startosinstall.

P.P.S It's possible, instead of my funky workaround with the preinstall_script, that you could use the --pidtosignal option instead with Munki. Here's an example using JAMF.

P.P.P.S. Looks as if Greg Neagle has started working on integrating startosinstall into Munki "natively"—yes!

Upgrading to Yosemite using Managed Software Center (Munki)

If you're running an older version of OS X (e.g., Mavericks or Mountain Lion) and the tech department is telling you to use Managed Software Center to upgrade to Yosemite, this is how you do it.

Prerequisites

  1. Set aside time for this upgrade. Keep in mind the entire process can take between 45-90 minutes. You will not be able to use your Mac for other things while this upgrade is happening.
  2. Back up important files. In theory, the upgrade shouldn't affect your data but make sure your CrashPlan has been running and completing backups before you start this upgrade process.
  3. Plug your computer in. If you have a laptop, even though your laptop battery will likely last longer than even two or three hours, you don't want to risk your battery running out before the upgrade process is complete.
  4. Do the upgrade at school. The network bandwidth at school is better than what you have at home, so the download of the update won't take as long as school, and the Managed Software Center will not work when you are at home. More importantly, Yosemite is no longer available in the Mac App Store.
  5. Don't be afraid to ask for help. The upgrade process, as outlined below, is fairly straightforward, but if you're at all nervous about it, feel free to drop by the tech office, and we'll be more than happy to walk you through it.

yosemiteupgrade01
First, go to your /Applications folder. Then find and open Managed Software Center.

yosemiteupgrade02
Click on the Software tab and then scroll down until you find Install OS X Yosemite.

Click the Install button underneath it.

yosemiteupgrade03
Once you click the Install button, you'll see it notify you that the update is Downloading.

yosemiteupgrade04
Click the Updates tab to check on the progress of the download. The download is several gigabytes in size (i.e., quite large), so the download may take a while (even with the school's Internet connection).

yosemiteupgrade06
Once the download finishes, Managed Software Center will notify you that a restart is required. If you haven't already quit out of your other programs and saved any unsaved files, do so now.

Then, click Log out and update.

At this point in the process, it'd be a great time to eat lunch, go for a walk, meet with a student, or engage in any activity that doesn't involve needing your Mac.

yosemiteupgrade07
In case your idea of a good time is eating some microwave popcorn while you watch a Mac upgrade to the latest operating system, you'll likely see something like this appear on your screen.

yosemiteupgrade08
As you're munching down that popcorn, you may also see a screen that looks like this.

yosemiteupgrade09
And then you may see something like this. Even if it says "23 minutes," it may take up to 30 or 40 minutes. If you see "less than one minute remaining," it will likely be another 5 minutes left.

Just let it all run. A few more screens may flash by quickly. You won't need to do anything again until you get to a login screen. As always, if you get stuck or have questions, ask the folks in the tech office. We're more than happy to help.

Read only if you're a Munki admin

Even though El Capitan is now the official latest release, not Yosemite, the same principle should apply. If you're using Munki, you can use createOSXinstallPkg to make a Munki-able package from an Install OS X Yosemite.app package.

Once you have the Install OS X Yosemite.app downloaded to your /Applications folder and you have the createOSXinstallPkg-master.zip downloaded and extracted to your ~/Downloads folder, just run these commands:

cd ~/Downloads/createOSXinstallPkg-master
sudo ./createOSXinstallPkg --source /Applications/Install\ OS\ X\ Yosemite.app
and you'll end up with a nice Munki-able InstallOSX_10.10.5_14F27.pkg you can run munkiimport on and distribute to your users.