summaryrefslogtreecommitdiff
path: root/sysutils/dsbmd/files/dsbmd.in
blob: 128431effe0fea27f96f83d8269220eccb8d38c3 (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
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: dsbmd
# REQUIRE: LOGIN devfs devd mountlate
# KEYWORD: shutdown
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# dsbmd_enable (bool):		Set to NO by default.
#				Set it to YES to enable dsbmd.
#

. /etc/rc.subr

name=dsbmd
command=%%PREFIX%%/libexec/dsbmd
rcvar=dsbmd_enable
pidfile=/var/run/dsbmd.pid
stop_cmd=dsbmd_stop

load_rc_config $name

: ${dsbmd_enable:="NO"}

dsbmd_stop()
{
	if [ -f ${pidfile} ]; then
		echo "Stopping ${name}."
		pid=$(cat ${pidfile})
		n=0
		while [ $n -lt 5 ]; do
			kill ${pid} 2>/dev/null || return 0
			n=$(($n + 1))
			sleep 1
		done
		kill -KILL ${pid} 2>/dev/null
	else
		echo "${name} is not running."
		return 1
	fi
}

run_rc_command "$1"