mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-25 04:43:33 +00:00
1f8dc94f2e
PR: ports/81220 Submitted by: Artem Naluzhny <tut@nhamon.com.ua> via maintainer
72 lines
1.3 KiB
Bash
72 lines
1.3 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
#
|
|
# Add the following lines to /etc/rc.conf to enable nagios:
|
|
#
|
|
#nagios_enable="YES"
|
|
#
|
|
|
|
. %%RC_SUBR%%
|
|
|
|
name=nagios
|
|
rcvar=`set_rcvar`
|
|
|
|
prefix=%%PREFIX%%
|
|
|
|
required_files=${prefix}/etc/nagios/nagios.cfg
|
|
|
|
NagiosBin=${prefix}/bin/nagios
|
|
NagiosCfg=${prefix}/etc/nagios/nagios.cfg
|
|
NagiosVar=%%NAGIOSDIR%%
|
|
NagiosLog=${NagiosVar}/status.log
|
|
NagiosTmp=${NagiosVar}/nagios.tmp
|
|
NagiosSav=${NagiosVar}/status.sav
|
|
NagiosCmd=${NagiosVar}/rw/nagios.cmd
|
|
NagiosRun=${NagiosVar}/nagios.lock
|
|
|
|
pidfile=${NagiosRun}
|
|
command=${NagiosBin}
|
|
command_args="-d $NagiosCfg"
|
|
nagios_user=%%NAGIOSUSER%%
|
|
|
|
start_precmd=start_precmd
|
|
stop_postcmd=stop_postcmd
|
|
restart_precmd=nagios_checkconfig
|
|
|
|
# set defaults
|
|
|
|
nagios_enable=${nagios_enable:-"NO"}
|
|
nagios_flags=${nagios_flags:-""}
|
|
|
|
nagios_checkconfig()
|
|
{
|
|
echo -n 'Performing sanity check on Nagios configuration: '
|
|
$NagiosBin -v $NagiosCfg > /dev/null 2>&1
|
|
if [ $? != 0 ]; then
|
|
echo 'FAILED.'
|
|
echo "Use '$NagiosBin -v $NagiosCfg' command for details."
|
|
return 1
|
|
else
|
|
echo 'OK.'
|
|
fi
|
|
}
|
|
|
|
start_precmd()
|
|
{
|
|
nagios_checkconfig; [ $? != 0 ] && return 1
|
|
|
|
su -m ${nagios_user} -c "touch ${NagiosVar}/nagios.log ${NagiosSav}"
|
|
rm -f ${NagiosCmd}
|
|
}
|
|
|
|
stop_postcmd()
|
|
{
|
|
rm -f $NagiosLog $NagiosTmp $NagiosRun $NagiosCmd
|
|
}
|
|
|
|
load_rc_config $name
|
|
run_rc_command "$1"
|