From 69a09eba91558f40c3b2015f45a2681ac6e56847 Mon Sep 17 00:00:00 2001 From: anima Date: Sat, 1 Feb 2025 19:17:16 +0100 Subject: [PATCH] add influxdb feature --- init.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/init.sh b/init.sh index 66b4606..fbe8c32 100644 --- a/init.sh +++ b/init.sh @@ -3,6 +3,7 @@ ICINGA2_FILE_API_CONF=/etc/icinga2/features-enabled/api.conf ICINGA2_FILE_API_USER_CONF=/etc/icinga2/conf.d/api-users.conf ICINGA2_FILE_ICINGADB_CONF=/etc/icinga2/features-enabled/icingadb.conf +ICINGA2_FILE_INFLUXDB_CONF=/etc/icinga2/features-enabled/influx.conf ## init icinga config files if need if [ -z "$(ls -A /data)" ]; then @@ -39,7 +40,7 @@ if [ ! -f "$ICINGA2_FILE_ICINGADB_CONF" ]; then /usr/sbin/icinga2 feature enable icingadb fi -## replace redis conf is env vars set (anytime) +## icingadb: replace redis conf is env vars set (anytime) if [ ! -z "$ICINGA2_ICINGADB_REDIS_HOST" ]; then echo set new redis host sed -i "s|\(//\)*host = \".*\"|host = \"$ICINGA2_ICINGADB_REDIS_HOST\"|g" $ICINGA2_FILE_ICINGADB_CONF @@ -53,5 +54,26 @@ if [ ! -z "$ICINGA2_ICINGADB_REDIS_PASS" ]; then sed -i "s|\(//\)*password = \".*\"|password = \"$ICINGA2_ICINGADB_REDIS_PASS\"|g" $ICINGA2_FILE_ICINGADB_CONF fi +## enable icingadb feature if not active +if [ ! -f "$ICINGA2_FILE_INFLUXDB_CONF" ]; then + echo enable influxdb + /usr/sbin/icinga2 feature enable influxdb +fi + +if [ ! -z "$ICINGA2_INFLUXDB_HOST" ]; then + echo set new influxdb host + sed -i "s|\(//\)*host = \".*\"|host = \"$ICINGA2_INFLUXDB_PASS\"|g" $ICINGA2_FILE_INFLUXDB_CONF +fi + +if [ ! -z "$ICINGA2_INFLUXDB_PORT" ]; then + echo set new influxdb port + sed -i "s|\(//\)*port = \".*\"|port = $ICINGA2_INFLUXDB_PORT|g" $ICINGA2_FILE_INFLUXDB_CONF +fi + +if [ ! -z "$ICINGA2_INFLUXDB_DB" ]; then + echo set new influxdb database + sed -i "s|\(//\)*database = \".*\"|database = \"$ICINGA2_INFLUXDB_DB\"|g" $ICINGA2_FILE_INFLUXDB_CONF +fi + # run CMD exec "$@" \ No newline at end of file