ttn-resin-gateway-rpi/resin-install.sh~

93 lines
2.0 KiB
Bash
Raw Normal View History

2016-03-22 04:38:11 +00:00
#! /bin/bash
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
# Stop on the first sign of trouble
set -e
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
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"
2016-03-22 04:25:53 +00:00
echo ""
2016-03-22 17:45:40 +00:00
# Check dependencies
echo "Installing dependencies..."
apt-get update
apt-get install swig libftdi-dev python-dev
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
# Install LoRaWAN packet forwarder repositories
INSTALL_DIR="/opt/ttn-gateway"
if [ ! -d "$INSTALL_DIR" ]; then mkdir $INSTALL_DIR; fi
pushd $INSTALL_DIR
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
# Build libraries
if [ ! -d libmpsse ]; then
git clone https://github.com/devttys0/libmpsse.git
pushd libmpsse/src
else
pushd libmpsse/src
git reset --hard
git pull
2016-03-22 04:25:53 +00:00
fi
2016-03-22 17:45:40 +00:00
./configure --disable-python
make
make install
ldconfig
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
popd
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
# 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
2016-03-22 04:38:11 +00:00
fi
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
cp ./libloragw/99-libftdi.rules /etc/udev/rules.d/99-libftdi.rules
sed -i -e 's/CFG_SPI= native/CFG_SPI= ftdi/g' ./libloragw/library.cfg
sed -i -e 's/PLATFORM= kerlink/PLATFORM= lorank/g' ./libloragw/library.cfg
sed -i -e 's/ATTRS{idProduct}=="6010"/ATTRS{idProduct}=="6014"/g' /etc/udev/rules.d/99-libftdi.rules
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
2016-03-22 04:38:11 +00:00
fi
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
make
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
popd
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
# 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
cp -f ./packet_forwarder/poly_pkt_fwd/global_conf.json ./bin/global_conf.json
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
# Restore location back to where we started the install
popd
# Copy startup shell script to the install directory
cp ./resin-run.sh $INSTALL_DIR/bin/resin-run.sh
2016-03-22 04:25:53 +00:00
2016-03-22 17:45:40 +00:00
echo "Installation completed."