2021-02-16 22:27:45 +00:00
|
|
|
#!/bin/bash
|
2021-02-17 00:05:31 +00:00
|
|
|
# SETUP:
|
|
|
|
# apt-get install libxml2-utils wget
|
|
|
|
# fill in APIEndPoint and Secret from bbb-conf --secret, or run as root
|
|
|
|
# set up cronjob:
|
2021-02-16 22:27:45 +00:00
|
|
|
# */1 * * * * status=`/path/to/chaospott_bbb.sh` && [ "$status" ] && echo $status > /path/to/htdocs/chaospott_bbb.json
|
2021-02-17 00:05:31 +00:00
|
|
|
# make JSON file available, e.g. in /var/www/bigbluebutton-default/
|
2021-02-16 22:27:45 +00:00
|
|
|
#
|
2021-02-17 00:05:31 +00:00
|
|
|
# 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
|
2021-02-16 22:27:45 +00:00
|
|
|
|
|
|
|
ROOM="Chaospott"
|
2021-02-17 00:05:31 +00:00
|
|
|
APIEndPoint=""
|
|
|
|
SECRET=""
|
2021-02-16 22:27:45 +00:00
|
|
|
|
|
|
|
[ -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
|
|
|
|
|
2021-02-17 00:05:31 +00:00
|
|
|
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
|
|
|
|
|
2021-02-16 22:27:45 +00:00
|
|
|
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}"
|