#!/sbin/openrc-run

# Sample init.d file for alpine linux.

daemon=/usr/bin/nrpe
conf=/etc/nrpe.cfg

depend() {
	need net
	after firewall
}

get_pidfile() {
	if [ -r $conf ]; then
		pidfile=$(awk -F= '/^pid_file/ {print $2}' $conf)
	fi
	pidfile=${pidfile:-/var/run/nrpe.pid}
}

start() {
	get_pidfile
	ebegin "Starting NRPE"
		start-stop-daemon --start --quiet \
			--pidfile $pidfile \
			--exec $daemon -- -d ${nrpe_options:- -c $conf}
	eend $?
}

stop() {
	get_pidfile
	ebegin "Stopping NRPE"
		start-stop-daemon --stop --quiet \
			--exec $daemon \
			--pidfile $pidfile
	eend $?
}

