summaryrefslogtreecommitdiffstats
path: root/net-mgmt/nrpe/files/nrpe2.in
blob: 59f94fa5847b3d074c0ae43d0ac8cdf9f4f26228 (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
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: nrpe2
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable nrpe2:
# nrpe2_enable (bool):    Set to "NO" by default.
#                         Set it to "YES" to enable nrpe2.
# nrpe2_flags (str):      Not set by default.
# nrpe2_configfile (str): Set to "%%PREFIX%%/etc/nrpe.cfg" by default.

. /etc/rc.subr

name=nrpe2
rcvar=nrpe2_enable

load_rc_config "${name}"

: ${nrpe2_enable:=NO}
: ${nrpe2_configfile:=%%PREFIX%%/etc/nrpe.cfg}

required_files="${nrpe2_configfile}"

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

start_precmd=nrpe2_prestart
stop_precmd=find_pidfile

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

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

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

run_rc_command "$1"
OpenPOWER on IntegriCloud