File autofs.init of Package autofs
xxxxxxxxxx
1
#!/bin/bash
2
#
3
# Copyright (C) 2011 SUSE Linux Products GmbH, Nuernberg, Germany.
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
#
19
20
### BEGIN INIT INFO
21
# Provides: autofs
22
# Required-Start: $network $syslog $remote_fs
23
# Should-Start: $portmap ypbind keyserv ldap nfsserver network-remotefs
24
# Required-Stop: $network $syslog $remote_fs
25
# Should-Stop: $portmap ypbind keyserv ldap nfsserver network-remotefs
26
# Default-Start: 3 5
27
# Default-Stop:
28
# Short-Description: automatic mounting of filesystems
29
# Description: Start the autofs daemon for automatic mounting of filesystems.
30
### END INIT INFO
31
32
#
33
# Location of the automount daemon and the init directory
34
#
35
DAEMON=/usr/sbin/automount
36
prog=`basename $DAEMON`
37
MODULE="autofs4"
38
DEVICE="autofs"
39
confdir=/etc/sysconfig
40
PIDFILE=/var/run/automount.pid
41
42
test -x $DAEMON || exit 5
43
44
PATH=/sbin:/usr/sbin:/bin:/usr/bin
45
export PATH
46
47
. /etc/rc.status
48
49
#
50
# Load customized configuration settings
51
#
52
if [ -r $confdir/autofs ]; then
53
. $confdir/autofs
54
fi
55
56
function start() {
57
# Make sure autofs4 module is loaded
58
if ! grep -q autofs /proc/filesystems; then
59
# Try load the autofs4 module fail if we can't
60
modprobe -q $MODULE >/dev/null 2>&1
61
if [ $? -eq 1 ]; then
62
echo "Error: failed to load $MODULE module."
63
return 1
64
fi
65
fi
66
67
# Use the AutoFS misc device unless it is explicitly disabled
68
if [ -z "$USE_MISC_DEVICE" -o "x$USE_MISC_DEVICE" = "xyes" ]; then
69
if [ -e "/proc/misc" ]; then
70
if ! grep -q autofs /proc/misc; then
71
sleep 1
72
fi
73
MINOR=`awk "/$DEVICE/ {print \\$1}" /proc/misc`
74
if [ -n "$MINOR" -a ! -c "/dev/$DEVICE" ]; then
75
mknod -m 0600 /dev/$DEVICE c 10 $MINOR
76
fi
77
fi
78
if [ -x /sbin/restorecon -a -c /dev/$DEVICE ]; then
79
/sbin/restorecon /dev/$DEVICE
80
fi
81
else
82
if [ -c /dev/$DEVICE ]; then
83
rm /dev/$DEVICE
84
fi
85
fi
86
87
if [ "$LOCAL_OPTIONS" ]; then
88
AUTOFS_OPTIONS="-O $LOCAL_OPTIONS $AUTOFS_OPTIONS"
89
fi
90
/sbin/startproc -w $DAEMON -p $PIDFILE $AUTOFS_OPTIONS
91
92
return $?
93
}
94
95
function stop() {
96
# Send SIGTERM first and set a maximum wait time of 45 seconds
97
# before sending SIGKILL
98
/sbin/killproc -t 45 -p $PIDFILE $DAEMON
99
}
100
101
RETVAL=0
102
103
case "$1" in
104
start)
105
echo -n "Starting $prog "
106
# Check if already running
107
if ! /sbin/checkproc $DAEMON; then
108
start
109
fi
110
111
rc_status -v
112
;;
113
stop)
114
echo -n "Shutting down $prog "
115
stop
116
117
rc_status -v
118
;;
119
try-restart|condrestart)
120
## Do a restart only if the service was active before.
121
## Note: try-restart is now part of LSB (as of 1.9).
122
if test "$1" = "condrestart"; then
123
echo "${attn}Use try-restart ${done}(LSB)${attn}${norm}"
124
fi
125
$0 status
126
if test $? = 0; then
127
$0 restart
128
else
129
rc_reset # Not running is not a failure.
130
fi
131
# Remember status and be quiet
132
rc_status
133
;;
134
restart)
135
$0 stop
136
$0 start
137
138
rc_status
139
;;
140
force-reload|reload)
141
echo -n "Reload service $prog "
142
/sbin/killproc -HUP $DAEMON
143
144
rc_status -v
145
;;
146
status)
147
echo -n "Checking for service $prog "
148
/sbin/checkproc $DAEMON
149
# NOTE: rc_status knows that we called this init script with
150
# "status" option and adapts its messages accordingly.
151
rc_status -v
152
;;
153
*)
154
echo "Usage: $0 {start|stop|status|try-restart|restart|reload}"
155
exit 1
156
;;
157
esac
158
159
rc_exit
160