File: autofs.init

package info (click to toggle)
autofs 5.1.7-1%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,836 kB
  • sloc: ansic: 35,461; yacc: 1,811; lex: 1,067; sh: 627; makefile: 553
file content (111 lines) | stat: -rw-r--r-- 2,134 bytes parent folder | download | duplicates (8)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#! /bin/sh
#

### BEGIN INIT INFO
# Provides: autofs
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Should-Start: ypbind nslcd slapd
# Should-Stop: ypbind nslcd slapd
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Automounts filesystems on demand
# Description: Automounts filesystems on demand
### END INIT INFO

# Location of the automount daemon and the init directory
#
PROG=automount
DAEMON=/usr/sbin/$PROG
NAME=autofs
PIDFILE="/var/run/$NAME.pid"

test -e $DAEMON || exit 0

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

. /lib/lsb/init-functions

#
# load customized configuation settings
#
if [ -r /etc/default/autofs ]; then
	. /etc/default/autofs
fi

start_stop_autofs() {
	start-stop-daemon "$@" --pidfile $PIDFILE --exec $DAEMON -- \
		$OPTIONS --pid-file $PIDFILE
}

start() {
	log_action_begin_msg "Starting $PROG"

	if ! grep -qw autofs /proc/filesystems
	then
		if ! modprobe autofs4 >/dev/null 2>&1
		then
			log_action_end_msg 1 "failed to load autofs4 module"
			return 1
		fi
	elif [ -f /proc/modules ] && grep -q "^autofs[^4]" /proc/modules
	then
		log_action_end_msg 1 "autofs kernel module is loaded, autofs4 required"
		return 1
	fi

	if ! start_stop_autofs --start --oknodo --quiet ; then
		log_action_end_msg 1 "no valid automount entries defined."
		return 1
	fi
	log_end_msg 0
	return 0
}

stop() {
	log_action_begin_msg "Stopping $PROG"
	if ! start_stop_autofs --stop --retry 5 --oknodo --quiet ; then
		log_action_end_msg 1
		return 1
	fi
	log_end_msg 0
	return 0
}

reload() {
	log_action_begin_msg "Reloading $PROG maps"
	if ! start_stop_autofs --stop --signal=HUP --quiet
	then
		log_action_end_msg 1 "$PROG not running"
		return 1
	fi
	log_action_end_msg 0
	return 0
}

forcestart() {
	OPTIONS="$OPTIONS --force"
	start
}

case "$1" in
	start|forcestart|stop|reload)
		$1
		;;
	restart|force-reload)
		stop
		start
		;;
	forcerestart)
		stop
		forcestart
		;;
	status)
		status_of_proc -p $PIDFILE $DAEMON $PROG
		;;
	*)
		echo "Usage: $0 {start|forcestart|stop|restart|forcerestart|reload|force-reload|status}"
		exit 1
		;;
esac