2016-03-22 04:38:11 +00:00
|
|
|
#! /bin/bash
|
2016-03-21 19:36:55 +00:00
|
|
|
|
2016-03-25 18:22:31 +00:00
|
|
|
# Stop on the first sign of trouble
|
2016-03-21 19:36:55 +00:00
|
|
|
set -e
|
|
|
|
|
2016-03-25 14:29:49 +00:00
|
|
|
echo "The Things Network RPi + IC880A Gateway Builder/Installer"
|
2016-03-21 21:06:34 +00:00
|
|
|
echo ""
|
2016-03-21 19:36:55 +00:00
|
|
|
|
2016-04-10 20:40:39 +00:00
|
|
|
# Install the necessary packages, whether they're used
|
|
|
|
# at build time or at runtime.
|
2016-04-10 20:32:36 +00:00
|
|
|
apt-get update
|
2016-04-10 20:40:39 +00:00
|
|
|
## needed by the "ip" command in set-gateway-id.sh called by run.sh
|
|
|
|
apt-get install iproute
|
2016-04-10 20:32:36 +00:00
|
|
|
|
2016-03-25 14:29:49 +00:00
|
|
|
# Build in a temp folder that we'll completely purge after build,
|
|
|
|
# and install into the linux folder where apps reside.
|
2016-03-21 19:36:55 +00:00
|
|
|
|
2016-03-25 14:29:49 +00:00
|
|
|
INSTALL_DIR="/opt/ttn-gateway"
|
2016-03-26 18:49:31 +00:00
|
|
|
if [ ! -d "$INSTALL_DIR" ]; then mkdir $INSTALL_DIR; fi
|
2016-03-25 14:06:47 +00:00
|
|
|
|
2016-03-26 17:19:33 +00:00
|
|
|
BUILD_DIR="$INSTALL_DIR/dev"
|
2016-03-26 18:49:31 +00:00
|
|
|
if [ ! -d "$BUILD_DIR" ]; then mkdir $BUILD_DIR; fi
|
2016-03-26 17:19:33 +00:00
|
|
|
|
2016-03-25 14:29:49 +00:00
|
|
|
# Switch to where we'll do the builds
|
2016-03-25 14:06:47 +00:00
|
|
|
pushd $BUILD_DIR
|
2016-03-21 19:36:55 +00:00
|
|
|
|
2016-03-25 14:29:49 +00:00
|
|
|
# Build WiringPi so that we can do Raspberry Pi I/O
|
2016-03-26 19:29:19 +00:00
|
|
|
if [ ! -d wiringPi ]; then
|
|
|
|
git clone git://git.drogon.net/wiringPi
|
|
|
|
pushd wiringPi
|
|
|
|
else
|
|
|
|
pushd wiringPi
|
|
|
|
git reset --hard
|
|
|
|
git pull
|
|
|
|
fi
|
2016-03-25 13:45:32 +00:00
|
|
|
./build
|
2016-03-21 19:36:55 +00:00
|
|
|
popd
|
|
|
|
|
2016-03-25 14:06:47 +00:00
|
|
|
# Build LoRa gateway app for this specific platform
|
2016-03-26 19:29:19 +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 13:45:32 +00:00
|
|
|
sed -i -e 's/PLATFORM= kerlink/PLATFORM= imst_rpi/g' ./libloragw/library.cfg
|
2016-03-26 16:36:31 +00:00
|
|
|
# Comment the following in or out as needed for hardware debugging
|
2016-03-26 17:56:33 +00:00
|
|
|
#sed -i -e 's/DEBUG_SPI= 0/DEBUG_SPI= 1/g' ./libloragw/library.cfg
|
|
|
|
#sed -i -e 's/DEBUG_REG= 0/DEBUG_REG= 1/g' ./libloragw/library.cfg
|
|
|
|
#sed -i -e 's/DEBUG_HAL= 0/DEBUG_HAL= 1/g' ./libloragw/library.cfg
|
2016-03-26 16:36:31 +00:00
|
|
|
#sed -i -e 's/DEBUG_AUX= 0/DEBUG_AUX= 1/g' ./libloragw/library.cfg
|
|
|
|
#sed -i -e 's/DEBUG_GPS= 0/DEBUG_GPS= 1/g' ./libloragw/library.cfg
|
2016-03-21 19:36:55 +00:00
|
|
|
make
|
|
|
|
popd
|
|
|
|
|
2016-03-25 14:29:49 +00:00
|
|
|
# Build the packet forwarder
|
2016-03-26 19:29:19 +00:00
|
|
|
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
|
2016-03-21 19:36:55 +00:00
|
|
|
make
|
|
|
|
popd
|
|
|
|
|
2016-03-25 14:29:49 +00:00
|
|
|
# Restore location back to where we were prior to starting the build
|
2016-03-21 22:04:58 +00:00
|
|
|
popd
|
2016-03-21 21:56:23 +00:00
|
|
|
|
2016-03-26 18:45:52 +00:00
|
|
|
# Copy things needed at runtime to where they'll be expected
|
2016-03-29 22:27:49 +00:00
|
|
|
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
|
2016-03-25 14:06:47 +00:00
|
|
|
|
2016-03-25 14:29:49 +00:00
|
|
|
echo "Build & Installation Completed."
|