From ec9e30ea5811a3d314654b4ff7f3a2f47a92fd37 Mon Sep 17 00:00:00 2001 From: Ray Ozzie Date: Mon, 21 Mar 2016 14:20:50 -0700 Subject: [PATCH] asdf --- install.sh | 39 --------------------------------------- install.sh~ | 2 ++ start.sh | 38 ++++++++++++++++++++++++++++++++++++++ start.sh~ | 11 ++++++++++- 4 files changed, 50 insertions(+), 40 deletions(-) diff --git a/install.sh b/install.sh index f8c031a..7fd3781 100755 --- a/install.sh +++ b/install.sh @@ -14,43 +14,6 @@ if [[ $1 != "" ]]; then VERSION=$1; fi echo "The Things Network Gateway installer" echo "" -# Retrieve gateway configuration for later -env - -echo "Configuring gateway:" - -if [[ $GATEWAY_NAME == "" ]]; then - echo "ERROR: NO GATEWAY_NAME FOUND IN ENVIRONMENT" - exit 1 -fi -echo GATEWAY_NAME: $GATEWAY_NAME - -if [[ $GATEWAY_EMAIL == "" ]]; then - echo "ERROR: NO GATEWAY_EMAIL FOUND IN ENVIRONMENT" - exit 1 -fi -echo GATEWAY_EMAIL: $GATEWAY_EMAIL - -if [[ $GATEWAY_LAT == "" ]]; then - echo "ERROR: NO GATEWAY_LAT (latitude) FOUND IN ENVIRONMENT" - exit 1 -fi -echo GATEWAY_LAT: $GATEWAY_LAT - -if [[ $GATEWAY_LON == "" ]]; then - echo "ERROR: NO GATEWAY_LON (longitude) FOUND IN ENVIRONMENT" - exit 1 -fi -echo GATEWAY_LON: $GATEWAY_LON - -if [[ $GATEWAY_ALT == "" ]]; then - echo "ERROR: NO GATEWAY_ALT (altitude) FOUND IN ENVIRONMENT" - exit 1 -fi -echo GATEWAY_ALT: $GATEWAY_ALT - -echo "" - # Check dependencies echo "Installing dependencies..." apt-get update @@ -118,8 +81,6 @@ if [ -f ./bin/poly_pkt_fwd ]; then rm ./bin/poly_pkt_fwd; fi ln -s $INSTALL_DIR/packet_forwarder/poly_pkt_fwd/poly_pkt_fwd ./bin/poly_pkt_fwd cp -f ./packet_forwarder/poly_pkt_fwd/global_conf.json ./bin/global_conf.json -echo -e "{\n\t\"gateway_conf\": {\n\t\t\"gateway_ID\": \"0000000000000000\",\n\t\t\"servers\": [ { \"server_address\": \"croft.thethings.girovito.nl\", \"serv_port_up\": 1700, \"serv_port_down\": 1701, \"serv_enabled\": true } ],\n\t\t\"ref_latitude\": $GATEWAY_LAT,\n\t\t\"ref_longitude\": $GATEWAY_LON,\n\t\t\"ref_altitude\": $GATEWAY_ALT,\n\t\t\"contact_email\": \"$GATEWAY_EMAIL\",\n\t\t\"description\": \"$GATEWAY_NAME\" \n\t}\n}" >./bin/local_conf.json - popd echo "Installation completed." diff --git a/install.sh~ b/install.sh~ index 890f9b2..f8c031a 100755 --- a/install.sh~ +++ b/install.sh~ @@ -15,6 +15,8 @@ echo "The Things Network Gateway installer" echo "" # Retrieve gateway configuration for later +env + echo "Configuring gateway:" if [[ $GATEWAY_NAME == "" ]]; then diff --git a/start.sh b/start.sh index 7bdc839..cc0b05d 100755 --- a/start.sh +++ b/start.sh @@ -1,5 +1,43 @@ #! /bin/bash +# Configure the global and local configuration files via the environment + +echo "Configuring gateway:" + +if [[ $GATEWAY_NAME == "" ]]; then + echo "ERROR: NO GATEWAY_NAME FOUND IN ENVIRONMENT" + exit 1 +fi +echo GATEWAY_NAME: $GATEWAY_NAME + +if [[ $GATEWAY_EMAIL == "" ]]; then + echo "ERROR: NO GATEWAY_EMAIL FOUND IN ENVIRONMENT" + exit 1 +fi +echo GATEWAY_EMAIL: $GATEWAY_EMAIL + +if [[ $GATEWAY_LAT == "" ]]; then + echo "ERROR: NO GATEWAY_LAT (latitude) FOUND IN ENVIRONMENT" + exit 1 +fi +echo GATEWAY_LAT: $GATEWAY_LAT + +if [[ $GATEWAY_LON == "" ]]; then + echo "ERROR: NO GATEWAY_LON (longitude) FOUND IN ENVIRONMENT" + exit 1 +fi +echo GATEWAY_LON: $GATEWAY_LON + +if [[ $GATEWAY_ALT == "" ]]; then + echo "ERROR: NO GATEWAY_ALT (altitude) FOUND IN ENVIRONMENT" + exit 1 +fi +echo GATEWAY_ALT: $GATEWAY_ALT + +echo "" + +echo -e "{\n\t\"gateway_conf\": {\n\t\t\"gateway_ID\": \"0000000000000000\",\n\t\t\"servers\": [ { \"server_address\": \"croft.thethings.girovito.nl\", \"serv_port_up\": 1700, \"serv_port_down\": 1701, \"serv_enabled\": true } ],\n\t\t\"ref_latitude\": $GATEWAY_LAT,\n\t\t\"ref_longitude\": $GATEWAY_LON,\n\t\t\"ref_altitude\": $GATEWAY_ALT,\n\t\t\"contact_email\": \"$GATEWAY_EMAIL\",\n\t\t\"description\": \"$GATEWAY_NAME\" \n\t}\n}" >./bin/local_conf.json + # Reset gateway ID based on MAC ./packet_forwarder/reset_pkt_fwd.sh start ./bin/local_conf.json diff --git a/start.sh~ b/start.sh~ index 6854e2e..7bdc839 100755 --- a/start.sh~ +++ b/start.sh~ @@ -1,5 +1,8 @@ #! /bin/bash +# Reset gateway ID based on MAC +./packet_forwarder/reset_pkt_fwd.sh start ./bin/local_conf.json + # Test the connection, wait if needed. while [[ $(ping -c1 google.com 2>&1 | grep " 0% packet loss") == "" ]]; do echo "[TTN Gateway]: Waiting for internet connection..." @@ -7,4 +10,10 @@ while [[ $(ping -c1 google.com 2>&1 | grep " 0% packet loss") == "" ]]; do done # Fire up the forwarder. -./poly_pkt_fwd \ No newline at end of file +while true + do + echo "[TTN Gateway]: Starting packet forwarder..." + ./poly_pkt_fwd + echo "[TTN Gateway]: Packet forwarder exited; retrying in 15s..." + sleep 15 + done