Subversion Repositories configs

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 - 1
#!/bin/bash
2
#
3
# rc file for automount using a Sun-style "master map".
4
#
5
# chkconfig: 345 28 72
6
# processname: /usr/sbin/automount
7
# config: /etc/auto.master
8
# description: Automounts filesystems on demand
9
#
10
### BEGIN INIT INFO
57 - 11
# Provides: autofs
12
# Required-Start: $network ypbind
13
# Required-Stop: $network ypbind
3 - 14
# Default-Start: 3 4 5
15
# Default-Stop: 0 1 2 6
16
# Short-Description: Automounts filesystems on demand
17
# Description: Automounts filesystems on demand
18
### END INIT INFO
19
#
20
# Location of the automount daemon and the init directory
21
#
22
DAEMON=/usr/sbin/automount
23
prog=`basename $DAEMON`
24
MODULE="autofs4"
25
DEVICE="autofs"
26
initdir=/etc/init.d
27
confdir=/etc/sysconfig
28
 
29
test -e $DAEMON || exit 0
30
 
31
if [ -r $initdir/functions ]; then
32
	. $initdir/functions
33
fi
34
 
35
PATH=/sbin:/usr/sbin:/bin:/usr/bin
36
export PATH
37
 
38
#
39
# load customized configuation settings
40
#
41
if [ -r $confdir/autofs ]; then
42
	. $confdir/autofs
43
fi
44
 
45
function start() {
46
	# Make sure autofs4 module is loaded
47
	if ! grep -q autofs /proc/filesystems
48
	then
49
		echo -n "Loading $MODULE: "
50
		# Try load the autofs4 module fail if we can't
51
		modprobe $MODULE >/dev/null 2>&1
52
		RETVAL=$?
53
		if [ $RETVAL -eq 1 ]
54
		then
55
			failure "Load $MODULE"
56
			echo
57
			return $RETVAL
58
		else
59
			success "Load $MODULE"
60
			echo
61
		fi
62
	elif ([ -f /proc/modules ] && lsmod) | grep -q autofs[^4]
63
	then
64
		RETVAL=1
65
		failure "Load $MODULE"
66
		echo
67
		return $RETVAL
68
	fi
69
 
70
	# Check misc device
71
	if [ -n "$USE_MISC_DEVICE" -a "x$USE_MISC_DEVICE" = "xyes" ]; then
72
		sleep 1
73
		if [ -e "/proc/misc" ]; then
74
			MINOR=`awk "/$DEVICE/ {print \\$1}" /proc/misc`
75
			if [ -n "$MINOR" -a ! -c "/dev/$DEVICE" ]; then
76
				mknod -m 0600 /dev/$DEVICE c 10 $MINOR
77
			fi
78
		fi
79
		if [ -x /sbin/restorecon -a -c /dev/$DEVICE ]; then
80
			/sbin/restorecon /dev/$DEVICE
81
		fi
82
	else
83
		if [ -c /dev/$DEVICE ]; then
84
			rm /dev/$DEVICE
85
		fi
86
	fi
87
 
88
	echo -n $"Starting $prog: "
89
	$prog $OPTIONS --pid-file /var/run/autofs.pid
90
	RETVAL=$?
91
	if [ $RETVAL -eq 0 ] ; then
92
		success "$prog startup"
93
	else
94
		failure "$prog startup"
95
	fi
96
	if [ $RETVAL -eq 0 ]; then
97
		touch /var/lock/subsys/autofs
98
	else
99
		RETVAL=1
100
	fi
101
	echo
102
	return $RETVAL
103
}
104
 
105
function stop() {
106
	echo -n $"Stopping $prog: "
107
	count=0
108
	while [ -n "`pidof $prog`" -a $count -lt 15 ] ; do
109
		killproc $prog -TERM >& /dev/null
110
		RETVAL=$?
111
		[ $RETVAL = 0 -a -z "`pidof $prog`" ] || sleep 3
112
		count=`expr $count + 1`
113
	done
114
	if [ $RETVAL -eq 0 ]; then
115
		rm -f /var/lock/subsys/autofs
116
	else
117
		RETVAL=1
118
	fi
119
	if [ -n "`pidof $prog`" ] ; then
120
		failure "$prog shutdown"
121
	else
122
		success "$prog shutdown"
123
	fi
124
	echo
125
	return $RETVAL
126
}
127
 
128
function restart() {
129
	status autofs > /dev/null 2>&1
130
	if [ $? -eq 0 ]; then
131
		stop
132
		if [ -n "`pidof $prog`" ]; then
133
			# If we failed to stop, try at least one more time
134
			# after waiting a little while
135
			sleep 20
136
			stop
137
			auto_pid=`pidof $prog`
138
			if [ -n "$auto_pid" ]; then
139
				kill -9 $auto_pid
140
			fi
141
		fi
142
	fi
143
	start
144
}
145
 
146
function reload() {
147
	if [ ! -f /var/lock/subsys/autofs ]; then
148
		echo $"$prog not running"
149
		RETVAL=1
150
		return $RETVAL
151
	fi
152
	pid=`pidof $prog`
153
	if [ -z $pid ]; then
154
		echo $"$prog not running"
155
		RETVAL=1
156
	else
157
		kill -HUP $pid 2> /dev/null
158
		echo $"Reloading maps"
159
		RETVAL=0
160
	fi
161
	return $RETVAL
162
}
163
 
164
function usage_message() {
165
	echo $"Usage: $0 {start|forcestart|stop|status|restart|force-reload|forcerestart|reload|condrestart|try-restart|usage}"
166
}
167
 
168
RETVAL=0
169
 
170
# allow non-root users to read status / usage
171
 
172
case "$1" in
173
	status)
174
		status -p /var/run/autofs.pid -l autofs $prog
175
		exit $?;
176
		;;
177
	usage)
178
		usage_message
179
		exit 0;
180
		;;
181
esac
182
 
183
# Only the root user may change the service status
184
if [ `id -u` -ne 0 ]; then
185
	echo "insufficient privilege to change service status"
186
	exit 4
187
fi
188
 
189
case "$1" in
190
	start)
191
		start
192
		;;
193
	forcestart)
194
		OPTIONS="$OPTIONS --force"
195
		start
196
		;;
197
	stop)
198
		stop
199
		;;
200
	restart|force-reload)
201
		restart
202
		;;
203
	forcerestart)
204
		OPTIONS="$OPTIONS --force"
205
		restart
206
		;;
207
	reload)
208
		reload
209
		;;
210
	condrestart|try-restart)
211
		if [ -f /var/lock/subsys/autofs ]; then
212
			restart
213
		fi
214
		;;
215
	*)
216
		usage_message
217
		exit 2
218
		;;
219
esac
220
 
221
exit $?
222