From 0631b34d211b4e244b23228051bc4cf7f87229d4 Mon Sep 17 00:00:00 2001 From: Ray Ozzie Date: Mon, 21 Mar 2016 21:21:11 -0700 Subject: [PATCH] asdf --- Dockerfile | 4 +- Dockerfile~ | 2 +- install.sh~ | 92 ---------------------------------- install.sh => resin-install.sh | 4 +- start.sh => resin-run.sh | 2 +- start.sh~ | 86 ------------------------------- 6 files changed, 6 insertions(+), 184 deletions(-) delete mode 100755 install.sh~ rename install.sh => resin-install.sh (97%) rename start.sh => resin-run.sh (96%) delete mode 100755 start.sh~ diff --git a/Dockerfile b/Dockerfile index 02d0215..08635ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,10 +8,10 @@ COPY . ~/ttn-gateway # Build the gateway WORKDIR ~/ttn-gateway -RUN ./install.sh +RUN ./resin-install.sh # Make sure we start up within the bin directory WORKDIR /opt/ttn-gateway/bin # Start it up -CMD ["sh", "-c", "./start.sh"] +CMD ["sh", "-c", "./resin-run.sh"] diff --git a/Dockerfile~ b/Dockerfile~ index 8cba6d7..02d0215 100644 --- a/Dockerfile~ +++ b/Dockerfile~ @@ -14,4 +14,4 @@ RUN ./install.sh WORKDIR /opt/ttn-gateway/bin # Start it up -CMD ["sh", "-c", "env && echo && ./start.sh"] +CMD ["sh", "-c", "./start.sh"] diff --git a/install.sh~ b/install.sh~ deleted file mode 100755 index 95d166e..0000000 --- a/install.sh~ +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -# Stop on the first sign of trouble -set -e - -if [ $UID != 0 ]; then - echo "ERROR: Operation not permitted. Forgot sudo?" - exit 1 -fi - -VERSION="master" -if [[ $1 != "" ]]; then VERSION=$1; fi - -echo "The Things Network Gateway installer" -echo "" - -# Check dependencies -echo "Installing dependencies..." -apt-get update -apt-get install swig libftdi-dev python-dev - -# Install LoRaWAN packet forwarder repositories -INSTALL_DIR="/opt/ttn-gateway" -if [ ! -d "$INSTALL_DIR" ]; then mkdir $INSTALL_DIR; fi -pushd $INSTALL_DIR - -# Build libraries -if [ ! -d libmpsse ]; then - git clone https://github.com/devttys0/libmpsse.git - pushd libmpsse/src -else - pushd libmpsse/src - git reset --hard - git pull -fi - -./configure --disable-python -make -make install -ldconfig - -popd - -# Build LoRa gateway app -if [ ! -d lora_gateway ]; then - git clone https://github.com/TheThingsNetwork/lora_gateway.git - pushd lora_gateway -else - pushd lora_gateway - git reset --hard - git pull -fi - -cp ./libloragw/99-libftdi.rules /etc/udev/rules.d/99-libftdi.rules - -sed -i -e 's/CFG_SPI= native/CFG_SPI= ftdi/g' ./libloragw/library.cfg -sed -i -e 's/PLATFORM= kerlink/PLATFORM= lorank/g' ./libloragw/library.cfg -sed -i -e 's/ATTRS{idProduct}=="6010"/ATTRS{idProduct}=="6014"/g' /etc/udev/rules.d/99-libftdi.rules - -make - -popd - -# Build packet forwarder -if [ ! -d packet_forwarder ]; then - git clone https://github.com/TheThingsNetwork/packet_forwarder.git - pushd packet_forwarder -else - pushd packet_forwarder - git pull - git reset --hard -fi - -make - -popd - -# Symlink poly packet forwarder -if [ ! -d bin ]; then mkdir bin; fi -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 - -# Startup shell script - -cp ./start.sh ./bin/start.sh - -# Restore location - -popd - -echo "Installation completed." diff --git a/install.sh b/resin-install.sh similarity index 97% rename from install.sh rename to resin-install.sh index f9e3122..4ca31f8 100755 --- a/install.sh +++ b/resin-install.sh @@ -1,4 +1,4 @@ -#!/bin/bash +!/bin/bash # Stop on the first sign of trouble set -e @@ -87,6 +87,6 @@ popd # Copy startup shell script to the install directory -cp ./start.sh $INSTALL_DIR/bin/start.sh +cp ./resin-run.sh $INSTALL_DIR/bin/resin-run.sh echo "Installation completed." diff --git a/start.sh b/resin-run.sh similarity index 96% rename from start.sh rename to resin-run.sh index d3db064..49eda91 100755 --- a/start.sh +++ b/resin-run.sh @@ -68,7 +68,7 @@ while true echo "[TTN Gateway]: Starting packet forwarder..." ./poly_pkt_fwd echo "******************" - echo "*** [TTN Gateway]: Packet forwarder exited; retrying in 15s..." + echo "*** [TTN Gateway]: EXIT (retrying in 15s)" echo "******************" sleep 15 done diff --git a/start.sh~ b/start.sh~ deleted file mode 100755 index c07955f..0000000 --- a/start.sh~ +++ /dev/null @@ -1,86 +0,0 @@ -#! /bin/bash - -# Display the environment, which is useful when debugging - -echo "**************************************************************" -echo "**************************************************************" -echo "Environment:" -env -echo "**************************************************************" -echo "**************************************************************" -echo "" - -# Configure the global and local configuration files via the environment - -echo "**************************************************************" -echo "**************************************************************" -echo "Gateway Configuration:" -echo "**************************************************************" -echo "**************************************************************" - -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 "**************************************************************" -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}" >./local_conf.json - -# Reset gateway ID based on MAC -../packet_forwarder/reset_pkt_fwd.sh start ./local_conf.json - -# Display gateway ID, which is very important for debugging - -echo "**************************************************************" -echo "**************************************************************" -grep gateway_ID local_conf.json -echo "**************************************************************" -echo "**************************************************************" -echo "" - -# 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..." - sleep 30 - done - -# Fire up the forwarder. -while true - do - echo "[TTN Gateway]: Starting packet forwarder..." - ./poly_pkt_fwd - echo "**************************************************************" - echo "**************************************************************" - echo "[TTN Gateway]: Packet forwarder exited; retrying in 15s..." - echo "**************************************************************" - echo "**************************************************************" - sleep 15 - done