Updates

Automating macOS and Package installation from the Recovery Partition

With the death of netboot and imaging, there is a need for automated refreshing of the macOS and initial package installation. Apple is moving towards using DEP and MDM, but that is not applicable for all scenarios, and tools such a bootstrappr and installr have come up to fill a need.

These command line tools run from the Recovery partition, so you can take a new Mac out of the box, boot to recovery, and do initial package installation (and possibly OS installation). This is awesome, but one of the nice things about netboot is that you could hold down the “n” key, select a workflow, and walk away knowing the machine would be refreshed. The recovery partition requires a few commands that need to be run to kick of the process, and potentially files on an external flash drive. Thanks for an amazing session by Rob Roy at PSUMacAdmins in 2018, I learned about using an Arduino HID project to send keyboard commands to a Mac over the USB port. We talked about using an Arduino to put the Mac in Recovery mode, open terminal and then run commands all automatically. So I set out to do to that, and it works great.

End Result:

  1. Unbox a Mac and boot to OS selector screen by holding option key
  2. Insert Arduino in USB port
  3. There is no step 3

The Arduino holds done “command-r” for about 1 minute to boot into recovery mode, then waiting for 1 more minute and then uses keyboard navigation to open terminal. Once terminal is opened, wifi is configured using networksetup. A shell screen is download from a webserver and run in bash. This way you can change the install scripts without having to change the Arduino. Here is how it looks during boot up:

Here it the Arduino sketchbook:

My setup.sh simply runs bootstrappr and has a single package to install in the DMG. Here is the script:

#!/bin/bash

echo It Worked

hdiutil mount http://tcs-script.s3.amazonaws.com/bootstrap.dmg
bash -c /Volumes/bootstrap/run

I have been thinking about create a bunch of these and selling them as USB sticks that could be configured with a Mac App, but not sure if anyone would care. Ping me on @tperfitt on twitter and let me know if it is something you would be interested in purchasing. It would basically be a thumb drive with a USB plug. It could also communicate with macOS so that you leave the device plugged in and send it command to go into recovery mode. At next reboot, the machine could be restarted to recovery and macOS restored.