#!/bin/bash # SETUP: apt-get install libxml2-utils wget # cronjob: # */1 * * * * status=`/path/to/chaospott_bbb.sh` && [ "$status" ] && echo $status > /path/to/htdocs/chaospott_bbb.json # ROOM="Chaospott" [ -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 APICallName="getMeetings" APIQueryString="" X=$( bbb-conf --secret | fgrep URL: ) APIEndPoint=${X##* } Y=$( bbb-conf --secret | fgrep Secret: ) Secret=${Y##* } 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}"