summaryrefslogtreecommitdiff
path: root/net-mgmt/nrpe3/files/nrpe3.in
blob: 16646430821bdbf6ceae79662f58192869a4d406 (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
#!/bin/sh

# PROVIDE: nrpe3
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable nrpe3:
# nrpe3_enable (bool):    Set to "NO" by default.
#                         Set it to "YES" to enable nrpe3.
# nrpe3_flags (str):      Not set by default.
# nrpe3_configfile (str): Set to "%%PREFIX%%/etc/nrpe.cfg" by default.

. /etc/rc.subr

name=nrpe3
rcvar=nrpe3_enable

load_rc_config "${name}"

: ${nrpe3_enable:=NO}
: ${nrpe3_configfile:=%%PREFIX%%/etc/nrpe.cfg}

required_files="${nrpe3_configfile}"

command="%%PREFIX%%/sbin/nrpe3"
command_args="-c ${nrpe3_configfile} -d"
extra_commands=reload
sig_reload=HUP

start_precmd=nrpe3_prestart
stop_precmd=find_pidfile

find_pidfile()
{
	[ -n "$nrpe3_pidfile" ] &&
	    warn "No longer necessary to set nrpe3_pidfile in rc.conf[.local]"

	if get_pidfile_from_conf pid_file ${nrpe3_configfile}; then
		pidfile="$_pidfile_from_conf"
	else
		pidfile='%%PIDDIR%%/nrpe3.pid'
	fi
}

nrpe3_prestart()
{
	find_pidfile
	install -d -o ${nrpe_user:-nagios} ${pidfile%/*}
}

run_rc_command "$1"