2014-12-11 09:27:31 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-06-18 10:27:35 +02:00
|
|
|
# Load sysconf on systems where the initsystem does not pass the environment
|
2018-06-15 17:04:28 +02:00
|
|
|
if [ "$1" != "" ]; then
|
2018-06-18 10:27:35 +02:00
|
|
|
if [ -r "$1" ]; then
|
2018-07-18 13:35:27 +02:00
|
|
|
. "$1"
|
2018-06-18 10:27:35 +02:00
|
|
|
else
|
2020-12-27 16:50:10 +01:00
|
|
|
echo "Unable to read sysconf from '$1'. Exiting."
|
|
|
|
exit 6
|
2018-06-18 10:27:35 +02:00
|
|
|
fi
|
2018-06-15 17:04:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Set defaults, to overwrite see "@ICINGA2_SYSCONFIGFILE@"
|
|
|
|
|
2020-12-27 16:50:10 +01:00
|
|
|
: "${ICINGA2_PID_FILE:="@ICINGA2_FULL_INITRUNDIR@/icinga2.pid"}"
|
|
|
|
: "${DAEMON:="@CMAKE_INSTALL_FULL_SBINDIR@/icinga2"}"
|
2015-10-21 14:41:48 +02:00
|
|
|
|
2014-12-11 09:27:31 +01:00
|
|
|
printf "Validating config files: "
|
|
|
|
|
|
|
|
OUTPUTFILE=`mktemp`
|
2015-03-17 22:23:02 +01:00
|
|
|
|
2015-12-04 15:49:36 +01:00
|
|
|
if type selinuxenabled >/dev/null 2>&1; then
|
|
|
|
if selinuxenabled; then
|
2020-12-27 16:50:10 +01:00
|
|
|
chcon -t icinga2_tmp_t "$OUTPUTFILE" >/dev/null 2>&1
|
2015-12-04 15:49:36 +01:00
|
|
|
fi
|
2015-10-21 14:41:48 +02:00
|
|
|
fi
|
2014-12-11 09:27:31 +01:00
|
|
|
|
2020-12-27 16:50:10 +01:00
|
|
|
if ! "$DAEMON" daemon --validate --color > "$OUTPUTFILE"; then
|
2014-12-11 09:27:31 +01:00
|
|
|
echo "Failed"
|
|
|
|
|
2020-12-27 16:50:10 +01:00
|
|
|
cat "$OUTPUTFILE"
|
|
|
|
rm -f "$OUTPUTFILE"
|
2014-12-11 09:27:31 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Done"
|
2020-12-27 16:50:10 +01:00
|
|
|
rm -f "$OUTPUTFILE"
|
2014-12-11 09:27:31 +01:00
|
|
|
|
|
|
|
printf "Reloading Icinga 2: "
|
|
|
|
|
2020-12-27 16:50:10 +01:00
|
|
|
if [ ! -e "$ICINGA2_PID_FILE" ]; then
|
2014-12-11 09:27:31 +01:00
|
|
|
exit 7
|
|
|
|
fi
|
|
|
|
|
2020-12-27 16:50:10 +01:00
|
|
|
pid=`cat "$ICINGA2_PID_FILE"`
|
|
|
|
if ! kill -HUP "$pid" >/dev/null 2>&1; then
|
2014-12-11 09:27:31 +01:00
|
|
|
echo "Error: Icinga not running"
|
|
|
|
exit 7
|
|
|
|
fi
|
|
|
|
|
2015-10-21 14:41:48 +02:00
|
|
|
echo "Done"
|
2014-12-11 09:27:31 +01:00
|
|
|
exit 0
|