Home > Mac administration, Mac OS X, Scripting > Deploying NFS automounts for Macs via installer package

Deploying NFS automounts for Macs via installer package

As a follow-up to this post by Peter Bukowinski, you can add NFS automounts to Macs running 10.6.x – 10.8.x using an edited /etc/auto_master file and a new /etc/automounts directory (the /etc/automounts directory does not exist by default in OS X.) Once added to the Mac in question, your Macs can then communicate with your NFS server(s) by mounting and unmounting shares using autofs.

Because the needed changes are file-based, you can deploy the NFS automounts with an installer package. That allows your NFS automount setup to be deployed as part of building a new machine, by your system management tool, or even just by running the package installer on the machine itself. See below the jump for how to package this using Iceberg.

Prerequisites:

Iceberg

Building the pieces:

Take a look at Peter’s post to see how to configure the /etc/automaster file and create the automount maps in /etc/automounts. Once you’ve built and tested them, make sure the permissions on them are as follows:

/etc/automasterroot:wheel rw-r–r–

/etc/automountsroot:wheel drwxr-xr-x

All files inside /etc/automountsroot:wheel rw-r–r–

Building the package:

Set up a new Iceberg project. Since we’ll need to run this installer with root privileges, I recommend setting the project type to Darwin: Package. That will open the project with the installation privileges automatically set to root.

Screen Shot 2012-06-26 at 9.59.35 AM

In this case, I’m naming the project Company NFS Automounts Installer.

Screen Shot 2012-06-29 at 12.11.58 PM

In the Files section, add your /etc/automaster file and /etc/automounts directory to the etc directory, inside of the private directory.

Screen Shot 2012-06-29 at 12.07.38 PM

The last pieces are backing up the existing /etc/automaster (just in case) and telling the autofs process about the new mount files.

To back up the existing /etc/automaster, I’m using the following preflight script:


#!/bin/sh
FILE_DATE=`date +%Y%m%d`
 
#################################################################
##         BACK UP PREVIOUS /etc/auto_master FILE             ##
#################################################################
 
if [ -f /etc/auto_master ]; then
   sudo mv /etc/auto_master /etc/auto_master_backup-$FILE_DATE
fi

This script renames the existing /etc/auto_master file and tags it with the current date.

To tell autofs about the new mounts, I’m using the following postflight script:


#!/bin/sh

/usr/sbin/automount -vc 

This script runs automount -vc to have the autofs process on the Mac flush its caches and re-read the /etc/auto_master file.

Screen Shot 2012-06-29 at 12.09.20 PM

Last step, go ahead and build the package. (If you don’t know to build, check the Help menu for the Iceberg User Guide. The information you need is in Chapter 3 – Creating a package.)

Once the package has been built, test it by taking it to a test machine running 10.6.8 or higher that doesn’t have the automounts on it and install it.

  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: