-
Notifications
You must be signed in to change notification settings - Fork 0
/
sip-inbound-start.sh
74 lines (69 loc) · 2.17 KB
/
sip-inbound-start.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
#!/usr/bin/bash
set -e
# -----------------------------------------------------------------------------
# Warning:
# This script only works for jibri newer than 8.0-140-gccc7278-1
#
# Packages:
# apt-get install curl jq
#
# Usage:
# export JITSI_HOST="https://jitsi.nordeck.corp"
# export JITSI_ROOM="myroom"
# export INVITER_USERNAME="[email protected]"
# #export INVITER_USERNAME="[email protected]:5060;transport=tcp"
# export INVITER_PASSWORD="1234"
# export INVITER_CONTACT="<sip:[email protected]:5060;transport=udp>"
# #export INVITER_CONTACT="<sip:[email protected]:5060;transport=tcp>"
# export PRIVATE_KEY_FILE="./signal.key"
#
# bash sip-inbound-start.sh <INVITEE>
#
# Example:
# bash sip-inbound-start.sh "sip:[email protected]"
# ------------------------------------------------------------------------------
[[ -z "$PRIVATE_KEY_FILE" ]] && PRIVATE_KEY_FILE="./signal.key" || true
INVITEE="$1"
DISPLAY_NAME=$(echo $INVITEE | cut -d: -f2 | cut -d@ -f1)
AUTO_ANSWER_TIMEOUT=30
JSON=$(cat <<EOF
{
"callParams": {
"callUrlInfo": {
"baseUrl": "$JITSI_HOST",
"callName": "$JITSI_ROOM"
}
},
"componentParams": {
"type": "SIP-JIBRI",
"region": "default-region",
"environment": "default-env"
},
"metadata": {
"sipClientParams": {
"userName": "$INVITER_USERNAME",
"password": "$INVITER_PASSWORD",
"contact": "$INVITER_CONTACT",
"sipAddress": "$INVITEE",
"displayName": "$DISPLAY_NAME",
"autoAnswer": true,
"autoAnswerTimer": $AUTO_ANSWER_TIMEOUT
}
}
}
EOF
)
# generate the bearer token
HEADER=$(echo -n '{"alg":"RS256","typ":"JWT","kid":"jitsi/signal"}' | \
base64 | tr '+/' '-_' | tr -d '=\n')
PAYLOAD=$(echo -n '{"iss":"signal","aud":"jitsi-component-selector"}' | \
base64 | tr '+/' '-_' | tr -d '=\n')
SIGN=$(echo -n "$HEADER.$PAYLOAD" | \
openssl dgst -sha256 -binary -sign $PRIVATE_KEY_FILE | \
openssl enc -base64 | tr '+/' '-_' | tr -d '=\n')
TOKEN="$HEADER.$PAYLOAD.$SIGN"
curl -sk \
-X POST $JITSI_HOST/jitsi-component-selector/sessions/start \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data @- <<< $JSON | jq '.'