Files
icingaweb2/init.sh
anima c6247cbbea
All checks were successful
build container icingaweb2 / build (push) Successful in 4m4s
chmod after init copy
2025-02-01 22:59:23 +01:00

53 lines
1.6 KiB
Bash

#!/bin/bash
ICINGAWEB2_FILE_APACHE_DEFAULT=/etc/apache2/sites-available/000-default.conf
ICINGAWEB2_FILE_APACHE_PORTS=/etc/apache2/ports.conf
ICINGAWEB2_PORT=8080
## init icinga config files if need
if [ -z "$(ls -A /data)" ]; then
# enable python script for inital deployments
ICINGAWEB2_CONF_ONCE=false
export INIT_DB=true
## move init files
echo init icingaweb2 config
cp -ax /data-init/* /data
rm -rf /data-init
chmod -R 33:33 /data
## check if a var exist they is must have for deployment
## because without this check, moduls init everytime and this blocks /setup page
if [ ! -z "$ICINGAWEB2_DEFAULT_ADMIN_USER" ]; then
## enable modules
icingacli module enable icingadb
mkdir -p /etc/icingaweb2/modules/icingadb/
icingacli module enable grafana
mkdir -p /etc/icingaweb2/modules/grafana/
else
## print setup token because no auto deployment will run
icingacli setup token create;
fi
fi
## apache setup
if [ ! -z "$ICINGAWEB2_PORT" ]; then
echo set icingaweb2 apache ports
sed -i "s|^Listen .*|Listen $ICINGAWEB2_PORT|" $ICINGAWEB2_FILE_APACHE_PORTS
sed -i "s|VirtualHost \*:.*>|VirtualHost \*:$ICINGAWEB2_PORT>|g" $ICINGAWEB2_FILE_APACHE_DEFAULT
fi
## edit icingaweb2 config only on first setup or is enabled
if { [ -z "${ICINGAWEB2_CONF_ONCE+x}" ] || [ "$ICINGAWEB2_CONF_ONCE" = "false" ]; } \
&& [ -n "${ICINGAWEB2_DEFAULT_ADMIN_USER+x}" ]; then
/usr/bin/python3 /root/conf_icingaweb2.py
fi
## init apache
. /etc/apache2/envvars
# icinga2 daemon -C -X ?
# run CMD
exec "$@"