summaryrefslogtreecommitdiffstats
path: root/etc/initsystem/safe-reload.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:32:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:32:39 +0000
commit56ae875861ab260b80a030f50c4aff9f9dc8fff0 (patch)
tree531412110fc901a5918c7f7442202804a83cada9 /etc/initsystem/safe-reload.cmake
parentInitial commit. (diff)
downloadicinga2-56ae875861ab260b80a030f50c4aff9f9dc8fff0.tar.xz
icinga2-56ae875861ab260b80a030f50c4aff9f9dc8fff0.zip
Adding upstream version 2.14.2.upstream/2.14.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'etc/initsystem/safe-reload.cmake')
-rw-r--r--etc/initsystem/safe-reload.cmake52
1 files changed, 52 insertions, 0 deletions
diff --git a/etc/initsystem/safe-reload.cmake b/etc/initsystem/safe-reload.cmake
new file mode 100644
index 0000000..0cba415
--- /dev/null
+++ b/etc/initsystem/safe-reload.cmake
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# Load sysconf on systems where the initsystem does not pass the environment
+if [ "$1" != "" ]; then
+ if [ -r "$1" ]; then
+ . "$1"
+ else
+ echo "Unable to read sysconf from '$1'. Exiting."
+ exit 6
+ fi
+fi
+
+# Set defaults, to overwrite see "@ICINGA2_SYSCONFIGFILE@"
+
+: "${ICINGA2_PID_FILE:="@ICINGA2_FULL_INITRUNDIR@/icinga2.pid"}"
+: "${DAEMON:="@CMAKE_INSTALL_FULL_SBINDIR@/icinga2"}"
+
+printf "Validating config files: "
+
+OUTPUTFILE=`mktemp`
+
+if type selinuxenabled >/dev/null 2>&1; then
+ if selinuxenabled; then
+ chcon -t icinga2_tmp_t "$OUTPUTFILE" >/dev/null 2>&1
+ fi
+fi
+
+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 "Error: Icinga not running"
+ exit 7
+fi
+
+echo "Done"
+exit 0