Quantcast
Channel: rtrouton – Der Flounder
Viewing all articles
Browse latest Browse all 764

First Boot Package Install Revisited

$
0
0

As covered previously, Greg Neagle’s createOSXinstallPkg is a useful tool for installing or upgrading Mac OS X in a variety of situations. One of the nicer features is that you can edit the OS X installer to install additional packages.

However, the limitations of the OS X install environment mean that there are a number of installers that won’t install correctly. In particular, packages that rely on pre- or postflight scripts to perform important tasks may fail to run properly in the OS X install environment.

To help work around this limitation, I developed First Boot Package Install.pkg, an installer package that enables other packages to be installed at first boot. It’s designed for use with createOSXinstallPkg with the goal of allowing installer packages that can’t run in the OS X Install environment to be incorporated into a createOSXinstallPkg-using deployment workflow.

The first version of First Boot Package Install.pkg had some limitations though, with the biggest one probably being that you couldn’t tell what it was doing when it was running. Instead, all that was displayed was the gray Apple loading screen.

AppleBootScreen

I tried various approaches of booting into verbose mode and writing log entries to the console, but none of the approaches were good enough to introduce into production. Fortunately, Per Olofsson developed exactly what I was looking for with his LoginLog tool.

login_log

Using LoginLog.app as a way to display updates to the user, I’ve been able to update First Boot Package Install.pkg with improved visual feedback. I’ve also now incorporated another piece of feedback I’ve received, which is to add a network check. This new check makes sure that the Mac has a network address other than 127.0.0.1 or 0.0.0.0 before it proceeds to install any packages. For more details, see below the jump.

To use First Boot Package Install.pkg‘s pre-built installer package:

1. Download the First_Boot_Package_Install.zip file from the installer directory on my GitHub repo:

https://github.com/rtrouton/First-Boot-Package-Install

Screen Shot 2013-05-12 at 5.45.21 PM

 

2. Once downloaded and unzipped, right-click on the package and choose Show Package Contents.

Screen Shot 2013-05-12 at 5.46.37 PM

 

3. Go to Contents: Resources: fb_installers

 

Screen Shot 2013-05-12 at 5.47.22 PM

4. Add one installer package to each numbered directory. The number of the directory indicates the install order, with 00 being the first.

Screen Shot 2013-05-12 at 5.47.42 PM

Screen Shot 2013-05-12 at 5.48.01 PM

As needed, more numbered directories may be added to the fb_installers directory. For numbers 9 or less, make sure to label the directory with a leading zero (For example, 06).

NOTE: createOSXinstallPkg has an upper limit of 350 MBs of available space for added packages. This is sufficient space for basic configuration, payload-free or bootstrapping packages, but it’s not a good idea to add Microsoft Office or similar large installers to this installer.

5. Once finished adding installers to the numbered directories, First Boot Package Install.pkg is ready to be added to a deployment workflow.

 

What’s supposed to happen

The installer package is designed to install packages in the desired order, then remove all traces. All actions occur while access to the OS X login window is blocked.

 

What the end-user sees

After the OS X install completes, it restarts and the LoginLog window appears over the login window. The LoginLog window will then display progress updates for as long as it takes for the packages to install. Once the install completes, the Mac automatically restarts and boots up normally to the login window.

Screen Shot 2014-04-17 at 5.23.37 PM

How First Boot Package Install.pkg works

 

When First Boot Package Install.pkg is installed via createOSXinstallPkg, it does the following:

 

1. Copies First Boot Package Install.pkg/Contents/Resources/fb_installers to /Users/Shared/fb_installers

2. The following files are installed:

 

/Library/LaunchDaemons/com.company.firstbootpackageinstall.plist

/Library/LaunchAgents/com.company.LoginLog.plist

/Library/PrivilegedHelperTools/LoginLog.app

/var/firstbootpackageinstall.sh

 

After OS X is installed by createOSXinstallPkg and reboots, the following process occurs:

 

1. The com.company.firstbootpackageinstall LaunchDaemon triggers /var/firstbootpackageinstall.sh to run.

2. /var/firstbootpackageinstall.sh stops the login window from loading and checks for the existence of /Users/Shared/fb_installers.

 

If /Users/Shared/fb_installers is not found, the following actions take place:

 

A. The login window is allowed to load.

B. The following files are deleted by /var/firstbootpackageinstall.sh:

 

/Library/LaunchDaemons/com.company.firstbootpackageinstall.plist

/Library/LaunchAgents/com.company.LoginLog.plist

/Library/PrivilegedHelperTools/LoginLog.app

 

C. /var/firstbootpackageinstall.sh checks for an existing /var/log/firstbootpackageinstall.log logfile and renames the existing logfile to include the current date and time.

D. /var/firstbootpackageinstall.sh deletes itself.

 

If /Users/Shared/fb_installers is found, the following actions take place:

 

A. If /Users/Shared/fb_installers exists, the login window is allowed to load

B. A log is created to record the actions taken by /var/firstbootpackageinstall.sh. By default, this logfile named firstbootpackageinstall.log and is stored in /var/log.

C. /Library/LaunchAgents/com.company.LoginLog.plist loads and launches /Library/PrivilegedHelperTools/LoginLog.app

D. /Library/PrivilegedHelperTools/LoginLog.app opens a window over the Mac’s login window and displays the logfile

E. A network check is run, to ensure that the Mac has a network address other than 127.0.0.1 or 0.0.0.0 (which are otherwise known as loopback addresses.) This network check will check every five seconds for the next 60 minutes for a working network connection.

 

Network check fails – If only loopback addresses are detected within 60 minutes, the script will take the following actions:

  • Log a failure message to the log
  • Delete /Users/Shared/fb_installers
  • Restart
  • On restart, the “if /Users/Shared/fb_installers is not found” actions occur

Network check succeeds – If a non-loopback address is detected, the script will take the following actions:

  • Log a success message to the log
  • Proceed with the rest of the script

 

F. The packages are installed, using the numbered subdirectories to set the order of installation

G. Once installation has finished, /Users/Shared/fb_installers is deleted

H. The Mac is restarted

I. On restart, the “if /Users/Shared/fb_installers is not found” actions occur.

 

All First Boot Package Install.pkg components and scripts are available at my GitHub repo:

https://github.com/rtrouton/First-Boot-Package-Install

The Iceberg project files are also available via the link above if you want to build a customized First Boot Package Install.pkg for your own environment.



Viewing all articles
Browse latest Browse all 764

Trending Articles