mirror of https://github.com/Icinga/icinga2.git
Exit from script instead of subshell on missing user
When executing `false || (echo bad; exit 1)`, the call to `exit` won't exit the script, it will only exit the subshell and the exit code will be stored in the return code `$?`. Since this is an error, we have to exit the script properly.
This commit is contained in:
parent
cb25be2d12
commit
d4251ea5ca
|
@ -53,9 +53,20 @@ if [ ! -e $ICINGA2_CONFIG_FILE ]; then
|
|||
exit 6
|
||||
fi
|
||||
|
||||
getent passwd $ICINGA2_USER >/dev/null 2>&1 || (echo "Icinga user '$ICINGA2_USER' does not exist. Exiting." && exit 6)
|
||||
getent group $ICINGA2_GROUP >/dev/null 2>&1 || (echo "Icinga group '$ICINGA2_GROUP' does not exist. Exiting." && exit 6)
|
||||
getent group $ICINGA2_COMMAND_GROUP >/dev/null 2>&1 || (echo "Icinga command group '$ICINGA2_COMMAND_GROUP' does not exist. Exiting." && exit 6)
|
||||
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
|
||||
|
||||
# Start Icinga 2
|
||||
start() {
|
||||
|
|
|
@ -21,9 +21,20 @@ fi
|
|||
: ${ICINGA2_LOG_DIR:="@ICINGA2_FULL_LOGDIR@"}
|
||||
: ${ICINGA2_CACHE_DIR:="@ICINGA2_FULL_CACHEDIR@"}
|
||||
|
||||
getent passwd $ICINGA2_USER >/dev/null 2>&1 || (echo "Icinga user '$ICINGA2_USER' does not exist. Exiting." && exit 6)
|
||||
getent group $ICINGA2_GROUP >/dev/null 2>&1 || (echo "Icinga group '$ICINGA2_GROUP' does not exist. Exiting." && exit 6)
|
||||
getent group $ICINGA2_COMMAND_GROUP >/dev/null 2>&1 || (echo "Icinga command group '$ICINGA2_COMMAND_GROUP' does not exist. Exiting." && exit 6)
|
||||
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
|
||||
|
||||
if [ ! -e "$ICINGA2_INIT_RUN_DIR" ]; then
|
||||
mkdir -m 755 "$ICINGA2_INIT_RUN_DIR"
|
||||
|
|
Loading…
Reference in New Issue