From ee48ad39dd1facf856cb07e62811278d84b126b9 Mon Sep 17 00:00:00 2001
From: anima
Date: Fri, 7 Feb 2025 03:04:17 +0100
Subject: [PATCH] move root api pw set before other users
---
init.sh | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/init.sh b/init.sh
index af7f74f..7bc220d 100644
--- a/init.sh
+++ b/init.sh
@@ -23,6 +23,12 @@ if [ -z "$(ls -A /data)" ]; then
mv $ICINGA2_CONF_DIR/*.conf $ICINGA2_GLOBAL_TEMPLATES/
mv $ICINGA2_GLOBAL_TEMPLATES/api-users.conf $ICINGA2_CONF_DIR/
+ ## only on inital setup replace one time the api root user password if a env var is set
+ if [ ! -z "$ICINGA2_API_USER_ROOT_PASS" ]; then
+ echo set inital api root user password
+ sed -i "s|password = \".*\"|password = \"$ICINGA2_API_USER_ROOT_PASS\"|g" $ICINGA2_FILE_API_USER_CONF
+ fi
+
## only on inital setup create a icingaweb api user if env var is set
## permission source: https://icinga.com/docs/icinga-web/latest/modules/monitoring/doc/05-Command-Transports/
if [ ! -z "$ICINGA2_API_USER_ICINGAWEB_PASS" ]; then
@@ -44,11 +50,6 @@ if [ -z "$(ls -A /data)" ]; then
fi
- ## only on inital setup replace one time the api root user password if a env var is set
- if [ ! -z "$ICINGA2_API_USER_ROOT_PASS" ]; then
- echo set inital api root user password
- sed -i "s|password = \".*\"|password = \"$ICINGA2_API_USER_ROOT_PASS\"|g" $ICINGA2_FILE_API_USER_CONF
- fi
fi