From f224e974b071e3590999d030bcee8f52b6317044 Mon Sep 17 00:00:00 2001 From: anima Date: Sun, 2 Feb 2025 21:13:57 +0100 Subject: [PATCH] remove api setup because master init do it --- init.sh | 50 ++++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/init.sh b/init.sh index 9d3be9c..a054517 100644 --- a/init.sh +++ b/init.sh @@ -25,37 +25,31 @@ if [ -z "$(ls -A /data)" ]; then fi -## init api user -if [ ! -f "$ICINGA2_FILE_API_CONF" ]; then - echo run api setup because no config exists - /usr/sbin/icinga2 api setup +## 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 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 + echo set inital icingadb api user + echo 'object ApiUser "icingaweb2" {' >> $ICINGA2_FILE_API_USER_CONF + echo " password = \"$ICINGA2_API_USER_ICINGAWEB_PASS\"" >> $ICINGA2_FILE_API_USER_CONF + echo ' permissions = [ "status/query", "actions/*", "objects/modify/*", "objects/query/*" ]' >> $ICINGA2_FILE_API_USER_CONF + echo '}' >> $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 - echo set inital icingadb api user - echo 'object ApiUser "icingaweb2" {' >> $ICINGA2_FILE_API_USER_CONF - echo " password = \"$ICINGA2_API_USER_ICINGAWEB_PASS\"" >> $ICINGA2_FILE_API_USER_CONF - echo ' permissions = [ "status/query", "actions/*", "objects/modify/*", "objects/query/*" ]' >> $ICINGA2_FILE_API_USER_CONF - echo '}' >> $ICINGA2_FILE_API_USER_CONF - fi +## only on inital setup create a pki-ticket api user if env var is set +## permission source: https://icinga.com/docs/icinga-2/latest/doc/06-distributed-monitoring/#csr-auto-signing-on-the-master +if [ ! -z "$ICINGA2_API_USER_SATELLITE_PASS" ]; then + echo set inital icingadb api user + echo 'object ApiUser "pki-ticket" {' >> $ICINGA2_FILE_API_USER_CONF + echo " password = \"$ICINGA2_API_USER_SATELLITE_PASS\"" >> $ICINGA2_FILE_API_USER_CONF + echo ' permissions = [ "actions/generate-ticket" ]' >> $ICINGA2_FILE_API_USER_CONF + echo '}' >> $ICINGA2_FILE_API_USER_CONF - ## only on inital setup create a pki-ticket api user if env var is set - ## permission source: https://icinga.com/docs/icinga-2/latest/doc/06-distributed-monitoring/#csr-auto-signing-on-the-master - if [ ! -z "$ICINGA2_API_USER_SATELLITE_PASS" ]; then - echo set inital icingadb api user - echo 'object ApiUser "pki-ticket" {' >> $ICINGA2_FILE_API_USER_CONF - echo " password = \"$ICINGA2_API_USER_SATELLITE_PASS\"" >> $ICINGA2_FILE_API_USER_CONF - echo ' permissions = [ "actions/generate-ticket" ]' >> $ICINGA2_FILE_API_USER_CONF - echo '}' >> $ICINGA2_FILE_API_USER_CONF - - fi fi ## enable icingadb feature if not active