2016-03-25 13:25:45 +00:00
|
|
|
#! /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 ""
|
|
|
|
|
2016-03-25 14:14:19 +00:00
|
|
|
# We will build in a place that we will purge after build,
|
|
|
|
# and will install just the required files in the appropriate place
|
2016-03-25 13:25:45 +00:00
|
|
|
|
2016-03-25 14:14:19 +00:00
|
|
|
BUILD_DIR="/tmp/ttn-gateway"
|
2016-03-25 13:25:45 +00:00
|
|
|
INSTALL_DIR="/opt/ttn-gateway"
|
2016-03-25 14:14:19 +00:00
|
|
|
|
2016-03-25 13:25:45 +00:00
|
|
|
if [ ! -d "$INSTALL_DIR" ]; then mkdir $INSTALL_DIR; fi
|
2016-03-25 14:14:19 +00:00
|
|
|
if [ ! -d "$BUILD_DIR" ]; then mkdir $BUILD_DIR; fi
|
|
|
|
|
|
|
|
pushd $BUILD_DIR
|
2016-03-25 13:25:45 +00:00
|
|
|
|
2016-03-25 14:06:47 +00:00
|
|
|
# Build WiringPi
|
|
|
|
if [ ! -d wiringPi ]; then
|
|
|
|
git clone git://git.drogon.net/wiringPi
|
|
|
|
pushd wiringPi
|
2016-03-25 13:25:45 +00:00
|
|
|
else
|
2016-03-25 14:06:47 +00:00
|
|
|
pushd wiringPi
|
2016-03-25 13:25:45 +00:00
|
|
|
git reset --hard
|
|
|
|
git pull
|
|
|
|
fi
|
|
|
|
|
2016-03-25 14:06:47 +00:00
|
|
|
./build
|
2016-03-25 13:25:45 +00:00
|
|
|
|
|
|
|
popd
|
|
|
|
|
2016-03-25 14:14:19 +00:00
|
|
|
# Build LoRa gateway app for this specific platform
|
2016-03-25 13:25:45 +00:00
|
|
|
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
|
|
|
|
|
2016-03-25 14:06:47 +00:00
|
|
|
sed -i -e 's/PLATFORM= kerlink/PLATFORM= imst_rpi/g' ./libloragw/library.cfg
|
2016-03-25 14:14:19 +00:00
|
|
|
# sed -i -e 's/DEBUG_HAL= 0/DEBUG_HAL= 1/g' ./libloragw/library.cfg
|
2016-03-25 13:25:45 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-03-25 14:14:19 +00:00
|
|
|
# Copy packet forwarder to where we will need it
|
2016-03-25 13:25:45 +00:00
|
|
|
if [ -f ./bin/poly_pkt_fwd ]; then rm ./bin/poly_pkt_fwd; fi
|
2016-03-25 14:14:19 +00:00
|
|
|
cp ./poly_pkt_fwd $INSTALL_DIR/poly_pkt_fwd
|
2016-03-25 13:25:45 +00:00
|
|
|
|
2016-03-25 14:14:19 +00:00
|
|
|
# Restore location back to where we started the build
|
2016-03-25 13:25:45 +00:00
|
|
|
|
|
|
|
popd
|
|
|
|
|
2016-03-25 14:14:19 +00:00
|
|
|
# Delete the build folder so that we save space
|
|
|
|
|
|
|
|
rm -rf $BUILD_DIR
|
|
|
|
|
|
|
|
echo "Build completed."
|