-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdemo.sh
executable file
·46 lines (38 loc) · 1.57 KB
/
demo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# Set up keycloak and a mqtt service to test the event listener manually.
# Set env variable KEYCLOAK_VERSION to any version you would like to
# test the listener against (it must be Quarkus-based so > 17)
# TODO support docker and choose the runtime to use automatically
echo "Building event listener provider ..."
mvn clean install
echo "Done."
echo
echo "Building keycloak with event listener ..."
podman build -t test_kc_event_listener --build-arg KEYCLOAK_VERSION=${KEYCLOAK_VERSION:-22.0} -f testing/Dockerfile .
echo "Done."
echo
echo "Starting compose ..."
podman-compose -f testing/docker-compose.yaml up -d
echo
echo "Waiting for keycloak to start ..."
until curl -s -f -o /dev/null http://localhost:8082/health/ready
do
echo "."
sleep 5
done
echo "Ready."
echo "Configuring mqtt event listener on master realm ..."
podman exec -ti testing_keycloak_1 /opt/keycloak/bin/kcadm.sh update events/config \
--target-realm master --set 'eventsListeners=["jboss-logging", "mqtt"]' \
--set eventsEnabled=true --set enabledEventTypes=[] \
--no-config --user admin --realm master --server http://localhost:8082 --password kcadmin
echo "Done."
echo
echo "To subscribe to published events:"
echo " mosquitto_sub -h localhost -u mqtt -P mqtt -t 'keycloak'"
echo
echo "To trigger a login event:"
echo " podman exec -ti testing_keycloak_1 /opt/keycloak/bin/kcadm.sh get users --target-realm master --no-config --user admin --realm master --server http://localhost:8082 --password kcadmin"
echo
echo "To kill the compose:"
echo " podman-compose -f testing/docker-compose.yaml down"