icinga2/etc/initsystem/icinga2-prepare-dirs

34 lines
1002 B
Bash

#!/bin/sh
#
# This script prepares directories and files needed for running Icinga2
#
# load system specific defines
SYSDEFFILE=$1
if [ -f "$SYSDEFFILE" ]; then
. $SYSDEFFILE
else
echo "Error: You need to supply the path to the Icinga2 sysdefines.conf as parameter."
exit 1
fi
mkdir -p $(dirname -- $ICINGA2_PID_FILE)
chown $ICINGA2_USER:$ICINGA2_GROUP $(dirname -- $ICINGA2_PID_FILE)
if [ -f $ICINGA2_PID_FILE ]; then
chown $ICINGA2_USER:$ICINGA2_GROUP $ICINGA2_PID_FILE
fi
mkdir -p $(dirname -- $ICINGA2_ERROR_LOG)
chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $(dirname -- $ICINGA2_ERROR_LOG)
chmod 750 $(dirname -- $ICINGA2_ERROR_LOG)
if [ -f $ICINGA2_ERROR_LOG ]; then
chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_ERROR_LOG
fi
if [ -f $ICINGA2_LOG ]; then
chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_LOG
fi
mkdir -p $ICINGA2_STATE_DIR/run/icinga2/cmd
chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_STATE_DIR/run/icinga2/cmd
chmod 2755 $ICINGA2_STATE_DIR/run/icinga2/cmd