summaryrefslogtreecommitdiffstats
path: root/startup/gentoo-init.in
blob: c7adc552aca46d44f53e1acba332177bc96e3fac (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
#!/sbin/openrc-run
#
# Copyright (c) 2016 Nagios(R) Core(TM) Development Team
#
# Start/stop the nrpe daemon.
#
# Goes in /etc/init.d - Config is in /etc/conf.d/nrpe

extra_started_commands="reload"

NRPE_BIN="@sbindir@/nrpe"
NRPE_PID="@piddir@/nrpe.pid"
NRPE_CFG=@pkgsysconfdir@/nrpe.cfg

depend() {
	use logger dns net localmount netmount nfsmount
}

checkconfig() {
	# Make sure the config file exists
	if [ ! -f $NRPE_CFG ]; then
		eerror "You need to setup $NRPE_CFG."
		return 1
	fi
	return 0
}

start() {
	checkconfig || return 1
	ebegin "Starting nrpe"
	# Make sure we have a sane current directory
	cd /
	start-stop-daemon --start --exec $NRPE_BIN --pidfile $NRPE_PID \
		--background -- -c $NRPE_CFG -f $NRPE_OPTS
	eend $?
}

stop() {
	ebegin "Stopping nrpe"
	start-stop-daemon --stop --exec $NRPE_BIN --pidfile $NRPE_PID
	eend $?
}

reload() {
	ebegin "Reloading nrpe"
	start-stop-daemon --stop --oknodo --exec $NRPE_BIN \
		--pidfile $NRPE_PID --signal HUP
	eend $?
}