Skip to content

Commit

Permalink
scripts, feat: recording-stop.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
emrahcom committed Mar 1, 2024
1 parent 1995cdd commit 0c0d3f1
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions scripts/jitsi-component-selector/recording-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/bash
set -e

# -----------------------------------------------------------------------------
# Packages:
# apt-get install curl
#
# Usage:
# export SELECTOR_HOST="http://172.17.17.1:8015"
# export JITSI_HOST="https://jitsi.mydomain.corp"
# export JITSI_ROOM="myroom"
# export PRIVATE_KEY_FILE="/some-path/asap-signal.key"
#
# bash recording-stop.sh <SESSION_ID>
# ------------------------------------------------------------------------------
[[ -z "$PRIVATE_KEY_FILE" ]] && \
PRIVATE_KEY_FILE="../../files/asap/asap.key" || \
true

SESSION_ID="$1"

JSON=$(cat <<EOF
{
"sessionId": "$SESSION_ID",
"callParams": {
"callUrlInfo": {
"baseUrl": "$JITSI_HOST",
"callName": "$JITSI_ROOM"
}
},
"metadata": {
"sinkType": "FILE"
}
}
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 $SELECTOR_HOST/jitsi-component-selector/sessions/stop \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data @- <<< $JSON

0 comments on commit 0c0d3f1

Please sign in to comment.