)
install(
- FILES prepare-dirs
+ FILES prepare-dirs safe-reload
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/icinga2
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
# Reload Icinga 2
reload() {
- printf "Reloading Icinga 2: "
-
- if [ ! -e $ICINGA2_PID_FILE ]; then
- exit 7
- fi
-
- pid=`cat $ICINGA2_PID_FILE`
- if kill -HUP $pid >/dev/null 2>&1; then
- echo "Done"
- else
- echo "Error: Icinga not running"
- exit 7
- fi
+ exec @CMAKE_INSTALL_PREFIX@/lib/icinga2/safe-reload $SYSCONFIGFILE
}
# Check the Icinga 2 configuration
ExecStartPre=@CMAKE_INSTALL_PREFIX@/lib/icinga2/prepare-dirs @ICINGA2_SYSCONFIGFILE@
ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 daemon -d -e ${ICINGA2_ERROR_LOG}
PIDFile=@ICINGA2_RUNDIR@/icinga2/icinga2.pid
-ExecReload=/bin/kill -HUP $MAINPID
+ExecReload=@CMAKE_INSTALL_PREFIX@/lib/icinga2/safe-reload @ICINGA2_SYSCONFIGFILE@
[Install]
WantedBy=multi-user.target
--- /dev/null
+#!/bin/sh
+# load system specific defines
+SYSCONFIGFILE=$1
+if [ -f "$SYSCONFIGFILE" ]; then
+ . $SYSCONFIGFILE
+else
+ echo "Error: You need to supply the path to the Icinga2 sysconfig file as parameter."
+ exit 1
+fi
+
+printf "Validating config files: "
+
+OUTPUTFILE=`mktemp`
+
+if ! $DAEMON daemon --validate --color > $OUTPUTFILE; then
+ echo "Failed"
+
+ cat $OUTPUTFILE
+ rm -f $OUTPUTFILE
+ exit 1
+fi
+
+echo "Done"
+rm -f $OUTPUTFILE
+
+printf "Reloading Icinga 2: "
+
+if [ ! -e $ICINGA2_PID_FILE ]; then
+ exit 7
+fi
+
+pid=`cat $ICINGA2_PID_FILE`
+if kill -HUP $pid >/dev/null 2>&1; then
+ echo "Done"
+else
+ echo "Error: Icinga not running"
+ exit 7
+fi
+
+exit 0
%config(noreplace) %{_sysconfdir}/%{name}/scripts/*
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/prepare-dirs
+%{_libexecdir}/%{name}/safe-reload
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp