adsb-receiver/bash/feeders/piaware.sh

185 wiersze
7.6 KiB
Bash
Czysty Zwykły widok Historia

2015-11-04 04:48:08 +00:00
#!/bin/bash
#####################################################################################
2016-02-18 15:41:39 +00:00
# ADS-B RECEIVER #
2015-11-04 04:48:08 +00:00
#####################################################################################
# #
# This script is not meant to be executed directly. #
# Instead execute install.sh to begin the installation process. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (c) 2015 Joseph A. Prochazka #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in all #
# copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## VAARIABLES
2016-01-08 17:02:34 +00:00
BUILDDIR=$PWD
2016-01-07 04:19:05 +00:00
PIAWAREDIR="$PWD/piaware_builder"
2015-11-04 04:48:08 +00:00
source ../bash/variables.sh
2016-01-07 04:19:05 +00:00
source ../bash/functions.sh
2015-11-04 04:48:08 +00:00
## INFORMATIVE MESSAGE ABOUT THIS SOFTWARE
2015-11-04 04:48:08 +00:00
clear
echo -e "\033[31m"
echo "-------------------------------"
echo " Now ready to install PiAware."
echo "-------------------------------"
echo -e "\033[33mPiAware is a package used to forward data read from an ADS-B receiver to FlightAware."
echo "It does this using a program, piaware, aided by some support programs."
echo ""
echo "piaware - establishes an encrypted session to FlightAware and forwards data"
echo "piaware-config - used to configure piaware like with a FlightAware username and password"
echo "piaware-status - used to check the status of piaware"
echo "faup1090 - run by piaware to connect to dump1090 or some other program producing beast-style ADS-B data and translate between its format and FlightAware's"
echo "fa-mlat-client - run by piaware to gather data for multilateration"
echo ""
echo "https://github.com/flightaware/piaware"
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE
## CHECK FOR PREREQUISITE PACKAGES
echo -e "\033[33m"
echo "Installing packages needed to build and fulfill dependencies..."
echo -e "\033[37m"
CheckPackage git
CheckPackage build-essential
CheckPackage debhelper
2016-08-19 14:36:32 +00:00
CheckPackage tcl8.6-dev
2015-11-04 04:48:08 +00:00
CheckPackage autoconf
CheckPackage python3-dev
2016-08-19 14:36:32 +00:00
CheckPackage python3-venv
2016-03-16 15:39:14 +00:00
CheckPackage virtualenv
2016-08-19 14:36:32 +00:00
CheckPackage dh-systemd
2015-11-04 04:48:08 +00:00
# libz-dev appears to have been replaced by zlib1g-dev at least in Ubuntu Vivid Vervet...
# Will need to check if this is the case with Raspbian and Debian as well.
#CheckPackage libz-dev
CheckPackage zlib1g-dev
CheckPackage tclx8.4
CheckPackage tcllib
CheckPackage tcl-tls
CheckPackage itcl3
2015-12-27 05:15:39 +00:00
## DOWNLOAD OR UPDATE THE PIAWARE_BUILDER SOURCE
# Check if the git repository already exists locally.
2016-01-07 04:19:05 +00:00
if [ -d $PIAWAREDIR ] && [ -d $PIAWAREDIR/.git ]; then
2015-12-27 05:15:39 +00:00
# A directory with a git repository containing the source code exists.
echo -e "\033[33m"
echo "Updating the local piaware_builder git repository..."
echo -e "\033[37m"
2016-01-07 04:19:05 +00:00
cd $PIAWAREDIR
2015-12-27 05:15:39 +00:00
git pull origin master
else
# A directory containing the source code does not exist in the build directory.
echo -e "\033[33m"
echo "Cloning the piaware_builder git repository locally..."
echo -e "\033[37m"
git clone https://github.com/flightaware/piaware_builder.git
2016-01-07 04:19:05 +00:00
cd $PIAWAREDIR
2015-12-27 05:15:39 +00:00
fi
2015-11-04 04:48:08 +00:00
## BUILD THE PIAWARE PACKAGE
echo -e "\033[33m"
echo "Building the PiAware package..."
echo -e "\033[37m"
./sensible-build.sh jessie
cd $PIAWAREDIR/package-jessie
2015-11-04 04:48:08 +00:00
dpkg-buildpackage -b
## INSTALL THE PIAWARE PACKAGE
echo -e "\033[33m"
echo "Installing the PiAware package..."
echo -e "\033[37m"
sudo dpkg -i $PIAWAREDIR/piaware_*.deb
# Move the .deb package into another directory simply to keep it for historical reasons.
if [ ! -d $PIAWAREDIR/packages ]; then
mkdir $PIAWAREDIR/packages
fi
mv $PIAWAREDIR/piaware_*.deb $PIAWAREDIR/packages/
mv $PIAWAREDIR/piaware_*.changes $PIAWAREDIR/packages/
2015-11-04 04:48:08 +00:00
2015-12-15 17:33:59 +00:00
## CHECK THAT THE PACKAGE INSTALLED
2016-01-07 04:19:05 +00:00
if [ $(dpkg-query -W -f='${STATUS}' piaware 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
2015-12-15 17:33:59 +00:00
echo "\033[31m"
echo "#########################################"
echo "# INSTALLATION HALTED! #"
echo "# UNABLE TO INSTALL A REQUIRED PACKAGE. #"
echo "#########################################"
echo ""
2015-12-15 17:33:59 +00:00
echo "The piaware package did not install properly!"
echo -e "\033[33m"
echo "This script has exited due to the error encountered."
echo "Please read over the above output in order to determine what went wrong."
echo ""
kill -9 `ps --pid $$ -oppid=`; exit
2015-12-15 17:33:59 +00:00
fi
2015-11-04 04:48:08 +00:00
## CONFIGURE FLIGHTAWARE
echo -e "\033[31m"
echo "CLAIM YOUR PIAWARE DEVICE"
2015-11-04 04:48:08 +00:00
echo -e "\033[33m"
echo "Please supply your FlightAware login in order to claim this device."
echo "After supplying your login PiAware will ask you to enter your password for verification."
echo "If you decide not to supply a login and password you should still be able to claim your"
echo "feeder by visting the page http://flightaware.com/adsb/piaware/claim."
2015-11-04 04:48:08 +00:00
echo -e "\033[37m"
read -p "Your FlightAware Login: " FALOGIN
2016-08-19 16:51:09 +00:00
read -p "Your FlightAware Password: " FAPASSWD1
read -p "Repeat Your FlightAware Password: " FAPASSWD2
2015-11-04 04:48:08 +00:00
2016-08-19 16:51:09 +00:00
# Check that the supplied passwords match.
while [ $FAPASSWD1 != $FAPASSWD2 ]; do
echo -e "\033[33m"
echo "The supplied passwords did not match."
echo -e "\033[37m"
read -p "Your FlightAware Password: " FAPASSWD1
read -p "Repeat Your FlightAware Password: " FAPASSWD2
done
echo ""
# Set the supplied user name and password in the configuration.
sudo piaware-config flightaware-user $FALOGIN
sudo piaware-config flightaware-password $FAPASSWD1
2015-11-04 04:48:08 +00:00
echo -e "\e[33m"
echo "Restarting PiAware to ensure all changes are applied..."
echo -e "\033[37m"
sudo /etc/init.d/piaware restart
echo -e "\033[33m"
echo "Installation and configuration of PiAware is now complete."
echo "Please look over the output generated to be sure no errors were encountered."
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE