chaospott_mumble/chaospott_bbb.sh

55 lines
1.8 KiB
Bash

#!/bin/bash
# SETUP:
# apt-get install libxml2-utils wget
# fill in APIEndPoint and Secret from bbb-conf --secret, or run as root
# set up cronjob:
# */1 * * * * status=`/path/to/chaospott_bbb.sh` && [ "$status" ] && echo $status > /path/to/htdocs/chaospott_bbb.json
# make JSON file available, e.g. in /var/www/bigbluebutton-default/
#
# should output something like
# {"active": true, "participantCount": 1, "startTime": 1613519724738}
# if room is active, or
# {"active": false, "participantCount": 0, "startTime": 0}
# if room is inactive
ROOM="Chaospott"
APIEndPoint=""
SECRET=""
[ -z `which xmllint` ] && exit 1
if which wget >/dev/null; then
CLIENT="wget -q -O -";
elif which curl >/dev/null; then
CLIENT="curl -s";
else
exit 1;
fi
if [ -z "$APIEndPoint" ]; then
X=$( bbb-conf --secret | fgrep URL: )
APIEndPoint=${X##* }
fi
if [ -z "$Secret" ]; then
Y=$( bbb-conf --secret | fgrep Secret: )
Secret=${Y##* }
fi
APICallName="getMeetings"
APIQueryString=""
S=$APICallName$APIQueryString$Secret
Checksum=$( echo -n $S | sha1sum | cut -f 1 -d ' ' )
if [[ "$APIQueryString" == "" ]]
then
URL="${APIEndPoint}api/$APICallName?checksum=$Checksum"
else
URL="${APIEndPoint}api/$APICallName?$APIQueryString&checksum=$Checksum"
fi
RESPONSE=`$CLIENT "$URL"`
active=`echo $RESPONSE | xmllint --xpath "string(//meeting[meetingName='$ROOM'])" -`
[ -z "$active" ] && active="false" || active="true"
participantcount=`echo $RESPONSE | xmllint --xpath "string(//meeting[meetingName='$ROOM']/participantCount)" -`
[ -z "$participantcount" ] && participantcount=0
starttime=`echo $RESPONSE | xmllint --xpath "string(//meeting[meetingName='$ROOM']/startTime)" -`
[ -z "$starttime" ] && starttime=0
echo "{\"active\": $active, \"participantCount\": $participantcount, \"startTime\": $starttime}"