Home > Mac administration, Mac OS X, Mac OS X Server, Scripting > Automating the setup of OS X Server on El Capitan and Yosemite

Automating the setup of OS X Server on El Capitan and Yosemite

As part of the development of Mac OS X, Apple has also developed Mac OS X Server as a way to provide access to both additional services on OS X and the management tools needed to administrate those services. While Mac OS X and Mac OS X Server used to be separate operating systems, Apple combined them into one release re-branded as OS X and moved the server-specific services and management tools into an OS X Server application available from the Mac App Store.

As part of the move to an application-based installation process, there was a capability removed from OS X Server: The ability to automate its setup entirely from the command line.

In order to run the initial setup of OS X Server, the following manually-run process was needed:

1. Log into the Mac using an account with administrator rights
2. Launch /Applications/Server.app

Screen Shot 2015 10 29 at 8 57 24 AM

3. Agree to the OS X Server license

Screen Shot 2015 10 29 at 8 57 35 AM

4. Provide administrator authorization when prompted.

Screen Shot 2015 10 29 at 8 57 46 AM

5. The initial setup of OS X Server would then proceed.

Screen Shot 2015 10 29 at 8 58 20 AM

 

For Mac sysadmins who needed to set up multiple instances of OS X Server, having this manual step involved slowed the setup process down considerably. To find out why this part needed to run manually, while at WWDC 2015 I asked the relevant Apple engineer why this was the case. The response was that the OS X Server license needed to be agreed to, to which I mentioned that Xcode had a similar requirement but that there was a way to agree to the license from the command line. The Apple engineer in question took that feedback and said it was a valid point.

At this point, the story skips forward to Brad Chapman discovering a new and undocumented way to agree to the license from the command line in OS X Server 5.0.x. Charles Edge built on that discovery and created an expect script to handle agreeing to the license and providing admin authorization. Charles’s method incorporated the use of an existing admin user’s username and password in the script, so in turn I’ve built on Charles’s work to create a completely automated setup script which does the following:

  1. Create a temporary user with a randomly generated password
  2. Give the temporary user admin privileges
  3. Run the initial setup and configuration of OS X Server’s services.
  4. Delete the temporary user

As part of the initial setup process:

  • Agree to the license
  • Authorize the setup process using the temporary user’s username and password

For more details, see below the jump.

This script is designed to automate the setup of OS X Server 5.0.3 and later by authorizing and using the server tool within /Applications/Server.app to run the initial setup and configuration of OS X Server’s services.

When launched, the script will check for the existence of the server setup tool. If the server setup tool is not located where the script expects it to be, the script will exit.

If the server setup tool is located in the expected location, the script will proceed with the following previously-mentioned actions:

  1. Create a temporary user with a randomly generated password
  2. Give the temporary user admin privileges
  3. Run the initial setup and configuration of OS X Server’s services.
  4. Delete the temporary user

As part of the initial setup process:

  • Agree to the license
  • Authorize the setup process using the temporary user’s username and password

 

 

I’ve tested this script with OS X Server 5.0.3 on both OS X 10.10.5 and OS X 10.11.1. In both cases, the script was able to run the initial setup and configuration of OS X Server’s services.

Screen Shot 2015 10 29 at 8 01 25 AM

 

Screen Shot 2015 10 29 at 7 44 15 AM

I’ve also verified that the script runs properly while the Mac is sitting at the login window. I tested this by creating a firstboot package with the Server.app installer package and a payload-free package containing this script. When the firstboot process ran, Server.app was installed, then the script ran the initial setup and configuration of OS X Server’s services.

Screen Shot 2015 10 29 at 7 54 03 AM

The script and its associated payload-free package are available on Github at the following address:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/setup_osx_server_dot_app

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: