Skip to content

Instantly share code, notes, and snippets.

@glamrock
Created November 21, 2013 15:47
Show Gist options
  • Save glamrock/7584028 to your computer and use it in GitHub Desktop.
Save glamrock/7584028 to your computer and use it in GitHub Desktop.
Internet: Don't use this code, I might be pulling a Rob Ford.
#!/bin/sh
# turn off debugging by default, change to 1 for debug log.
debug=0
wget=$(which wget)
# in the future this should get read with uci
# but since we're not exposing the value to change stick with Commotion default.
json_info_host='127.0.0.1'
json_info_port='9090'
json_info_url="http://$json_info_host:$json_info_port/all/"
node_json=$(echo "\r\n" |nc "$json_info_host" "$json_info_port")
# this needs to get added to the luci config page, but until then
# go with a reasonable expected default.
bb_listener_script_path='bigboard-listener.py'
# check if we're running at all, and exit if not
enabled=$(uci get commotion-dash.@dashboard[0].enabled)
if [ $enabled == 'true' ];then
bb_host=$(uci get commotion-dash.@dashboard[0].gatherer)
bb_host=$(echo "$bb_host" | sed -e 's/http:\/\///')
bb_listener_url="http://$bb_host/$bb_listener_script_path"
if [ "$debug" -eq 1 ]; then
logger -t commotion.dash.bigboard-send -s "Bigboard enabled"
logger -t commotion.dash.bigboard-send -s "$bb_listener_url"
fi
"$wget" -O --post-data="json=$node_json" --header=Content-Type:application/json "$bb_listener_url"
exit 0
# bigboard isn't enabled. just exit
else
if [ "$debug" -eq 1 ]; then
logger -t commotion.dash.bigboard-send -s "Bigboard disabled"
fi
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment