2015-11-04 04:48:08 +00:00
#!/bin/bash
2024-06-30 03:49:36 +00:00
## INCLUDE EXTERNAL SCRIPTS
source $RECEIVER_BASH_DIRECTORY /variables.sh
source $RECEIVER_BASH_DIRECTORY /functions.sh
## BEGIN SETUP
2017-10-02 19:36:29 +00:00
2024-06-18 20:37:40 +00:00
clear
echo -e " \n\e[91m ${ RECEIVER_PROJECT_TITLE } "
2017-10-03 18:08:52 +00:00
echo ""
2017-10-03 00:40:46 +00:00
echo -e "\e[92m Setting up FlightAware PiAware client..."
2017-10-03 18:08:52 +00:00
echo ""
2017-10-02 19:36:29 +00:00
echo -e "\e[93m ------------------------------------------------------------------------------\e[96m"
2017-10-03 18:08:52 +00:00
echo ""
2017-10-02 19:36:29 +00:00
2024-06-30 03:49:36 +00:00
# Confirm component installation
2024-07-07 18:35:11 +00:00
if ! whiptail --backtitle " ${ RECEIVER_PROJECT_TITLE } " --title "FlightAware PiAware client Setup" --yesno "The FlightAware PiAware client takes data from a local dump1090 instance and shares this with FlightAware using the piaware package, for more information please see their website:\n\n https://www.flightaware.com/adsb/piaware/\n\nContinue setup by installing the FlightAware PiAware client?" 13 78 3>& 1 1>& 2 2>& 3; then
2024-06-18 20:37:40 +00:00
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 FlightAware PiAware client setup halted.\e[39m"
2017-10-03 18:08:52 +00:00
echo ""
2024-06-30 03:49:36 +00:00
read -p "Press enter to continue..." discard
2016-09-02 20:47:46 +00:00
exit 1
fi
2015-11-04 04:48:08 +00:00
2024-06-30 03:49:36 +00:00
## CHECK FOR PREREQUISITE PACKAGES
2015-11-04 04:48:08 +00:00
2017-10-03 00:40:46 +00:00
echo -e "\e[95m Installing packages needed to fulfill dependencies for FlightAware PiAware client...\e[97m"
2017-10-03 18:08:52 +00:00
echo ""
2015-11-04 04:48:08 +00:00
CheckPackage build-essential
2024-06-14 16:02:25 +00:00
CheckPackage git
CheckPackage devscripts
2015-11-04 04:48:08 +00:00
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
2024-06-14 16:02:25 +00:00
CheckPackage python3-setuptools
2015-11-04 04:48:08 +00:00
CheckPackage zlib1g-dev
2024-06-14 16:02:25 +00:00
CheckPackage openssl
CheckPackage libboost-system-dev
CheckPackage libboost-program-options-dev
CheckPackage libboost-regex-dev
CheckPackage libboost-filesystem-dev
CheckPackage patchelf
CheckPackage python3-pip
2024-06-14 21:02:23 +00:00
CheckPackage python3-setuptools
CheckPackage python3-wheel
2024-06-14 17:21:54 +00:00
CheckPackage net-tools
CheckPackage tclx8.4
CheckPackage tcllib
CheckPackage itcl3
2024-06-14 21:02:23 +00:00
CheckPackage libssl-dev
CheckPackage tcl-dev
CheckPackage chrpath
2024-06-28 04:32:18 +00:00
2024-06-30 03:49:36 +00:00
# Some older distros may need different packages than newer ones
2024-06-28 04:32:18 +00:00
case ${ RECEIVER_OS_CODE_NAME } in
focal)
CheckPackage python3-dev
; ;
*)
CheckPackage python3-build
; ;
esac
2024-06-18 20:37:40 +00:00
echo ""
2024-06-30 03:49:36 +00:00
2024-06-18 20:37:40 +00:00
## DOWNLOAD OR UPDATE THE TCLTLS REBUILD SOURCE
2024-06-14 21:02:23 +00:00
2024-06-18 20:37:40 +00:00
echo -e "\e[95m Preparing the tcltls rebuild Git repository...\e[97m"
echo ""
2024-06-30 03:49:36 +00:00
# Build the FlightAware version of tcl-tls to address network issues with the stock package
if [ [ -d $RECEIVER_BUILD_DIRECTORY /tcltls-rebuild && -d $RECEIVER_BUILD_DIRECTORY /tcltls-rebuild/.git ] ] ; then
# A directory with a git repository containing the source code already exists
2024-06-14 21:02:23 +00:00
echo -e "\e[94m Entering the tcltls-rebuild git repository directory...\e[97m"
2024-06-30 03:49:36 +00:00
cd $RECEIVER_BUILD_DIRECTORY /tcltls-rebuild 2>& 1
2024-06-14 21:02:23 +00:00
echo -e "\e[94m Updating the local tcltls-rebuild git repository...\e[97m"
echo ""
git pull 2>& 1
else
2024-06-30 03:49:36 +00:00
# A directory containing the source code does not exist in the build directory
2024-06-14 21:02:23 +00:00
echo -e "\e[94m Entering the ADS-B Receiver Project build directory...\e[97m"
2024-06-30 03:49:36 +00:00
cd $RECEIVER_BUILD_DIRECTORY 2>& 1
2024-06-14 21:02:23 +00:00
echo -e "\e[94m Cloning the tcltls-rebuild git repository locally...\e[97m"
echo ""
git clone https://github.com/flightaware/tcltls-rebuild 2>& 1
fi
2024-06-18 20:37:40 +00:00
echo ""
2024-06-30 03:49:36 +00:00
2024-06-18 20:37:40 +00:00
## BUILD AND INSTALL THE DUMP1090-FA PACKAGE
echo -e "\e[95m Building and installing the tcltls rebuild package...\e[97m"
echo -e ""
2024-06-14 21:02:23 +00:00
echo -e "\e[94m Entering the tcltls-rebuild source directory...\e[97m"
2024-06-30 03:49:36 +00:00
cd $RECEIVER_BUILD_DIRECTORY /tcltls-rebuild/tcltls-1.7.22 2>& 1
2024-06-14 21:02:23 +00:00
echo -e "\e[94m Building the tcltls-rebuild package...\e[97m"
echo ""
dpkg-buildpackage -b 2>& 1
echo ""
echo -e "\e[94m Installing the tcltls-rebuild package...\e[97m"
echo ""
2024-06-30 03:49:36 +00:00
sudo dpkg -i $RECEIVER_BUILD_DIRECTORY /tcltls-rebuild/tcl-tls_1.7.22-2+fa1_*.deb 2>& 1
2024-06-14 21:02:23 +00:00
echo ""
2024-06-14 21:26:09 +00:00
echo -e "\e[94m Moving the tcltls-rebuild binary package into the archive directory...\e[97m"
echo ""
2024-06-30 03:49:36 +00:00
cp -vf $RECEIVER_BUILD_DIRECTORY /piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY /package-archive/ 2>& 1
2024-06-14 21:26:09 +00:00
echo ""
2024-06-30 03:49:36 +00:00
## START INSTALLATION
2017-10-02 19:36:29 +00:00
2017-10-03 00:40:46 +00:00
echo -e "\e[95m Begining the FlightAware PiAware client installation process...\e[97m"
2017-10-03 18:08:52 +00:00
echo ""
2015-12-27 05:15:39 +00:00
2024-06-30 03:49:36 +00:00
if [ [ -d $RECEIVER_BUILD_DIRECTORY /piaware_builder && -d $RECEIVER_BUILD_DIRECTORY /piaware_builder/.git ] ] ; then
# A directory with a git repository containing the source code already exists
2016-09-02 20:47:46 +00:00
echo -e "\e[94m Entering the piaware_builder git repository directory...\e[97m"
2024-06-30 03:49:36 +00:00
cd $RECEIVER_BUILD_DIRECTORY /piaware_builder 2>& 1
2016-09-02 20:47:46 +00:00
echo -e "\e[94m Updating the local piaware_builder git repository...\e[97m"
2017-10-03 18:08:52 +00:00
echo ""
2017-10-02 19:36:29 +00:00
git pull 2>& 1
2015-12-27 05:15:39 +00:00
else
2024-06-30 03:49:36 +00:00
# A directory containing the source code does not exist in the build directory
2016-09-02 20:47:46 +00:00
echo -e "\e[94m Entering the ADS-B Receiver Project build directory...\e[97m"
2024-06-30 03:49:36 +00:00
cd $RECEIVER_BUILD_DIRECTORY 2>& 1
2016-09-02 20:47:46 +00:00
echo -e "\e[94m Cloning the piaware_builder git repository locally...\e[97m"
2017-10-03 18:08:52 +00:00
echo ""
2017-10-03 00:40:46 +00:00
git clone https://github.com/flightaware/piaware_builder.git 2>& 1
2015-12-27 05:15:39 +00:00
fi
2024-06-18 20:37:40 +00:00
echo ""
2015-11-04 04:48:08 +00:00
2024-06-30 03:49:36 +00:00
2017-10-02 19:36:29 +00:00
## BUILD AND INSTALL THE COMPONENT PACKAGE
2015-11-04 04:48:08 +00:00
2017-10-03 00:40:46 +00:00
echo -e "\e[95m Building and installing the FlightAware PiAware client package...\e[97m"
2017-10-03 18:08:52 +00:00
echo ""
2017-10-02 19:36:29 +00:00
2024-06-30 03:49:36 +00:00
# Change to the component build directory
echo -e "\e[94m Entering the piaware_builder git repository directory...\e[97m"
cd $RECEIVER_BUILD_DIRECTORY /piaware_builder 2>& 1
2016-08-31 15:46:10 +00:00
2024-06-30 03:49:36 +00:00
# Execute build script
distro = "bookworm"
case $RECEIVER_OS_CODE_NAME in
2024-06-28 04:32:18 +00:00
buster | focal)
2024-06-30 03:49:36 +00:00
distro = "buster"
2024-06-14 16:02:25 +00:00
; ;
2024-06-28 04:32:18 +00:00
bullseye | jammy)
2024-06-30 03:49:36 +00:00
distro = "bullseye"
2024-06-14 16:02:25 +00:00
; ;
2024-06-14 21:02:23 +00:00
bookworm)
2024-06-30 03:49:36 +00:00
distro = "bookworm"
2024-06-14 16:02:25 +00:00
; ;
esac
echo -e "\e[94m Executing the FlightAware PiAware client build script...\e[97m"
echo ""
2024-06-30 03:49:36 +00:00
./sensible-build.sh $distro
2024-06-14 16:02:25 +00:00
echo ""
2024-06-30 03:49:36 +00:00
# Change to build script directory
2024-06-14 16:02:25 +00:00
echo -e "\e[94m Entering the FlightAware PiAware client build directory...\e[97m"
2024-06-30 03:49:36 +00:00
cd $RECEIVER_BUILD_DIRECTORY /piaware_builder/package-${ distro } 2>& 1
2024-06-14 16:02:25 +00:00
2024-06-30 03:49:36 +00:00
# Build binary package
2024-06-14 16:02:25 +00:00
echo -e "\e[94m Building the FlightAware PiAware client package...\e[97m"
echo ""
dpkg-buildpackage -b 2>& 1
echo ""
2024-06-30 03:49:36 +00:00
# Install binary package
2024-06-14 16:02:25 +00:00
echo -e "\e[94m Installing the FlightAware PiAware client package...\e[97m"
echo ""
2024-06-30 03:49:36 +00:00
sudo dpkg -i $RECEIVER_BUILD_DIRECTORY /piaware_builder/piaware_*.deb 2>& 1
2024-06-14 16:02:25 +00:00
echo ""
2017-10-02 19:36:29 +00:00
2024-06-14 16:02:25 +00:00
# Check that the component package was installed successfully.
echo -e "\e[94m Checking that the FlightAware PiAware client package was installed properly...\e[97m"
2017-10-02 19:36:29 +00:00
2024-06-30 03:49:36 +00:00
if [ [ $( dpkg-query -W -f= '${STATUS}' piaware 2>/dev/null | grep -c "ok installed" ) -eq 0 ] ] ; then
2017-10-03 18:08:52 +00:00
echo ""
2024-06-14 16:02:25 +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!"
2017-10-03 18:08:52 +00:00
echo ""
2024-06-14 16:02:25 +00:00
echo -e "\e[93mThe package \"piaware\" could not be installed.\e[39m"
2017-10-03 18:08:52 +00:00
echo ""
2024-06-14 16:02:25 +00:00
echo -e "\e[93m ------------------------------------------------------------------------------"
echo -e "\e[92m FlightAware PiAware client setup halted.\e[39m"
2017-10-03 18:08:52 +00:00
echo ""
2024-06-30 03:49:36 +00:00
read -p "Press enter to continue..." discard
2024-06-14 16:02:25 +00:00
exit 1
else
# Create binary package archive directory.
2024-06-30 03:49:36 +00:00
if [ [ ! -d $RECEIVER_BUILD_DIRECTORY /package-archive ] ] ; then
2024-06-14 16:02:25 +00:00
echo -e "\e[94m Creating package archive directory...\e[97m"
2017-10-03 18:08:52 +00:00
echo ""
2024-06-30 03:49:36 +00:00
mkdir -vp $RECEIVER_BUILD_DIRECTORY /package-archive 2>& 1
2017-10-03 18:08:52 +00:00
echo ""
2017-10-02 19:36:29 +00:00
fi
2024-06-14 16:02:25 +00:00
# Archive binary package.
echo -e "\e[94m Moving the FlightAware PiAware client binary package into the archive directory...\e[97m"
echo ""
2024-06-30 03:49:36 +00:00
cp -vf $RECEIVER_BUILD_DIRECTORY /piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY /package-archive/ 2>& 1
2024-06-14 16:02:25 +00:00
echo ""
2016-08-31 15:46:10 +00:00
fi
2015-11-04 04:48:08 +00:00
2024-06-30 03:49:36 +00:00
2017-10-02 19:36:29 +00:00
## COMPONENT POST INSTALL ACTIONS
2017-09-28 02:02:45 +00:00
2017-10-02 19:36:29 +00:00
# Instruct the user as to how they can claim their receiver online.
2017-10-03 18:08:52 +00:00
whiptail --backtitle " ${ RECEIVER_PROJECT_TITLE } " --title "Claiming Your PiAware Device" --msgbox "FlightAware requires you claim your feeder online using the following URL:\n\n http://flightaware.com/adsb/piaware/claim\n\nTo claim your device simply visit the address listed above." 12 78
2015-12-15 17:33:59 +00:00
2024-06-30 03:49:36 +00:00
## SETUP COMPLETE
2016-01-23 19:39:21 +00:00
2017-10-02 19:36:29 +00:00
# Return to the project root directory.
echo -e " \e[94m Returning to ${ RECEIVER_PROJECT_TITLE } root directory...\e[97m "
2024-06-30 03:49:36 +00:00
cd $RECEIVER_ROOT_DIRECTORY 2>& 1
2015-11-04 04:48:08 +00:00
2017-10-03 18:08:52 +00:00
echo ""
2017-10-02 19:36:29 +00:00
echo -e "\e[93m ------------------------------------------------------------------------------"
2017-10-03 00:40:46 +00:00
echo -e "\e[92m FlightAware PiAware client setup is complete.\e[39m"
2017-10-03 18:08:52 +00:00
echo ""
2024-06-30 03:49:36 +00:00
read -p "Press enter to continue..." discard
2016-09-06 18:32:28 +00:00
exit 0