0175383f0a
propogated by copy and paste. 1. Primarily the "empty variable" default assignment, which is mostly ${name}_flags="", but fix a few others as well. 2. Where they are not already documented, add the existence of the _flags (or other deleted empties) option to the comments, and in some cases add comments from scratch. 3. Replace things that look like: prefix=%%PREFIX%% command=${prefix}/sbin/foo to just use %%PREFIX%%. In many cases the $prefix variable is only used once, and in some cases it is not used at all. 4. In a few cases remove ${name}_flags from command_args 5. Remove a long-stale comment about putting the port's rc.d script in /etc/rc.d (which is no longer necessary). No PORTREVISION bumps because all of these changes are noops.
69 lines
1.5 KiB
Bash
69 lines
1.5 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: nagios
|
|
# REQUIRE: DAEMON
|
|
# BEFORE: LOGIN
|
|
# KEYWORD: shutdown
|
|
|
|
#
|
|
# Add the following lines to /etc/rc.conf to enable nagios:
|
|
# nagios_enable (bool): Set to "NO" by default.
|
|
# Set it to "YES" to enable nagios.
|
|
# nagios_flags (str): Set to "" by default.
|
|
# nagios_configfile (str): Set to "%%PREFIX%%/etc/nagios/nagios.cfg" by default.
|
|
#
|
|
|
|
. %%RC_SUBR%%
|
|
|
|
name="nagios"
|
|
rcvar=`set_rcvar`
|
|
|
|
command="%%PREFIX%%/bin/nagios"
|
|
command_args="-d"
|
|
extra_commands="reload"
|
|
pidfile="%%NAGIOSDIR%%/nagios.lock"
|
|
nagios_user="%%NAGIOSUSER%%"
|
|
|
|
start_precmd="start_precmd"
|
|
stop_postcmd="stop_postcmd"
|
|
restart_precmd="nagios_checkconfig"
|
|
reload_precmd="nagios_checkconfig"
|
|
sig_reload=HUP
|
|
|
|
[ -z "${nagios_enable}" ] && nagios_enable="NO"
|
|
[ -z "${nagios_configfile}" ] && nagios_configfile="%%PREFIX%%/etc/nagios/nagios.cfg"
|
|
|
|
load_rc_config "${name}"
|
|
|
|
required_files="${nagios_configfile}"
|
|
command_args="${command_args} ${nagios_configfile}"
|
|
|
|
nagios_checkconfig() {
|
|
echo -n "Performing sanity check of nagios configuration: "
|
|
${command} -v ${nagios_configfile} 2>&1 >/dev/null
|
|
if [ $? != 0 ]; then
|
|
echo "FAILED"
|
|
${command} -v ${nagios_configfile}
|
|
return 1
|
|
else
|
|
echo "OK"
|
|
fi
|
|
}
|
|
|
|
start_precmd() {
|
|
if ! nagios_checkconfig; then
|
|
return 1
|
|
fi
|
|
|
|
su -m "${nagios_user}" -c "touch \"%%NAGIOSDIR%%/nagios.log\" \"%%NAGIOSDIR%%/status.sav\""
|
|
rm -f "%%NAGIOSDIR%%/rw/nagios.cmd"
|
|
}
|
|
|
|
stop_postcmd() {
|
|
rm -f "%%NAGIOSDIR%%/nagios.tmp" "%%NAGIOSDIR%%/rw/nagios.cmd"
|
|
}
|
|
|
|
run_rc_command "$1"
|