#!/bin/bash
set -e

if [ -d /opt/import ];then
    if [ ! -f /opt/kcsetup/realm-imported ];then
        echo "Importing realm from /opt/import..."
        /opt/keycloak/bin/kc.sh import --dir /opt/import
        touch /opt/kcsetup/realm-imported
    else
        echo "Realm already imported!"
    fi
fi

exec /opt/keycloak/bin/kc.sh "$@"
