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. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
2016-09-06 19:34:19 +00:00
# Copyright (c) 2015-2016 Joseph A. Prochazka #
2015-11-04 04:48:08 +00:00
# #
# 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. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
2016-01-08 16:17:22 +00:00
## VARIABLES
2015-11-04 04:48:08 +00:00
2016-09-06 19:34:19 +00:00
PROJECTROOTDIRECTORY = " $PWD "
BASHDIRECTORY = " $PROJECTROOTDIRECTORY /bash "
BUILDDIRECTORY = " $PROJECTROOTDIRECTORY /build "
PLANEFINDERBUILDDIRECTORY = " $PROJECTROOTDIRECTORY /build/planefinder "
DEVICEIPADDRESS = ` ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/' `
2015-11-04 04:48:08 +00:00
2016-09-07 17:09:15 +00:00
## INCLUDE EXTERNAL SCRIPTS
2015-11-04 04:48:08 +00:00
2016-09-06 19:34:19 +00:00
source $BASHDIRECTORY /variables.sh
source $BASHDIRECTORY /functions.sh
2016-01-08 16:17:22 +00:00
2016-09-06 19:34:19 +00:00
## BEGIN SETUP
2015-11-04 04:48:08 +00:00
2016-09-06 19:34:19 +00:00
clear
2016-09-13 18:39:47 +00:00
echo -e " \n\e[91m $ADSB_PROJECTTITLE "
2015-11-04 04:48:08 +00:00
echo ""
2016-09-06 19:34:19 +00:00
echo -e "\e[92m Setting up the Plane Finder ADS-B Client..."
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[96m"
echo ""
2016-09-13 18:39:47 +00:00
whiptail --backtitle " $ADSB_PROJECTTITLE " --title "Plane Finder ADS-B Client Setup" --yesno "The Plane Finder ADS-B Client is an easy and accurate way to share your ADS-B and MLAT data with Plane Finder. It comes with a beautiful user interface that helps you explore and interact with your data in realtime.\n\n https://planefinder.net/sharing/client\n\nContinue setup by installing the Plane Finder ADS-B Client?" 13 78
2016-09-06 19:34:19 +00:00
CONTINUESETUP = $?
if [ $CONTINUESETUP = 1 ] ; then
# Setup has been halted by the user.
echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m"
echo -e " Setup has been halted at the request of the user."
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m Plane Finder ADS-B Client setup halted.\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
exit 1
fi
2015-11-04 04:48:08 +00:00
## CHECK FOR PREREQUISITE PACKAGES
2016-09-06 19:34:19 +00:00
echo -e "\e[95m Installing packages needed to build and fulfill dependencies...\e[97m"
echo ""
2015-11-04 04:48:08 +00:00
if [ [ ` uname -m` = = "x86_64" ] ] ; then
2016-10-11 15:06:33 +00:00
if [ $( dpkg --print-foreign-architectures $1 2>/dev/null | grep -c "i386" ) -eq 0 ] ; then
2016-09-06 19:34:19 +00:00
echo -e "\e[94m Adding the i386 architecture...\e[97m"
2015-12-01 10:22:36 +00:00
sudo dpkg --add-architecture i386
2016-09-06 19:34:19 +00:00
echo -e "\e[94m Downloading latest package lists for enabled repositories and PPAs...\e[97m"
echo ""
2015-12-01 10:22:36 +00:00
sudo apt-get update
echo ""
fi
CheckPackage libc6:i386
2015-11-04 04:48:08 +00:00
else
2015-12-01 10:22:36 +00:00
CheckPackage libc6
2015-11-04 04:48:08 +00:00
fi
2015-12-01 10:22:36 +00:00
CheckPackage wget
2015-11-04 04:48:08 +00:00
## DOWNLOAD THE PLANEFINDER ADS-B CLIENT PACKAGE
2016-09-06 19:34:19 +00:00
echo ""
echo -e "\e[95m Downloading the Plane Finder ADS-B Client package...\e[97m"
echo ""
2016-09-06 20:19:14 +00:00
# Create the planefinder build directory if it does not exist.
2016-09-06 19:34:19 +00:00
if [ ! -d $PLANEFINDERBUILDDIRECTORY ] ; then
echo -e "\e[94m Creating the Plane Finder ADS-B Client build directory...\e[97m"
mkdir $PLANEFINDERBUILDDIRECTORY
fi
# Download the appropriate package depending on the devices architecture.
2016-03-10 16:26:33 +00:00
if [ [ ` uname -m` = = "armv7l" ] ] || [ [ ` uname -m` = = "armv6l" ] ] ; then
2016-09-06 19:34:19 +00:00
echo -e " \e[94m Downloading the Plane Finder ADS-B Client v $PFCLIENTVERSIONARM for ARM devices...\e[97m "
echo ""
wget http://client.planefinder.net/pfclient_${ PFCLIENTVERSIONARM } _armhf.deb -O $PLANEFINDERBUILDDIRECTORY /pfclient_${ PFCLIENTVERSIONARM } _armhf.deb
2015-11-04 04:48:08 +00:00
else
2016-09-06 19:34:19 +00:00
echo -e " \e[94m Downloading the Plane Finder ADS-B Client v $PFCLIENTVERSIONI386 for I386 devices...\e[97m "
echo ""
wget http://client.planefinder.net/pfclient_${ PFCLIENTVERSIONI386 } _i386.deb -O $PLANEFINDERBUILDDIRECTORY /pfclient_${ PFCLIENTVERSIONI386 } _i386.deb
2015-11-04 04:48:08 +00:00
fi
## INSTALL THE PLANEFINDER ADS-B CLIENT PACKAGE
2016-09-06 19:34:19 +00:00
echo -e "\e[95m Installing the Plane Finder ADS-B Client package...\e[97m"
echo ""
echo -e "\e[94m Entering the Plane Finder ADS-B Client build directory...\e[97m"
cd $PLANEFINDERBUILDDIRECTORY
# Install the proper package depending on the devices architecture.
2016-10-11 15:06:33 +00:00
if [ [ ` uname -m` = = "armv7l" ] ] || [ [ ` uname -m` = = "armv6l" ] ] || [ [ ` uname -m` = = "aarch64" ] ] ; then
2016-09-06 19:34:19 +00:00
echo -e " \e[94m Installing the Plane Finder ADS-B Client v $PFCLIENTVERSIONARM for ARM devices package...\e[97m "
echo ""
sudo dpkg -i $PLANEFINDERBUILDDIRECTORY /pfclient_${ PFCLIENTVERSIONARM } _armhf.deb
2015-11-04 04:48:08 +00:00
else
2016-09-06 19:34:19 +00:00
echo -e " \e[94m Installing the Plane Finder ADS-B Client v $PFCLIENTVERSIONI386 for I386 devices package...\e[97m "
2015-12-01 10:22:36 +00:00
if [ [ ` lsb_release -si` = = "Debian" ] ] ; then
# Force architecture if this is Debian.
2016-09-06 19:34:19 +00:00
echo -e "\e[94m NOTE: dpkg executed with added flag --force-architecture.\e[97m"
echo ""
sudo dpkg -i --force-architecture $PLANEFINDERBUILDDIRECTORY /pfclient_${ PFCLIENTVERSIONI386 } _i386.deb
2015-12-01 10:22:36 +00:00
else
2016-09-06 20:19:14 +00:00
echo ""
2016-09-06 19:34:19 +00:00
sudo dpkg -i $PLANEFINDERBUILDDIRECTORY /pfclient_${ PFCLIENTVERSIONI386 } _i386.deb
2015-12-01 10:22:36 +00:00
fi
2015-11-04 04:48:08 +00:00
fi
2016-09-06 19:34:19 +00:00
# Check that the Plane Finder ADS-B Client package was installed successfully.
echo ""
echo -e "\e[94m Checking that the pfclient package was installed properly...\e[97m"
2016-01-07 04:19:05 +00:00
if [ $( dpkg-query -W -f= '${STATUS}' pfclient 2>/dev/null | grep -c "ok installed" ) -eq 0 ] ; then
2016-09-06 19:34:19 +00:00
# If the pfclient package could not be installed halt setup.
2016-03-07 16:44:26 +00:00
echo ""
2016-09-06 19:34:19 +00:00
echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m"
echo -e " UNABLE TO INSTALL A REQUIRED PACKAGE."
echo -e " SETUP HAS BEEN TERMINATED!"
2015-12-15 17:33:59 +00:00
echo ""
2016-09-06 19:34:19 +00:00
echo -e "\e[93mThe package \"pfclient\" could not be installed.\e[39m"
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m Plane Finder ADS-B Client setup halted.\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
exit 1
2015-12-15 17:33:59 +00:00
fi
2015-11-04 04:48:08 +00:00
## DISPLAY FINAL SETUP INSTRUCTIONS WHICH CONNOT BE HANDLED BY THIS SCRIPT
2016-09-13 18:39:47 +00:00
whiptail --backtitle " $ADSB_PROJECTTITLE " --title "Plane Finder ADS-B Client Setup Instructions" --msgbox " At this point the Plane Finder ADS-B Client should be installed and running howeverThis script is only capable of installing the Plane Finder ADS-B Client. There are stilla few steps left which you must manually do through the Plane Finder ADS-B Client itself.\n\nVisit the following URL: http:// ${ DEVICEIPADDRESS } :30053\n\nThe follow the instructions supplied by the Plane Finder ADS-B Client.\n\nUse the following settings when asked for them.\n\nData Format: Beast\nTcp Address: 127.0.0.1\nTcp Port: 30005 " 20 78
2016-09-06 19:34:19 +00:00
## PLANE FINDER ADS-B CLIENT SETUP COMPLETE
# Enter into the project root directory.
echo -e "\e[94m Entering the ADS-B Receiver Project root directory...\e[97m"
cd $PROJECTROOTDIRECTORY
2015-11-04 04:48:08 +00:00
echo ""
2016-09-06 19:34:19 +00:00
echo -e "\e[93m-------------------------------------------------------------------------------------------------------"
echo -e "\e[92m Plane Finder ADS-B Client setup is complete.\e[39m"
2015-11-04 04:48:08 +00:00
echo ""
read -p "Press enter to continue..." CONTINUE
2016-09-06 19:34:19 +00:00
exit 0