Fix: 'which' isn't available on minimal CentOS installs

fixes #10417
This commit is contained in:
Gunnar Beutner 2015-10-21 14:41:48 +02:00
parent e93dd3cf15
commit 2a2da04af6
2 changed files with 10 additions and 11 deletions

View File

@ -47,7 +47,7 @@ fi
mkdir -p $ICINGA2_RUN_DIR/icinga2/cmd mkdir -p $ICINGA2_RUN_DIR/icinga2/cmd
chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $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/ restorecon -R $ICINGA2_RUN_DIR/icinga2/
fi fi
chmod 2750 $ICINGA2_RUN_DIR/icinga2/cmd chmod 2750 $ICINGA2_RUN_DIR/icinga2/cmd

View File

@ -1,20 +1,20 @@
#!/bin/sh #!/bin/sh
# load system specific defines # load system specific defines
SYSCONFIGFILE=$1 SYSCONFIGFILE=$1
if [ -f "$SYSCONFIGFILE" ]; then if [ ! -f "$SYSCONFIGFILE" ]; then
. $SYSCONFIGFILE echo "Error: You need to supply the path to the Icinga2 sysconfig file as a parameter."
else
echo "Error: You need to supply the path to the Icinga2 sysconfig file as parameter."
exit 1 exit 1
fi fi
. $SYSCONFIGFILE
printf "Validating config files: " printf "Validating config files: "
OUTPUTFILE=`mktemp` 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 if ! $DAEMON daemon --validate --color > $OUTPUTFILE; then
echo "Failed" echo "Failed"
@ -34,11 +34,10 @@ if [ ! -e $ICINGA2_PID_FILE ]; then
fi fi
pid=`cat $ICINGA2_PID_FILE` pid=`cat $ICINGA2_PID_FILE`
if kill -HUP $pid >/dev/null 2>&1; then if ! kill -HUP $pid >/dev/null 2>&1; then
echo "Done"
else
echo "Error: Icinga not running" echo "Error: Icinga not running"
exit 7 exit 7
fi fi
echo "Done"
exit 0 exit 0