41 lines
692 B
Bash
Executable File
41 lines
692 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eu -o pipefail
|
|
|
|
add_user() {
|
|
set -eu
|
|
|
|
keycloak_add_user_script="/opt/jboss/keycloak/bin/add-user-keycloak.sh"
|
|
|
|
if $keycloak_add_user_script -r master -u "$ADMIN_USER" -p "$ADMIN_PASS"; then
|
|
echo "=====> root user added"
|
|
else
|
|
echo "=====> Failed to add root user"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
setup_root_user() {
|
|
set -eu
|
|
|
|
keycloak_add_user_json="/opt/jboss/keycloak/standalone/configuration/keycloak-add-user.json"
|
|
|
|
if [ ! -f "$keycloak_add_user_json" ]; then
|
|
add_user
|
|
else
|
|
if ! grep -q "$ADMIN_USER" "$keycloak_add_user_json"; then
|
|
add_user
|
|
fi
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
set -eu
|
|
|
|
setup_root_user
|
|
}
|
|
|
|
main
|
|
|
|
/opt/jboss/tools/docker-entrypoint.sh "$@"
|