diff --git a/Dockerfile b/Dockerfile index 92802d2..10cfb05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,8 @@ WORKDIR /ttn-gateway RUN ./build.sh # Copy the run shell script after build, so we can modify it without rebuilding -COPY run.sh /opt/ttn-gateway/bin/run.sh -WORKDIR /opt/ttn-gateway/bin +COPY run.sh /opt/ttn-gateway/run.sh +WORKDIR /opt/ttn-gateway # Start it up CMD ["sh", "-c", "./run.sh"] diff --git a/Dockerfile~ b/Dockerfile~ index 0b2118e..92802d2 100644 --- a/Dockerfile~ +++ b/Dockerfile~ @@ -4,12 +4,13 @@ FROM resin/raspberrypi-buildpack-deps ENV INITSYSTEM on # Build the gateway -COPY resin-install.sh /ttn-gateway/resin-install.sh +COPY build.sh /ttn-gateway/build.sh WORKDIR /ttn-gateway -RUN ./resin-install.sh +RUN ./build.sh # Copy the run shell script after build, so we can modify it without rebuilding -COPY resin-run.sh /opt/ttn-gateway/bin/resin-run.sh +COPY run.sh /opt/ttn-gateway/bin/run.sh +WORKDIR /opt/ttn-gateway/bin # Start it up -CMD ["sh", "-c", "/opt/ttn-gateway/bin/resin-run.sh"] +CMD ["sh", "-c", "./run.sh"] diff --git a/build.sh b/build.sh index 56933f3..4194e4e 100755 --- a/build.sh +++ b/build.sh @@ -70,16 +70,13 @@ make popd -# Copy packet forwarder to where we will need it -if [ -f ./bin/poly_pkt_fwd ]; then rm ./bin/poly_pkt_fwd; fi -cp ./poly_pkt_fwd $INSTALL_DIR/poly_pkt_fwd - # Restore location back to where we started the build - popd -# Delete the build folder so that we save space +# Copy packet forwarder to where we will need it +cp $BUILD_DIR/packet_forwarder/poly_pkt_fwd/poly_pkt_fwd $INSTALL_DIR/poly_pkt_fwd +# Delete the build folder so that we save space rm -rf $BUILD_DIR echo "Build completed." diff --git a/build.sh~ b/build.sh~ index 0ec4818..56933f3 100755 --- a/build.sh~ +++ b/build.sh~ @@ -14,16 +14,16 @@ 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 -#apt-get install swig python-dev +# We will build in a place that we will purge after build, +# and will install just the required files in the appropriate place -# Install LoRaWAN packet forwarder repositories +BUILD_DIR="/tmp/ttn-gateway" INSTALL_DIR="/opt/ttn-gateway" + if [ ! -d "$INSTALL_DIR" ]; then mkdir $INSTALL_DIR; fi -pushd $INSTALL_DIR +if [ ! -d "$BUILD_DIR" ]; then mkdir $BUILD_DIR; fi + +pushd $BUILD_DIR # Build WiringPi if [ ! -d wiringPi ]; then @@ -39,7 +39,7 @@ fi popd -# Build LoRa gateway app +# Build LoRa gateway app for this specific platform if [ ! -d lora_gateway ]; then git clone https://github.com/TheThingsNetwork/lora_gateway.git pushd lora_gateway @@ -50,7 +50,7 @@ else fi sed -i -e 's/PLATFORM= kerlink/PLATFORM= imst_rpi/g' ./libloragw/library.cfg -sed -i -e 's/DEBUG_HAL= 0/DEBUG_HAL= 1/g' ./libloragw/library.cfg +# sed -i -e 's/DEBUG_HAL= 0/DEBUG_HAL= 1/g' ./libloragw/library.cfg make @@ -70,13 +70,16 @@ make popd -# Symlink poly packet forwarder -if [ ! -d bin ]; then mkdir bin; fi +# Copy packet forwarder to where we will need it 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 ./poly_pkt_fwd $INSTALL_DIR/poly_pkt_fwd -# Restore location back to where we started the install +# Restore location back to where we started the build popd -echo "Installation completed." +# Delete the build folder so that we save space + +rm -rf $BUILD_DIR + +echo "Build completed."