From ba41d7f2499d31c2b0a15d2be412ed66f1c20b52 Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Wed, 17 Jan 2018 13:25:40 +0100 Subject: [PATCH] Get ICINGA2_USER and GROUP from sysconfig --- etc/initsystem/icinga2.init.d.cmake | 14 ++++++-------- etc/initsystem/prepare-dirs | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/etc/initsystem/icinga2.init.d.cmake b/etc/initsystem/icinga2.init.d.cmake index 080fb2779..ac494a8a2 100644 --- a/etc/initsystem/icinga2.init.d.cmake +++ b/etc/initsystem/icinga2.init.d.cmake @@ -31,16 +31,14 @@ if [ ! -e $ICINGA2_CONFIG_FILE ]; then exit 6 fi -ICINGA2_USER=`$DAEMON variable get --current RunAsUser` -if [ $? != 0 ]; then - echo "Could not fetch RunAsUser variable. Error '$ICINGA2_USER'. Exiting." - exit 6 +if [ ! $ICINGA2_USER ]; then + echo "Could not fetch \$ICINGA2_USER. Exiting." + exit 6 fi -ICINGA2_GROUP=`$DAEMON variable get --current RunAsGroup` -if [ $? != 0 ]; then - echo "Could not fetch RunAsGroup variable. Error '$ICINGA2_GROUP'. Exiting." - exit 6 +if [ ! $ICINGA2_GROUP ]; then + echo "Could not fetch \$ICINGA2_GROUP. Exiting." + exit 6 fi getent passwd $ICINGA2_USER >/dev/null 2>&1 || (echo "Icinga user '$ICINGA2_USER' does not exist. Exiting." && exit 6) diff --git a/etc/initsystem/prepare-dirs b/etc/initsystem/prepare-dirs index 799e3226f..44b8343a8 100644 --- a/etc/initsystem/prepare-dirs +++ b/etc/initsystem/prepare-dirs @@ -13,16 +13,14 @@ else fi -ICINGA2_USER=`$DAEMON variable get --current RunAsUser` -if [ $? != 0 ]; then - echo "Could not fetch RunAsUser variable. Error '$ICINGA2_USER'. Exiting." - exit 6 +if [ ! $ICINGA2_USER ]; then + echo "Could not fetch \$ICINGA2_USER. Exiting." + exit 6 fi -ICINGA2_GROUP=`$DAEMON variable get --current RunAsGroup` -if [ $? != 0 ]; then - echo "Could not fetch RunAsGroup variable. Error '$ICINGA2_GROUP'. Exiting." - exit 6 +if [ ! $ICINGA2_GROUP ]; then + echo "Could not fetch \$ICINGA2_GROUP. Exiting." + exit 6 fi getent passwd $ICINGA2_USER >/dev/null 2>&1 || (echo "Icinga user '$ICINGA2_USER' does not exist. Exiting." && exit 6)