#!/usr/bin/bash

# This setting must go before configure-ironic since it has different defaults.
export IRONIC_USE_MARIADB=${IRONIC_USE_MARIADB:-false}

# shellcheck disable=SC1091
. /bin/configure-ironic.sh

# Ramdisk logs
mkdir -p /shared/log/ironic/deploy

run_ironic_dbsync

if [[ "$IRONIC_TLS_SETUP" == "true" ]] && [[ "${RESTART_CONTAINER_CERTIFICATE_UPDATED}" == "true" ]]; then
    # shellcheck disable=SC2034
    inotifywait -m -e delete_self "${IRONIC_CERT_FILE}" | while read -r file event; do
        kill $(pgrep ironic)
    done &
fi

configure_ironic_auth

exec /usr/bin/ironic
