NFS Services Administrator's Guide

Configuring and Administering AutoFS
Using Executable Maps
Chapter 3 133
Using Executable Maps
An executable map is a map whose entries are generated dynamically by
a program or a script. AutoFS determines whether a map is executable
by checking whether the execute bit is set in its permissions string.
If a map is not executable, make sure its execute bit is not set. When the
AutoFS daemon locates a map whose execute bit is set, then instead of
opening the file and searching for an entry, the daemon executes the file
as a program and passes the key to be located within the map as an
argument. Executable AutoFS maps return a map entry on the standard
output. If they cannot supply a map entry for the key, they do not return
anything. You can list executable AutoFS maps in the master map or
include them in the local AutoFS map files.
For example, the following executable map, implemented as a shell
script, emulates the AutoFS built-in -hosts map for /net. It obtains a
list of exported file systems from an NFS server (its name given as the
key argument). It then formats the pathnames into a multiple-mount
map entry and sorts the list to order the mounts correctly into a
top-down hierarchy, as follows:
!/bin/sh /usr/sbin/showmount -e $1 | awk ‘NR > 1 \
{print $1“t””’$1’:”$1” “ }’ | sort