-
Notifications
You must be signed in to change notification settings - Fork 42
/
mgmt.sh
executable file
·86 lines (72 loc) · 2.92 KB
/
mgmt.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
RED='\033[1;31m'
GREEN='\033[0;32m'
NOCOLOR='\033[0m'
source .env
#DOMAIN ,REALM TODO
echo "curl \"$MGMT_URL/authentication/\" \
-H 'Content-Type: application/json' \
--data-binary '{ \"strategy\": \"local\", \"email\": \"edumeet-admin@localhost\", \"password\": \"supersecret\" }' -s | jq -r '.accessToken'";
ACCESSTOKEN=$(curl --insecure "$MGMT_URL/authentication/" \
-H 'Content-Type: application/json' \
--data-binary '{ "strategy": "local", "email": "edumeet-admin@localhost", "password": "supersecret" }' -s | jq -r '.accessToken' )
echo -e "
${GREEN}Step 1. get accessToken : ${RED}
$ACCESSTOKEN
${NOCOLOR}
"
if [ -z "${ACCESSTOKEN}" ];
then
echo -e "${RED}ERROR: accessToken emtpy ${NOCOLOR}";
exit;
fi
# Get tennants
echo $(curl --insecure "$MGMT_URL/tenants" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESSTOKEN" -s)
# add tennant
echo -e "
${GREEN}Add tenant : ${NOCOLOR}
curl \"$MGMT_URL/tenants\" \
-H 'Content-Type: application/json' \
-H \"Authorization: Bearer $ACCESSTOKEN\" \
--data-binary '{\"name\":\"dev\"}'
"
# Get fqdn
echo $(curl --insecure "$MGMT_URL/tenantFQDNs" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESSTOKEN" -s)
#add fqdn
echo -e "
${GREEN}Add fqdn : ${NOCOLOR}
curl \"$MGMT_URL/tenantFQDNs\" \
-H 'Content-Type: application/json' \
-H \"Authorization: Bearer $ACCESSTOKEN\" \
--data-binary '{\"tenantId\":1,\"fqdn\":\"${MAIN_DOMAIN}\"}'
"
# Get tenantOAuths
echo $(curl --insecure "$MGMT_URL/tenantOAuths" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESSTOKEN" -s)
echo -e "
${GREEN}Add tenantOAuths : ${NOCOLOR}
curl \"$MGMT_URL/tenantOAuths\" \
-H 'Content-Type: application/json' \
-H \"Authorization: Bearer $ACCESSTOKEN\" \
--data-binary '{ \"tenantId\":1,\"key\":\"edumeet-dev-client\",\"secret\":\"1MAJARGQM0nYhSmRNDSHCLIgBfuZXkv6\", \"authorize_url\":\"https://${MAIN_DOMAIN}/kc/realms/dev/protocol/openid-connect/auth\",\"access_url\":\"https://${MAIN_DOMAIN}/kc/realms/dev/protocol/openid-connect/token\",\"profile_url\": \"https://${MAIN_DOMAIN}/kc/realms/dev/protocol/openid-connect/userinfo\",\"redirect_uri\": \"https://${MAIN_DOMAIN}/mgmt/oauth/tenant/callback\",\"scope\":\"openid profile email\",\"scope_delimiter\":\" \"}'
"
# get rooms
curl --insecure "$MGMT_URL/rooms" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESSTOKEN"
# add room
echo -e "
${GREEN}Add room (with the user jwt token): ${NOCOLOR}
curl '"$MGMT_URL/rooms"' \\
-H 'Content-Type: application/json' \\
-H '"Authorization: Bearer $ACCESSTOKEN"' \\
--data-binary '{ \"name\": \"testroom2\",\"description\": \"testdesc\",\"maxActiveVideos\":4, \"tenantId\":1}'
"
exit;
# for patching
# curl --request PATCH