2014-05-18 23:14:30 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# This script prepares directories and files needed for running Icinga2
|
|
|
|
#
|
|
|
|
|
2018-06-18 10:27:35 +02:00
|
|
|
# Load sysconf on systems where the initsystem does not pass the environment
|
2018-06-15 17:04:28 +02:00
|
|
|
if [ "$1" != "" ]; then
|
2018-06-18 10:27:35 +02:00
|
|
|
if [ -r "$1" ]; then
|
2018-07-18 13:35:27 +02:00
|
|
|
. "$1"
|
2018-06-18 10:27:35 +02:00
|
|
|
else
|
|
|
|
echo "Unable to read sysconf from '$1'. Exiting." && exit 6
|
|
|
|
fi
|
2018-06-15 17:04:28 +02:00
|
|
|
fi
|
|
|
|
|
2018-05-23 13:37:29 +02:00
|
|
|
# Set defaults, to overwrite see "@ICINGA2_SYSCONFIGFILE@"
|
2014-11-25 18:42:13 +01:00
|
|
|
|
2020-12-27 16:50:10 +01:00
|
|
|
: "${ICINGA2_USER:="@ICINGA2_USER@"}"
|
|
|
|
: "${ICINGA2_GROUP:="@ICINGA2_GROUP@"}"
|
|
|
|
: "${ICINGA2_COMMAND_GROUP:="@ICINGA2_COMMAND_GROUP@"}"
|
|
|
|
: "${ICINGA2_INIT_RUN_DIR:="@ICINGA2_FULL_INITRUNDIR@"}"
|
|
|
|
: "${ICINGA2_LOG_DIR:="@ICINGA2_FULL_LOGDIR@"}"
|
|
|
|
: "${ICINGA2_CACHE_DIR:="@ICINGA2_FULL_CACHEDIR@"}"
|
2014-11-25 18:42:13 +01:00
|
|
|
|
2020-12-27 16:09:07 +01:00
|
|
|
if ! getent passwd "$ICINGA2_USER" >/dev/null 2>&1; then
|
|
|
|
echo "Icinga user '$ICINGA2_USER' does not exist. Exiting."
|
|
|
|
exit 6
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! getent group "$ICINGA2_GROUP" >/dev/null 2>&1; then
|
|
|
|
echo "Icinga group '$ICINGA2_GROUP' does not exist. Exiting."
|
|
|
|
exit 6
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! getent group "$ICINGA2_COMMAND_GROUP" >/dev/null 2>&1; then
|
|
|
|
echo "Icinga command group '$ICINGA2_COMMAND_GROUP' does not exist. Exiting."
|
|
|
|
exit 6
|
|
|
|
fi
|
2014-10-20 21:41:04 +02:00
|
|
|
|
2018-07-31 11:59:09 +02:00
|
|
|
if [ ! -e "$ICINGA2_INIT_RUN_DIR" ]; then
|
2020-06-08 15:14:29 +02:00
|
|
|
mkdir -m 755 "$ICINGA2_INIT_RUN_DIR"
|
|
|
|
mkdir -m 2750 "$ICINGA2_INIT_RUN_DIR"/cmd
|
2014-05-18 23:14:30 +02:00
|
|
|
fi
|
|
|
|
|
2020-12-27 16:50:10 +01:00
|
|
|
chown -R "$ICINGA2_USER:$ICINGA2_COMMAND_GROUP" "$ICINGA2_INIT_RUN_DIR"
|
2018-06-06 14:31:47 +02:00
|
|
|
|
2020-12-27 16:50:10 +01:00
|
|
|
test -e "$ICINGA2_LOG_DIR" || install -m 750 -o "$ICINGA2_USER" -g "$ICINGA2_COMMAND_GROUP" -d "$ICINGA2_LOG_DIR"
|
2017-11-29 13:56:10 +01:00
|
|
|
|
2015-11-18 20:18:04 +01:00
|
|
|
if type restorecon >/dev/null 2>&1; then
|
2018-07-31 11:59:09 +02:00
|
|
|
restorecon -R "$ICINGA2_INIT_RUN_DIR"/
|
2015-03-17 19:51:54 +01:00
|
|
|
fi
|
2017-07-01 13:59:58 +02:00
|
|
|
|
2020-12-27 16:50:10 +01:00
|
|
|
test -e "$ICINGA2_CACHE_DIR" || install -m 750 -o "$ICINGA2_USER" -g "$ICINGA2_COMMAND_GROUP" -d "$ICINGA2_CACHE_DIR"
|