- Update to 1.10.2 - Stagify - Use new LIB_DEPENDS syntax - Add USES gmake - Remove a lot of no longer needed variables and logic from the old nagios port - Install Apache 2.x configuration examples by default, no longer provide an option to depend on www/apache22 to be more flexible - Use ports system's own way to add and remove users and groups. Remove pkg-{de,}install - Don't use the install-commandmode make target. ICINGADIR and ICINGALOGDIR are now created from the icinga rc-script - Remove embedded Perl option which is considered broken by the developers - Remove UNHANDLED_HACK option - another relict from the old nagios port.
141 lines
3.1 KiB
Bash
141 lines
3.1 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: icinga
|
|
# REQUIRE: LOGIN
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Add the following lines to /etc/rc.conf to enable icinga:
|
|
# icinga_enable (bool): Set to "NO" by default.
|
|
# Set it to "YES" to enable icinga.
|
|
# icinga_precache (bool): Set to "NO" by default.
|
|
# Set it to "YES" to enable pre-caching.
|
|
# icinga_flags (str): Set to "" by default.
|
|
# icinga_configfile (str): Set to "%%PREFIX%%/etc/icinga/icinga.cfg" by default.
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="icinga"
|
|
rcvar=icinga_enable
|
|
|
|
load_rc_config "${name}"
|
|
|
|
: ${icinga_enable:="NO"}
|
|
: ${icinga_configfile="%%PREFIX%%/etc/icinga/icinga.cfg"}
|
|
: ${icinga_precache:="NO"}
|
|
|
|
command="%%PREFIX%%/bin/icinga"
|
|
command_args="-d"
|
|
extra_commands="reload checkconfig configtest"
|
|
icinga_user="%%ICINGAUSER%%"
|
|
icinga_group="%%ICINGAGROUP%%"
|
|
|
|
icinga_dir="%%ICINGADIR%%"
|
|
icinga_logdir="%%ICINGALOGDIR%%"
|
|
|
|
pidfile="${icinga_dir}/icinga.lock"
|
|
icinga_logfile="${icinga_logdir}/${name}.log"
|
|
icinga_statusfile="${icinga_dir}/status.sav"
|
|
icinga_cmdfile="${icinga_dir}/rw/${name}.cmd"
|
|
|
|
start_cmd="start_cmd"
|
|
checkconfig_cmd="icinga_checkconfig verbose"
|
|
configtest_cmd="${checkconfig_cmd}"
|
|
start_precmd="start_precmd"
|
|
stop_postcmd="stop_postcmd"
|
|
restart_precmd="icinga_checkconfig"
|
|
reload_precmd="reload_precmd"
|
|
sig_reload=HUP
|
|
|
|
required_files="${icinga_configfile}"
|
|
command_args="${command_args} ${icinga_configfile}"
|
|
|
|
icinga_cacheconfig() {
|
|
if ! checkyesno icinga_precache; then
|
|
return 0
|
|
fi
|
|
|
|
echo -n "Pre-Caching icinga configuration: "
|
|
${command} -pv ${icinga_configfile} 2>&1 >/dev/null
|
|
if [ $? != 0 ]; then
|
|
echo "FAILED"
|
|
${command} -v ${icinga_configfile}
|
|
return 1
|
|
else
|
|
command_args="-u -x ${command_args}"
|
|
echo "OK"
|
|
fi
|
|
}
|
|
|
|
icinga_checkconfig() {
|
|
echo -n "Performing sanity check of icinga configuration: "
|
|
|
|
if [ "$1" != "verbose" ]; then
|
|
${command} -v ${icinga_configfile} 2>&1 >/dev/null
|
|
else
|
|
${command} -v ${icinga_configfile}
|
|
fi
|
|
|
|
|
|
if [ $? != 0 ]; then
|
|
echo "FAILED"
|
|
${command} -v ${icinga_configfile}
|
|
return 1
|
|
else
|
|
echo "OK"
|
|
fi
|
|
}
|
|
|
|
reload_precmd() {
|
|
if ! icinga_checkconfig; then
|
|
return 1
|
|
fi
|
|
|
|
if ! icinga_cacheconfig; then
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
start_precmd() {
|
|
for d in "${icinga_dir}" \
|
|
"${icinga_dir}/checkresults" \
|
|
"${icinga_logdir}" \
|
|
"${icinga_logdir}/archives"; do
|
|
if [ ! -d "${d}" ]; then
|
|
install -d -o "${icinga_user}" -g "${icinga_group}" "${icinga_dir}"/checkresults
|
|
fi
|
|
done
|
|
|
|
if [ ! -d "${icingadir}/rw" ]; then
|
|
install -d -o "${icinga_user}" -g "%%WWWGRP%%" "${icinga_dir}"/rw
|
|
fi
|
|
|
|
if ! icinga_checkconfig; then
|
|
return 1
|
|
fi
|
|
|
|
if ! icinga_cacheconfig; then
|
|
return 1
|
|
fi
|
|
|
|
if [ ! -f "${icinga_logfile}" ]; then
|
|
install -o "${icinga_user}" -g "${icinga_group}" -m 644 /dev/null "${icinga_logfile}"
|
|
fi
|
|
if [ ! -f "${icinga_statusfile}" ]; then
|
|
install -o "${icinga_user}" -g "${icinga_group}" -m 644 /dev/null "${icinga_statusfile}"
|
|
fi
|
|
rm -f "${icinga_cmdfile}"
|
|
}
|
|
|
|
stop_postcmd() {
|
|
rm -f "${icinga_dir}/icinga.tmp" "${icinga_cmdfile}"
|
|
}
|
|
|
|
start_cmd() {
|
|
${command} ${command_args}
|
|
}
|
|
|
|
run_rc_command "$1"
|