83 lines
1.6 KiB
Bash
Executable File
83 lines
1.6 KiB
Bash
Executable File
#! /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
|
|
#apt-get install swig 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 WiringPi
|
|
if [ ! -d wiringPi ]; then
|
|
git clone git://git.drogon.net/wiringPi
|
|
pushd wiringPi
|
|
else
|
|
pushd wiringPi
|
|
git reset --hard
|
|
git pull
|
|
fi
|
|
|
|
./build
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
# Restore location back to where we started the install
|
|
|
|
popd
|
|
|
|
echo "Installation completed."
|