This commit is contained in:
Ray Ozzie 2016-03-22 11:09:32 -07:00
parent 30d77be52f
commit 14fe106886
2 changed files with 47 additions and 15 deletions

View File

@ -16,36 +16,41 @@ echo "******************"
if [[ $GATEWAY_REGION == "" ]]; then
echo "ERROR: NO GATEWAY_REGION FOUND IN ENVIRONMENT"
exit 1
while true; do sleep 10; done
fi
echo GATEWAY_REGION: $GATEWAY_REGION
if [[ $GATEWAY_NAME == "" ]]; then
echo "ERROR: NO GATEWAY_NAME FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_NAME: $GATEWAY_NAME
if [[ $GATEWAY_EMAIL == "" ]]; then
echo "ERROR: NO GATEWAY_EMAIL FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_EMAIL: $GATEWAY_EMAIL
if [[ $GATEWAY_LAT == "" ]]; then
echo "ERROR: NO GATEWAY_LAT (latitude) FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_LAT: $GATEWAY_LAT
if [[ $GATEWAY_LON == "" ]]; then
echo "ERROR: NO GATEWAY_LON (longitude) FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_LON: $GATEWAY_LON
if [[ $GATEWAY_ALT == "" ]]; then
echo "ERROR: NO GATEWAY_ALT (altitude) FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_ALT: $GATEWAY_ALT
@ -55,15 +60,14 @@ echo ""
# load the region-appropriate global conf
echo eval curl "https://raw.githubusercontent.com/rayozzie/ttn-gateway-conf/master/$GATEWAY_REGION-global-conf.json --output ./global-conf.json
eval curl "https://raw.githubusercontent.com/rayozzie/ttn-gateway-conf/master/$GATEWAY_REGION-global-conf.json --output ./global-conf.json
err=$?
if [ $err -ne 0 ]
if curl --fail "https://raw.githubusercontent.com/rayozzie/ttn-gateway-conf/master/$GATEWAY_REGION-global-conf.json --output ./global-conf.json
then
sleep 1
else
echo "******************"
echo "ERROR: GATEWAY_REGION not found: $err"
echo "ERROR: GATEWAY_REGION not found"
echo "******************"
while true; do sleep 10; done # don't exit in resin
exit 1
fi

View File

@ -14,32 +14,43 @@ echo "******************"
echo "*** Configuration:"
echo "******************"
if [[ $GATEWAY_REGION == "" ]]; then
echo "ERROR: NO GATEWAY_REGION FOUND IN ENVIRONMENT"
while true; do sleep 10; done
fi
echo GATEWAY_REGION: $GATEWAY_REGION
if [[ $GATEWAY_NAME == "" ]]; then
echo "ERROR: NO GATEWAY_NAME FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_NAME: $GATEWAY_NAME
if [[ $GATEWAY_EMAIL == "" ]]; then
echo "ERROR: NO GATEWAY_EMAIL FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_EMAIL: $GATEWAY_EMAIL
if [[ $GATEWAY_LAT == "" ]]; then
echo "ERROR: NO GATEWAY_LAT (latitude) FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_LAT: $GATEWAY_LAT
if [[ $GATEWAY_LON == "" ]]; then
echo "ERROR: NO GATEWAY_LON (longitude) FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_LON: $GATEWAY_LON
if [[ $GATEWAY_ALT == "" ]]; then
echo "ERROR: NO GATEWAY_ALT (altitude) FOUND IN ENVIRONMENT"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
echo GATEWAY_ALT: $GATEWAY_ALT
@ -47,6 +58,23 @@ echo GATEWAY_ALT: $GATEWAY_ALT
echo "******************"
echo ""
# load the region-appropriate global conf
echo eval curl "https://raw.githubusercontent.com/rayozzie/ttn-gateway-conf/master/$GATEWAY_REGION-global-conf.json --output ./global-conf.json
eval curl "https://raw.githubusercontent.com/rayozzie/ttn-gateway-conf/master/$GATEWAY_REGION-global-conf.json --output ./global-conf.json
err=$?
if [ $err -ne 0 ]
then
echo "******************"
echo "ERROR: GATEWAY_REGION not found: $err"
echo "******************"
while true; do sleep 10; done # don't exit in resin
exit 1
fi
# create local.conf
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}" >./local_conf.json
# Reset gateway ID based on MAC