diff --git a/Dockerfile b/Dockerfile index e5c809a..0703bae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,14 +8,12 @@ ENV INITSYSTEM on # and thus forces a full rebuild. Not used outside of Dockerfile.) ENV TTN_GATEWAY_SOFTWARE 48 -# Build the gateway -COPY build.sh /opt/ttn-gateway/dev/build.sh -WORKDIR /opt/ttn-gateway/dev -RUN ./build.sh && rm -rf /opt/ttn-gateway/dev +# Copy the build and run environment +COPY . /opt/ttn-gateway/ +WORKDIR /opt/ttn-gateway/ -# Copy the run shell script after build, so we can modify it without rebuilding -COPY run.sh /opt/ttn-gateway/run.sh -WORKDIR /opt/ttn-gateway +# Build the gateway (or comment this out if debugging on-device) +RUN ./dev/build.sh && rm -rf ./dev # Start it up CMD ["sh", "-c", "./run.sh"] diff --git a/build.sh b/dev/build.sh similarity index 95% rename from build.sh rename to dev/build.sh index 2ed16e2..7b9d5cb 100755 --- a/build.sh +++ b/dev/build.sh @@ -65,7 +65,7 @@ popd popd # Copy things needed at runtime to where they'll be expected -cp $BUILD_DIR/packet_forwarder/reset_pkt_fwd.sh $INSTALL_DIR/reset_pkt_fwd.sh -cp $BUILD_DIR/packet_forwarder/poly_pkt_fwd/poly_pkt_fwd $INSTALL_DIR/poly_pkt_fwd +cp $BUILD_DIR/packet_forwarder/reset_pkt_fwd.sh $INSTALL_DIR/set-gateway-id.sh +cp $BUILD_DIR/packet_forwarder/poly_pkt_fwd/poly_pkt_fwd $INSTALL_DIR/ttn-gateway echo "Build & Installation Completed." diff --git a/run.sh b/run.sh index 771258c..af846f1 100755 --- a/run.sh +++ b/run.sh @@ -1,5 +1,12 @@ #! /bin/bash +# Exit if we're debugging and haven't yet built the gateway + +if [ ! -f "ttn-gateway" ]; then + echo "ERROR: gateway executable not yet built" + exit 1 +fi + # We need to be online, wait if needed. while [[ $(ping -c1 google.com 2>&1 | grep " 0% packet loss") == "" ]]; do @@ -153,7 +160,7 @@ echo -e "{\n\ # Set gateway_ID in local_conf.json to the gateway's MAC address echo "******************" -./reset_pkt_fwd.sh start ./local_conf.json +./set-gateway-id.sh start ./local_conf.json echo "******************" echo "" @@ -172,7 +179,7 @@ sleep 0.1 while true do echo "[TTN Gateway]: Starting packet forwarder..." - ./poly_pkt_fwd + ./ttn-gateway echo "******************" echo "*** [TTN Gateway]: EXIT (retrying in 15s)" echo "******************"