3
# Copyright (C) 2004-2008 Tim Cutts <timc@chiark.greenend.org.uk>
4
# Copyright (C) 2001-2003 Philippe Troin <phil@fifi.org>
5
# Copyright (C) 1996-98 by Dominik Kubla, <kubla@Uni-Mainz.DE> and
6
# Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
11
# Required-Start: $portmap $remote_fs $syslog
12
# Required-Stop: $portmap $remote_fs $syslog
13
# Should-Start: ypbind nslcd
14
# Should-Stop: ypbind nslcd
15
# Default-Start: 2 3 4 5
17
# Short-Description: BSD automounter
18
# Description: Automount local and remote filesystems
21
PATH=/usr/sbin:/sbin:/usr/bin:/bin
25
CONF=/etc/default/am-utils
27
# If the package is removed, skip it.
28
test -x /usr/sbin/amd || exit 0
33
echo "$0: not configured yet (try running \"dpkg-reconfigure am-utils\")." 1>&2
38
if test "$AM_UTILS_USE_NIS" = true
40
map="$AM_UTILS_NIS_MASTER_MAP"
41
case "$AM_UTILS_NIS_MASTER_MAP_KEY_STYLE" in
43
key="$AM_UTILS_NIS_KEY"
44
AMDARGS="`ypmatch \"$key\" \"$map\"`"
47
AMDARGS="`ypcat \"$map\"`"
50
AMDARGS="`ypcat -k \"$map\"`"
53
AMDARGS="`sh -c \"$AM_UTILS_NIS_CUSTOM\"`"
56
echo "$0: bad key style"
62
echo "$0: cannot find master map" 1>&2
68
if [ "$AM_UTILS_MAP_NET" = true ]
70
AMDARGS="$AMDARGS /net /usr/share/am-utils/amd.net"
73
if [ "$AM_UTILS_MAP_HOME" = true ]
75
AMDARGS="$AMDARGS /home /etc/passwd"
78
AMDARGS="$AMDARGS $AM_UTILS_MAP_OTHERS"
81
if [ "$AM_UTILS_CLUSTERNAME" != "" ]; then
82
AMDARGS="-C \"$AM_UTILS_CLUSTERNAME\" $AMDARGS"
88
pid="`amq -p 2>/dev/null`"
89
if [ -n "$pid" ]; then
90
echo "Starting automounter: amd is already running" 1>&2
94
# If the hostname is not a FQHN, add the -d command line switch,
95
# so that hostnames in the maps are stripped correctly.
99
*) if test "$AM_UTILS_USE_NIS" = true; then
100
dnsdomainname=`dnsdomainname`
101
if [ "$dnsdomainname" ] ; then
102
dnsdomain="-d $dnsdomainname"
104
echo "$0: please setup your domainname" 1>&2
115
echo -n "Starting automounter: amd"
116
/usr/sbin/amd -F /etc/am-utils/amd.conf $dnsdomain $AMDARGS
121
# This function tries to kill an amd which hasn't exited nicely.
122
# This happens really easily, especially if using mount_type autofs
124
# Get the currently mounted filesystems
125
filesystems=`/bin/tempfile -s .amd`
126
if [ $? -ne 0 ]; then
130
amq | awk '$2 !~ "root" {print $1}' > $filesystems
137
if kill -s 0 $pid; then
142
# Attempt to forcibly unmount the remaining filesystems
144
tac $filesystems | while read fs; do
145
umount -l -f "$fs" || returncode=1
154
pid="`amq -p 2>/dev/null`"
155
if [ -z "$pid" ]; then
156
echo "Stopping automounter: amd not running" 1>&2
164
echo -n "Requesting amd unmount filesystems: "
165
amq | awk '{print $1}' | tac | xargs -r -n 1 amq -u
167
echo -n "Stopping automounter: amd "
169
# wait until amd has finished; this may take a little bit, and amd can't
170
# start while an old one is running
173
while [ $i -le $maxsecs ] && kill -s 0 $pid >/dev/null 2>&1; do
177
[ $i -eq 15 ] && echo -n " [will wait `expr $maxsecs - $i` secs more] "
179
if kill -s 0 $pid >/dev/null 2>&1
202
restart|force-reload)
208
# amd tests itself if its map files have changed, so nothing to do here
212
echo "Usage: /etc/init.d/amd {start|stop|restart|[force-]reload}"