diff --git a/resin-run.sh b/resin-run.sh index c4f9091..2bc763f 100755 --- a/resin-run.sh +++ b/resin-run.sh @@ -58,6 +58,18 @@ else exit 1 fi +# fetch location info, which we'll use as a hint to the gateway software + +if curl -sS --fail ipinfo.io --output ./ipinfo.json +then + echo "Gateway Location:" + IPINFO=$(cat ./ipinfo.json) + echo $IPINFO +else + echo "Unable to determine gateway location" + IPINFO="\"\"" +fi + # set up environmental defaults for local.conf if [[ $GW_GPS == "" ]]; then GW_GPS="true"; fi @@ -118,9 +130,9 @@ echo -e "{\n\ \t\t\"ghoststream\": $GW_GHOSTSTREAM,\n\ \t\t\"radiostream\": $GW_RADIOSTREAM,\n\ \t\t\"statusstream\": $GW_STATUSSTREAM,\n\ -\t\t\"server_address\": $GW_SERVER_ADDRESS,\n\ -\t\t\"serv_port_up\": $GW_SERV_PORT_UP,\n\ -\t\t\"serv_port_down\": $GW_SERV_PORT_DOWN,\n\ +# \t\t\"server_address\": $GW_SERVER_ADDRESS,\n\ +# \t\t\"serv_port_up\": $GW_SERV_PORT_UP,\n\ +# \t\t\"serv_port_down\": $GW_SERV_PORT_DOWN,\n\ \t\t\"keepalive_interval\": $GW_KEEPALIVE_INTERVAL,\n\ \t\t\"stat_interval\": $GW_STAT_INTERVAL,\n\ \t\t\"push_timeout_ms\": $GW_PUSH_TIMEOUT_MS,\n\ @@ -139,6 +151,7 @@ echo -e "{\n\ \t\t\"ngrok_path\": $GW_NGROK_PATH,\n\ \t\t\"system_calls\": $GW_SYSTEM_CALLS,\n\ \t\t\"platform\": $GW_PLATFORM,\n\ +\t\t\"ipinfo\": $IPINFO,\n\ \t\t\"gateway_ID\": \"0000000000000000\"\n\ \t}\n\ }" >./local_conf.json diff --git a/resin-run.sh~ b/resin-run.sh~ index b73f861..c4f9091 100755 --- a/resin-run.sh~ +++ b/resin-run.sh~ @@ -69,7 +69,7 @@ if [[ $GW_GHOSTSTREAM == "" ]]; then GW_GHOSTSTREAM="false"; fi if [[ $GW_RADIOSTREAM == "" ]]; then GW_RADIOSTREAM="true"; fi if [[ $GW_STATUSSTREAM == "" ]]; then GW_STATUSSTREAM="true"; fi -if [[ $GW_SERVER_ADDRESS == "" ]]; then GW_SERVER_ADDRESS="127.0.0.1"; fi +if [[ $GW_SERVER_ADDRESS == "" ]]; then GW_SERVER_ADDRESS="\"127.0.0.1\""; fi if [[ $GW_SERV_PORT_UP == "" ]]; then GW_SERV_PORT_UP="1600"; fi if [[ $GW_SERV_PORT_DOWN == "" ]]; then GW_SERV_PORT_DOWN="1601"; fi @@ -81,25 +81,25 @@ if [[ $GW_FORWARD_CRC_VALID == "" ]]; then GW_FORWARD_CRC_VALID="true"; fi if [[ $GW_FORWARD_CRC_ERROR == "" ]]; then GW_FORWARD_CRC_ERROR="false"; fi if [[ $GW_FORWARD_CRC_DISABLED == "" ]]; then GW_FORWARD_CRC_DISABLED="false"; fi -if [[ $GW_GPS_TTY_PATH == "" ]]; then GW_GPS_TTY_PATH="/dev/ttyAMA0"; fi +if [[ $GW_GPS_TTY_PATH == "" ]]; then GW_GPS_TTY_PATH="\"/dev/ttyAMA0\""; fi if [[ $GW_FAKE_GPS == "" ]]; then GW_FAKE_GPS="true"; fi -if [[ $GW_GHOST_ADDRESS == "" ]]; then GW_GHOST_ADDRESS="127.0.0.1"; fi +if [[ $GW_GHOST_ADDRESS == "" ]]; then GW_GHOST_ADDRESS="\"127.0.0.1\""; fi if [[ $GW_GHOST_PORT == "" ]]; then GW_GHOST_PORT="1918"; fi -if [[ $GW_MONITOR_ADDRESS == "" ]]; then GW_MONITOR_ADDRESS="127.0.0.1"; fi +if [[ $GW_MONITOR_ADDRESS == "" ]]; then GW_MONITOR_ADDRESS="\"127.0.0.1\""; fi if [[ $GW_MONITOR_PORT == "" ]]; then GW_MONITOR_PORT="2008"; fi -if [[ $GW_SSH_PATH == "" ]]; then GW_SSH_PATH="/usr/bin/ssh"; fi +if [[ $GW_SSH_PATH == "" ]]; then GW_SSH_PATH="\"/usr/bin/ssh\""; fi if [[ $GW_SSH_PORT == "" ]]; then GW_SSH_PORT="22"; fi if [[ $GW_HTTP_PORT == "" ]]; then GW_HTTP_PORT="80"; fi -if [[ $GW_NGROK_PATH == "" ]]; then GW_NGROK_PATH="/usr/bin/ngrok"; fi +if [[ $GW_NGROK_PATH == "" ]]; then GW_NGROK_PATH="\"/usr/bin/ngrok\""; fi if [[ $GW_SYSTEM_CALLS == "" ]]; then GW_SYSTEM_CALLS="[\"df -m\",\"free -h\",\"uptime\",\"who -a\",\"uname -a\"]"; fi -if [[ $GW_PLATFORM == "" ]]; then GW_PLATFORM="*"; fi +if [[ $GW_PLATFORM == "" ]]; then GW_PLATFORM="\"*\""; fi # create local.conf