summaryrefslogtreecommitdiff
blob: 27e15cf654dbeab8cb6a977b53c3f51cc48efd57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/autofs/files/autofs5.initd,v 1.1 2011/04/03 09:49:15 pva Exp $

DAEMON=/usr/sbin/automount
PIDFILE=/var/run/autofs.pid
DEVICE=autofs

depend() {
	need localmount	
	use ypbind nfs slapd portmap net
}

opts="start stop restart status reload"

start() {
	ebegin "Starting automounter"

	# Ensure autofs support is loaded
	grep -q autofs /proc/filesystems || modprobe -q autofs4
	if [ $? -ne 0 ]; then
		eend 1 "No autofs support available in kernel"
		return 1
	fi

	# Check misc device
	if [ -n "${USE_MISC_DEVICE}" -a "${USE_MISC_DEVICE}" = "yes" ]; then
		sleep 1
		if [ -e "/proc/misc" ]; then
			MINOR=$(awk "/${DEVICE}/ {print \$1}" /proc/misc)
			[ -n "${MINOR}" -a ! -c "/dev/${DEVICE}" ] && \
				mknod -m 0600 "/dev/${DEVICE}" c 10 ${MINOR}
			if [ $? -ne 0 ]; then
				eend 1 "Could not create '/dev/${DEVICE}'"
				return 1
			fi
		fi
		[ -x /sbin/restorecon -a -c "/dev/${DEVICE}" ] && \
			/sbin/restorecon "/dev/${DEVICE}"
		if [ $? -ne 0 ]; then
			eend 1 "Failed to execute '/sbin/restorecon \"/dev/${DEVICE}\"'"
			return 1
		fi
	else
		[ -c "/dev/${DEVICE}" ] && rm -rf "/dev/${DEVICE}"
	fi

	start-stop-daemon --start --exec ${DAEMON} -- -p ${PIDFILE} ${OPTIONS}

	eend $?
}

stop() {
	ebegin "Stopping automounter"
	start-stop-daemon --stop --quiet -R TERM/45 -p ${PIDFILE}
	eend $?
}

reload() {
	ebegin "Reloading automounter"
	if [ ! -r "${PIDFILE}" ]; then
		eend 1 "automount not running"
	else
		kill -HUP $(cat "${PIDFILE}") 2> /dev/null
		eend $?
	fi
}