]> granicus.if.org Git - icinga2/commitdiff
Fix: 'which' isn't available on minimal CentOS installs
authorGunnar Beutner <gunnar@beutner.name>
Wed, 21 Oct 2015 12:41:48 +0000 (14:41 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 21 Oct 2015 12:41:48 +0000 (14:41 +0200)
fixes #10417

etc/initsystem/prepare-dirs
etc/initsystem/safe-reload

index 5e36f10dbe05eb125f0295d14586a9ee0ba41af8..8472466e9005daee78272a7fe5f90b03bf3c31f7 100644 (file)
@@ -47,7 +47,7 @@ fi
 
 mkdir -p $ICINGA2_RUN_DIR/icinga2/cmd
 chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_RUN_DIR/icinga2/cmd
-if [ $(which restorecon) ]; then
+if which restorecon >/dev/null 2&>1; then
        restorecon -R $ICINGA2_RUN_DIR/icinga2/
 fi
 chmod 2750 $ICINGA2_RUN_DIR/icinga2/cmd
index f49f29f6bc21e30db9f9b67562c5f5e395c7dfd0..70a1a4aba2ac2973f3e03a91c26c6561544b9aae 100644 (file)
@@ -1,20 +1,20 @@
 #!/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."
+if [ ! -f "$SYSCONFIGFILE" ]; then
+       echo "Error: You need to supply the path to the Icinga2 sysconfig file as a parameter."
        exit 1
 fi
 
+. $SYSCONFIGFILE
+
 printf "Validating config files: "
 
 OUTPUTFILE=`mktemp`
-if [ $(which chcon) ]; then
-        chcon -t icinga2_tmp_t $OUTPUTFILE
-fi
 
+if env chcon >/dev/null 2&>1; then
+       chcon -t icinga2_tmp_t $OUTPUTFILE
+fi
 
 if ! $DAEMON daemon --validate --color > $OUTPUTFILE; then
        echo "Failed"
@@ -34,11 +34,10 @@ if [ ! -e $ICINGA2_PID_FILE ]; then
 fi
 
 pid=`cat $ICINGA2_PID_FILE`
-if kill -HUP $pid >/dev/null 2>&1; then
-       echo "Done"
-else
+if ! kill -HUP $pid >/dev/null 2>&1; then
        echo "Error: Icinga not running"
        exit 7
 fi
 
+echo "Done"
 exit 0