#!/usr/bin/bash

export IRONIC_DEPLOYMENT="API"
export IRONIC_HTTPD=${IRONIC_HTTPD:-"false"}

. /bin/configure-ironic.sh

if [ "$IRONIC_HTTPD" == "true" ]; then
    python3 -c 'import os; import sys; import jinja2; sys.stdout.write(jinja2.Template(sys.stdin.read()).render(env=os.environ))' < /etc/httpd-ironic-api.conf.j2 > /etc/httpd/conf.d/ironic.conf

    . /bin/runhttpd
else
    exec /usr/bin/ironic-api --config-file /usr/share/ironic/ironic-dist.conf ${IRONIC_CONFIG_OPTIONS}
fi
