-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6141df9
commit 12bff40
Showing
4 changed files
with
71 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
/opt/jboss/keycloak/bin/add-user-keycloak.sh -r sirixdb -u admin -p admin --roles create,modify,delete,view | ||
#!/bin/bash | ||
|
||
KEYCLOAK_HOME="/opt/keycloak" | ||
REALM="sirixdb" | ||
USERNAME="admin" | ||
PASSWORD="admin" | ||
ROLES="create,modify,delete,view" | ||
|
||
user_exists() { | ||
$KEYCLOAK_HOME/bin/kcadm.sh get users -r "$REALM" -q "username=$USERNAME" --fields username | grep -q "\"username\" : \"$USERNAME\"" | ||
} | ||
|
||
$KEYCLOAK_HOME/bin/kcadm.sh config credentials --server http://localhost:8080 --realm master --user "$USERNAME" --password "$PASSWORD" | ||
|
||
if user_exists; then | ||
echo "User '$USERNAME' already exists in realm '$REALM'." | ||
else | ||
if $KEYCLOAK_HOME/bin/kcadm.sh create users -r "$REALM" -s username="$USERNAME" -s enabled=true && \ | ||
$KEYCLOAK_HOME/bin/kcadm.sh set-password -r "$REALM" --username "$USERNAME" --new-password "$PASSWORD" && \ | ||
for role in $(echo $ROLES | tr "," "\n"); do | ||
$KEYCLOAK_HOME/bin/kcadm.sh add-roles -r "$REALM" --uusername "$USERNAME" --rolename "$role" | ||
done; then | ||
echo "User '$USERNAME' added to realm '$REALM'." | ||
else | ||
echo "Failed to add user '$USERNAME' to realm '$REALM'." | ||
exit 1 | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Start Keycloak in the background | ||
/opt/keycloak/bin/kc.sh "$@" & | ||
|
||
# Wait for Keycloak to be ready | ||
until curl -sf http://localhost:8080 > /dev/null; do | ||
echo "Waiting for Keycloak to be ready..." | ||
sleep 5 | ||
done | ||
|
||
# Keycloak is ready, run the create-sirix-users.sh script | ||
/opt/keycloak/scripts/create-sirix-users.sh | ||
|
||
# Keep the container running | ||
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters