diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7f4562fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +EXTRAS_CHOICES +FEEDER_CHOICES +build/adsbexchange +build/airplaneslive +build/beast-splitter +build/duckdns +build/dump1090* +build/dump978* +build/flightradar24 +build/flyitalyadsb +build/piaware_builder +build/planefinder +build/package-archive +logs diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f457359..1e6ed35e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,22 @@ The following is a history of the changes made to this project. -## v2.8.4 *(July 13th, 2024)* :rooster: +## v2.8.5 *(July 23rd, 2024)* + +* The PiAware installation script now supports Ubuntu Noble Numbat. *(unofficial fix)* +* The installation of PiAware is no longer required when choosing to install dump1090-fa. +* The dump1090-fa installation script now mimics the current dump1090-fa installation instructions. +* All scripts excluding those related to the portal now utilize the new logging functions. +* Logging to the logs directory is enabled by default but can be disabled with --no-logging or -n. +* Added variables which can be modified to adjust text colors used by the bash scripts. +* Added the --version and -v arguments in order to display the current project version. +* Additional script cleanup done to various files. +* Removed scripting used for image setup. +* Updated the latest Flightradar24 Client version to 1.0.48-0. -### Installers +## v2.8.4 *(July 13th, 2024)* :rooster: * Added the option to install the airplanes.live feeder client and web interface. - -### Portal - * Can now toggle daily data purges as well specify the number of days to keep within the portal. * Rewrote the aircraft.py script and fixed issues found with newer versions of dump1090. * Rewrote the maintenance.py script and addressed issue mentioned in an incompatible pull request. diff --git a/README.md b/README.md index c3679798..355b876a 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Your local repositories master branch will be updated each time install.sh is ex The following software can be installed using these scripts. -### The ADS-B Receiver Web Portal +### The ADS-B Portal Included is the option to install the ADS-B Portal which offers the following features. @@ -70,12 +70,12 @@ When setting up the portal you will have to choose between a lite or advanced in The project currently supports the following Linux distributions. -* Armbian _(Bookworm and Jammy)_ -* Debian _(Bookworm and Bullseye)_ +* Armbian _(Bookworm, Jammy and Noble)_ +* Debian _(Bookworm, Bullseye and Trixie)_ * DietPi _(Bookworm aand Bullseye)_ * Rasbperry PI OS _(Bookworm and Bullseye)_ -* Ubuntu _(Jammy Jellyfish and Focal Fossa)_ +* Ubuntu _(Jammy Jellyfish, Focal Fossa and Noble Numbat)_ _Support is available via this repository through the use of the issue tracker or discussions._ -[Support for Ubuntu Noble Numbat is on hold due to incompatibilities with PiAware's MLAT client.](https://github.com/jprochazka/adsb-receiver/issues/575) +_At this time support for PiAware on distributions based on Debian Trixie and Ubuntu Noble Numbat employ an unofficial fix._ diff --git a/bash/decoders/dump1090-fa.sh b/bash/decoders/dump1090-fa.sh index 43ba58fd..47aa2957 100755 --- a/bash/decoders/dump1090-fa.sh +++ b/bash/decoders/dump1090-fa.sh @@ -1,6 +1,6 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh @@ -9,176 +9,197 @@ source $RECEIVER_BASH_DIRECTORY/functions.sh ## BEGIN SETUP clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo "" -echo -e "\e[92m Setting up dump1090-fa..." -echo "" -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo "" -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump1090-fa Setup" --yesno "Dump 1090 is a Mode-S decoder specifically designed for RTL-SDR devices. Dump1090-fa is a fork of the dump1090-mutability version of dump1090 that is specifically designed for FlightAware's PiAware software.\n\nIn order to use this version of dump1090 FlightAware's PiAware software must be installed as well.\n\n https://github.com/flightaware/dump1090\n\nContinue setup by installing dump1090-fa?" 14 78; then - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." +log_project_title +log_title_heading "Setting up the FlightAware Dump1090 decoder" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "FlightAware Dump1090 Decoder Setup" \ + --yesno "FlightAware Dump1090 is an ADS-B, Mode S, and Mode 3A/3C demodulator and decoder that will receive and decode aircraft transponder messages received via a directly connected software defined radio, or from data provided over a network connection.\n\nWebsite: https://www.flightaware.com/\nGitHub Repository: https://github.com/flightaware/dump1090\n\nWould you like to begin the setup process now?" \ + 14 78; then echo "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m Dump1090-fa setup halted.\e[39m" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightAware Dump1090 decoder setup halted" echo "" - read -p "Press enter to continue..." discard exit 1 fi - ## CHECK FOR PREREQUISITE PACKAGES -echo -e "\e[95m Installing packages needed to build and fulfill dependencies...\e[97m" -echo "" -CheckPackage build-essential -CheckPackage fakeroot -CheckPackage debhelper -CheckPackage librtlsdr-dev -CheckPackage pkg-config -CheckPackage libncurses-dev -CheckPackage libbladerf-dev -CheckPackage libhackrf-dev -CheckPackage liblimesuite-dev -CheckPackage libsoapysdr-dev -CheckPackage lighttpd -echo "" +log_heading "Installing packages needed to fulfill FlightAware Dump1090 decoder dependencies" + +check_package build-essential +check_package debhelper +check_package devscripts +check_package fakeroot +check_package libbladerf-dev +check_package libhackrf-dev +check_package liblimesuite-dev +check_package libncurses-dev +check_package librtlsdr-dev +check_package libsoapysdr-dev +check_package lighttpd +check_package pkg-config ## BLACKLIST UNWANTED RTL-SDR MODULES -BlacklistModules +log_heading "Blacklist unwanted RTL-SDR kernel modules." +blacklist_modules -## DOWNLOAD OR UPDATE THE DUMP1090-FA SOURCE -echo -e "\e[95m Preparing the dump1090-fa Git repository...\e[97m" -echo "" +## CLONE OR PULL THE FLIGHTAWARE DUMP1090 DECODER SOURCE + +log_heading "Preparing the FlightAware Dump1090 Git repository" + if [[ -d $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090 && -d $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/.git ]]; then - # A directory with a git repository containing the source code already exists - echo -e "\e[94m Entering the dump1090-fa git repository directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090 2>&1 - echo -e "\e[94m Updating the local dump1090-fa git repository...\e[97m" + log_message "Entering the dump1090 git repository directory" + cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090 + log_message "Pulling the dump1090 git repository" echo "" - git pull + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE else - # A directory containing the source code does not exist in the build directory - echo -e "\e[94m Creating the ADS-B Receiver Project build directory...\e[97m" + log_message "Creating the FlightAware dump1090 Project build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/dump1090-fa + mkdir -v $RECEIVER_BUILD_DIRECTORY/dump1090-fa 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" - echo -e "\e[94m Entering the dump1090-fa build directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa 2>&1 - echo -e "\e[94m Cloning the dump1090-fa git repository locally...\e[97m" + log_message "Entering the FlightAware dump1090 Project build directory" + cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa + log_message "Cloning the dump1090 git repository" echo "" - git clone https://github.com/flightaware/dump1090.git + git clone https://github.com/flightaware/dump1090.git 2>&1 | tee -a $RECEIVER_LOG_FILE fi ## BUILD AND INSTALL THE DUMP1090-FA PACKAGE +log_heading "Building the FlightAware dump1090-fa package" + +log_message "Entering the dump1090 Git repository" +cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090 + +log_message "Determining which distribution to build the package tree for" +case $RECEIVER_OS_CODE_NAME in + focal) + distro="buster" + ;; + bullseye|jammy|bookworm|noble) + distro="bullseye" + ;; +esac +log_message "Preparing to build dump1090-fa for ${distro}" echo "" -echo -e "\e[95m Building and installing the dump1090-fa package...\e[97m" +./prepare-build.sh $distro 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -echo -e "\e[94m Entering the dump1090-fa git repository directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090 2>&1 -echo -e "\e[94m Building the dump1090-fa package...\e[97m" +log_message "Entering the package-${distro} directory" +cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/package-$distro +log_message "Building the dump1090-fa Debian package" echo "" -dpkg-buildpackage -b +dpkg-buildpackage -b --no-sign 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -echo -e "\e[94m Entering the dump1090-fa build directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa 2>&1 -echo -e "\e[94m Installing the dump1090-fa package...\e[97m" +log_message "Installing the dump1090-fa Debian package" echo "" -echo "dump1090-fa_${DUMP1090_FA_VERSION}_*.deb" -sudo dpkg -i dump1090-fa_${DUMP1090_FA_VERSION}_*.deb - -# Check that the package was installed +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/dump1090-fa_$DUMP1090_FA_VERSION_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -echo -e "\e[94m Checking that the dump1090-fa package was installed properly...\e[97m" -if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") = 0 ]]; then - # If the dump1090-fa package could not be installed halt setup + +log_message "Checking that the dump1090-fa Debian package was installed" +if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then echo "" - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " UNABLE TO INSTALL A REQUIRED PACKAGE." - echo -e " SETUP HAS BEEN TERMINATED!" + log_alert_heading "INSTALLATION HALTED" echo "" - echo -e "\e[93mThe package \"dump1090-fa\" could not be installed.\e[39m" + log_alert_message "The dump1090-fa Debian package failed to install" + log_alert_message "Setup has been terminated" echo "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m Dump1090-fa setup halted.\e[39m" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightAware Dump1090 decoder setup halted" echo "" read -p "Press enter to continue..." discard exit 1 fi -# Create binary package archive directory if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then - echo -e "\e[94m Creating package archive directory...\e[97m" - echo -e "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 - echo -e "" + log_message "Creating the Debian package archive directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" fi - -# Archive binary package -echo -e "\e[94m Moving the dump1090-mutability binary package into the archive directory...\e[97m" -echo "" -cp -vf $RECEIVER_BUILD_DIRECTORY/dump1090-fa/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 +log_message "Copying the dump1090-fa Debian package into the Debian package archive directory" echo "" +cp -vf $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE -## DUMP1090-FA POST INSTALLATION CONFIGURATION - -# Ask for a Bing Maps API key -bing_maps_key=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Bing Maps API Key" --nocancel --inputbox "\nProvide a Bing Maps API key here to enable the Bing imagery layer.\nYou can obtain a free key at https://www.bingmapsportal.com/\n\nProviding a Bing Maps API key is not required to continue." 11 78 "${DUMP1090_BING_MAPS_KEY}" 3>&1 1>&2 2>&3) -if [[ -n $bing_maps_key ]]; then - echo -e "\e[94m Setting the Bing Maps API Key to ${DUMP1090_BING_MAPS_KEY}...\e[97m" - ChangeConfig "BingMapsAPIKey" $bing_maps_key "/usr/share/dump1090-fa/html/config.js" -fi -# Download Heywhatsthat.com maximum range rings -if [[ ! -f "/usr/share/dump1090-fa/html/upintheair.json" ]]; then - if (whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Heywhaststhat.com Maximum Range Rings" --yesno "Maximum range rings can be added to dump1090-fa usings data obtained from Heywhatsthat.com. In order to add these rings to your dump1090-fa map you will first need to visit http://www.heywhatsthat.com and generate a new panorama centered on the location of your receiver. Once your panorama has been generated a link to the panorama will be displayed in the top left hand portion of the page. You will need the view id which is the series of letters and/or numbers after \"?view=\" in this URL.\n\nWould you like to add heywhatsthat.com maximum range rings to your map?" 16 78); then - setup_heywhatsthat="true" - - # Ask the user for the Heywhatsthat.com panorama ID - heywhatsthat_id_title="Heywhatsthat.com Panorama ID" - while [[ -z $heywhatsthat_id ]] ; do - heywhatsthat_id=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${heywhatsthat_id_title}" --nocancel --inputbox "\nEnter your Heywhatsthat.com panorama ID." 8 78 3>&1 1>&2 2>&3) - heywhatsthat_id_title="Heywhatsthat.com Panorama ID (REQUIRED)" - done +## POST INSTALLATION OPERATIONS - # Ask the user what altitude in meters to set the first range ring - heywhatsthat_ring_one_title="Heywhatsthat.com First Ring Altitude" - while [[ -z $heywhatsthat_ring_one ]] ; do - heywhatsthat_ring_one=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${heywhatsthat_ring_one_title}" --nocancel --inputbox "\nEnter the first ring's altitude in meters.\n(default 3048 meters or 10000 feet)" 8 78 "3048" 3>&1 1>&2 2>&3) - heywhatsthat_ring_one_title="Heywhatsthat.com First Ring Altitude (REQUIRED)" - done +log_heading "Performing post installation operations" - # Ask the user what altitude in meters to set the second range ring - heywhatsthat_ring_two_title="Heywhatsthat.com Second Ring Altitude" - while [[ -z $heywhatsthat_ring_two ]] ; do - heywhatsthat_ring_two=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${heywhatsthat_ring_two_title}" --nocancel --inputbox "\nEnter the second ring's altitude in meters.\n(default 12192 meters or 40000 feet)" 8 78 "12192" 3>&1 1>&2 2>&3) - heywhatsthat_ring_two_title="Heywhatsthat.com Second Ring Altitude (REQUIRED)" +log_message "Checking if a heywhatsthat upintheair.json file exists" +if [[ ! -f "/usr/share/dump1090-fa/html/upintheair.json" ]]; then + log_message "Asking the user if they want to add heywhatsthat maximum range rings" + if (whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Setup heywhaststhat Maximum Range Rings" \ + --yesno "Maximum range rings can be added to the FlightAware Dump1090 map usings data obtained from heywhatsthat. In order to add these rings to your FlightAware dump1090 map you will first need to visit http://www.heywhatsthat.com and generate a new panorama centered on the location of your receiver. Once your panorama has been generated a link to the panorama will be displayed in the top left hand portion of the page. You will need the view ID which is the series of letters and numbers after ?view= in the URL.\n\nWould you like to add heywhatsthat maximum range rings to your map?" \ + 16 78); then + log_message "Asking the user for the heywhatsthat panarama ID" + heywhatsthat_panorama_id_title="Enter the heywhatsthat Panorama ID" + while [[ -z $heywhatsthat_panorama_id ]] ; do + heywhatsthat_panorama_id=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${heywhatsthat_panorama_id_title}" \ + --inputbox "Please enter your Heywhatsthat panorama ID." \ + 8 78 3>&1 1>&2 2>&3) + whiptail_exit_status=$? + if [[ $whiptail_exit_status == 0 ]]; then + log_alert_message "Setup of heywhatsthat maximum range rings was cancelled" + break + fi + heywhatsthat_panorama_id_title="Enter the Heywhatsthat Panorama ID [REQUIRED]" done - fi - # If the Heywhatsthat.com maximum range rings are to be added download them now - if [[ "${setup_heywhatsthat}" = "true" ]]; then - echo -e "\e[94m Downloading JSON data pertaining to the supplied panorama ID...\e[97m" - echo "" - sudo wget -O /usr/share/dump1090-fa/html/upintheair.json "http://www.heywhatsthat.com/api/upintheair.json?id=${heywhatsthat_id}&refraction=0.25&alts=${heywhatsthat_ring_one},${heywhatsthat_ring_two}" - echo "" + if [[ $whiptail_exit_status != 0 ]]; then + log_message "Asking the user what the altitude is for the first ring" + heywhatsthat_ring_one_altitude_title="First heywhatsthat Ring Altitude" + while [[ -z $heywhatsthat_ring_one_altitude ]] ; do + heywhatsthat_ring_one_altitude=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${heywhatsthat_ring_one_altitude_title}" \ + --nocancel \ + --inputbox "Enter the first ring's altitude in meters.\n(default 3048 meters or 10000 feet)" \ + 8 78 \ + "3048" 3>&1 1>&2 2>&3) + heywhatsthat_ring_one_altitude_title="First heywhatsthat Ring Altitude [REQUIRED]" + done + log_message "Asking the user what the altitude is for the second ring" + heywhatsthat_ring_two_altitude_title="Second heywhatsthat Ring Altitude" + while [[ -z $heywhatsthat_ring_two_altitude ]] ; do + heywhatsthat_ring_two_altitude=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${heywhatsthat_ring_two_altitude_title}" \ + --nocancel \ + --inputbox "Enter the second ring's altitude in meters.\n(default 12192 meters or 40000 feet)" \ + 8 78 \ + "12192" 3>&1 1>&2 2>&3) + heywhatsthat_ring_two_altitude_title="Second heywhatsthat Ring Altitude [REQUIRED]" + done + + log_message "Downloading JSON data file assigned to panorama ID ${heywhatsthat_panorama_id}" + echo "" + sudo wget -v -O /usr/share/skyaware/html/upintheair.json "http://www.heywhatsthat.com/api/upintheair.json?id=${heywhatsthat_panarama_id}&refraction=0.25&alts=${heywhatsthat_ring_one_altitude},${heywhatsthat_ring_two_altitude}" 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + log_message "Heywhatsthat configuration complete" + fi + else + log_message "Heywhatsthat maximum range rings was skipped" fi fi -### SETUP COMPLETE -# Return to the project root directory -echo -e "\e[94m Entering the ADS-B Receiver Project root directory...\e[97m" -cd $RECEIVER_ROOT_DIRECTORY 2>&1 +## SETUP COMPLETE + +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY echo "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m Dump1090-fa setup is complete.\e[39m" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "FlightAware Dump1090 decoder setup is complete" echo "" read -p "Press enter to continue..." discard diff --git a/bash/decoders/dump978-fa.sh b/bash/decoders/dump978-fa.sh index 57b1bbc2..62c71184 100755 --- a/bash/decoders/dump978-fa.sh +++ b/bash/decoders/dump978-fa.sh @@ -1,6 +1,6 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh @@ -9,171 +9,223 @@ source $RECEIVER_BASH_DIRECTORY/functions.sh ## BEGIN SETUP clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo "" -echo -e "\e[92m Setting up dump978-fa..." -echo "" -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo "" -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump978-fa Setup" --yesno "This is the FlightAware 978MHz UAT decoder. It is a reimplementation in C++, loosely based on the demodulator from https://github.com/mutability/dump978.\n\n https://github.com/flightaware/dump978\n\nContinue setup by installing dump978-fa?" 14 78; then - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." +log_project_title +log_title_heading "Setting up the FlightAware Dump978 decoder" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "FlightAware Dump978 Setup" \ + --yesno "This is the FlightAware 978MHz UAT decoder. It is a reimplementation in C++, loosely based on the demodulator from https://github.com/mutability/dump978.\n\n https://github.com/flightaware/dump978\n\nContinue setup by installing dump978-fa?" \ + 14 78; then echo "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m Dump978-fa setup halted.\e[39m" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightAware Dump978 decoder setup halted" echo "" - read -p "Press enter to continue..." discard exit 1 fi +## GATHER REQUIRED INFORMATION FROM THE USER + +log_heading "Gather information required to configure the ADS-B decoder and dump978-fa if needed" + +log_message "Checking if an ADS-B decoder is installed" +adsb_decoder_installed="false" +if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then + log_message "An ADS-B decoder appears to be installed" + adsb_decoder_installed="true" +fi + +if [[ "${adsb_decoder_installed}" == "true" ]]; then + log_message "Checking if dump978-fa has been configured" + if [[ -f /etc/default/dump978-fa ]]; then + log_message "A dump978-fa configuration file exists" + else + log_message "Informing the user an ADS-B decoder appears to be installed" + whiptail --backtitle "FlightAware Dump978 Configuration" \ + --title "RTL-SDR Dongle Assignments" \ + --msgbox "It appears one of the dump1090 decoder packages has been installed on this device. In order to run dump978 in tandem with dump1090 you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run both decoders on a single device you will need to have two separate RTL-SDR devices connected to your device." \ + 12 78 + + log_message "Asking the user to assign a RTL-SDR device serial number to the ADS-B decoder" + dump1090_device_serial_title="Enter the Dump1090 RTL-SDR Device Serial" + while [[ -z $dump1090_device_serial ]] ; do + dump1090_device_serial=$(whiptail --backtitle "FlightAware Dump978 Configuration" \ + --title "${dump1090_device_serial_title}" \ + --inputbox "\nEnter the serial number for your dump1090 RTL-SDR device." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $dump1090_device_serial == 0 ]]; then + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted due to lack of required information" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightAware Dump978 decoder setup halted" + exit 1 + fi + dump1090_device_serial_title="Enter the Dump1090 RTL-SDR Device Serial (REQUIRED)" + done + + log_message "Asking the user to assign a RTL-SDR device serial number to dump978-fa" + dump978_device_serial_title="Enter the Dump978 RTL-SDR Device Serial" + while [[ -z $dump978_device_serial ]] ; do + dump978_device_serial=$(whiptail --backtitle "FlightAware Dump978 Configuration" \ + --title "${dump978_device_serial_title}" \ + --inputbox "\nEnter the serial number for your dump978 RTL-SDR device." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $dump978_device_serial == 0 ]]; then + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted due to lack of required information" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightAware Dump978 decoder setup halted" + exit 1 + fi + dump978_device_serial_title="Enter the Dump1090 RTL-SDR Device Serial (REQUIRED)" + done + fi +fi + + ## CHECK FOR PREREQUISITE PACKAGES -echo -e "\e[95m Installing packages needed to build and fulfill dependencies...\e[97m" -echo "" -CheckPackage build-essential -CheckPackage debhelper -CheckPackage libboost-system-dev -CheckPackage libboost-program-options-dev -CheckPackage libboost-regex-dev -CheckPackage libboost-filesystem-dev -CheckPackage libsoapysdr-dev -CheckPackage soapysdr-module-rtlsdr -echo "" +log_heading "Installing packages needed to fulfill FlightAware Dump978 decoder dependencies" + +check_package build-essential +check_package debhelper +check_package libboost-filesystem-dev +check_package libboost-program-options-dev +check_package libboost-regex-dev +check_package libboost-system-dev +check_package libsoapysdr-dev +check_package soapysdr-module-rtlsdr ## BLACKLIST UNWANTED RTL-SDR MODULES -BlacklistModules +log_heading "Blacklist unwanted RTL-SDR kernel modules" +blacklist_modules -## DOWNLOAD OR UPDATE THE DUMP978-FA SOURCE -echo -e "\e[95m Preparing the dump978-fa Git repository...\e[97m" -echo "" +## CLONE OR PULL THE FLIGHTAWARE DUMP978 DECODER SOURCE + +log_heading "Preparing the FlightAware Dump978 Git repository" + if [[ -d $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978 && -d $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978/.git ]]; then - # A directory with a git repository containing the source code already exists. - echo -e "\e[94m Entering the dump978-fa git repository directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978 2>&1 - echo -e "\e[94m Updating the local dump978-fa git repository...\e[97m" + log_message "Entering the FlightAware dump978 git repository directory" + cd $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978 + log_message "Pulling the dump1090 git repository" echo "" - git pull + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE else - # A directory containing the source code does not exist in the build directory. - echo -e "\e[94m Creating the ADS-B Receiver Project build directory...\e[97m" + log_message "Creating the FlightAware dump978 Project build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/dump978-fa + mkdir -v $RECEIVER_BUILD_DIRECTORY/dump978-fa 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" - echo -e "\e[94m Entering the dump978-fa build directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY/dump978-fa 2>&1 - echo -e "\e[94m Cloning the dump978-fa git repository locally...\e[97m" + log_message "Entering the ADS-B Receiver Project build directory" + cd $RECEIVER_BUILD_DIRECTORY/dump978-fa + log_message "Cloning the FlightAware dump978 git repository" echo "" - git clone https://github.com/flightaware/dump978.git + git clone https://github.com/flightaware/dump978.git 2>&1 | tee -a $RECEIVER_LOG_FILE fi -echo "" -## BUILD AND INSTALL THE DUMP978-FA PACKAGE +## BUILD AND INSTALL THE DUMP978-FA and SKYAWARE978 PACKAGES + +log_heading "Building the FlightAware dump978-fa and skyaware978 packages" -echo -e "\e[95m Building and installing the dump978-fa package...\e[97m" +log_message "Entering the dump978 Git repository" +cd $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978 + +log_message "Building the dump978-fa package" echo "" -echo -e "\e[94m Entering the dump978-fa git repository directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978 2>&1 -echo -e "\e[94m Building the dump978-fa package...\e[97m" +dpkg-buildpackage -b 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -dpkg-buildpackage -b + +log_message "Installing the dump978-fa Debian package" echo "" -echo -e "\e[94m Entering the dump978-fa build directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/dump978-fa 2>&1 -echo -e "\e[94m Installing the dump978-fa package...\e[97m" +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978-fa_${DUMP978_FA_VERSION}_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978-fa_${DUMP978_FA_VERSION}_*.deb +log_message "Installing the skyaware978 Debian package" echo "" -echo -e "\e[94m Installing the skyaware978 package...\e[97m" +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/skyaware978_${DUMP978_FA_VERSION}_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/skyaware978_${DUMP978_FA_VERSION}_*.deb -# Check that the package was installed -echo "" -echo -e "\e[94m Checking that the dump978-fa package was installed properly...\e[97m" +log_message "Checking that the dump978-fa Debian package was installed" if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then echo "" - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " UNABLE TO INSTALL A REQUIRED PACKAGE." - echo -e " SETUP HAS BEEN TERMINATED!" + log_alert_heading "INSTALLATION HALTED" echo "" - echo -e "\e[93mThe package \"dump978-fa\" could not be installed.\e[39m" + log_alert_message "The dump978-fa Debian package failed to install" + log_alert_message "Setup has been terminated" echo "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m Dump978-fa setup halted.\e[39m" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightAware Dump978 decoder setup halted" echo "" read -p "Press enter to continue..." discard exit 1 fi -# Create binary package archive directory -if [[ ! -d "${RECEIVER_BUILD_DIRECTORY}/package-archive" ]]; then - echo -e "\e[94m Creating package archive directory...\e[97m" - echo -e "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 - echo -e "" +log_message "Checking that the skyaware978 Debian package was installed" +if [[ $(dpkg-query -W -f='${STATUS}' skyaware978 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then + echo "" + log_alert_heading "INSTALLATION HALTED" + echo "" + log_alert_message "The skyaware978 Debian package failed to install" + log_alert_message "Setup has been terminated" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightAware Dump978 decoder setup halted" + echo "" + read -p "Press enter to continue..." discard + exit 1 fi -# Archive binary package -echo -e "\e[94m Moving the dump978-fa binary package into the archive directory...\e[97m" +if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then + log_message "Creating the Debian package archive directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" +fi +log_message "Copying the dump978-fa Debian package into the Debian package archive directory" echo "" -cp -vf $RECEIVER_BUILD_DIRECTORY/dump978-fa/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 +cp -vf $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978-fa_*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" +log_message "Copying the skyaware978 Debian package into the Debian package archive directory" +echo "" +cp -vf $RECEIVER_BUILD_DIRECTORY/dump978-fa/skyaware978_*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE ## CONFIGURATION -# Check if the dump1090-fa package is installed -echo -e "\e[94m Checking if the dump1090-fa package is installed...\e[97m" -if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then - # Check if dump978-fa has already been configured - echo -e "\e[94m Checking if the dump978-fa package has been configured...\e[97m" - if grep -wq "driver=rtlsdr,serial=" /etc/default/dump978-fa; then - echo -e "\e[94m This dump978-fa installation appears to have been configured...\e[97m" - else - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "RTL-SDR Dongle Assignments" --msgbox "It appears one of the dump1090 packages has been installed on this device. In order to run dump978 in tandem with dump1090 you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run both decoders on a single device you will need to have two separate RTL-SDR devices connected to your device." 12 78 - # Ask the user which USB device is to be used for dump1090 - dump1090_device_serial=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump1090 RTL-SDR Dongle" --nocancel --inputbox "\nEnter the serial number for your dump1090 RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) - while [[ -z $dump1090_device_serial ]] ; do - dump1090_device_serial=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump1090 RTL-SDR Dongle (REQUIRED)" --nocancel --inputbox "\nEnter the serial number for your dump1090 RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) - done - # Ask the user which USB device is to be use for dump978 - dump978_device_serial=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump978 RTL-SDR Dongle" --nocancel --inputbox "\nEnter the serial number for your dump978 RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) - while [[ -z $dump978_device_serial ]] ; do - dump978_device_serial=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump978 RTL-SDR Dongle (REQUIRED)" --nocancel --inputbox "\nEnter the serial number for your dump978 RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) - done +if [[ "${adsb_decoder_installed}" == "true" ]]; then + + log_heading "Configuring the ADS-B decoder and dump978-fa so they can work in tandem" + + log_message "Assigning RTL-SDR device with serial ${dump978_device_serial} to dump978-fa" + sudo sed -i -e "s/driver=rtlsdr/driver=rtlsdr,serial=${dump978_device_serial}/g" /etc/default/dump978-fa + log_message "Restarting dump978-fa...\e[97m" + sudo systemctl restart dump978-fa - # Assign the specified RTL-SDR dongle to dump978-fa - echo -e "\e[94m Assigning RTL-SDR dongle '${dump978_device_serial}' to dump978-fa...\e[97m" - sudo sed -i -e "s/driver=rtlsdr/driver=rtlsdr,serial=${dump978_device_serial}/g" /etc/default/dump978-fa - echo -e "\e[94m Restarting dump978-fa...\e[97m" - sudo service dump978-fa force-reload - - # Assign the specified RTL-SDR dongle to dump1090-fa - if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then - echo -e "\e[94m Assigning RTL-SDR dongle '${dump1090_device_serial}' to dump1090-fa...\e[97m" - ChangeConfig "RECEIVER_SERIAL" $dump1090_device_serial "/etc/default/dump1090-fa" - echo -e "\e[94m Restarting dump1090-fa...\e[97m" - sudo service dump1090-fa force-reload - fi + if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then + log_message "Assigning RTL-SDR device with serial ${dump1090_device_serial} to the FlightAware Dump1090 decoder" + change_config "RECEIVER_SERIAL" $dump1090_device_serial "/etc/default/dump1090-fa" + log_message "Restarting dump1090-fa" + sudo systemctl restart dump1090-fa fi fi ## SETUP COMPLETE -# Return to the project root directory -echo -e "\e[94m Entering the ADS-B Receiver Project root directory...\e[97m" -cd ${RECEIVER_ROOT_DIRECTORY} 2>&1 +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY echo "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m Dump978-fa setup is complete.\e[39m" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "FlightAware Dump978 decoder setup is complete" echo "" read -p "Press enter to continue..." discard diff --git a/bash/extras/beastsplitter.sh b/bash/extras/beastsplitter.sh index 40772042..38d15abd 100755 --- a/bash/extras/beastsplitter.sh +++ b/bash/extras/beastsplitter.sh @@ -1,20 +1,19 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo -e "" -echo -e "\e[92m Setting up beast-splitter..." -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo -e "" -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Beast-Splitter Setup" --yesno "beast-splitter is a helper utility for the Mode-S Beast.\n\nThe Beast provides a single data stream over a (USB) serial port. If you have more than one thing that wants to read that data stream, you need something to redistribute the data. This is what beast-splitter does.\n\n https://github.com/flightaware/beast-splitter\n\nContinue beast-splitter setup?" 15 78; then +log_project_title +log_title_heading "Setting up beast-splitter" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Beast-Splitter Setup" \ + --yesno "beast-splitter is a helper utility for the Mode-S Beast.\n\nThe Beast provides a single data stream over a (USB) serial port. If you have more than one thing that wants to read that data stream, you need something to redistribute the data. This is what beast-splitter does.\n\n https://github.com/flightaware/beast-splitter\n\nContinue beast-splitter setup?" \ + 15 78; then + echo "" echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" echo -e " Setup has been halted at the request of the user." echo -e "" @@ -26,111 +25,156 @@ if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Beast-Splitter Se fi -## GATHER CONFIGURATION OPTIONS +## GATHER REQUIRED INFORMATION FROM THE USER -if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Enable Beast Splitter" --defaultno --yesno "By default Beast Splitter is disabled. Would you like to enable Beast Splitter now?" 8 65; then +log_heading "Gather information required to configure beast-splitter" + +log_message "Asking user if beast-splitter should be enabled" +if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Enable Beast Splitter" \ + --defaultno \ + --yesno "By default Beast Splitter is disabled. Would you like to enable Beast Splitter now?" 8 65; then enable_beastsplitter="true" else enable_beastsplitter="false" fi -input_options=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Input Options for Beast Splitter" --nocancel --inputbox "Enter the option telling Beast Splitter where to read data from. You should provide one of the following either --net or --serial.\n\nExamples:\n--serial /dev/beast\n--net remotehost:remoteport" 8 78 3>&1 1>&2 2>&3) -output_options=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Output Options for Beast Splitter" --nocancel --inputbox "Enter the option to tell Beast Splitter where to send output data. You can do so by establishing an outgoing connection or accepting inbound connections.\\Examples:\n--connect remotehost:remoteport\n --listen remotehost:remoteport" 8 78 3>&1 1>&2 2>&3) + +log_message "Asking user for the beast-splitter input option" +input_options=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Input Options for Beast Splitter" \ + --inputbox "Enter the option telling Beast Splitter where to read data from. You should provide one of the following either --net or --serial.\n\nExamples:\n--serial /dev/beast\n--net remotehost:remoteport" \ + 8 78 3>&1 1>&2 2>&3) +if [[ $input_options == 0 ]]; then + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted due to lack of required information" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "beast-splitter setup halted" + exit 1 +fi + +log_message "Asking user for the beast-splitter output option" +output_options=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Output Options for Beast Splitter" \ + --nocancel --inputbox "Enter the option to tell Beast Splitter where to send output data. You can do so by establishing an outgoing connection or accepting inbound connections.\\Examples:\n--connect remotehost:remoteport\n --listen remotehost:remoteport" \ + 8 78 3>&1 1>&2 2>&3) +if [[ $output_options == 0 ]]; then + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted due to lack of required information" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "beast-splitter setup halted" + exit 1 +fi + ## CHECK FOR PREREQUISITE PACKAGES -echo -e "\e[95m Checking that the required packages are installed...\e[97m" -echo -e "" -CheckPackage build-essential -CheckPackage debhelper -CheckPackage libboost-system-dev -CheckPackage libboost-program-options-dev -CheckPackage libboost-regex-dev -echo "" +log_heading "Installing packages needed to fulfill beast-splitter dependencies" + +check_package build-essential +check_package debhelper +check_package libboost-system-dev +check_package libboost-program-options-dev +check_package libboost-regex-dev -## DOWNLOAD SOURCE +## CLONE OR PULL THE FLIGHTAWARE DUMP978 DECODER SOURCE -echo -e "\e[95m Downloading the beast-splitter repository from GitHub...\e[97m" -echo -e "" +log_heading "Preparing the FlightAware Dump978 Git repository" -echo -e "\e[94m Checking if the Git repository has already been cloned...\e[97m" if [[ -d $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter && -d $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter/.git ]]; then - # A directory with a git repository containing the source code already exists - echo -e "\e[94m Entering the local beast-splitter git repository directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter 2>&1 - echo -e "\e[94m Updating the local beast-splitter git repository...\e[97m" - echo -e "" - git pull 2>&1 + log_message "Entering the beast-splitter git repository directory" + cd $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter + log_message "Pulling the beast-splitter git repository" + echo "" + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE else - # A directory containing the source code does not exist in the build directory - echo -e "\e[94m Creating the beast-splitter build directory...\e[97m" + log_message "Creating the beast-splitter build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/beast-splitter 2>&1 + mkdir -v $RECEIVER_BUILD_DIRECTORY/beast-splitter 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" - echo -e "\e[94m Entering the beast-splitter build directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY/beast-splitter 2>&1 - echo -e "\e[94m Cloning the beast-splitter git repository locally...\e[97m" - echo -e "" - git clone https://github.com/flightaware/beast-splitter.git 2>&1 + log_message "Entering the beast-splitter build directory" + cd $RECEIVER_BUILD_DIRECTORY/beast-splitter + log_message "Cloning the FlightAware dump978 git repository" + echo "" + git clone https://github.com/flightaware/beast-splitter.git 2>&1 | tee -a $RECEIVER_LOG_FILE fi -echo "" -## BUILD AND INSTALL +## BUILD AND INSTALL THE BEAST-SPLITTER PACKAGE -echo -e "\e[95m Building and installing the beast-splitter package...\e[97m" -echo -e "" +log_heading "Building the beast-splitter package" -echo -e "\e[94m Entering the beast-splitter git repository directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter 2>&1 +log_message "Entering the beast-splitter Git repository" +cd $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter -echo -e "\e[94m Executing the beast-splitter build script...\e[97m" -echo -e "" -dpkg-buildpackage -b 2>&1 -echo -e "" - -echo -e "\e[94m Entering the beast-splitter build directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/beast-splitter 2>&1 +log_message "Building the beast-splitter package" +echo "" +dpkg-buildpackage -b 2>&1 | tee -a $RECEIVER_LOG_FILE +echo "" -echo -e "\e[94m Installing the beast-splitter package...\e[97m" +log_message "Installing the beast-splitter Debian package" echo "" -sudo dpkg -i beast-splitter_*.deb 2>&1 +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -# Archive binary package +log_message "Checking that the beast-splitter Debian package was installed" +if [[ $(dpkg-query -W -f='${STATUS}' beast-splitter 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then + echo "" + log_alert_heading "INSTALLATION HALTED" + echo "" + log_alert_message "The beast-splitter Debian package failed to install" + log_alert_message "Setup has been terminated" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "beast-splitter setup halted" + echo "" + read -p "Press enter to continue..." discard + exit 1 +fi + if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then - echo -e "\e[94m Creating package archive directory...\e[97m" + log_message "Creating the Debian package archive directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi -echo -e "\e[94m Moving the beast-splitter package into the archive directory...\e[97m" -echo "" -cp -vp $RECEIVER_BUILD_DIRECTORY/beast-splitter/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 +log_message "Copying the beast-splitter Debian package into the Debian package archive directory" echo "" +cp -vf $RECEIVER_BUILD_DIRECTORY/beast-splitter/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE + +## CONFIGURATION -## CONFIGURE BEAST SPLITTER +log_heading "Configuring beast-splitter" -echo -e "\e[94m Configuring beast-splitter...\e[97m" -ChangeConfig "ENABLED" $enable_beastsplitter "/etc/default/beast-splitter" -ChangeConfig "INPUT_OPTIONS" $input_options "/etc/default/beast-splitter" -ChangeConfig "OUTPUT_OPTIONS" $output_options "/etc/default/beast-splitter" +log_message "Setting ENABLED to ${enable_beastsplitter}" +change_config "ENABLED" "${enable_beastsplitter}" "/etc/default/beast-splitter" +log_message "Setting INPUT_OPTIONS to ${input_options}" +change_config "INPUT_OPTIONS" "${input_options}" "/etc/default/beast-splitter" +log_message "Setting OUTPUT_OPTIONS to ${output_options}" +change_config "OUTPUT_OPTIONS" "${output_options}" "/etc/default/beast-splitter" + +if [[ "${enable_beastsplitter}" == "true" ]]; then + log_message "Starting the beast-splitter process" + sudo systemctl start beast-splitter +else + log_message "Making sure beast-splitter is not running" + sudo systemctl stop beast-splitter +fi ## SETUP COMPLETE -# Return to the project root directory -echo -e "\e[94m Entering the ADS-B Receiver Project root directory...\e[97m" -cd $RECEIVER_ROOT_DIRECTORY 2>&1 +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m beast-splitter setup is complete.\e[39m" -echo -e "" -if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]]; then - read -p "Press enter to continue..." discard -fi +echo "" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "beast-splitter setup is complete" +echo "" +read -p "Press enter to continue..." discard exit 0 diff --git a/bash/extras/duckdns.sh b/bash/extras/duckdns.sh index f9490dac..9b569464 100755 --- a/bash/extras/duckdns.sh +++ b/bash/extras/duckdns.sh @@ -1,134 +1,119 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo "" -echo -e "\e[92m Setting up Duck DNS..." -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo "" -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Duck DNS Dynamic DNS" --yesno "Duck DNS is a free dynamic DNS service hosted on Amazon VPC.\n\nPLEASE NOTE:\n\nBefore continuing this setup it is recommended that you visit the Duck DNS website and signup for then setup a sub domain which will be used by this device. You will need both the domain and token supplied to you after setting up your account.\n\n http://www.duckdns.org\n\nContinue with Duck DNS update script setup?" 18 78; then - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." +log_project_title +log_title_heading "Setting up Duck DNS" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Duck DNS Dynamic DNS" \ + --yesno "Duck DNS is a free dynamic DNS service hosted on Amazon VPC.\n\nPLEASE NOTE:\n\nBefore continuing this setup it is recommended that you visit the Duck DNS website and signup for then setup a sub domain which will be used by this device. You will need both the domain and token supplied to you after setting up your account.\n\n http://www.duckdns.org\n\nContinue with Duck DNS update script setup?" \ + 18 78; then echo "" - echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" - echo -e "\e[92m Duck DNS setup halted.\e[39m" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "Duck DNS setup halted" echo "" - read -p "Press enter to continue..." discard exit 1 fi -echo -e "\e[95m Setting up Duck DNS on this device...\e[97m" -echo "" - ## CHECK FOR PREREQUISITE PACKAGES -# Check that the required packages are installed -echo -e "\e[95m Installing packages needed to build and fulfill dependencies...\e[97m" -echo "" -CheckPackage cron -CheckPackage curl -exho "" +log_heading "Installing packages needed to fulfill PlaneFinder client dependencies" +check_package cron +check_package curl -## CONFIRM SETTINGS -# Ask for the user sub domain to be assigned to this device -domain_title="Duck DNS Sub Domain" -while [[ -z $domain ]] ; do - domain=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title $domain_title --nocancel --inputbox "\nPlease enter the Duck DNS sub domain you selected after registering.\nIf you do not have one yet visit http://www.ducknds.org to obtain one." 9 78 3>&1 1>&2 2>&3) - domain_title="Duck DNS Sub Domain (REQUIRED)" +## GATHER REQUIRED INFORMATION FROM THE USER + +log_heading "Gather information required to configure Duck DNS support" + +log_message "Asking the user for the sub domain to be assigned to this device" +duckdns_domain_title="Duck DNS Sub Domain" +while [[ -z $duckdns_domain ]]; do + duckdns_domain=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${duckdns_domain_title}" \ + --inputbox "\nPlease enter the Duck DNS sub domain you selected after registering.\nIf you do not have one yet visit http://www.ducknds.org to obtain one." \ + 9 78 3>&1 1>&2 2>&3) + if [[ $duckdns_domain == 0 ]]; then + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted due to lack of required information" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "Duck DNS decoder setup halted" + exit 1 + fi + duckdns_domain_title="Duck DNS Sub Domain (REQUIRED)" done -# Ask for the Duck DNS token to be assigned to this receiver -token_title="Duck DNS Token" -while [[ -z "${DUCKDNS_TOKEN}" ]] ; do - token=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title $token_title --nocancel --inputbox "\nPlease enter your Duck DNS token." 8 78 3>&1 1>&2 2>&3) - token_title="Duck DNS Token (REQUIRED)" +log_message "Asking the user for the Duck DNS token" +duckdns_token_title="Duck DNS Token" +while [[ -z $duckdns_token ]]; do + duckdns_token=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${duckdns_token_title}" \ + --inputbox "\nPlease enter your Duck DNS token." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $duckdns_domain == 0 ]]; then + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted due to lack of required information" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "Duck DNS setup halted" + exit 1 + fi + duckdns_token_title="Duck DNS Token (REQUIRED)" done -## PROJECT BUILD DIRECTORY +## CREATE THE DUCK DNS SCRIPT -# Create the build directory if it does not already exist -if [[ ! -d $RECEIVER_BUILD_DIRECTORY ]]; then - echo -e "\e[94m Creating the ADS-B Receiver Project build directory...\e[97m" - mkdir -vp $RECEIVER_BUILD_DIRECTORY 2>&1 -fi +log_heading "Creating the Duck DNS script" -# Create a component directory within the build directory if it does not already exist if [[ ! -d $RECEIVER_BUILD_DIRECTORY/duckdns ]]; then - echo -e "\e[94m Creating the directory ${RECEIVER_BUILD_DIRECTORY}/duckdns...\e[97m" + log_message "Creating the Duck DNS build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/duckdns 2>&1 + mkdir -v $RECEIVER_BUILD_DIRECTORY/duckdns 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi - -## CREATE SCRIPT - -# Create then set permissions on the file duck.sh -echo -e "\e[94m Creating the Duck DNS update script...\e[97m" +log_message "Creating the Duck DNS update script" tee $RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh > /dev/null <&1 +chmod -v 700 $RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" - -## ADD TO CRON - -echo -e "\e[94m Adding the DuckDNS cron file...\e[97m" +log_message "Creating the Duck DNS cron file" sudo tee /etc/cron.d/duckdns_ip_address_update > /dev/null </dev/null 2>&1 EOF -echo "" - - -## START SCRIPTS - -echo -e "\e[95m Starting Duck DNS...\e[97m" -echo "" - -# Kill any currently running instance - pid=`ps -efww | grep -w "duck.sh " | awk -vpid=$$ '$2 != pid { print $2 }'` - if [[ -n $pid ]]; then - echo -e "\e[94m Killing the duck.sh process...\e[97m" - echo "" - sudo kill $pid 2>&1 - sudo kill -9 $pid 2>&1 - echo "" - fi -done -# Run the Duck DNS update script for the first time -echo -e "\e[94m Executing the Duck DNS update script...\e[97m" +log_message "Executing the Duck DNS update script" echo "" -$RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh 2>&1 +$RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh echo "" ## SETUP COMPLETE -# Return to the project root directory. -echo -e "\e[94m Entering the ADS-B Receiver Project root directory...\e[97m" -cd $RECEIVER_ROOT_DIRECTORY 2>&1 +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY echo "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m Duck DNS setup is complete.\e[39m" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "Duck DNS setup is complete" echo "" read -p "Press enter to continue..." discard diff --git a/bash/feeders/adsbexchange.sh b/bash/feeders/adsbexchange.sh index 1ebccee8..d4df02ad 100755 --- a/bash/feeders/adsbexchange.sh +++ b/bash/feeders/adsbexchange.sh @@ -1,66 +1,64 @@ #!/bin/bash -### INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo -e "" -echo -e "\e[92m Setting up the ADS-B Exchange feed..." -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo -e "" -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B Exchange Feed Setup" --yesno "ADS-B Exchange is a co-op of ADS-B/Mode S/MLAT feeders from around the world, and the world’s largest source of unfiltered flight data.\n\n http://www.adsbexchange.com/how-to-feed/\n\nContinue setting up the ADS-B Exchange feed?" 18 78 3>&1 1>&2 2>&3; then - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." - echo -e "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m ADS-B Exchange feed setup halted.\e[39m" - echo -e "" - read -p "Press enter to continue..." discard +log_project_title +log_title_heading "Setting up the ADS-B Exchange client" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "ADS-B Exchange Feed Setup" \ + --yesno "ADS-B Exchange is a co-op of ADS-B/Mode S/MLAT feeders from around the world, and the world’s largest source of unfiltered flight data.\n\n http://www.adsbexchange.com/how-to-feed/\n\nContinue setting up the ADS-B Exchange feed?" \ + 18 78; then + echo "" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "ADS-B Exchange client setup halted" + echo "" exit 1 fi -## DOWNLOAD AND EXECUTE THE INSTALL SCRIPT +## DOWNLOAD AND EXECUTE THE ADS-B EXCHANGE CLIENT INSTALL SCRIPT -# Explain the process -whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B Exchange Feed Setup" --msgbox "Scripts supplied by ADS-B Exchange will be used in order to install or upgrade this system. Interaction with the script exececuted will be required in order to complete the installation." 10 78 +log_heading "Downloading the proper ADS-B Exchange client script" -echo -e "\e[95m Preparing to execute either the install or upgrade script...\e[97m" -echo "" +log_message "Informing the user of how the installation process will work" +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "ADS-B Exchange Feed Setup" \ + --msgbox "Scripts supplied by ADS-B Exchange will be used in order to install or upgrade this system. Interaction with the script exececuted will be required in order to complete the installation." \ + 10 78 -# Create the build directory if needed then enter it if [[ ! -d $RECEIVER_BUILD_DIRECTORY/adsbexchange ]]; then - echo -e "\e[94m Creating the ADSBExchange build directory...\e[97m" - mkdir $RECEIVER_BUILD_DIRECTORY/adsbexchange + log_message "Creating the ADSBExchange build directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/adsbexchange 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" fi -echo -e "\e[94m Entering the ADSBExchange build directory...\e[97m" +log_message "Entering the ADSBExchange build directory" cd $RECEIVER_BUILD_DIRECTORY/adsbexchange -# Determine if the feeder is already installed or not +log_message "Determining whether the installation or upgrade script should be used" action_to_perform="install" if [[ -f /lib/systemd/system/adsbexchange-mlat.service && -f /lib/systemd/system/adsbexchange-feed.service ]]; then action_to_perform="upgrade" fi -# Begin the install or upgrade process -echo -e "\e[94m Downloading the ${action_to_perform} script...\e[97m" +log_message "Downloading the ADS-B Exchange client ${action_to_perform} script" echo "" if [[ "${action_to_perform}" = "install" ]]; then - wget -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh https://www.adsbexchange.com/feed.sh + wget -v -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh https://www.adsbexchange.com/feed.sh 2>&1 | tee -a $RECEIVER_LOG_FILE else - wget -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh https://www.adsbexchange.com/feed-update.sh + wget -v -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh https://www.adsbexchange.com/feed-update.sh 2>&1 | tee -a $RECEIVER_LOG_FILE fi +echo "" -echo -e "\e[94m Making the ${action_to_perform} script executable...\e[97m" -chmod -x $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh -echo -e "\e[94m Executing the ${action_to_perform} script...\e[97m" +log_message "Executing the ADS-B Exchange client ${action_to_perform} script" echo "" sudo bash $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh echo "" @@ -68,41 +66,52 @@ echo "" ## INSTALL THE ADS-B EXCHANGE STATS PACKAGE -if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B Exchange Feed Setup" --yesno "ADS-B Exchange offers the option to install their stats package in order to send your stats to their site.\n\nWould you like to install the stats package now?" 12 78; then - echo -e "\e[95m Executing the ADS-B Exchange script to install their web interface...\e[97m" - echo "" - echo -e "\e[94m Downloading the stats package installation script...\e[97m" +log_heading "Starting the ADS-B Exchange stats package setup process" + +log_message "Asking if the user wishes to install the ADS-B Exchange stats package" +if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "ADS-B Exchange Feed Setup" \ + --yesno "ADS-B Exchange offers the option to install their stats package in order to send your stats to their site.\n\nWould you like to install the stats package now?" \ + 12 78; then + log_message "Downloading the ADS-B Exchange stats package installation script" echo "" - curl -L -o $RECEIVER_BUILD_DIRECTORY/adsbexchange/axstats.sh https://adsbexchange.com/stats.sh + wget -v -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/axstats.sh https://adsbexchange.com/stats.sh 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" - echo -e "\e[94m Executing the stats package installation script...\e[97m" + echo -e "Executing the ADS-B Exchange stats package installation script" echo "" sudo bash $RECEIVER_BUILD_DIRECTORY/adsbexchange/axstats.sh echo "" +else + log_message "The user opted out of installing the ADS-B Exchange stats package" fi ## INSTALL THE ADS-B EXCHANGE WEB INTERFACE -if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B Exchange Feed Setup" --yesno "ADS-B Exchange offers the option to install an additional web interface.\n\nWould you like to install the web interface now?" 12 78; then - echo -e "\e[95m Executing the ADS-B Exchange script to install their web interface...\e[97m" - echo "" - echo -e "\e[94m Executing the ADS-B Exchange web interface installation script...\e[97m" +log_heading "Starting the ADS-B Exchange web interface setup process" + +log_message "Asking if the user wishes to install the ADS-B Exchange web interface" +if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "ADS-B Exchange Feed Setup" \ + --yesno "ADS-B Exchange offers the option to install an additional web interface.\n\nWould you like to install the web interface now?" \ + 12 78; then + echo -e "Executing the ADS-B Exchange web interface installation script" echo "" sudo bash /usr/local/share/adsbexchange/git/install-or-update-interface.sh echo "" +else + log_message "The user opted out of installing the ADS-B Exchange web interface" fi -## ADS-B EXCHANGE FEED SETUP COMPLETE +## SETUP COMPLETE -# Enter into the project root directory. -echo -e "\e[94m Entering the ADS-B Receiver Project root directory...\e[97m" +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" cd $RECEIVER_ROOT_DIRECTORY echo "" -echo -e "\e[93m-------------------------------------------------------------------------------------------------------" -echo -e "\e[92m ADS-B Exchange feed setup is complete.\e[39m" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "ADS-B Exchange client client setup is complete" echo "" read -p "Press enter to continue..." discard diff --git a/bash/feeders/airplaneslive.sh b/bash/feeders/airplaneslive.sh index 8d515a4c..f1450628 100755 --- a/bash/feeders/airplaneslive.sh +++ b/bash/feeders/airplaneslive.sh @@ -1,113 +1,118 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo -e "" -echo -e "\e[92m Setting up the airplanes.live feeder client..." -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo -e "" - - -# Confirm component installation. -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Airplanes.live Feeder Client Setup" --yesno "The airplanes.live feeder client takes data from a local dump1090 instance and shares this with airplanes.live. for more information please see their website:\n\n https://airplanes.live/how-to-feed/\n\nContinue setup by installing the airplanes.live feeder client?" 13 78 3>&1 1>&2 2>&3; then - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." - echo -e "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m Airplanes.live feeder client setup halted.\e[39m" - echo -e "" - read -p "Press enter to continue..." discard +log_project_title +log_title_heading "Setting up the Airplanes.live client" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Airplanes.live Feeder Client Setup" \ + --yesno "The airplanes.live feeder client takes data from a local dump1090 instance and shares this with airplanes.live. for more information please see their website:\n\n https://airplanes.live/how-to-feed/\n\nContinue setup by installing the airplanes.live feeder client?" \ + 13 78; then + echo "" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "Airplanes.live client setup halted" + echo "" exit 1 fi -## START FEEDER INSTALLATION +## CHECK FOR PREREQUISITE PACKAGES + +log_heading "Installing packages needed to fulfill FlightAware Dump1090 decoder dependencies" -echo -e "" -echo -e "\e[95m Begining the airplanes.live feeder client installation process...\e[97m" -echo -e "" +check_package net-tools + + +## DOWNLOAD AND EXECUTE THE AIRPLANES.LIVE CLIENT INSTALL SCRIPT + +log_heading "Begining the airplanes.live client installation process" + +log_message "Informing the user of how the installation process will work" +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Airplanes.live Client Setup" \ + --msgbox "Scripts supplied by airplanes.live will be used in order to install or upgrade this system. Interaction with the script exececuted will be required in order to complete the installation." \ + 10 78 -# Create the component build directory if it does not exist if [[ ! -d $RECEIVER_BUILD_DIRECTORY/airplaneslive ]]; then - echo -e "\e[94m Creating the airplanes.live feeder client build directory...\e[97m" + log_message "Creating the airplanes.live build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/airplaneslive + mkdir -v $RECEIVER_BUILD_DIRECTORY/airplaneslive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi +log_message "Entering the airplanes.live build directory" +cd $RECEIVER_BUILD_DIRECTORY/airplaneslive -# Change to the component build directory -echo -e "\e[94m Entering the airplanes.live feeder client build directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/airplaneslive 2>&1 +log_message "Downloading the airplanes.live client installation script" echo "" +wget -v -O $RECEIVER_BUILD_DIRECTORY/airplaneslive/install.sh https://raw.githubusercontent.com/airplanes-live/feed/main/install.sh 2>&1 | tee -a $RECEIVER_LOG_FILE -# Download the official airplanes.live feeder installation script -echo -e "\e[95m Beginning the airplanes.live feeder client installation...\e[97m" -echo -e "" - -echo -e "\e[94m Downloading the airplanes.live feeder client installation script...\e[97m" -echo "" -wget -v https://raw.githubusercontent.com/airplanes-live/feed/main/install.sh - -echo -e "\e[94m Executing the airplanes.live feeder client installation script...\e[97m" +log_message "Executing the airplanes.live client installation script" echo "" sudo bash $RECEIVER_BUILD_DIRECTORY/airplaneslive/install.sh echo "" -## CHECK THE STATUS OF THE FEEDER +## CHECK THE STATUS OF THE CLIENT + +log_heading "Checking if the reciver is now feeding airplanes.live" -echo -e "\e[95m Checking if the reciver is now feeding airplanes.live...\e[97m" -echo -e "" -"\e[95m Checking for connections on ports 30004 and 31090 to IP address 78.46.234.18...\e[97m" -netstat_output = `netstat -t -n | grep -E '30004|31090'` -if [[ $netstat_output == *"78.46.234.18:30004 ESTABLISHED"* && $netstat_output == *"78.46.234.18:31090 ESTABLISHED"* ]] - "\e[95m The receiver appears to be feeding airplanes.live...\e[97m" +log_message "Checking for connections on ports 30004 and 31090 to IP address 78.46.234.18" +netstat_output=`netstat -t -n | grep -E '30004|31090'` +if [[ $netstat_output == *"78.46.234.18:30004 ESTABLISHED"* && $netstat_output == *"78.46.234.18:31090 ESTABLISHED"* ]]; then + log_message "This device appears to be connected to airplanes.live" else - "\e[91m The receiver does not appear to be feeding airplanes.live at this time...\e[97m" - "\e[95m Please reboot your device and run the command ''netstat -t -n | grep -E '30004|31090' to see if a connection has been astablished.\e[97m" - "\e[95m If the issue presists supply the last 20 lines given by the following command on the airplanes.live discord.\e[97m" - "\e[95m 'sudo journalctl -u airplanes-feed --no-pager'\e[97m" - "\e[95m 'sudo journalctl -u airplanes-mlat --no-pager'\e[97m" + echo "" + log_alert_message "The receiver does not appear to be feeding airplanes.live at this time" + log_alert_message "Please reboot your device and run the command 'netstat -t -n | grep -E '30004|31090' to see if a connection has been astablished" + log_alert_message "If the issue presists supply the last 20 lines given by the following command on the airplanes.live discord" + log_alert_message " 'sudo journalctl -u airplanes-feed --no-pager'" + log_alert_message " 'sudo journalctl -u airplanes-mlat --no-pager'" fi -echo "" ## INSTALL THE AIRPLANES.LIVE WEB INTERFACE -if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Airplanes.live Web Interface Setup" --yesno "Airplanes.live offers the option to install an additional web interface.\n\nWould you like to install the web interface now?" 12 78; then - echo -e "\e[95m Begining the airplanes.live web interface installation...\e[97m" +log_heading "Starting the airplanes.live web interface setup process" + +log_message "Asking if the user wishes to install the ADS-B Exchange web interface" +if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Airplanes.live Web Interface Setup" \ + --yesno "Airplanes.live offers the option to install an additional web interface.\n\nWould you like to install the web interface now?" \ + 12 78; then echo "" - echo -e "\e[94m Executing the airplanes.live web interface installation script...\e[97m" + log_message "Executing the airplanes.live web interface installation script" echo "" sudo bash sudo bash /usr/local/share/airplanes/git/install-or-update-interface.sh - echo "" +else + log_message "The user opted out of installing the airplanes.live web interface" fi -## POST INSTALLATION INFORMATION +## POST INSTALLATION OPERATIONS -whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Airplanes.live Feeder Setup Complete" --msgbox "Setup of the airplanes.live feeder client is now complete. You can check your feeder status at https://airplanes.live/myfeed." 12 78 +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Airplanes.live Client Setup Complete" \ + --msgbox "Setup of the airplanes.live client is now complete. You can check your feeder status at https://airplanes.live/myfeed." \ + 12 78 ## SETUP COMPLETE -# Return to the project root directory -echo -e "\e[94m Returning to ${RECEIVER_PROJECT_TITLE} root directory...\e[97m" -cd $RECEIVER_ROOT_DIRECTORY 2>&1 +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m Airplanes.live feeder client setup is complete.\e[39m" -echo -e "" +echo "" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "Airplanes.live client setup is complete" +echo "" read -p "Press enter to continue..." discard exit 0 diff --git a/bash/feeders/flightradar24.sh b/bash/feeders/flightradar24.sh index 92d3b107..6027e0f5 100755 --- a/bash/feeders/flightradar24.sh +++ b/bash/feeders/flightradar24.sh @@ -1,105 +1,97 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo -e "" -echo -e "\e[92m Setting up FlightRadar24 feeder client..." -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo -e "" - -# Confirm component installation. -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "FlightRadar24 feeder client Setup" --yesno "The FlightRadar24 feeder client takes data from a local dump1090 instance and shares this with FlightRadar24 using the fr24feed package, for more information please see their website:\n\n https://www.flightradar24.com/share-your-data\n\nContinue setup by installing the FlightRadar24 feeder client?" 13 78 3>&1 1>&2 2>&3; then - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." - echo -e "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m FlightRadar24 feeder client setup halted.\e[39m" - echo -e "" - read -p "Press enter to continue..." discard +log_project_title +log_title_heading "Setting up the FlightRadar24 client" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "FlightRadar24 feeder client Setup" \ + --yesno "The FlightRadar24 feeder client takes data from a local dump1090 instance and shares this with FlightRadar24 using the fr24feed package, for more information please see their website:\n\n https://www.flightradar24.com/share-your-data\n\nContinue setup by installing the FlightRadar24 feeder client?" \ + 13 78; then + echo "" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightRadar24 client setup halted" + echo "" exit 1 fi -## START INSTALLATION +## DOWNLOAD AND EXECUTE THE FLIGHTRADAR24 CLIENT INSTALL SCRIPT -echo -e "" -echo -e "\e[95m Begining the FlightRadar24 feeder client installation process...\e[97m" -echo -e "" +log_heading "Begining the FlightRadar24 client installation process" -# Create the component build directory if it does not exist if [[ ! -d $RECEIVER_BUILD_DIRECTORY/flightradar24 ]]; then - echo -e "\e[94m Creating the FlightRadar24 feeder client build directory...\e[97m" + log_message "Creating the FlightRadar24 build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/flightradar24 + mkdir -v $RECEIVER_BUILD_DIRECTORY/flightradar24 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi +log_message "Entering the FlightRadar24 build directory" +cd $RECEIVER_BUILD_DIRECTORY/flightradar24 -# Change to the component build directory -echo -e "\e[94m Entering the FlightRadar24 feeder client build directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/flightradar24 2>&1 +log_message "Downloading the airplanes.live client installation script" echo "" - -# Download the official Flightradar24 installation script -echo -e "\e[95m Beginning the Flightradar24 client installation...\e[97m" -echo -e "" - -echo -e "\e[94m Downloading the Flightradar24 client installation script...\e[97m" +wget -v -O $RECEIVER_BUILD_DIRECTORY/flightradar24/install.sh https://fr24.com/install.sh 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -wget -v https://fr24.com/install.sh -echo -e "\e[94m Executing the Flightradar24 client installation script...\e[97m" +log_message "Executing the airplanes.live client installation script" echo "" sudo bash $RECEIVER_BUILD_DIRECTORY/flightradar24/install.sh echo "" -# Check that the component package was installed successfully. -echo -e "\e[94m Checking that the FlightRadar24 feeder client package was installed properly...\e[97m" +## CHECK THE STATUS OF THE CLIENT + +log_heading "Checking if the FlightRadar24 client was installed successfully" + +echo -e "\e[94m Checking that the FlightRadar24 client package was installed" if [[ $(dpkg-query -W -f='${STATUS}' fr24feed 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then - echo -e "" - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " UNABLE TO INSTALL A REQUIRED PACKAGE." - echo -e " SETUP HAS BEEN TERMINATED!" - echo -e "" - echo -e "\e[93mThe package \"fr24feed\" could not be installed.\e[39m" - echo -e "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m FlightRadar24 feeder client setup halted.\e[39m" - echo -e "" - read -p "Press enter to continue..." CONTINUE + echo "" + log_alert_heading "INSTALLATION HALTED" + echo "" + log_alert_message "FlightRadar24 package installation failed" + log_alert_message "Setup has been terminated" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightRadar24 client setup failed" + echo "" + read -p "Press enter to continue..." discard exit 1 fi -## COMPONENT POST INSTALL ACTIONS +## POST INSTALLATION OPERATIONS -# If sharing to other networks alongside Flightradar24 make sure MLAT is disabled -echo -e "\e[94m Flightradar24 asks that MLAT be disabled if sharing with other networks...\e[97m" -ChangeConfig "mlat" "no" "/etc/fr24feed.ini" -ChangeConfig "mlat-without-gps" "no" "/etc/fr24feed.ini" -echo -e "\e[94m Restarting the Flightradar24 client...\e[97m" +log_heading "Performing post installation operations" + +log_message "Flightradar24 asks that MLAT be disabled if sharing with other networks" +change_config "mlat" "no" "/etc/fr24feed.ini" +change_config "mlat-without-gps" "no" "/etc/fr24feed.ini" +log_message "Restarting the Flightradar24 client" sudo systemctl restart fr24feed +log_warning_message "If the Flightradar24 client is the only feeder utilizing MLAT execute the following commands to enable MLAT" +log_warning_message 'sudo sed -i -e "s/\(mlat *= *\).*/\1\"yes\"/" /etc/fr24feed.ini' +log_warning_message 'sudo sed -i -e "s/\(mlat-without-gps *= *\).*/\1\"yes\"/" /etc/fr24feed.ini' + ## SETUP COMPLETE -# Return to the project root directory -echo -e "\e[94m Returning to ${RECEIVER_PROJECT_TITLE} root directory...\e[97m" -cd $RECEIVER_ROOT_DIRECTORY 2>&1 +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m FlightRadar24 feeder client setup is complete.\e[39m" -echo -e "" +echo "" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "FlightRadar24 client setup is complete" +echo "" read -p "Press enter to continue..." discard exit 0 diff --git a/bash/feeders/flyitalyadsb.sh b/bash/feeders/flyitalyadsb.sh old mode 100644 new mode 100755 index 39888364..b1ae0946 --- a/bash/feeders/flyitalyadsb.sh +++ b/bash/feeders/flyitalyadsb.sh @@ -1,99 +1,88 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo -e "" -echo -e "\e[92m Setting up the Fly Italy ADS-B feeder client..." -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo -e "" - -# Confirm component installation. -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Fly Italy ADS-B feeder client Setup" --yesno "The Fly Italy ADS-B feeder client takes data from a local dump1090 instance and shares this with Fly Italy ADS-B. for more information please see their website:\n\n https://flyitalyadsb.com/come-condividere-la-propria-antenna/\n\nContinue setup by installing the Fly Italy ADS-B feeder client?" 13 78 3>&1 1>&2 2>&3; then - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." - echo -e "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m Fly Italy ADS-B feeder client setup halted.\e[39m" - echo -e "" - read -p "Press enter to continue..." discard +log_project_title +log_title_heading "Setting up the Fly Italy ADS-B client" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Fly Italy ADS-B feeder client Setup" \ + --yesno "The Fly Italy ADS-B feeder client takes data from a local dump1090 instance and shares this with Fly Italy ADS-B. for more information please see their website:\n\n https://flyitalyadsb.com/come-condividere-la-propria-antenna/\n\nContinue setup by installing the Fly Italy ADS-B feeder client?" \ + 13 78; then + echo "" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "Fly Italy ADS-B client setup halted" + echo "" exit 1 fi -## START FEEDER +## DOWNLOAD AND EXECUTE THE PROPER FLY ITALY ADS-B CLIENT SCRIPT -echo -e "" -echo -e "\e[95m Begining the Fly Italy ADS-B feeder client installation process...\e[97m" -echo -e "" +log_heading "Begining the Fly Italy ADS-B client installation process" -# Create the component build directory if it does not exist +log_message "Informing the user of how the installation process will work" +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Fly Italy ADS-B Client Setup" \ + --msgbox "Scripts supplied by Fly Italy ADS-B will be used in order to install or upgrade this system. Interaction with the script exececuted will be required in order to complete the installation." \ + 10 78 if [[ ! -d $RECEIVER_BUILD_DIRECTORY/flyitalyadsb ]]; then - echo -e "\e[94m Creating the Fly Italy ADS-B feeder client build directory...\e[97m" + log_message "Creating the Fly Italy ADS-B build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/flyitalyadsb + mkdir -v $RECEIVER_BUILD_DIRECTORY/flyitalyadsb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi +log_message "Entering the Fly Italy ADS-B build directory" +cd $RECEIVER_BUILD_DIRECTORY/flyitalyadsb -# Change to the component build directory -echo -e "\e[94m Entering the Fly Italy ADS-B feeder client build directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/flyitalyadsb 2>&1 +log_message "Downloading the Fly Italy ADS-B installation script" echo "" - -# Download the official Fly Italy ADS-B feeder installation script -echo -e "\e[95m Beginning the Fly Italy ADS-B feeder client installation...\e[97m" -echo -e "" - -echo -e "\e[94m Downloading the Fly Italy ADS-B feeder client installation script...\e[97m" -echo "" -wget -v https://raw.githubusercontent.com/flyitalyadsb/fly-italy-adsb/master/install.sh - -echo -e "\e[94m Executing the Fly Italy ADS-B feeder client installation script...\e[97m" +wget -v -O $RECEIVER_BUILD_DIRECTORY/flyitalyadsb/install.sh https://raw.githubusercontent.com/flyitalyadsb/fly-italy-adsb/master/install.sh 2>&1 | tee -a $RECEIVER_LOG_FILE +log_message "Executing the Fly Italy ADS-B feeder installation script" echo "" sudo bash $RECEIVER_BUILD_DIRECTORY/flyitalyadsb/install.sh -echo "" - -## INSTALL UPDATER - -if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Install The Fly Italy ADS-B Updater" --yesno "It is recommended that the Fly Italy ADS-B updater be installed as well.\n\nWould you like to install the updater at this time?" 12 78; - # Download the official Fly Italy ADS-B feeder updater script - echo -e "\e[95m Beginning the Fly Italy ADS-B feeder updater installation...\e[97m" - echo -e "" - - echo -e "\e[94m Downloading the Fly Italy ADS-B feeder updater installation script...\e[97m" +log_message "Asking if the user wishes to install the Fly Italy ADS-B updater" +if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Install The Fly Italy ADS-B Updater" \ + --yesno "It is recommended that the Fly Italy ADS-B updater be installed as well.\n\nWould you like to install the updater at this time?" \ + 12 78; then + log_message "Downloading the Fly Italy ADS-B updater script" echo "" - wget -v wget https://raw.githubusercontent.com/flyitalyadsb/mlat-client/master/scripts/install_updater.sh - - echo -e "\e[94m Executing the Fly Italy ADS-B feeder updater installation script...\e[97m" + wget -v -O $RECEIVER_BUILD_DIRECTORY/flyitalyadsb/install_updater.sh https://raw.githubusercontent.com/flyitalyadsb/mlat-client/master/scripts/install_updater.sh 2>&1 | tee -a $RECEIVER_LOG_FILE + log_message "Executing the Fly Italy ADS-B feeder updater script" echo "" sudo bash $RECEIVER_BUILD_DIRECTORY/flyitalyadsb/install_updater.sh - echo "" fi -## POST INSTALLATION INFORMATION +## POST INSTALLATION OPERATIONS + +log_heading "Performing post installation operations" + +log_message "Informing user as to how to check client status" +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Fly Italy ADS-B Feeder Setup Complete" \ + --msgbox "To check the status of your installation vist https://flyitalyadsb.com/stato-ricevitore/.\n\nFor information on configuring your Fly Italy ADS-B feeder visit https://flyitalyadsb.com/configurazione-script/" \ + 12 78 -whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Fly Italy ADS-B Feeder Setup Complete" --msgbox "To check the status of your installation vist https://flyitalyadsb.com/stato-ricevitore/.\n\nFor information on configuring your Fly Italy ADS-B feeder visit https://flyitalyadsb.com/configurazione-script/" 12 78 ## SETUP COMPLETE -# Return to the project root directory -echo -e "\e[94m Returning to ${RECEIVER_PROJECT_TITLE} root directory...\e[97m" -cd $RECEIVER_ROOT_DIRECTORY 2>&1 +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m Fly Italy ADS-B feeder client setup is complete.\e[39m" -echo -e "" +echo "" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "Fly Italy ADS-B client setup is complete" +echo "" read -p "Press enter to continue..." discard exit 0 diff --git a/bash/feeders/openskynetwork.sh b/bash/feeders/openskynetwork.sh index 6bd0b319..6658963c 100755 --- a/bash/feeders/openskynetwork.sh +++ b/bash/feeders/openskynetwork.sh @@ -1,77 +1,88 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo -e "" -echo -e "\e[92m Setting up OpenSky Network feeder client..." -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo -e "" - -# Confirm component installation. -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "OpenSky Network feeder client Setup" --yesno "The OpenSky Network is a community-based receiver network which continuously collects air traffic surveillance data. Unlike other networks, OpenSky keeps the collected data forever and makes it accessible to researchers. For more information please see their website:\n\n https://opensky-network.org/\n\nContinue setup by installing the OpenSky Network feeder client?" 13 78 3>&1 1>&2 2>&3; then - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." - echo -e "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m OpenSky Network feeder client setup halted.\e[39m" - echo -e "" - read -p "Press enter to continue..." discard +log_project_title +log_title_heading "Setting up the OpenSky Network client" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "OpenSky Network feeder client Setup" \ + --yesno "The OpenSky Network is a community-based receiver network which continuously collects air traffic surveillance data. Unlike other networks, OpenSky keeps the collected data forever and makes it accessible to researchers. For more information please see their website:\n\n https://opensky-network.org/\n\nContinue setup by installing the OpenSky Network feeder client?" \ + 13 78; then + echo "" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "OpenSky Network client setup halted" + echo "" exit 1 fi +## CHECK FOR PREREQUISITE PACKAGES + +log_heading "Installing packages needed to fulfill OpenSky Network client dependencies" + +check_package apt-transport-https + + ## ADD THE OPENSKY NETWORK APT REPOSITORY TO THE SYSTEM IF IT DOES NOT ALREADY EXIST -echo -e "\e[95m Setting up the OpenSky Network apt repository if it has not yet been setup...\e[97m" -echo "" +log_heading "Setting up the OpenSky Network apt repository if it has not yet been setup...\e[97m" +log_message "Checking if the OpenSky Network apt repository is set up" if ! grep -q "^deb .*opensky." /etc/apt/sources.list /etc/apt/sources.list.d/*; then - echo -e "\e[94m The OpenSky Network apt repository is not set up...\e[97m" - CheckPackage apt-transport-https - echo -e "\e[94m Downloading the OpenSky Network apt repository GPG key...\e[97m" + log_message "The OpenSky Network apt repository is not set up" + + if [[ ! -d $RECEIVER_BUILD_DIRECTORY/openskynetwork ]]; then + log_message "Creating the OpenSky Network build directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/openskynetwork 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + fi + log_message "Entering the OpenSky Network build directory" + cd $RECEIVER_BUILD_DIRECTORY/openskynetwork + + log_message "Downloading and adding the OpenSky Network apt repository GPG key" echo "" - wget -O - https://opensky-network.org/files/firmware/opensky.gpg.pub | sudo apt-key add - + wget -v -O $RECEIVER_BUILD_DIRECTORY/openskynetwork/opensky.gpg.pub https://opensky-network.org/files/firmware/opensky.gpg.pub 2>&1 | tee -a $RECEIVER_LOG_FILE + wget -q -O - https://opensky-network.org/files/firmware/opensky.gpg.pub | sudo apt-key add - 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" - echo -e "\e[94m Adding the OpenSky Network apt repository...\e[97m" + log_message "Adding the OpenSky Network apt repository" sudo bash -c "echo deb https://opensky-network.org/repos/debian opensky custom > /etc/apt/sources.list.d/opensky.list" else - echo -e "\e[94m The OpenSky Network apt repository already exists in /etc/apt/sources.list.d/...\e[97m" + log_message "The OpenSky Network apt repository is already set up" fi -echo "" ## INSTALL THE OPENSKY NETWORK FEEDER PACKAGE USING APT -echo -e "\e[95m Installing the OpenSky Network feeder package...\e[97m" -echo "" +log_heading "Installing the OpenSky Network feeder package" -echo -e "\e[94m Downloading the latest package lists for all enabled repositories and PPAs...\e[97m" +log_message "Downloading the latest package lists for all enabled repositories and PPAs" echo "" -sudo apt-get update +sudo apt-get update 2>&1 | tee -a $RECEIVER_LOG_FILE +echo "" +log_message "Installing the OpenSky Network fedder package using apt" +echo "" +sudo apt-get install opensky-feeder echo "" -echo -e "\e[94m Installing the OpenSky Network fedder package using apt...\e[97m" -CheckPackage opensky-feeder ## SETUP COMPLETE -# Return to the project root directory -echo -e "\e[94m Returning to ${RECEIVER_PROJECT_TITLE} root directory...\e[97m" -cd ${RECEIVER_ROOT_DIRECTORY} 2>&1 +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m OpenSky Network feeder client setup is complete.\e[39m" -echo -e "" +echo "" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "OpenSky Network client setup is complete" +echo "" read -p "Press enter to continue..." discard exit 0 diff --git a/bash/feeders/piaware.sh b/bash/feeders/piaware.sh index 14911c25..4c16acc6 100755 --- a/bash/feeders/piaware.sh +++ b/bash/feeders/piaware.sh @@ -1,236 +1,281 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +# THE FLIGHTAWARE PIAWARE CLIENT SETUP SCRIPT -source $RECEIVER_BASH_DIRECTORY/variables.sh -source $RECEIVER_BASH_DIRECTORY/functions.sh +# JPROCHAZKA/PIAWARE_BUILDER REPOSITORY +# ----------------------------------------------------------------------------------- +# I submitted a fix to support Debian Trixie and Ubuntu Noble Numbat to FlightAware's +# piaware_builder repository. Until the changes are merged into their Git reposiory +# the installation will be done using the fork I created along with the branch which +# contains the changes needed in order to build the package. +# +# https://github.com/flightaware/piaware_builder/pull/26 +# TCLTLS-REBUILD +# ----------------------------------------------------------------------------------- +# Along with PiAware, a version of tcltls maintained by FlightAware can be installed. +# This package is only needed for Debian Buster and possibly Ubuntu Focal Fossa. Once +# these releases pass their end of life date the scripting will be removed. +# +# Debian Buster's end of life occured June 30, 2024 and is no longer supported. +# Ubuntu Focal Fossa's end of life is scheduled for April 2025. -## BEGIN SETUP -clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo "" -echo -e "\e[92m Setting up FlightAware PiAware client..." -echo "" -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo "" +## PRE INSTALLATION OPERATIONS + +source $RECEIVER_BASH_DIRECTORY/variables.sh +source $RECEIVER_BASH_DIRECTORY/functions.sh -# Confirm component installation -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 - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." +clear +log_project_title +log_title_heading "Setting up the FlightAware PiAware client" +log_title_message "------------------------------------------------------------------------------" +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; then echo "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m FlightAware PiAware client setup halted.\e[39m" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightAware PiAware client setup halted" echo "" - read -p "Press enter to continue..." discard exit 1 fi ## CHECK FOR PREREQUISITE PACKAGES -echo -e "\e[95m Installing packages needed to fulfill dependencies for FlightAware PiAware client...\e[97m" -echo "" -CheckPackage build-essential -CheckPackage git -CheckPackage devscripts -CheckPackage debhelper -CheckPackage tcl8.6-dev -CheckPackage autoconf -CheckPackage python3-dev -CheckPackage python3-venv -CheckPackage python3-setuptools -CheckPackage zlib1g-dev -CheckPackage openssl -CheckPackage libboost-system-dev -CheckPackage libboost-program-options-dev -CheckPackage libboost-regex-dev -CheckPackage libboost-filesystem-dev -CheckPackage patchelf -CheckPackage python3-pip -CheckPackage python3-setuptools -CheckPackage python3-wheel -CheckPackage net-tools -CheckPackage tclx8.4 -CheckPackage tcllib -CheckPackage itcl3 -CheckPackage libssl-dev -CheckPackage tcl-dev -CheckPackage chrpath - -# Some older distros may need different packages than newer ones -case ${RECEIVER_OS_CODE_NAME} in - focal) - CheckPackage python3-dev - ;; - *) - CheckPackage python3-build - ;; -esac +log_heading "Installing packages needed to fulfill FlightAware PiAware client dependencies" + +check_package autoconf +check_package build-essential +check_package chrpath +check_package debhelper +check_package devscripts +check_package git +check_package itcl3 +check_package libboost-filesystem-dev +check_package libboost-program-options-dev +check_package libboost-regex-dev +check_package libboost-system-dev +check_package libssl-dev +check_package net-tools +check_package openssl +check_package patchelf +check_package python3-dev +check_package python3-pip +check_package python3-setuptools +check_package python3-venv +check_package python3-wheel +check_package tcl-dev +check_package tcl8.6-dev +check_package tcllib +check_package tclx8.4 +check_package zlib1g-dev + +if [[ "${RECEIVER_OS_CODE_NAME}" == "noble" ]]; then + check_package python3-pyasyncore +fi -echo "" +if [[ "${RECEIVER_OS_CODE_NAME}" == "focal" ]]; then + check_package python3-dev +else + check_package python3-build + check_package tcl-tls +fi -## DOWNLOAD OR UPDATE THE TCLTLS REBUILD SOURCE +## CLONE OR PULL THE TCLTLS REBUILD GIT REPOSITORY -echo -e "\e[95m Preparing the tcltls rebuild Git repository...\e[97m" -echo "" -# 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 - echo -e "\e[94m Entering the tcltls-rebuild git repository directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild 2>&1 - echo -e "\e[94m Updating the local tcltls-rebuild git repository...\e[97m" - echo "" - git pull 2>&1 -else - # A directory containing the source code does not exist in the build directory - echo -e "\e[94m Entering the ADS-B Receiver Project build directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY 2>&1 - echo -e "\e[94m Cloning the tcltls-rebuild git repository locally...\e[97m" +if [[ "${RECEIVER_OS_CODE_NAME}" == "focal" ]]; then + + log_heading "Preparing the FlightAware tcltls-rebuild Git repository" + + if [[ -d $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild && -d $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/.git ]]; then + log_message "Entering the tcltls-rebuild git repository directory" + cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild + log_message "Updating the local tcltls-rebuild git repository" + echo "" + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE + else + log_message "Creating the tcltls-rebuild build directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + log_message "Entering the tcltls-rebuild build directory" + cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild + log_message "Cloning the tcltls-rebuild git repository locally" + echo "" + git clone https://github.com/flightaware/tcltls-rebuild 2>&1 | tee -a $RECEIVER_LOG_FILE + fi echo "" - git clone https://github.com/flightaware/tcltls-rebuild 2>&1 -fi -echo "" -## BUILD AND INSTALL THE DUMP1090-FA PACKAGE + ## BUILD AND INSTALL THE TCLTLS-REBUILD PACKAGE -echo -e "\e[95m Building and installing the tcltls rebuild package...\e[97m" -echo -e "" + log_heading "Beginning the FlightAware tcltls-rebuild installation process" -echo -e "\e[94m Entering the tcltls-rebuild source directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcltls-1.7.22 2>&1 -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 "" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcl-tls_1.7.22-2+fa1_*.deb 2>&1 -echo "" -echo -e "\e[94m Moving the tcltls-rebuild binary package into the archive directory...\e[97m" -echo "" -cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 -echo "" + log_message "Checking if the FlightAware tcltls-rebuild is required" + + log_message "Entering the tcltls-rebuild source directory" + cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcltls-1.7.22 + log_message "Building the tcltls-rebuild package" + echo "" + dpkg-buildpackage -b 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + log_message "Installing the tcltls-rebuild package" + echo "" + sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcl-tls_1.7.22-2+fa1_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + + log_message "Checking that the FlightAware tcltls-rebuild package was installed properly" + if [[ $(dpkg-query -W -f='${STATUS}' tcltls 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then + echo "" + log_alert_heading "INSTALLATION HALTED" + echo "" + log_alert_message "FlightAware tcltls-rebuild package installation failed" + log_alert_message "Setup has been terminated" + echo "" + log_title_message "------------------------------------------------------------------------------" + "FlightAware PiAware client setup failed" + echo "" + read -p "Press enter to continue..." discard + exit 1 + else + if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then + log_message "Creating the package archive directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + fi + log_message "Copying the FlightAware tcltls-rebuild Debian package into the archive directory" + echo "" + cp -vf $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE + fi +fi -## START INSTALLATION +## CLONE OR PULL THE PIAWARE_BUILDER GIT REPOSITORY -echo -e "\e[95m Begining the FlightAware PiAware client installation process...\e[97m" -echo "" +log_heading "Preparing the FlightAware piaware_builder Git repository" 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 - echo -e "\e[94m Entering the piaware_builder git repository directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY/piaware_builder 2>&1 - echo -e "\e[94m Updating the local piaware_builder git repository...\e[97m" + log_message "Entering the piaware_builder git repository directory" + cd $RECEIVER_BUILD_DIRECTORY/piaware_builder + log_message "Updating the local piaware_builder git repository" echo "" - git pull 2>&1 + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE else - # A directory containing the source code does not exist in the build directory - echo -e "\e[94m Entering the ADS-B Receiver Project build directory...\e[97m" - cd $RECEIVER_BUILD_DIRECTORY 2>&1 - echo -e "\e[94m Cloning the piaware_builder git repository locally...\e[97m" + log_message "Creating the FlightAware piaware_builder build directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/piaware_builder 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + log_message "Entering the ADS-B Receiver Project build directory" + cd $RECEIVER_BUILD_DIRECTORY + log_message "Cloning the piaware_builder git repository locally" echo "" - git clone https://github.com/flightaware/piaware_builder.git 2>&1 + + # --- START TEMPORARY NOBLE FIX --- + if [[ "${RECEIVER_OS_CODE_NAME}" == "noble" ]]; then + git clone https://github.com/jprochazka/piaware_builder.git 2>&1 | tee -a $RECEIVER_LOG_FILE + else + git clone https://github.com/flightaware/piaware_builder.git 2>&1 | tee -a $RECEIVER_LOG_FILE + fi + + #git clone https://github.com/flightaware/piaware_builder.git 2>&1 | tee -a $RECEIVER_LOG_FILE + # --- END TEMPORARY NOBLE FIX --- fi -echo "" -## BUILD AND INSTALL THE COMPONENT PACKAGE +## BUILD AND INSTALL THE PIAWARE CLIENT PACKAGE -echo -e "\e[95m Building and installing the FlightAware PiAware client package...\e[97m" -echo "" +log_heading "Beginning the FlightAware PiAware installation process" -# 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 +log_message "Entering the piaware_builder git repository directory" +cd $RECEIVER_BUILD_DIRECTORY/piaware_builder -# Execute build script +# --- START TEMPORARY NOBLE FIX --- +if [[ "${RECEIVER_OS_CODE_NAME}" == "noble" ]]; then + git checkout trixie +fi +# --- END TEMPORARY NOBLE FIX --- + +log_message "Determining which piaware_builder build strategy should be use" distro="bookworm" case $RECEIVER_OS_CODE_NAME in - buster | focal) + focal) distro="buster" ;; bullseye | jammy) distro="bullseye" ;; - bookworm) + bookworm | noble) distro="bookworm" ;; esac -echo -e "\e[94m Executing the FlightAware PiAware client build script...\e[97m" +log_message "Setting distribution to build for to ${distro}" + +log_message "Executing the FlightAware PiAware client build script" echo "" -./sensible-build.sh $distro +./sensible-build.sh $distro 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" - -# Change to build script directory -echo -e "\e[94m Entering the FlightAware PiAware client build directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/piaware_builder/package-${distro} 2>&1 - -# Build binary package -echo -e "\e[94m Building the FlightAware PiAware client package...\e[97m" +log_message "Entering the FlightAware PiAware client build directory" +cd $RECEIVER_BUILD_DIRECTORY/piaware_builder/package-${distro} +log_message "Building the FlightAware PiAware client package" echo "" -dpkg-buildpackage -b 2>&1 +dpkg-buildpackage -b 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" - -# Install binary package -echo -e "\e[94m Installing the FlightAware PiAware client package...\e[97m" +log_message "Installing the FlightAware PiAware client package" echo "" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/piaware_builder/piaware_*.deb 2>&1 +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/piaware_builder/piaware_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -# Check that the component package was installed successfully. -echo -e "\e[94m Checking that the FlightAware PiAware client package was installed properly...\e[97m" - +log_message "Checking that the FlightAware PiAware client package was installed properly" if [[ $(dpkg-query -W -f='${STATUS}' piaware 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then + log_alert_heading "INSTALLATION HALTED" echo "" - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " UNABLE TO INSTALL A REQUIRED PACKAGE." - echo -e " SETUP HAS BEEN TERMINATED!" + log_alert_message "FlightAware PiAware package installation failed" + log_alert_message "Setup has been terminated" echo "" - echo -e "\e[93mThe package \"piaware\" could not be installed.\e[39m" - echo "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m FlightAware PiAware client setup halted.\e[39m" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "FlightAware PiAware client setup failed" echo "" read -p "Press enter to continue..." discard exit 1 else - # Create binary package archive directory. if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then - echo -e "\e[94m Creating package archive directory...\e[97m" + log_message "Creating the package archive directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi - - # Archive binary package. - echo -e "\e[94m Moving the FlightAware PiAware client binary package into the archive directory...\e[97m" - echo "" - cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 + log_message "Copying the FlightAware PiAware client binary package into the archive directory" echo "" + cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE fi -## COMPONENT POST INSTALL ACTIONS +## POST INSTALLATION OPERATIONS + +log_heading "Performing post installation operations" -# Instruct the user as to how they can claim their receiver online. -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 +log_message "Displaying the message informing the user on how to claim their device" +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 ## SETUP COMPLETE -# Return to the project root directory. -echo -e "\e[94m Returning to ${RECEIVER_PROJECT_TITLE} root directory...\e[97m" -cd $RECEIVER_ROOT_DIRECTORY 2>&1 +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY echo "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m FlightAware PiAware client setup is complete.\e[39m" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "FlightAware PiAware client setup is complete" echo "" read -p "Press enter to continue..." discard diff --git a/bash/feeders/planefinder.sh b/bash/feeders/planefinder.sh index ee3dec3b..ddcda2a1 100755 --- a/bash/feeders/planefinder.sh +++ b/bash/feeders/planefinder.sh @@ -1,148 +1,128 @@ #!/bin/bash -## INCLUDE EXTERNAL SCRIPTS +## PRE INSTALLATION OPERATIONS source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo -e "" -echo -e "\e[92m Setting up PlaneFinder ADS-B Client..." -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo -e "" - -# Confirm component installation -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "PlaneFinder ADS-B Client Setup" --yesno "The PlaneFinder 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 PlaneFinder ADS-B Client?" 13 78 3>&1 1>&2 2>&3; then - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user." - echo -e "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m PlaneFinder ADS-B Client setup halted.\e[39m" - echo -e "" - read -p "Press enter to continue..." discard +log_project_title +log_title_heading "Setting up the PlaneFinder client" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "PlaneFinder ADS-B Client Setup" \ + --yesno "The PlaneFinder 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 PlaneFinder ADS-B Client?" \ + 13 78; then + echo "" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "PlaneFinder client setup halted" + echo "" exit 1 fi ## CHECK FOR PREREQUISITE PACKAGES -echo -e "\e[95m Installing packages needed to fulfill dependencies for PlaneFinder ADS-B Client...\e[97m" -echo -e "" -CheckPackage wget +log_heading "Installing packages needed to fulfill PlaneFinder client dependencies" + +check_package wget -# Some architectures require additional packages. case "${RECIEVER_CPU_ARCHITECTURE}" in "aarch64") - echo -e "\e[94m Adding support for the armhf architecture...\e[97m" sudo dpkg --add-architecture armhf - CheckPackage libc6:armhf + check_package libc6:armhf ;; esac -echo "" -## DETERMINE WHICH PACACKAGE TO INSTALL +## DOWNLOAD AND INSTALL THE PROPER PLANEFINDER CLIENT DEBIAN PACKAGE + + +log_heading "Begining the PlaneFinder client installation process" + -echo -e "\e[94m Determining the package to install...\e[97m" -BASE_DOWNLOAD_URL="http://client.planefinder.net/" +log_message "Determining which Debian package to install" case "${RECIEVER_CPU_ARCHITECTURE}" in - "armv7l"|"armv6l") - PACKAGE_NAME="pfclient_${PLANEFINDER_CLIENT_VERSION_ARMHF}_armhf.deb" - ;; - "aarch64") - PACKAGE_NAME="pfclient_${PLANEFINDER_CLIENT_VERSION_ARM64}_armhf.deb" + "armv7l"|"armv6l"|"aarch64") + package_name="pfclient_${pfclient_current_version_armhf}_armhf.deb" ;; "x86_64") - PACKAGE_NAME="pfclient_${PLANEFINDER_CLIENT_VERSION_AMD64}_amd64.deb" + package_name="pfclient_${pfclient_current_version_amd64}_amd64.deb" ;; "i386") - PACKAGE_NAME="pfclient_${PLANEFINDER_CLIENT_VERSION_I386}_i386.deb" + package_name="pfclient_${pfclient_current_version_amd64}_i386.deb" ;; *) - echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " Unsupported CPU archetecture." - echo -e "" - echo -e " Archetecture Detected: ${CPU_ARCHITECTURE}" - echo -e "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m PlaneFinder ADS-B Client setup halted.\e[39m" - echo -e "" - read -p "Press enter to continue..." CONTINUE + echo "" + log_alert_heading "INSTALLATION HALTED" + echo "" + log_alert_message "Unsupported CPU Archetecture" + log_alert_message "Archetecture Detected: ${CPU_ARCHITECTURE}" + log_alert_message "Setup has been terminated" + echo "" + log_title_message "------------------------------------------------------------------------------" + log_title_heading "PlaneFinder client setup failed" + echo "" + read -p "Press enter to continue..." discard exit 1 ;; esac - -## START INSTALLATION - -echo -e "" -echo -e "\e[95m Begining the PlaneFinder ADS-B Client installation process...\e[97m" -echo -e "" - -# Create the component build directory if it does not exist if [[ ! -d $RECEIVER_BUILD_DIRECTORY/planefinder ]]; then - echo -e "\e[94m Creating the PlaneFinder ADS-B Client build directory...\e[97m" + log_message "Creating the PlaneFinder build directory" echo "" mkdir -vp $RECEIVER_BUILD_DIRECTORY/planefinder echo "" fi -echo -e "\e[94m Entering the PlaneFinder ADS-B Client build directory...\e[97m" -cd $RECEIVER_BUILD_DIRECTORY/planefinder 2>&1 -echo "" - - -## DOWNLOAD AND INSTALL THE PACKAGE +log_message "Entering the PlaneFinder build directory" +cd $RECEIVER_BUILD_DIRECTORY/planefinder -echo -e "\e[95m Installing the PlaneFinder ADS-B Client package...\e[97m" -echo -e "" - -# Download the appropriate package depending on the devices architecture -echo -e "\e[94m Downloading the appropriate deb package...\e[97m" +log_message "Downloading the appropriate PlaneFinder client Debian package" +echo "" +wget -v -O $RECEIVER_BUILD_DIRECTORY/planefinder/$package_name http://client.planefinder.net/$package_name 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -wget --no-check-certificate ${BASE_DOWNLOAD_URL}/${PACKAGE_NAME} -O $RECEIVER_BUILD_DIRECTORY/planefinder/${PACKAGE_NAME} -# Install the proper package depending on the devices architecture -echo -e "\e[94m Installing the PlaneFinder Client...\e[97m" +log_message "Installing the PlaneFinder Client Debian package" echo -e "" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/planefinder/${PACKAGE_NAME} 2>&1 +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/planefinder/$package_name 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" -# Archive the deb package -echo -e "\e[94m Archiving the deb package...\e[97m" -if [[ ! -d "${RECEIVER_BUILD_DIRECTORY}/package-archive" ]]; then - echo -e "\e[94m Creating package archive directory...\e[97m" - echo -e "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 - echo -e "" +if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then + log_message "Creating the package archive directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" fi -echo -e "\e[94m Moving the PlaneFinder ADS-B Client binary package into the archive directory...\e[97m" -echo -e "" -mv -vf $RECEIVER_BUILD_DIRECTORY/planefinder/pfclient_*.deb $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 -echo -e "" +log_message "Copying the PlaneFinder client Debian package into the archive directory" +echo "" +cp -vf $RECEIVER_BUILD_DIRECTORY/planefinder/$package_name $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE +echo "" + +## POST INSTALLATION OPERATIONS -## COMPONENT POST INSTALL ACTIONS +log_heading "Performing post installation operations" -# Display final setup instructions which cannot be handled by this script +log_message "Displaying the message informing the user on how to complete setup" RECEIVER_IP_ADDRESS=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` -whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "PlaneFinder ADS-B Client Setup Instructions" --msgbox "At this point the PlaneFinder ADS-B Client should be installed and running; however this script is only capable of installing the PlaneFinder ADS-B Client. There are still a few steps left which you must manually do through the PlaneFinder ADS-B Client at the following URL:\n\n http://${RECEIVER_IP_ADDRESS}:30053\n\nThe follow the instructions supplied by the PlaneFinder 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 +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "PlaneFinder ADS-B Client Setup Instructions" \ + --msgbox "At this point the PlaneFinder ADS-B Client should be installed and running; however this script is only capable of installing the PlaneFinder ADS-B Client. There are still a few steps left which you must manually do through the PlaneFinder ADS-B Client at the following URL:\n\n http://${RECEIVER_IP_ADDRESS}:30053\n\nThe follow the instructions supplied by the PlaneFinder 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 ## SETUP COMPLETE -# Return to the project root directory. -echo -e "\e[94m Returning to ${RECEIVER_PROJECT_TITLE} root directory...\e[97m" -cd $RECEIVER_ROOT_DIRECTORY 2>&1 +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m PlaneFinder ADS-B Client setup is complete.\e[39m" -echo -e "" +echo "" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "PlaneFinder client setup is complete" +echo "" read -p "Press enter to continue..." discard exit 0 diff --git a/bash/functions.sh b/bash/functions.sh index 539323d8..4fc072b3 100755 --- a/bash/functions.sh +++ b/bash/functions.sh @@ -1,53 +1,138 @@ #!/bin/bash -# Detect if a package is installed and if not attempt to install it -function CheckPackage { +## LOGGING FUNCTIONS + +# Log a to the log file +function log_to_file() { + if [[ "${RECEIVER_LOGGING_ENABLED}" == "true" ]]; then + time_stamp='' + if [[ -z $2 || "${2}" == "true" ]]; then + printf -v time_stamp '[%(%Y-%m-%d %H:%M:%S)T]' -1 + fi + + if [[ ! -z $3 && "${3}" == "inline" ]]; then + printf "${time_stamp} ${1}" >> $RECEIVER_LOG_FILE + else + echo "${time_stamp} ${1}" >> $RECEIVER_LOG_FILE + fi + fi +} + +# Logs the "PROJECT TITLE" to the console +function log_project_title() { + log_to_file "${RECEIVER_PROJECT_TITLE}" + echo -e "${display_project_name} ${RECEIVER_PROJECT_TITLE}${display_default}" + echo "" +} + +# Logs a "HEADING" to the console +function log_heading() { + log_to_file "${1}" + echo "" + echo -e "${display_heading} ${1}${display_default}" + echo "" +} + +# Logs a "MESSAGE" to the console +function log_message() { + log_to_file "${1}" + echo -e "${display_message} ${1}${display_default}" +} + +# Logs an alert "HEADING" to the console +function log_alert_heading() { + log_to_file "${1}" + echo -e "${display_alert_heading} ${1}${display_default}" +} + +# Logs an alert "MESSAGE" to the console +function log_alert_message() { + log_to_file "${1}" + echo -e "${display_alert_message} ${1}${display_default}" +} + +# Logs an title "HEADING" to the console +function log_title_heading() { + log_to_file "${1}" + echo -e "${display_title_heading} ${1}${display_default}" +} + +# Logs an title "MESSAGE" to the console +function log_title_message() { + log_to_file "${1}" + echo -e "${display_title_message} ${1}${display_default}" +} + +# Logs a warning "HEADING" to the console +function log_warning_heading() { + log_to_file "${1}" + echo -e "${display_warning_heading} ${1}${display_default}" +} + +# Logs a warning "MESSAGE" to the console +function log_warning_message() { + log_to_file "${1}" + echo -e "${display_warning_message} ${1}${display_default}" +} + +function log_message_inline() { + log_to_file "${1}" "true" "inline" + printf "${display_message} ${1}${display_default}" +} + +function log_false_inline() { + log_to_file "${1}" "false" + echo -e "${display_false_inline} ${1}${display_default}" +} + +function log_true_inline() { + log_to_file "${1}" "false" + echo -e "${display_true_inline} ${1}${display_default}" +} + + +## CHECK IF THE SUPPLIED PACKAGE IS INSTALLED AND IF NOT ATTEMPT TO INSTALL IT + +function check_package() { attempt=1 max_attempts=5 wait_time=5 while (( $attempt -le `(($max_attempts + 1))` )); do - - # If the maximum attempts has been reached if [[ $attempt > $max_attempts ]]; then - echo -e "\n\e[91m \e[5mINSTALLATION HALTED!\e[25m" - echo -e " UNABLE TO INSTALL A REQUIRED PACKAGE." - echo -e " SETUP HAS BEEN TERMINATED!\n" - echo -e "\e[93mThe package \"$1\" could not be installed in ${max_attempts} attempts.\e[39m\n" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Unable to install a required package" + log_alert_message "The package $1 could not be installed in ${max_attempts} attempts" exit 1 fi - # Check if the package is already installed - printf "\e[94m Checking if the package $1 is installed..." + log_message_inline "Checking if the package $1 is installed" if [[ $(dpkg-query -W -f='${STATUS}' $1 2>/dev/null | grep -c "ok installed") = 0 ]]; then - - # If this is not the first attempt at installing this package... if [[ $attempt > 1 ]]; then - echo -e "\e[91m \e[5m[INSTALLATION ATTEMPT FAILED]\e[25m" - echo -e "\e[94m Will attempt to Install the package $1 again in ${wait_time} seconds (ATTEMPT ${attempt} OF ${max_attempts})..." + log_alert_message "Inastallation attempt failed" + log_alert_message "Will attempt to Install the package $1 again in ${wait_time} seconds (attempt ${attempt} of ${max_attempts})" sleep $wait_time else - echo -e "\e[91m [NOT INSTALLED]" - echo -e "\e[94m Installing the package $1..." + log_false_inline "[NOT INSTALLED]" + log_message "Installing the package ${1}" fi - - # Attempt to install the required package - echo -e "\e[97m" + echo "" attempt=$((attempt+1)) - sudo apt-get install -y $1 - echo -e "\e[39m" + sudo apt-get install -y $1 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" else - # The package appears to be installed - echo -e "\e[92m [OK]\e[39m" + log_true_inline "[OK]" break fi done } -# Blacklist DVB-T drivers for RTL-SDR devices -function BlacklistModules { + +## BLACKLIST DVB-T DRIVERS FOR RTL-SDR DEVICES + +function blacklist_modules() { if [[ ! -f /etc/modprobe.d/rtlsdr-blacklist.conf || `cat /etc/modprobe.d/rtlsdr-blacklist.conf | wc -l` < 9 ]]; then - echo -en "\e[94m Blacklisting unwanted RTL-SDR kernel modules so they are not loaded...\e[97m" + log_message "Blacklisting unwanted RTL-SDR kernel modules so they are not loaded" sudo tee /etc/modprobe.d/rtlsdr-blacklist.conf > /dev/null </dev/null | grep -c "ok installed") -eq 1 ]] ; then - # Explain to the user that the receiver's latitude and longitude is required. - RECEIVER_LATLON_DIALOG=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Receiver Latitude and Longitude" --msgbox "Your receivers latitude and longitude are required for distance calculations, you will now be asked to supply these values for your receiver.\n\nIf you do not have this information you can obtain it using the web based \"Geocode by Address\" utility hosted on another of the lead developers websites:\n\n https://www.swiftbyte.com/toolbox/geocode" 15 78 3>&1 1>&2 2>&3) - - # Ask the user for the receiver's latitude. - RECEIVER_LATITUDE_TITLE="Receiver Latitude" - while [[ -z "${RECEIVER_LATITUDE}" ]] ; do - RECEIVER_LATITUDE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${RECEIVER_LATITUDE_TITLE}" --nocancel --inputbox "\nEnter your receiver's latitude.\n(Example: XX.XXXXXXX)" 9 78 3>&1 1>&2 2>&3) - RECEIVER_LATITUDE_TITLE="Receiver Latitude (REQUIRED)" - done - - # Ask the user for the receiver's longitude. - RECEIVER_LONGITUDE_TITLE="Receiver Longitude" - while [[ -z "${RECEIVER_LONGITUDE}" ]] ; do - RECEIVER_LONGITUDE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${RECEIVER_LONGITUDE_TITLE}" --nocancel --inputbox "\nEnter your receeiver's longitude.\n(Example: XX.XXXXXXX)" 9 78 3>&1 1>&2 2>&3) - RECEIVER_LONGITUDE_TITLE="Receiver Longitude (REQUIRED)" - done - - echo -e "\e[94m Setting the receiver's latitude to ${RECEIVER_LATITUDE}...\e[97m" - ChangeConfig "LAT" ${RECEIVER_LATITUDE} "/etc/default/dump1090-mutability" - echo -e "\e[94m Setting the receiver's longitude to ${RECEIVER_LONGITUDE}...\e[97m" - ChangeConfig "LON" ${RECEIVER_LONGITUDE} "/etc/default/dump1090-mutability" - - # Ask if dump1090-mutability should bind on all IP addresses. - if (whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Bind Dump1090-mutability To All IP Addresses" --defaultno --yesno "By default dump1090-mutability is bound only to the local loopback IP address(s) for security reasons. However some people wish to make dump1090-mutability's data accessable externally by other devices. To allow this dump1090-mutability can be configured to listen on all IP addresses bound to this device. It is recommended that unless you plan to access this device from an external source that dump1090-mutability remain bound only to the local loopback IP address(s).\n\nWould you like dump1090-mutability to listen on all IP addesses?" 15 78) then - echo -e "\e[94m Binding dump1090-mutability to all available IP addresses...\e[97m" - CommentConfig "NET_BIND_ADDRESS" "/etc/default/dump1090-mutability" - else - echo -e "\e[94m Binding dump1090-mutability to the localhost IP addresses...\e[97m" - ChangeConfig "NET_BIND_ADDRESS" "127.0.0.1" "/etc/default/dump1090-mutability" - fi - - # Reload dump1090-mutability to ensure all changes take effect. - echo -e "\e[94m Reloading dump1090-mutability...\e[97m" - echo -e "" - sudo service dump1090-mutability force-reload -fi - -# Download Heywhatsthat.com maximum range rings if the user wishes them to be displayed. -if [[ ! -f "/usr/share/dump1090-mutability/html/upintheair.json" ]] || [[ ! -f "/usr/share/dump1090-fa/html/upintheair.json" ]] ; then - if (whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Heywhatsthat.com Maximum Range Rings" --yesno "Maximum range rings can be added to dump1090-mutability usings data obtained from Heywhatsthat.com. In order to add these rings to your dump1090-mutability map you will first need to visit http://www.heywhatsthat.com and generate a new panorama centered on the location of your receiver. Once your panorama has been generated a link to the panorama will be displayed in the top left hand portion of the page. You will need the view id which is the series of letters and/or numbers after \"?view=\" in this URL.\n\nWould you like to add heywhatsthat.com maximum range rings to your map?" 16 78); then - HEYWHATSTHATID_TITLE="Heywhatsthat.com Panorama ID" - while [[ -z "${HEYWHATSTHATID}" ]] ; do - HEYWHATSTHATID=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${HEYWHATSTHATID_TITLE}" --nocancel --inputbox "\nEnter your Heywhatsthat.com panorama ID." 8 78 3>&1 1>&2 2>&3) - HEYWHATSTHATID_TITLE="Heywhatsthat.com Panorama ID (REQUIRED)" - done - HEYWHATSTHATRINGONE_TITLE="Heywhatsthat.com First Ring Altitude" - while [[ -z "${HEYWHATSTHATRINGONE}" ]] ; do - HEYWHATSTHATRINGONE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${HEYWHATSTHATRINGONE_TITLE}" --nocancel --inputbox "\nEnter the first ring's altitude in meters.\n(default 3048 meters or 10000 feet)" 8 78 "3048" 3>&1 1>&2 2>&3) - HEYWHATSTHATRINGONE_TITLE="Heywhatsthat.com First Ring Altitude (REQUIRED)" - done - HEYWHATSTHATRINGTWO_TITLE="Heywhatsthat.com Second Ring Altitude" - while [[ -z "${HEYWHATSTHATRINGTWO}" ]] ; do - HEYWHATSTHATRINGTWO=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${HEYWHATSTHATRINGTWO_TITLE}" --nocancel --inputbox "\nEnter the second ring's altitude in meters.\n(default 12192 meters or 40000 feet)" 8 78 "12192" 3>&1 1>&2 2>&3) - HEYWHATSTHATRINGTWO_TITLE="Heywhatsthat.com Second Ring Altitude (REQUIRED)" - done - echo -e "\e[94m Downloading JSON data pertaining to the supplied panorama ID...\e[97m" - echo -e "" - if [[ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then - HTMLPATH="/usr/share/dump1090-mutability/html/upintheair.json" - else - HTMLPATH="/usr/share/dump1090-fa/html/upintheair.json" - fi - sudo wget -O ${HTMLPATH} "http://www.heywhatsthat.com/api/upintheair.json?id=${HEYWHATSTHATID}&refraction=0.25&alts=${HEYWHATSTHATRINGONE},${HEYWHATSTHATRINGTWO}" - fi -else - echo -e "\e[94m Heywhatsthat.com maximum range rings setup skipped..." -fi - -# Dump1090 configuration is now complete. -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m Dump1090 configuration complete.\e[39m" -echo -e "" -if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then - read -p "Press enter to continue..." CONTINUE -fi - - -# CONFIGURE PIAWARE IF NEEDED - -if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then - clear - echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" - echo -e "" - echo -e "\e[92m Configure PiAware..." - echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" - echo -e "" - - # Confirm if the user is able to claim their PiAware instance online. - FLIGHTAWARE_LOCAL_CREDENTIALS=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Claim Your PiAware Device" --yesno "Although it is possible to configure your FlightAware credentials locally, these will be stored in plaintext which represents a security risk that should be avoided.\n\nFlightAware recommends claiming your feeder online using the following page:\n\n http://flightaware.com/adsb/piaware/claim\n\nWill you be able to access the FlightAware website from the same public IP address as the feeder will be sending data from?" 16 78 3>&1 1>&2 2>&3) - - if [[ "${FLIGHTAWARE_LOCAL_CREDENTIALS}" -eq "1" ]] ; then - # Ask for the users FlightAware login. - FLIGHTAWARE_LOGIN=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Your FlightAware Login" --nocancel --inputbox "\nEnter your FlightAware login.\nLeave this blank to manually claim your PiAware device." 9 78 3>&1 1>&2 2>&3) - if [[ ! "${FLIGHTAWARE_LOGIN}" = "" ]] ; then - # If the user supplied their FlightAware login continue with the device claiming process. - FLIGHTAWARE_PASSWORD1_TITLE="Your FlightAware Password" - while [[ -z "${FLIGHTAWARE_PASSWORD1}" ]] ; do - FLIGHTAWARE_PASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${FLIGHTAWARE_PASSWORD1_TITLE}" --nocancel --passwordbox "\nEnter your FlightAware password." 8 78 3>&1 1>&2 2>&3) - done - FLIGHTAWARE_PASSWORD2_TITLE="Confirm Your FlightAware Password" - while [[ -z "${FLIGHTAWARE_PASSWORD2}" ]] ; do - FLIGHTAWARE_PASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${FLIGHTAWARE_PASSWORD2_TITLE}" --nocancel --passwordbox "\nConfirm your FlightAware password." 8 78 3>&1 1>&2 2>&3) - done - while [[ ! "${FLIGHTAWARE_PASSWORD1}" = "${FLIGHTAWARE_PASSWORD2}" ]] ; do - FLIGHTAWARE_PASSWORD1="" - FLIGHTAWARE_PASSWORD2="" - # Display an error message if the passwords did not match. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Claim Your PiAware Device" --msgbox "Passwords did not match.\nPlease enter your password again." 9 78 - FLIGHTAWARE_PASSWORD1_TITLE="Your FlightAware Password (REQUIRED)" - while [[ -z "${FLIGHTAWARE_PASSWORD1}" ]] ; do - FLIGHTAWARE_PASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${FLIGHTAWARE_PASSWORD1_TITLE}" --nocancel --passwordbox "\nEnter your FlightAware password." 8 78 3>&1 1>&2 2>&3) - done - FLIGHTAWARE_PASSWORD2_TITLE="Confirm Your FlightAware Password (REQUIRED)" - while [[ -z "${FLIGHTAWARE_PASSWORD2}" ]] ; do - FLIGHTAWARE_PASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${FLIGHTAWARE_PASSWORD2_TITLE}" --nocancel --passwordbox "\nConfirm your FlightAware password." 8 78 3>&1 1>&2 2>&3) - done - done - else - # Display a message to the user stating they need to manually claim their device. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Claim Your PiAware Device" --msgbox "Please supply your FlightAware login in order to claim this device, after supplying this you will ask you to enter your password for verification.\n\nIf you decide not to provide a login and password at this time you should still be able to claim your feeder by visting the following site:\n\n http://flightaware.com/adsb/piaware/claim" 13 78 - fi - fi - - # PiAware configuration is now complete. - echo -e "" - echo -e "\e[93m ------------------------------------------------------------------------------" - echo -e "\e[92m PiAware configuration complete.\e[39m" - echo -e "" - if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then - read -p "Press enter to continue..." CONTINUE - fi -fi - -## SETUP THE ADS-B RECEIVER PROJECT WEB PORTAL - -chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/install.sh -${RECEIVER_BASH_DIRECTORY}/portal/install.sh -if [[ $? -ne 0 ]] ; then - exit 1 -fi - -## FINALIZE IMAGE SETUP - -# remove the "image" file. -rm -f image - -whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B Receiver Project Image Setup" --msgbox "Image setup is now complete. If you have any questions or comments on the project let us know on our website.\n\n https://www.adsbreceiver.net\n\nRemember to install additional features simply run ./install.sh again." 12 78 - -exit 0 diff --git a/bash/init.sh b/bash/init.sh index 1f7e14f0..93289bfd 100755 --- a/bash/init.sh +++ b/bash/init.sh @@ -1,105 +1,135 @@ #!/bin/bash -## CHECK IF THIS IS THE FIRST RUN USING AN IMAGE RELEASE - -if [[ -f $RECEIVER_ROOT_DIRECTORY/image ]] ; then - chmod +x $RECEIVER_BASH_DIRECTORY/image.sh - $RECEIVER_BASH_DIRECTORY/image.sh - if [[ $? != 0 ]] ; then - echo -e "\n\n \e[91m IMAGE SETUP HAS BEEN TERMINATED.\e[39m\n" - exit 1 - fi - exit 0 -fi - - -## INCLUDE EXTERNAL SCRIPTS +## PRE EXECUTION OPERATIONS +source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh -## DISPLAY WELCOME SCREEN +## DISPLAY THE WELCOME SCREEN -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "The ADS-B Receiver Project" --yesno "Thanks for choosing The ADS-B Receiver Project to setup your receiver.\n\nMore information on this project as well as news, support, and discussions can be found on the projects official website located at:\n\n https://www.adsbreceiver.net\n\nWould you like to continue setup?" 14 78; then - # Setup has been halted by the user. - echo -e "\n\e[91m \e[5mSETUP HALTED!\e[25m" - echo -e " Setup has been halted at the request of the user.\e[37m\n" - read -p "Press enter to continue..." discard +log_heading "Displaying the welcome message" + +log_message "Displaying the welcome message to the user" +echo "" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "The ADS-B Receiver Project" \ + --yesno "Thanks for choosing The ADS-B Receiver Project to setup your receiver.\n\nMore information on this project as well as news, support, and discussions can be found on the projects official website located at:\n\n https://www.adsbreceiver.net\n\nWould you like to continue setup?" \ + 14 78; then + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" exit 1 fi -## ATTEMPT TO UPDATE THE REPOSITORY +## ATTEMPT TO CHANGE AND/OR UPDATE THE REPOSITORY -# Skip update if the development flag was set or the selected branch is not present in origin if [[ $RECEIVER_DEVELOPMENT_MODE != "true" ]]; then current_branch=`git rev-parse --abbrev-ref HEAD` + clear - echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}\n" - echo -e "\e[92m Fetching the latest version of the '${RECEIVER_PROJECT_BRANCH}' branch." - echo -e "\e[93m -----------------------------------------------------------------------------\e[97m\n" + log_project_title + log_title_heading "Fetching the latest version of the ${RECEIVER_PROJECT_BRANCH} branch" + log_title_message "------------------------------------------------------------------------------" + + log_heading "Checking out and updating the appropriate branch" - # Ask if the user wishes to back up this branch if core files have been changed if [[ `git status --porcelain --untracked-files=no` && `git ls-remote --heads https://github.com/jprochazka/adsb-receiver.git refs/heads/master | wc -l` = 1 ]]; then - if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Stash Changes To Branch '${current_branch}'" --defaultno --yesno "There appears to be changes to the current branch. In order to switch to or fetch the '${current_branch}' branch these changes will need to be stashed. Would you like to stash these changes now?" 14 78; then - echo -e "\e[94m Stashing changes to the ${current_branch} branch...\e[97m\n" - git stash + if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Stash Changes To Branch ${current_branch}" \ + --defaultno \ + --yesno "There appears to be changes to the current branch. In order to switch to or fetch the ${current_branch} branch these changes will need to be stashed. Would you like to stash these changes now?" \ + 14 78; then + log_message "Stashing changes made to the ${current_branch} branch" + git stash 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" else - echo -e " \e[91m SETUP HAS BEEN TERMINATED.\e[39m\n" + log_alert_heading "INSTALLATION HALTED" + log_alert_message "Setup has been halted at the request of the user" + echo "" exit 1 fi fi - # Checkout the appropriate branch if [[ "${current_branch}" != "${RECEIVER_PROJECT_BRANCH}" ]]; then - echo -e "\e[94m Switching to branch ${RECEIVER_PROJECT_BRANCH}...\e[97m\n" - git checkout $RECEIVER_PROJECT_BRANCH + log_message "Switching to branch ${RECEIVER_PROJECT_BRANCH}" + echo "" + git checkout $RECEIVER_PROJECT_BRANCH 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" fi - # Fetch the most recent version of the branch from origin and reset any changes if [[ `git ls-remote --heads https://github.com/jprochazka/adsb-receiver.git refs/heads/$RECEIVER_PROJECT_BRANCH | wc -l` = 1 ]]; then - echo -e "\n\e[94m Fetching branch ${RECEIVER_PROJECT_BRANCH} from origin...\e[97m" - git fetch origin - echo -e "\e[94m Performing hard reset of branch ${RECEIVER_PROJECT_BRANCH} so it matches origin/${RECEIVER_PROJECT_BRANCH}...\e[97m\n" + log_message "Fetching branch ${RECEIVER_PROJECT_BRANCH} from origin" + echo "" + git fetch origin 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + log_message "Performing hard reset of branch ${RECEIVER_PROJECT_BRANCH} so it matches origin/${RECEIVER_PROJECT_BRANCH}" + echo "" git reset --hard origin/$RECEIVER_PROJECT_BRANCH else - echo -e "\e[94m The '${RECEIVER_PROJECT_BRANCH}' does not appear to be in origin...\e[97m" + log_message "The branch ${RECEIVER_PROJECT_BRANCH} does not appear to be in origin" fi - echo -e "\n\e[93m -----------------------------------------------------------------------------" - echo -e "\e[92m Finished fetching the latest version the '${RECEIVER_PROJECT_BRANCH}' branch.\e[39m\n" + log_title_message "-----------------------------------------------------------------------------" + log_title_heading "Finished fetching the latest version the '${RECEIVER_PROJECT_BRANCH}' branch." + echo "" read -p "Press enter to continue..." discard fi ## ASK IF OPERATING SYSTEM SHOULD BE UPDATED -if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Operating System Updates" --yesno "It is recommended that you update your system before building and/or installing any ADS-B receiver related packages. This script can do this for you at this time if you like.\n\nWould you like to update your operating system now?" 11 78; then +log_heading "Performing operating system updates if so desired" + +log_message "Asking the user if they wish to update the operating system" +if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Operating System Updates" \ + --yesno "It is recommended that you update your system before building and/or installing any ADS-B receiver related packages. This script can do this for you at this time if you like.\n\nWould you like to update your operating system now?" \ + 11 78; then clear - echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}\n" - echo -e "\e[92m Downloading and installing the latest updates for your operating system." - echo -e "\e[93m ------------------------------------------------------------------------\e[97m\n" - sudo apt-get -y dist-upgrade - echo -e "\n\e[93m ------------------------------------------------------------------------" - echo -e "\e[92m Your operating system should now be up to date.\e[39m\n" + log_project_title + log_title_heading "Downloading and installing the latest updates for your operating system" + log_title_message "------------------------------------------------------------------------------" + + log_heading "Updating the operating system" + + log_message "Updating the operating system using apt-get" + echo "" + sudo apt-get -y dist-upgrade 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + log_title_message "------------------------------------------------------------------------" + log_title_heading "Your operating system should now be up to date" + echo "" read -p "Press enter to continue..." discard fi ## EXECUTE BASH/MAIN.SH -chmod +x $RECEIVER_BASH_DIRECTORY/main.sh +clear + +log_heading "Executing the script bash/main.sh" + +log_message "Executing bash/main" bash $RECEIVER_BASH_DIRECTORY/main.sh if [[ $? -ne 0 ]] ; then - echo -e "\e[91m ANY FURTHER SETUP AND/OR INSTALLATION REQUESTS HAVE BEEN TERMINIATED\e[39m\n" + echo "" + log_alert_heading "ANY FURTHER SETUP AND/OR INSTALLATION REQUESTS HAVE BEEN TERMINIATED" + echo "" exit 1 fi + ## INSTALLATION COMPLETE -# Display the installation complete message box -whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Software Installation Complete" --msgbox "INSTALLATION COMPLETE\n\nDO NOT DELETE THIS DIRECTORY!\n\nFiles needed for certain items to run properly are contained within this directory. Deleting this directory may result in your receiver not working properly.\n\nHopefully, these scripts and files were found useful while setting up your ADS-B Receiver. Feedback regarding this software is always welcome. If you have any issues or wish to submit feedback, feel free to do so on GitHub.\n\n https://github.com/jprochazka/adsb-receiver" 20 65 -echo -e "\n\e[91m Installation complete.\n" +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Software Installation Complete" \ + --msgbox "INSTALLATION COMPLETE\n\nDO NOT DELETE THIS DIRECTORY!\n\nFiles needed for certain items to run properly are contained within this directory. Deleting this directory may result in your receiver not working properly.\n\nHopefully, these scripts and files were found useful while setting up your ADS-B Receiver. Feedback regarding this software is always welcome. If you have any issues or wish to submit feedback, feel free to do so on GitHub.\n\n https://github.com/jprochazka/adsb-receiver" \ + 20 65 + +echo "" +log_alert_heading "Installation complete" +echo "" exit 0 diff --git a/bash/main.sh b/bash/main.sh index 9974ae21..60e2d6c7 100755 --- a/bash/main.sh +++ b/bash/main.sh @@ -5,569 +5,484 @@ source ${RECEIVER_BASH_DIRECTORY}/variables.sh source ${RECEIVER_BASH_DIRECTORY}/functions.sh -## Set the project title variable. -export RECEIVER_PROJECT_TITLE="The ADS-B Receiver Project v${PROJECT_VERSION} Installer" -############### -## FUNCTIONS - -## DECODERS - -# Execute the dump1090-fa setup script. -function InstallDump1090Fa() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/decoders/dump1090-fa.sh - ${RECEIVER_BASH_DIRECTORY}/decoders/dump1090-fa.sh - if [[ $? -ne 0 ]] ; then - exit 1 +## 1090MHZ DECODERS + +# FlightAware dump1090 +install_1090mhz_decoder="false" +if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") == 1 ]] ; then + chosen_1090mhz_decoder="dump1090-fa" + if [[ $(sudo dpkg -s dump1090-fa 2>/dev/null | grep -c "Version: ${dump1090_fa_current_version}") == 0 ]] ; then + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "FlightAware Dump1090 Upgrade Available" \ + --defaultno \ + --yesno "An updated version of FlightAware dump1090 is available.\n\nWould you like to install the new version?" \ + 16 65 + if [[ $? == 0 ]]; then + install_1090mhz_decoder="true" + fi fi -} +else + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "FlightAware dump978" \ + --defaultno \ + --yesno "FlightAware dump1090 is capable of demodulating ADS-B, Mode S, Mode 3A/3C signals received by an SDR device.\n\nGitHub Repository: https://github.com/flightaware/dump1090\n\nWould you like to install FlightAware dump1090?" \ + 10 65 + if [[ $? == 0 ]]; then + install_978mhz_decoder="true" + fi +fi -# Execute the dump978 setup script. -function InstallDump978Fa() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/decoders/dump978-fa.sh - ${RECEIVER_BASH_DIRECTORY}/decoders/dump978-fa.sh - if [[ $? -ne 0 ]] ; then +function install_dump1090-fa() { + ${RECEIVER_BASH_DIRECTORY}/decoders/dump1090-fa.sh + if [[ $? != 0 ]] ; then exit 1 fi } -## FEEDERS -# Execute the ADS-B Exchange setup script. -function InstallAdsbExchange() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/adsbexchange.sh - ${RECEIVER_BASH_DIRECTORY}/feeders/adsbexchange.sh - if [[ $? -ne 0 ]] ; then - exit 1 - fi -} +## 978MHZ DECODERS -# Execute the airplanes.live setup script. -function InstallAirplanesLive() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/airplaneslive.sh - ${RECEIVER_BASH_DIRECTORY}/feeders/airplaneslive.sh - if [[ $? -ne 0 ]] ; then - exit 1 +# Flightaware dump978 +install_978mhz_decoder="false" +if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") == 1 ]]; then + chosen_978mhz_decoder="dump978-fa" + if [[ $(sudo dpkg -s dump978-fa 2>/dev/null | grep -c "Version: ${dump978_fa_current_version}") == 0 ]]; then + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "FlightAware dump978 Upgrade Available" \ + --defaultno --yesno "An updated version of FlightAware dump978 is available.\n\nWould you like to install the new version?" \ + 16 65 + if [[ $? == 0 ]]; then + install_978mhz_decoder="true" + fi fi -} - -# Execute the Flightradar24 Feeder client setup script. -function InstallFlightradar24() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/flightradar24.sh - ${RECEIVER_BASH_DIRECTORY}/feeders/flightradar24.sh - if [[ $? -ne 0 ]] ; then - exit 1 +else + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "FlightAware dump978" \ + --defaultno \ + --yesno "FlightAware dump978 is capable of demodulating UAT received by an SDR device.\n\nGitHub Repository: https://github.com/flightaware/dump978\n\nWould you like to install FlightAware dump978?" \ + 10 65 + if [[ $? == 0 ]]; then + install_978mhz_decoder="true" fi -} +fi -# Execute the Fly Italy ADS-B Feeder client setup script. -function InstallFlyItalyAdsb() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/flyitalyadsb.sh - ${RECEIVER_BASH_DIRECTORY}/feeders/flyitalyadsb.sh - if [[ $? -ne 0 ]] ; then +function install_dump978-fa() { + ${RECEIVER_BASH_DIRECTORY}/decoders/dump978-fa.sh + if [[ $? != 0 ]] ; then exit 1 fi } -# Execute the OpenSky Network setup script. -function InstallOpenSkyNetwork() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/openskynetwork.sh - ${RECEIVER_BASH_DIRECTORY}/feeders/openskynetwork.sh - if [[ $? -ne 0 ]] ; then - exit 1 - fi -} +## AGGREGATE SITE CLIENTS -# Execute the PiAware setup script -function InstallPiAware() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/piaware.sh - ${RECEIVER_BASH_DIRECTORY}/feeders/piaware.sh - if [[ $? -ne 0 ]] ; then - exit 1 - fi -} +declare array feeder_list +touch ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES -# Execute the Plane Finder Client setup script. -function InstallPlaneFinder() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/planefinder.sh - ${RECEIVER_BASH_DIRECTORY}/feeders/planefinder.sh - if [[ $? -ne 0 ]] ; then +# ADS-B Exchange +if [[ -f /lib/systemd/system/adsbexchange-mlat.service && -f /lib/systemd/system/adsbexchange-feed.service ]]; then + echo "ADS-B Exchange Feed Client (reinstall)" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES + feeder_list=("${feeder_list[@]}" 'ADS-B Exchange Feed Client (reinstall/update)' '' OFF) +else + echo "ADS-B Exchange Feed Client" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES + feeder_list=("${feeder_list[@]}" 'ADS-B Exchange Feed Client' '' OFF) +fi +function install_adsbexchange_client() { + ${RECEIVER_BASH_DIRECTORY}/feeders/adsbexchange.sh + if [[ $? != 0 ]] ; then exit 1 fi } -## Portal +# Airplanes.live +if [[ -f /lib/systemd/system/airplanes-feed.service && -f /lib/systemd/system/airplanes-mlat.service ]]; then + echo "Airplanes.live Feeder (reinstall)" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES + feeder_list=("${feeder_list[@]}" 'Airplanes.live Feeder (reinstall)' '' OFF) +else + echo "Airplanes.live Feeder" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES + feeder_list=("${feeder_list[@]}" 'Airplanes.live Feeder' '' OFF) +fi -# Execute the ADS-B Receiver Project Web Portal setup script. -function InstallWebPortal() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/install.sh - ${RECEIVER_BASH_DIRECTORY}/portal/install.sh - if [[ $? -ne 0 ]] ; then +function install_airplaneslive_client() { + ${RECEIVER_BASH_DIRECTORY}/feeders/airplaneslive.sh + if [[ $? != 0 ]] ; then exit 1 fi } -## Extras - -# Execute the beast-splitter setup script. -function InstallBeastSplitter() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/extras/beeastsplitter.sh - ${RECEIVER_BASH_DIRECTORY}/extras/beastsplitter.sh - if [[ $? -ne 0 ]] ; then - exit 1 +# FlightAware PiAware +if [[ $(dpkg-query -W -f='${STATUS}' piaware 2>/dev/null | grep -c "ok installed") == 0 ]]; then + feeder_list=("${feeder_list[@]}" 'FlightAware PiAware' '' OFF) +else + if [[ $(sudo dpkg -s piaware 2>/dev/null | grep -c "Version: ${piaware_current_version}") == 0 ]]; then + feeder_list=("${feeder_list[@]}" 'FlightAware PiAware (upgrade)' '' OFF) + else + feeder_list=("${feeder_list[@]}" 'FlightAware PiAware (reinstall)' '' OFF) fi -} +fi -# Execute the Duck DNS setup script. -function InstallDuckDns() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/extras/duckdns.sh - ${RECEIVER_BASH_DIRECTORY}/extras/duckdns.sh - if [[ $? -ne 0 ]] ; then +function install_flightaware_client() { + ${RECEIVER_BASH_DIRECTORY}/feeders/piaware.sh + if [[ $? != 0 ]] ; then exit 1 fi } -############# -## DIALOGS - -## Decoders - -# Check if the dump1090-fa package is installed. -if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then - DUMP1090_FORK="fa" - DUMP1090_IS_INSTALLED="true" - # Check if a newer version can be installed. - if [[ $(sudo dpkg -s dump1090-fa 2>/dev/null | grep -c "Version: ${DUMP1090_FA_VERSION}") -eq 0 ]] ; then - whiptail --backtitle "RECEIVER_PROJECT_TITLE" --title "Dump1090-fa Upgrade Available" --defaultno --yesno "An updated version of dump1090-fa is available.\n\nWould you like to download, build, then install the new version?" 16 65 - case $? in - 0) - DUMP1090_DO_UPGRADE="true" - ;; - 1) - DUMP1090_DO_UPGRADE="false" - ;; - esac +# Flightradar24 +if [[ $(dpkg-query -W -f='${STATUS}' fr24feed 2>/dev/null | grep -c "ok installed") == 0 ]]; then + feeder_list=("${feeder_list[@]}" 'Flightradar24 Client' '' OFF) +else + if [[ $(sudo dpkg -s fr24feed 2>/dev/null | grep -c "Version: ${fr24feed_current_version}") == 0 ]]; then + feeder_list=("${feeder_list[@]}" 'Flightradar24 Client (upgrade)' '' OFF) + else + feeder_list=("${feeder_list[@]}" 'Flightradar24 Client (reinstall)' '' OFF) fi fi -# If no dump1090 fork is installed then attempt to install one. -if [[ ! "${DUMP1090_IS_INSTALLED}" = "true" ]] ; then - DUMP1090_OPTION=$(whiptail --nocancel --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Choose Dump1090 Version To Install" --radiolist "Dump1090 does not appear to be present on this device. In order to continue setup dump1090 will need to exist on this device. Please select your prefered dump1090 version from the list below.\n\nPlease note that in order to run dump1090-fa PiAware will need to be installed as well." 16 65 2 "dump1090-fa" "(FlightAware)" ON 3>&1 1>&2 2>&3) - case ${DUMP1090_OPTION} in - "dump1090-fa") - DUMP1090_FORK="fa" - DUMP1090_DO_INSTALL="true" - ;; - *) - DUMP1090_DO_INSTALL="false" - ;; - esac -fi - -# If the FlightAware fork of dump1090 is or has been chosen to be installed PiAware must be installed. -if [[ "${DUMP1090_FORK}" = "fa" && "${DUMP1090_DO_INSTALL}" = "true" || "${DUMP1090_DO_UPGRADE}" = "true" ]]; then - FORCE_PIAWARE_INSTALL="true" -fi - -# Check if the dump978-fa package is installed. -if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then - # Dump978 appears to be present on this device. - DUMP978_FORK="fa" - DUMP978_IS_INSTALLED="true" - if [[ $(sudo dpkg -s dump978-fa 2>/dev/null | grep -c "Version: ${DUMP978_FA_VERSION}") -eq 0 ]]; then - whiptail --backtitle "RECEIVER_PROJECT_TITLE" --title "Dump978-fa Upgrade Available" --defaultno --yesno "An updated version of dump978-fa is available.\n\nWould you like to download, build, then install the new version?" 16 65 - case $? in - 0) - DUMP978_DO_UPGRADE="true" - ;; - 1) - DUMP978_DO_UPGRADE="false" - ;; - esac +function install_flightradar24_client() { + ${RECEIVER_BASH_DIRECTORY}/feeders/flightradar24.sh + if [[ $? != 0 ]] ; then + exit 1 fi -else - # Dump978 does not appear to be present on this device. - DUMP978_IS_INSTALLED="false" - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump978-fa Not Installed" --defaultno --yesno "Dump978 is an experimental demodulator/decoder for 978MHz UAT signals. These scripts can setup dump978 for you. However keep in mind a second RTL-SDR device will be required to feed data to it.\n\nDo you wish to install dump978?" 10 65 - case $? in - 0) - DUMP978_DO_INSTALL="true" - ;; - 1) - DUMP978_DO_INSTALL="false" - ;; - esac -fi - -## Feeder Selection Menu - -# Declare the FEEDER_LIST array and the FEEDER_CHOICES file which will store choices for feeders which are available for install. -declare array FEEDER_LIST -touch ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES - -# Check if the ADS-B Exchange feeder has been set up. -if [[ -f /lib/systemd/system/adsbexchange-mlat.service && -f /lib/systemd/system/adsbexchange-feed.service ]]; then - # The feeder appears to be set up. - echo "ADS-B Exchange Feeder (reinstall)" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES - FEEDER_LIST=("${FEEDER_LIST[@]}" 'ADS-B Exchange Feeder (reinstall)' '' OFF) -else - # The feeder does not appear to be set up. - echo "ADS-B Exchange Feeder" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES - FEEDER_LIST=("${FEEDER_LIST[@]}" 'ADS-B Exchange Feeder' '' OFF) -fi - -# Check if the airplanes.live feeder has been set up. -if [[ -f /lib/systemd/system/airplanes-feed.service && -f /lib/systemd/system/airplanes-mlat.service ]]; then - # The feeder appears to be set up. - echo "Airplanes.live Feeder (reinstall)" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Airplanes.live Feeder (reinstall)' '' OFF) -else - # The feeder does not appear to be set up. - echo "Airplanes.live Feeder" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Airplanes.live Feeder' '' OFF) -fi +} -# Check if the Fly Italy ADS-B feeder has been set up. +# Fly Italy ADS-B if [[ -f /lib/systemd/system/flyitalyadsb-mlat.service && -f /lib/systemd/system/flyitalyadsb-feed.service ]]; then - # The feeder appears to be set up. echo "Fly Italy ADS-B Feeder (upgrade)" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Fly Italy ADS-B Feeder (upgrade)' '' OFF) + feeder_list=("${feeder_list[@]}" 'Fly Italy ADS-B Feeder (reinstall)' '' OFF) else - # The feeder does not appear to be set up. echo "Fly Italy ADS-B Feeder" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Fly Italy ADS-B Feeder' '' OFF) + feeder_list=("${feeder_list[@]}" 'Fly Italy ADS-B Feeder' '' OFF) fi -# Check for the OpenSky Network package. -if [[ $(dpkg-query -W -f='${STATUS}' opensky-feeder 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then - # The OpenSky Network feeder package appears to not be installed. - FEEDER_LIST=("${FEEDER_LIST[@]}" 'OpenSky Network Feeder' '' OFF) -else - # Check if a newer version can be installed if this is not a Raspberry Pi device. - if [[ $(sudo dpkg -s opensky-feeder 2>/dev/null | grep -c "Version: ${OPENSKY_NETWORK_CLIENT_VERSION}") -eq 0 ]]; then - FEEDER_LIST=("${FEEDER_LIST[@]}" 'OpenSky Network Feeder (upgrade)' '' OFF) - else - FEEDER_LIST=("${FEEDER_LIST[@]}" 'OpenSky Network Feeder (reinstall)' '' OFF) +function install_flyitalyadsb_client() { + ${RECEIVER_BASH_DIRECTORY}/feeders/flyitalyadsb.sh + if [[ $? != 0 ]] ; then + exit 1 fi -fi +} -# Check for the PiAware package. -if [[ $(dpkg-query -W -f='${STATUS}' piaware 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then - # Do not show the PiAware install option if the FlightAware fork of dump1090 has been chosen. - if [[ "${DUMP1090_FORK}" != "fa" ]] ; then - if [[ -z "${PIAWARE_INSTALL}" && "${PIAWARE_INSTALL}" = "true" ]]; then - echo "FlightAware PiAware" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES - fi - fi +# OpenSky Network +if [[ $(dpkg-query -W -f='${STATUS}' opensky-feeder 2>/dev/null | grep -c "ok installed") == 0 ]]; then + feeder_list=("${feeder_list[@]}" 'OpenSky Network Feeder' '' OFF) else - # Check if a newer version can be installed. - if [[ $(sudo dpkg -s piaware 2>/dev/null | grep -c "Version: ${PIAWARE_VERSION}") -eq 0 ]]; then - FEEDER_LIST=("${FEEDER_LIST[@]}" 'FlightAware PiAware (upgrade)' '' OFF) - else - FEEDER_LIST=("${FEEDER_LIST[@]}" 'FlightAware PiAware (reinstall)' '' OFF) + if [[ $(sudo dpkg -s opensky-feeder 2>/dev/null | grep -c "Version: ${opensky_feeder_current_version}") == 0 ]]; then + feeder_list=("${feeder_list[@]}" 'OpenSky Network Feeder (reinstall)' '' OFF) fi fi -# Check for the Flightradar24 Feeder Client package. -if [[ $(dpkg-query -W -f='${STATUS}' fr24feed 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then - # Add this choice to the FEEDER_LIST array to be used by the whiptail menu. - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Flightradar24 Client' '' OFF) -else - # Check if a newer version can be installed if this is not a Raspberry Pi device. - if [[ $(sudo dpkg -s fr24feed 2>/dev/null | grep -c "Version: ${FLIGHTRADAR24_CLIENT_VERSION_I386}") -eq 0 ]]; then - # Add this choice to the FEEDER_LIST array to be used by the whiptail menu. - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Flightradar24 Client (upgrade)' '' OFF) - else - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Flightradar24 Client (reinstall)' '' OFF) +function install_openskynetwork_client() { + ${RECEIVER_BASH_DIRECTORY}/feeders/openskynetwork.sh + if [[ $? != 0 ]] ; then + exit 1 fi -fi +} -# Check for the Planefinder ADS-B Client package. -if [[ $(dpkg-query -W -f='${STATUS}' pfclient 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then - # The Planefinder Client package does not appear to be installed. - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client' '' OFF) +# Planefinder +if [[ $(dpkg-query -W -f='${STATUS}' pfclient 2>/dev/null | grep -c "ok installed") == 0 ]]; then + feeder_list=("${feeder_list[@]}" 'Plane Finder Client' '' OFF) else - # Check if a newer version can be installed. - PLANEFINDER_CLIENT_INSTALLED_VERSION=$(sudo dpkg -s pfclient | grep Version | awk '{print $2}') + pfclient_installed_version=$(sudo dpkg -s pfclient | grep Version | awk '{print $2}') case "${CPU_ARCHITECTURE}" in "armv7l"|"armv6l") - if [[ ! "$PLANEFINDER_CLIENT_INSTALLED_VERSION" = "${PLANEFINDER_CLIENT_VERSION_ARMHF}" ]]; then - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client (upgrade)' '' OFF) + if [[ "$pfclient_installed_version" != "${pfclient_current_version_armhf}" ]]; then + feeder_list=("${feeder_list[@]}" 'Plane Finder Client (upgrade)' '' OFF) else - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client (reinstall)' '' OFF) + feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF) fi ;; "aarch64") - if [[ ! "$PLANEFINDER_CLIENT_INSTALLED_VERSION" = "${PLANEFINDER_CLIENT_VERSION_ARM64}" ]]; then - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client (upgrade)' '' OFF) + if [[ "$pfclient_installed_version" != "${pfclient_current_version_arm64}" ]]; then + feeder_list=("${feeder_list[@]}" 'Plane Finder Client (upgrade)' '' OFF) else - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client (reinstall)' '' OFF) + feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF) fi ;; "x86_64") - if [[ ! "$PLANEFINDER_CLIENT_INSTALLED_VERSION" = "${PLANEFINDER_CLIENT_VERSION_AMD64}" ]]; then - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client (upgrade)' '' OFF) + if [[ "$pfclient_installed_version" != "${pfclient_current_version_amd64}" ]]; then + feeder_list=("${feeder_list[@]}" 'Plane Finder Client (upgrade)' '' OFF) else - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client (reinstall)' '' OFF) + feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF) fi ;; "i386") - if [[ ! "$PLANEFINDER_CLIENT_INSTALLED_VERSION" = "${PLANEFINDER_CLIENT_VERSION_I386}" ]]; then - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client (upgrade)' '' OFF) + if [[ "$pfclient_installed_version" != "${pfclient_current_version_i386}" ]]; then + feeder_list=("${feeder_list[@]}" 'Plane Finder Client (upgrade)' '' OFF) else - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client (reinstall)' '' OFF) + feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF) fi ;; *) - FEEDER_LIST=("${FEEDER_LIST[@]}" 'Plane Finder Client (reinstall)' '' OFF) + feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF) esac fi -if [[ -n "${FEEDER_LIST}" ]] ; then - # Display a checklist containing feeders that are not installed if any. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Feeder Installation Options" --checklist --nocancel --separate-output "The following feeders are available for installation.\nChoose the feeders you wish to install." 15 65 7 "${FEEDER_LIST[@]}" 2>${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES -else - # Since all available feeders appear to be installed inform the user of the fact. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "All Feeders Installed" --msgbox "It appears that all the optional feeders available for installation by this script have been installed already." 8 65 +function install_planefinder_client() { + ${RECEIVER_BASH_DIRECTORY}/feeders/planefinder.sh + if [[ $? != 0 ]] ; then + exit 1 + fi +} + +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Client Installation Options" \ + --checklist \ + --nocancel \ + --separate-output "The following clients are available for installation.\nChoose the clients you wish to install." \ + 15 65 7 "${feeder_list[@]}" 2>${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES + + +## PORTALS + +# ADS-B Portal +install_portal="false" +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Install The ADS-B Portal" \ + --defaultno \ + --yesno "The ADS-B Portal is a web interface for your receiver. More information can be found in the ADS-B Receiver Project GitHub repository.\n\nhttps://github.com/jprochazka/adsb-receiver\n\nWould you like to install the ADS-B Portal?" \ + 14 78 +if [[ $? == 0 ]]; then + install_portal="true" fi -## ADS-B Receiver Project Web Portal +function install_adsb-portal() { + ${RECEIVER_BASH_DIRECTORY}/portal/install.sh + if [[ $? != 0 ]] ; then + exit 1 + fi +} -# Ask if the web portal should be installed. -whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Install The ADS-B Receiver Project Web Portal" --yesno "The ADS-B Receiver Project Web Portal is a lightweight web interface for dump-1090 installations.\n\nCurrent features include the following:\n Unified navigation between all web pages.\n System and dump1090 performance graphs.\n\nWould you like to install the ADS-B Receiver Project web portal?" 14 78 -case $? in - 0) - WEBPORTAL_DO_INSTALL="true" - ;; - 1) - WEBPORTAL_DO_INSTALL="false" - ;; -esac ## Extras -# Declare the EXTRAS_LIST array and the EXTRAS_CHOICES file which will store choices for extras which are available for install. -declare array EXTRAS_LIST +declare array extras_list touch ${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES -# Check if the beast-splitter package is installed. -if [[ $(dpkg-query -W -f='${STATUS}' beast-splitter 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then - # The beast-splitter package appears to not be installed. - EXTRAS_LIST=("${EXTRAS_LIST[@]}" 'beast-splitter' '' OFF) +# Beast-splitter +if [[ $(dpkg-query -W -f='${STATUS}' beast-splitter 2>/dev/null | grep -c "ok installed") == 0 ]]; then + extras_list=("${extras_list[@]}" 'beast-splitter' '' OFF) else - # Offer the option to build then reinstall the beast-splitter package. - EXTRAS_LIST=("${EXTRAS_LIST[@]}" 'beast-splitter (reinstall)' '' OFF) + extras_list=("${extras_list[@]}" 'beast-splitter (reinstall)' '' OFF) fi -# Check if the Duck DNS update script exists. +function install_beastsplitter() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/extras/beeastsplitter.sh + ${RECEIVER_BASH_DIRECTORY}/extras/beastsplitter.sh + if [[ $? != 0 ]] ; then + exit 1 + fi +} + +# Duck DNS if [[ ! -f "${RECEIVER_BUILD_DIRECTORY}/duckdns/duck.sh" ]]; then # Duck DNS does not appear to be set up on this device. - EXTRAS_LIST=("${EXTRAS_LIST[@]}" 'Duck DNS Free Dynamic DNS Hosting' '' OFF) + extras_list=("${extras_list[@]}" 'Duck DNS Free Dynamic DNS Hosting' '' OFF) else # Offer the option to install/setup Duck DNS once more. - EXTRAS_LIST=("${EXTRAS_LIST[@]}" 'Duck DNS Free Dynamic DNS Hosting (reinstall)' '' OFF) + extras_list=("${extras_list[@]}" 'Duck DNS Free Dynamic DNS Hosting (reinstall)' '' OFF) fi -# Display a menu the user can use to pick extras to be installed. -if [[ -n "${EXTRAS_LIST}" ]]; then - # Display a checklist containing feeders that are not installed if any. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Feeder Installation Options" --checklist --nocancel --separate-output "The following extras are available for installation, please select any which you wish to install." 13 65 4 "${EXTRAS_LIST[@]}" 2>${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES -else - # Since all available extras appear to be installed inform the user of the fact. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "All Extras Installed" --msgbox "It appears that all the optional extras available for installation by this script have been installed already." 8 65 -fi +function install_duckdns() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/extras/duckdns.sh + ${RECEIVER_BASH_DIRECTORY}/extras/duckdns.sh + if [[ $? -ne 0 ]] ; then + exit 1 + fi +} + +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Extras Installation Options" \ + --checklist \ + --nocancel \ + --separate-output "The following extras are available for installation, please select any which you wish to install." \ + 13 65 4 "${extras_list[@]}" 2>${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES + + ## Setup Confirmation -declare CONFIRMATION +declare confirmation_message -# Check if anything is to be done before moving on. -if [[ "${DUMP1090_DO_INSTALL}" = "false" && "${DUMP1090_DO_UPGRADE}" = "false" && "${DUMP978_DO_INSTALL}" = "false" && "${DUMP978_DO_UPGRADE}" = "false" && "${WEBPORTAL_DO_INSTALL}" = "false" && ! -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" && ! -s "${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES" ]]; then - # Nothing was chosen to be installed. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Nothing to be done" --msgbox "Nothing has been selected to be installed so the script will exit now." 10 65 - echo -e "\e[31m" - echo -e " Nothing was selected to do or be installed." - echo -e "\e[37m" +if [[ "${install_1090mhz_decoder}" == "false" && "${install_1090mhz_decoder}" == "false" && "${install_portal}" == "false" && ! -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" && ! -s "${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES" ]]; then + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Nothing to be done" \ + --msgbox "Nothing has been selected to be installed so the script will exit now." \ + 10 65 + echo "" + log_alert_heading "Nothing was selected to do or be installed" + echo "" exit 1 else - # The user decided to install software. - CONFIRMATION="The following software will be installed:\n" - - # dump1090 - if [[ "${DUMP1090_DO_UPGRADE}" = "true" ]]; then - case ${DUMP1090_FORK} in - "fa") - CONFIRMATION="${CONFIRMATION}\n * dump1090-fa (upgrade)" - ;; - esac - elif [[ "${DUMP1090_DO_INSTALL}" = "true" ]]; then - case ${DUMP1090_FORK} in - "fa") - CONFIRMATION="${CONFIRMATION}\n * dump1090-fa" + confirmation_message="The following software will be installed:\n" + + # 1090MHz decoders + if [[ "${install_1090mhz_decoder}" == "true" ]]; then + case ${chosen_1090mhz_decoder} in + "dump1090-fa") + confirmation_message="${confirmation_message}\n * FlightAware dump1090" ;; esac fi - # dump978 - if [[ "${DUMP978_DO_UPGRADE}" = "true" ]]; then - CONFIRMATION="${CONFIRMATION}\n * dump978 (rebuild)" - elif [[ "${DUMP978_DO_INSTALL}" = "true" ]]; then - CONFIRMATION="${CONFIRMATION}\n * dump978" - fi - - # If PiAware is required add it to the list. - if [[ "${DUMP1090_FORK}" = "fa" && $(dpkg-query -W -f='${STATUS}' piaware 2>/dev/null | grep -c "ok installed") -eq 0 || "${PIAWARE_INSTALL}" = "true" ]]; then - CONFIRMATION="${CONFIRMATION}\n * FlightAware PiAware" + # 978MHz decoders + if [[ "${install_978mhz_decoder}" = "true" ]]; then + case ${chosen_978mhz_decoder} in + "dump978-fa") + confirmation_message="${confirmation_message}\n * FlightAware dump978" + ;; + esac fi + # Aggragate site clients if [[ -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" ]]; then - while read FEEDER_CHOICE + while read feeder_choice do - CONFIRMATION="${CONFIRMATION}\n * ${FEEDER_CHOICE}" + confirmation_message="${confirmation_message}\n * ${feeder_choice}" done < ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES fi - if [[ "${WEBPORTAL_DO_INSTALL}" = "true" ]]; then - CONFIRMATION="${CONFIRMATION}\n * ADS-B Receiver Project Web Portal" + # Portals + if [[ "${WEBPORTAL_DO_INSTALL}" == "true" ]]; then + confirmation_message="${confirmation_message}\n * ADS-B Receiver Project Web Portal" fi + # Extras if [[ -s "${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES" ]]; then - while read EXTRAS_CHOICE + while read extra_choice do - CONFIRMATION="${CONFIRMATION}\n * ${EXTRAS_CHOICE}" + confirmation_message="${confirmation_message}\n * ${extra_choice}" done < ${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES fi - CONFIRMATION="${CONFIRMATION}\n\n" + confirmation_message="${confirmation_message}\n\n" fi -# Ask for confirmation before moving on. -CONFIRMATION="${CONFIRMATION}Do you wish to continue setup?" -if ! (whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Confirm You Wish To Continue" --yesno "${CONFIRMATION}" 21 78) then - echo -e "\e[31m" - echo " Installation canceled by user." +confirmation_message="${confirmation_message}Do you wish to continue setup?" +if ! (whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Confirm You Wish To Continue" --yesno "${confirmation_message}" 21 78); then + echo "" + log_alert_heading "Installation cancelled by user" + echo "" exit 1 fi -################# -## BEGIN SETUP -## Decoders +## BEGIN SETUP -if [[ "${DUMP1090_DO_INSTALL}" = "true" || "${DUMP1090_DO_UPGRADE}" = "true" ]]; then - case ${DUMP1090_FORK} in - "fa") - InstallDump1090Fa +# 1090MHz Decoders +if [[ "${install_1090mhz_decoder}" == "true" ]]; then + case ${chosen_1090mhz_decoder} in + "dump1090-fa") + install_dump1090-fa ;; esac fi -if [[ "${DUMP978_DO_INSTALL}" = "true" || "${DUMP978_DO_UPGRADE}" = "true" ]]; then - InstallDump978Fa +# 978MHz Decoders +if [[ "${install_978mhz_decoder}" == "true" ]]; then + case ${chosen_978mhz_decoder} in + "dump978-fa") + install_dump978-fa + ;; + esac fi -## Feeders - -# Moved execution of functions outside of while loop. -# Inside the while loop the installation scripts are not stopping at reads. - -RUN_ADSBEXCHANGE_SCRIPT="false" -RUN_PIAWARE_SCRIPT="false" -RUN_FLIGHTRADAR24_SCRIPT="false" -RUN_FLYITALYADSB_SCRIPT -RUN_OPENSKYNETWORK_SCRIPT="false" -RUN_PLANEFINDER_SCRIPT="false" +run_adsbexchange_script="false" +run_airplaneslive_script="false" +run_flightaware_script="false" +run_flightradar24_script="false" +run_flyitalyadsb_script="false" +run_openskynetwork_script="false" +run_planefinder_script="false" +# Aggragate site clients if [[ -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" ]]; then - while read FEEDER_CHOICE + while read feeder_choice do - case ${FEEDER_CHOICE} in - "ADS-B Exchange Feeder"|"ADS-B Exchange Feeder (reinstall)") - RUN_ADSBEXCHANGE_SCRIPT="true" + case ${feeder_choice} in + "ADS-B Exchange Feed Client"|"ADS-B Exchange Feed Client (reinstall/update)") + run_adsbexchange_script="true" ;; "Airplanes.live Feeder"|"Airplanes.live Feeder (reinstall)") - RUN_AIRPLANESLIVE_SCRIPT="true" + run_airplaneslive_script="true" ;; "FlightAware PiAware"|"FlightAware PiAware (upgrade)"|"FlightAware PiAware (reinstall)") - RUN_PIAWARE_SCRIPT="true" + run_flightaware_script="true" ;; "Flightradar24 Client"|"Flightradar24 Client (upgrade)"|"Flightradar24 Client (reinstall)") - RUN_FLIGHTRADAR24_SCRIPT="true" + run_flightradar24_script="true" ;; - "Fly Italy ADS-B Feeder"|"Fly Italy ADS-B Feeder (upgrade)") - RUN_FLYITALYADSB_SCRIPT="true" + "Fly Italy ADS-B Feeder"|"Fly Italy ADS-B Feeder (reinstall)") + run_flyitalyadsb_script="true" ;; - "OpenSky Network Feeder") - RUN_OPENSKYNETWORK_SCRIPT="true" + "OpenSky Network Feeder"|"OpenSky Network Feeder (reinstall)") + run_openskynetwork_script="true" ;; "Plane Finder Client"|"Plane Finder Client (upgrade)"|"Plane Finder Client (reinstall)") - RUN_PLANEFINDER_SCRIPT="true" + run_planefinder_script="true" ;; esac done < ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES fi -if [[ "${RUN_ADSBEXCHANGE_SCRIPT}" = "true" ]]; then - InstallAdsbExchange +if [[ "${run_adsbexchange_script}" == "true" ]]; then + install_adsbexchange_client fi -if [[ "${RUN_AIRPLANESLIVE_SCRIPT}" = "true" ]]; then - InstallAirplanesLive +if [[ "${run_airplaneslive_script}" == "true" ]]; then + install_airplaneslive_client fi -if [[ "${RUN_PIAWARE_SCRIPT}" = "true" || "${FORCE_PIAWARE_INSTALL}" = "true" ]]; then - InstallPiAware +if [[ "${run_flightaware_script}" == "true" ]]; then + install_flightaware_client fi -if [[ "${RUN_FLIGHTRADAR24_SCRIPT}" = "true" ]]; then - InstallFlightradar24 +if [[ "${run_flightradar24_script}" == "true" ]]; then + install_flightradar24_client fi -if [[ "${RUN_FLYITALYADSB_SCRIPT}" = "true" ]]; then - InstallFlyItalyAdsb +if [[ "${run_flyitalyadsb_script}" == "true" ]]; then + install_flyitalyadsb_client fi -if [[ "${RUN_OPENSKYNETWORK_SCRIPT}" = "true" ]]; then - InstallOpenSkyNetwork +if [[ "${run_openskynetwork_script}" == "true" ]]; then + install_openskynetwork_client fi -if [[ "${RUN_PLANEFINDER_SCRIPT}" = "true" ]]; then - InstallPlaneFinder +if [[ "${run_planefinder_script}" == "true" ]]; then + install_planefinder_client fi -## ADS-B Receiver Project Web Portal - -if [[ "${WEBPORTAL_DO_INSTALL}" = "true" ]]; then - InstallWebPortal +# Portals +if [[ "${install_portal}" == "true" ]]; then + install_adsb-portal fi -# Moved execution of functions outside of while loop. -# Inside the while loop the installation scripts are not stopping at reads. +# Extras -RUN_BEASTSPLITTER_SCRIPT="false" -RUN_DUCKDNS_SCRIPT="false" +run_beastsplitter_script="false" +run_duckdns_script="false" if [[ -s "${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES" ]]; then - while read EXTRAS_CHOICE + while read extras_choice do - case ${EXTRAS_CHOICE} in + case ${extras_choice} in "beast-splitter"|"beast-splitter (reinstall)") - RUN_BEASTSPLITTER_SCRIPT="true" + run_beastsplitter_script="true" ;; "Duck DNS Free Dynamic DNS Hosting"|"Duck DNS Free Dynamic DNS Hosting (reinstall)") - RUN_DUCKDNS_SCRIPT="true" + run_duckdns_script="true" ;; esac done < ${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES fi -if [[ "${RUN_BEASTSPLITTER_SCRIPT}" = "true" ]]; then - InstallBeastSplitter +if [[ "${run_adsbexchange_script}" == "true" ]]; then + install_beastsplitter fi -if [[ "${RUN_DUCKDNS_SCRIPT}" = "true" ]]; then - InstallDuckDns +if [[ "${run_duckdns_script}" == "true" ]]; then + install_duckdns fi exit 0 diff --git a/bash/portal/graphs.sh b/bash/portal/graphs.sh index 8f474d8b..c649601b 100755 --- a/bash/portal/graphs.sh +++ b/bash/portal/graphs.sh @@ -69,9 +69,9 @@ fi if [[ "${DUMP1090_INSTALLED}" = "true" ]] && [[ "${DUMP1090_FORK}" = "mutability" ]] ; then echo -e "\e[94m Modifying the dump1090-mutability configuration file to add noise measurements...\e[97m" - EXTRA_ARGS=`GetConfig "EXTRA_ARGS" "/etc/default/dump1090-mutability"` + EXTRA_ARGS=`get_config "EXTRA_ARGS" "/etc/default/dump1090-mutability"` EXTRA_ARGS=$(sed -e 's/^[[:space:]]*//' <<<"EXTRA_ARGS --measure-noise") - ChangeConfig "EXTRA_ARGS" "${RECEIVER_LONGITUDE}" "/etc/default/dump1090-mutability" + change_config "EXTRA_ARGS" "${RECEIVER_LONGITUDE}" "/etc/default/dump1090-mutability" echo -e "\e[94m Reloading the systemd manager configuration...\e[97m" sudo systemctl daemon-reload diff --git a/bash/portal/install.sh b/bash/portal/install.sh index 5befe40f..64ff58b1 100755 --- a/bash/portal/install.sh +++ b/bash/portal/install.sh @@ -38,7 +38,7 @@ fi # We will need to make sure Lighttpd is installed first before we go any further. echo -e "\e[95m Installing packages needed to fulfill dependencies...\e[97m" echo -e "" -CheckPackage lighttpd +check_package lighttpd # Assign the Lighthttpd document root directory to a variable. RAW_DOCUMENT_ROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root` @@ -110,7 +110,7 @@ else else # Install the MySQL server package now if it is not already installed. whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "MySQL Server Setup" --msgbox "This script will now check for the MySQL server package. If the MySQL server package is not installed it will be installed at this time.\n\nPlease note you may be asked questions used to secure your database server installation after the setup process." 12 78 - CheckPackage mariadb-server + check_package mariadb-server if [[ $(dpkg-query -W -f='${STATUS}' mariadb-server 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then echo -e "\e[94m Executing the mysql_secure_installation script...\e[97m" sudo mysql_secure_installation @@ -219,44 +219,44 @@ case $RECEIVER_OS_DISTRIBUTION in esac # Install PHP. -CheckPackage php${DISTRO_PHP_VERSION}-cgi +check_package php${DISTRO_PHP_VERSION}-cgi if (( $(echo "${DISTRO_PHP_VERSION} < 8" | bc -l) )); then - CheckPackage php${DISTRO_PHP_VERSION}-json + check_package php${DISTRO_PHP_VERSION}-json fi # Performance graph dependencies. -CheckPackage collectd-core -CheckPackage rrdtool +check_package collectd-core +check_package rrdtool # Portal dependencies. if [ "$RECEIVER_MTA" == "POSTFIX" ] || [ -z "$RECEIVER_MTA" ]; then - CheckPackage postfix + check_package postfix fi -CheckPackage libpython3-stdlib +check_package libpython3-stdlib # Install packages needed for advanced portal setups. if [[ "${ADVANCED}" = "true" ]] ; then - CheckPackage python3-pyinotify - CheckPackage python3-apt + check_package python3-pyinotify + check_package python3-apt case "${DATABASEENGINE}" in "MySQL") - CheckPackage mariadb-client - CheckPackage python3-mysqldb - CheckPackage php${DISTRO_PHP_VERSION}-mysql + check_package mariadb-client + check_package python3-mysqldb + check_package php${DISTRO_PHP_VERSION}-mysql ;; "SQLite") - CheckPackage sqlite3 + check_package sqlite3 if [ `bc -l <<< "$DISTRO_PHP_VERSION >= 7.0"` -eq 1 ]; then - CheckPackage php${DISTRO_PHP_VERSION}-sqlite3 + check_package php${DISTRO_PHP_VERSION}-sqlite3 else - CheckPackage php${DISTRO_PHP_VERSION}-sqlite + check_package php${DISTRO_PHP_VERSION}-sqlite fi ;; esac else if [ ! $DISTRO_PHP_VERSION == "5" ]; then - CheckPackage php${DISTRO_PHP_VERSION}-xml + check_package php${DISTRO_PHP_VERSION}-xml fi fi diff --git a/bash/tools/image_setup.sh b/bash/tools/image_setup.sh deleted file mode 100755 index ff869edc..00000000 --- a/bash/tools/image_setup.sh +++ /dev/null @@ -1,230 +0,0 @@ -#!/bin/bash - -##################################################################################### -# ADS-B RECEIVER # -##################################################################################### -# # -# This script is meant only to create offical Raspbian releases for this project. # -# # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# # -# Copyright (c) 2015-2016 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. # -# # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - - - ################################################################ - ## THIS SCRIPT IS ONLY MEANT FOR RASPBIAN IMAGE PREPERATION ## - ################################################################ - # # - # This script must be ran from the projects root directory. # - # # - # pi@darkstar: ./bash/tools/image_setup.sh # - # # - ################################################################ - - -clear - -## VARIABLES - -RECEIVER_ROOT_DIRECTORY="${PWD}" -RECEIVER_BASH_DIRECTORY="${RECEIVER_ROOT_DIRECTORY}/bash" -RECEIVER_BUILD_DIRECTORY="${RECEIVER_ROOT_DIRECTORY}/build" - -## INCLUDE EXTERNAL SCRIPTS - -source ${RECEIVER_BASH_DIRECTORY}/variables.sh -source ${RECEIVER_BASH_DIRECTORY}/functions.sh - -echo -e "" -echo -e "\e[91m The ADS-B Receiver Project Image Preparation Script\e[97m" -echo -e "" - -## UPDATE REPOSITORY LISTS AND OPERATING SYSTEM - -echo -e "\e[95m Updating repository lists and operating system...\e[97m" -echo -e "" -sudo apt-get update -sudo apt-get -y dist-upgrade - -## INSTALL DUMP1090 - -echo -e "" -echo -e "\e[95m Installing prerequisite packages...\e[97m" -echo -e "" -CheckPackage git -CheckPackage curl -CheckPackage build-essential -CheckPackage debhelper -CheckPackage cron -CheckPackage rtl-sdr -CheckPackage librtlsdr-dev -CheckPackage libusb-1.0-0-dev -CheckPackage pkg-config -CheckPackage lighttpd -CheckPackage fakeroot -CheckPackage bc - -## SETUP RTL-SDR RULES - -echo -e "\e[95m Setting up RTL-SDR udev rules...\e[97m" -sudo curl --http1.1 https://raw.githubusercontent.com/osmocom/rtl-sdr/master/rtl-sdr.rules --output /etc/udev/rules.d/rtl-sdr.rules -sudo service udev restart -BlacklistModules - -# Ask which version of dump1090 to install. -DUMP1090OPTION=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Choose Dump1090 Version" --menu "Which version of dump1090 is to be installed?" 12 65 2 "dump1090-mutability" "(Mutability)" "dump1090-fa" "(FlightAware)" 3>&1 1>&2 2>&3) - -case ${DUMP1090OPTION} in - "dump1090-mutability") - echo -e "\e[95m Installing dump1090-mutability...\e[97m" - echo -e "" - - # Dump1090-mutability - echo -e "" - echo -e "\e[95m Installing dump1090-mutability...\e[97m" - echo -e "" - mkdir -vp ${RECEIVER_BUILD_DIRECTORY}/dump1090-mutability - cd ${RECEIVER_BUILD_DIRECTORY}/dump1090-mutability 2>&1 - git clone https://github.com/mutability/dump1090.git - cd ${RECEIVER_BUILD_DIRECTORY}/dump1090-mutability/dump1090 2>&1 - dpkg-buildpackage -b - cd ${RECEIVER_BUILD_DIRECTORY}/dump1090-mutability 2>&1 - sudo dpkg -i dump1090-mutability_1.15~dev_*.deb - ;; - "dump1090-fa") - echo -e "\e[95m Installing dump1090-fa and PiAware...\e[97m" - echo -e "" - - # Install prerequisite packages. - echo -e "\e[95m Installing additional dump1090-fa and PiAware prerequisite packages...\e[97m" - echo -e "" - CheckPackage dh-systemd - CheckPackage libncurses5-dev - CheckPackage cmake - CheckPackage doxygen - CheckPackage libtecla-dev - CheckPackage help2man - CheckPackage pandoc - CheckPackage tcl8.6-dev - CheckPackage autoconf - CheckPackage python3-dev - CheckPackage python3-venv - CheckPackage virtualenv - CheckPackage zlib1g-dev - CheckPackage tclx8.4 - CheckPackage tcllib - CheckPackage tcl-tls - CheckPackage itcl3 - CheckPackage net-tools - - # bladeRF - echo "" - echo -e "\e[95m Installing bladeRF...\e[97m" - echo "" - mkdir -vp ${RECEIVER_BUILD_DIRECTORY}/bladeRF - cd ${RECEIVER_BUILD_DIRECTORY}/bladeRF 2>&1 - git clone https://github.com/Nuand/bladeRF.git - cd ${RECEIVER_BUILD_DIRECTORY}/bladeRF/bladeRF 2>&1 - dpkg-buildpackage -b - cd ${RECEIVER_BUILD_DIRECTORY}/bladeRF 2>&1 - sudo dpkg -i libbladerf1_*.deb - sudo dpkg -i libbladerf-dev_*.deb - sudo dpkg -i libbladerf-udev_*.deb - - # Dump1090-fa - echo -e "" - echo -e "\e[95m Installing dump1090-fa...\e[97m" - echo -e "" - mkdir -vp ${RECEIVER_BUILD_DIRECTORY}/dump1090-fa - cd ${RECEIVER_BUILD_DIRECTORY}/dump1090-fa 2>&1 - git clone https://github.com/flightaware/dump1090.git - cd ${RECEIVER_BUILD_DIRECTORY}/dump1090-fa/dump1090 2>&1 - dpkg-buildpackage -b - cd ${RECEIVER_BUILD_DIRECTORY}/dump1090-fa 2>&1 - sudo dpkg -i dump1090-fa_*.deb - - # PiAware - cd ${RECEIVER_BUILD_DIRECTORY} 2>&1 - git clone https://github.com/flightaware/piaware_builder.git - cd ${RECEIVER_BUILD_DIRECTORY}/piaware_builder 2>&1 - ./sensible-build.sh jessie - cd ${RECEIVER_BUILD_DIRECTORY}/piaware_builder/package-jessie 2>&1 - dpkg-buildpackage -b - sudo dpkg -i ${RECEIVER_BUILD_DIRECTORY}/piaware_builder/piaware_*.deb - ;; - *) - # Nothing selected. - exit 1 - ;; -esac - -## INSTALL THE BASE PORTAL PREREQUISITES PACKAGES - -echo -e "" -echo -e "\e[95m Installing packages needed by the ADS-B Receiver Project Web Portal...\e[97m" -echo -e "" -CheckPackage lighttpd -CheckPackage collectd-core -CheckPackage rrdtool -CheckPackage libpython2.7 -CheckPackage php7.0-cgi -CheckPackage php7.0-json - -## PREVIOUS LOCALE SCRIPTING THAT SET LOCALE NO LONGER WORKS PROPERLY ON STRETCH. -## The scripting setting this using this script has been removed for now. -## We will manually set this using rasp-config when creating the script in the meantime. -## Later I will look into automating this but time is short on the v2.6.0 release. - -## TOUCH THE IMAGE FILE - -echo -e "\e[95m Touching the \"image\" file...\e[97m" -cd ${RECEIVER_ROOT_DIRECTORY} 2>&1 -touch image - -## CHANGE THE PASSWORD FOR THE USER PI - -echo -e "\e[95m Changing the password for the user pi...\e[97m" -echo "pi:adsbreceiver" | sudo chpasswd - -## ENABLE SSH - -echo -e "\e[95m Touching the \"ssh\" file...\e[97m" -sudo touch /boot/ssh -echo -e "\e[95m Reconfiguring openssh-server...\e[97m" -sudo rm -f /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server - -## CLEAR BASH HISTORY - -history -c && history -w - -## DONE - -echo -e "" -echo -e "\e[91m Image preparation completed.)\e[39m" -echo -e "\e[91m Device will be shut down in 5 seconds.\e[39m" -echo -e "" - -sleep 5 -sudo halt - -exit 0 diff --git a/bash/tools/portal_backup.sh b/bash/tools/portal_backup.sh index b41f4ae0..ff094e27 100644 --- a/bash/tools/portal_backup.sh +++ b/bash/tools/portal_backup.sh @@ -1,38 +1,5 @@ #!/bin/bash -##################################################################################### -# ADS-B RECEIVER # -##################################################################################### -# # -# This script was created to allow users to backup their portal data. At this # -# time this script has not been integrated into the current collection of # -# scripts. However this script, possibly in a modified form, will be integrated # -# for simplified use by those who set up their receivers using this project. # -# # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# # -# Copyright (c) 2015-2018 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. # -# # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - ## VARIABLES BACKUPDATE=$(date +"%Y-%m-%d-%H%M%S") @@ -43,64 +10,58 @@ RAWDOCUMENTROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep ser LIGHTTPDDOCUMENTROOT=`sed 's/.*"\(.*\)"[^"]*$/\1/' <<< ${RAWDOCUMENTROOT}` COLLECTD_RRD_DIRECTORY="/var/lib/collectd/rrd" + ## BEGIN THE BACKUP PROCESS clear -echo -e "\n\e[91m ADSB Receiver Project Maintenance" +echo -e "\n\e[91m ADS-B Portal Maintenance" echo -e "" -echo -e "\e[92m Backing up portal data..." +echo -e "\e[92m Backing up portal data" echo -e "\e[93m ------------------------------------------------------------------------------\e[97m" echo -e "" echo -e "\e[95m Backing up current portal data...\e[97m" echo -e "" + ## PREPARE TO BEGIN CREATING BACKUPS -# Get the database type used. echo -e "\e[94m Declare the database engine being used...\e[97m" DATABASEENGINE=`grep 'db_driver' ${LIGHTTPDDOCUMENTROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` -echo -e "\e[94m Declare whether or not the advnaced portal features were installed...\e[97m" +echo -e "\e[94m Declare whether or not the advanaced portal features were installed...\e[97m" -# Decide if the advanced portal features were installed or not. -echo -e "\e[94m Declare whether or not the advnaced portal features were installed...\e[97m" +echo -e "\e[94m Declare whether or not the advanaced portal features were installed...\e[97m" if [[ "${DATABASEENGINE}" = "xml" ]] ; then ADVANCED=FALSE else ADVANCED=TRUE fi -# Get the path to the SQLite database if SQLite is used for the database. if [[ "${DATABASEENGINE}" = "sqlite" ]] ; then DATABASEPATH=`grep 'db_host' ${LIGHTTPDDOCUMENTROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` fi -# Assign the MySQL login credentials to variables if a MySQL database is being used. if [[ "${DATABASEENGINE}" = "mysql" ]] ; then MYSQLDATABASE=`grep 'db_database' ${LIGHTTPDDOCUMENTROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` MYSQLUSERNAME=`grep 'db_username' ${LIGHTTPDDOCUMENTROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` MYSQLPASSWORD=`grep 'db_password' ${LIGHTTPDDOCUMENTROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` fi -# Check that the backup directory exists. echo -e "\e[94m Checking that the directory ${BACKUPSDIRECTORY} exists...\e[97m" if [[ ! -d "${BACKUPSDIRECTORY}" ]] ; then - # Create the backups directory. echo -e "\e[94m Creating the directory ${BACKUPSDIRECTORY}...\e[97m" mkdir -vp ${BACKUPSDIRECTORY} fi -# Check that the temporary directory exists. echo -e "\e[94m Checking that the directory ${TEMPORARY_DIRECTORY} exists...\e[97m" if [[ ! -d "${TEMPORARY_DIRECTORY}" ]] ; then - # Create the tmp directory. echo -e "\e[94m Creating the directory ${TEMPORARY_DIRECTORY}...\e[97m" mkdir -vp ${TEMPORARY_DIRECTORY} fi + ## BACKUP THE COLLECTD RRD FILES BY EXPORTING THEM TO XML. -# Export the collectd round robin database files to the temporary directory as XML files. RRD_FILE_LIST=`find ${COLLECTD_RRD_DIRECTORY} -name '*.rrd'` if [[ -z "${RRD_FILE_LIST}" ]]; then echo -e "\e[94m No RRD file found in ${COLLECTD_RRD_DIRECTORY}...\e[97m" @@ -117,10 +78,10 @@ else done fi + ## BACKUP PORTAL USING LITE FEATURES AND XML FILES if [[ "${ADVANCED}" = "FALSE" ]] ; then - # Copy the portal XML data files to the temporary directory. echo -e "\e[94m Checking that the directory ${TEMPORARY_DIRECTORY}/var/www/html/data/ exists...\e[97m" if [[ ! -d "${TEMPORARY_DIRECTORY}/var/www/html/data/" ]] ; then mkdir -vp ${TEMPORARY_DIRECTORY}/var/www/html/data/ @@ -129,18 +90,18 @@ if [[ "${ADVANCED}" = "FALSE" ]] ; then sudo cp -R /var/www/html/data/*.xml ${TEMPORARY_DIRECTORY}/var/www/html/data/ else + ## BACKUP PORTAL USING ADVANCED FEATURES AND A SQLITE DATABASE if [[ "${DATABASEENGINE}" = "sqlite" ]] ; then - # Copy the portal SQLite database file to the temporary directory. echo -e "\e[94m Backing up the SQLite database file to ${TEMPORARY_DIRECTORY}/var/www/html/data/portal.sqlite...\e[97m" sudo cp -R ${DATABASEPATH} ${TEMPORARY_DIRECTORY}/var/www/html/data/portal.sqlite fi + ## BACKUP PORTAL USING ADVANCED FEATURES AND A MYSQL DATABASE if [[ "${DATABASEENGINE}" = "mysql" ]] ; then - # Dump the current MySQL database to a .sql text file. echo -e "\e[94m Dumping the MySQL database ${MYSQLDATABASE} to the file ${TEMPORARY_DIRECTORY}/${MYSQLDATABASE}.sql...\e[97m" mysqldump -u${MYSQLUSERNAME} -p${MYSQLPASSWORD} ${MYSQLDATABASE} > ${TEMPORARY_DIRECTORY}/${MYSQLDATABASE}.sql fi @@ -148,16 +109,14 @@ fi ## COMPRESS AND DATE THE BACKUP ARCHIVE -# Create the backup archive. echo -e "\e[94m Compressing the backed up files...\e[97m" echo -e "" tar -zcvf ${BACKUPSDIRECTORY}/adsb-receiver_data_${BACKUPDATE}.tar.gz ${TEMPORARY_DIRECTORY} echo -e "" - -# Remove the temporary directory. echo -e "\e[94m Removing the temporary backup directory...\e[97m" sudo rm -rf ${TEMPORARY_DIRECTORY} + ## BACKUP PROCESS COMPLETE echo -e "\e[32m" diff --git a/bash/variables.sh b/bash/variables.sh index a5a2b1e7..c0bb0ba4 100644 --- a/bash/variables.sh +++ b/bash/variables.sh @@ -1,24 +1,35 @@ #!/bin/bash -## SOFTWARE VERSIONS +## DISPLAY COLORS + +display_default="\033[0m" +display_heading="\033[1;36m" +display_message="\033[2;36m" +display_project_name="\033[1;31m" +display_title_heading="\033[1;32m" +display_title_message="\033[2;32m" +display_warning_heading="\033[1;33m" +display_warning_message="\033[2;33m" +display_alert_heading="\033[1;31m" +display_alert_message="\033[2;31m" +display_false_inline="\033[2;31m" +display_true_inline="\033[2;32m" -# The ADS-B Receiver Project -PROJECT_VERSION="2.8.4" +## SOFTWARE VERSIONS # FlightAware -DUMP1090_FA_VERSION="9.0" -DUMP978_FA_VERSION="9.0" -PIAWARE_VERSION="9.0.1" -SKYAWARE978_VERSION="9.0" +dump1090_fa_current_version="9.0" +dump978_fa_current_version="9.0" +piaware_current_version="9.0.1" # PlaneFinder Client -PLANEFINDER_CLIENT_VERSION_ARMHF="5.0.161" -PLANEFINDER_CLIENT_VERSION_ARM64="5.1.440" -PLANEFINDER_CLIENT_VERSION_AMD64="5.0.162" -PLANEFINDER_CLIENT_VERSION_I386="5.0.161" +pfclient_current_version_armhf="5.0.161" +pfclient_current_version_arm64="5.1.440" +pfclient_current_version_amd64="5.0.162" +pfclient_current_version_i386="5.0.161" # Flightradar24 Client -FLIGHTRADAR24_CLIENT_VERSION="1.0.18-5" +fr24feed_current_version="1.0.48-0" # OpenSky Network Client -OPENSKY_NETWORK_CLIENT_VERSION="2.1.7-1" +opensky_feeder_current_version="2.1.7-1" diff --git a/build/.gitignore b/build/.gitignore deleted file mode 100644 index 7a7f2ddd..00000000 --- a/build/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# exclude build directories -AboveTustin/ -adsbexchange/ -acarsdec/ -dump1090* -gps/ -hab/ -mlat-client/ -mlat-client* -ogn/ -phantomjs* -piaware_builder/ -planefinder/ -portal/graphs/dump1090.pyc -portal/logging/ diff --git a/build/display/current_total-aircraft_with-positions.py b/build/display/current_total-aircraft_with-positions.py deleted file mode 100644 index a4375a11..00000000 --- a/build/display/current_total-aircraft_with-positions.py +++ /dev/null @@ -1,77 +0,0 @@ -##################################################################################### -# ADS-B RECEIVER # -##################################################################################### -# # -# A set of scripts created to automate the process of installing the software # -# needed to setup a Mode S decoder as well as feeders which are capable of # -# sharing your ADS-B results with many of the most popular ADS-B aggregate sites. # -# # -# Project Hosted On GitHub: https://github.com/jprochazka/adsb-receiver # -# # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# # -# 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. # -# # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -import json -import datetime - -from oled.device import ssd1306, sh1106 -from oled.render import canvas -from PIL import ImageDraw, ImageFont -from time import time, sleep - - -with open('/run/dump1090-mutability/aircraft.json') as aircraft_json: - aircraft_data = json.load(aircraft_json) - - -def date_and_time(): - now = datetime.datetime.now() - return now.strftime("%m/%d/%Y %I:%M %p") - -def aircraft_total(): - return len(aircraft_data['aircraft']) - -def aircraft_with_positions(): - with_positions = 0 - for aircraft in aircraft_data['aircraft']: - if 'seen_pos' in aircraft: - with_positions += 1 - return with_positions - - -def stats(oled): - font = ImageFont.load_default() - font2 = ImageFont.truetype('fonts/alert.ttf', 12) - font3 = ImageFont.truetype('fonts/alert.ttf', 36) - with canvas(oled) as draw: - draw.text((0, 0), date_and_time(), font=font2, fill=255) - draw.text((0, 14), "Total / With Positions", font=font2, fill=255) - draw.text((0, 28), str(aircraft_total()) + "/" + str(aircraft_with_positions()), font=font3, fill=255) - -def main(): - oled = ssd1306(port=1, address=0x3C) - stats(oled) - -if __name__ == "__main__": - main() diff --git a/build/display/fonts/alert.ttf b/build/display/fonts/alert.ttf deleted file mode 100644 index f07f9530..00000000 Binary files a/build/display/fonts/alert.ttf and /dev/null differ diff --git a/build/portal/html/classes/template.class.php b/build/portal/html/classes/template.class.php index 2f874490..9fb9c451 100644 --- a/build/portal/html/classes/template.class.php +++ b/build/portal/html/classes/template.class.php @@ -9,7 +9,7 @@ function display(&$pageData) { // Check if the portal is installed or needs upgraded. - $thisVersion = "2.8.4"; + $thisVersion = "2.8.5"; if (!file_exists($_SERVER['DOCUMENT_ROOT']."/classes/settings.class.php")) { header ("Location: /install/install.php"); diff --git a/build/portal/html/install/index.php b/build/portal/html/install/index.php index fdcb0bd8..6880ecf6 100644 --- a/build/portal/html/install/index.php +++ b/build/portal/html/install/index.php @@ -29,7 +29,7 @@ ///////////////////////////////////////////////////////////////////////////////////// // The most current stable release. - $thisVersion = "2.8.4"; + $thisVersion = "2.8.5"; // Begin the upgrade process if this release is newer than what is installed. if (file_exists($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php")) { diff --git a/build/portal/html/install/upgrade-v2.8.5.php b/build/portal/html/install/upgrade-v2.8.5.php new file mode 100644 index 00000000..a06b0181 --- /dev/null +++ b/build/portal/html/install/upgrade-v2.8.5.php @@ -0,0 +1,68 @@ +updateSetting("version", "2.8.5"); + $common->updateSetting("patch", ""); + + // The upgrade process completed successfully. + $results['success'] = TRUE; + $results['message'] = "Upgrade to v2.8.5 successful."; + return $results; + + } catch(Exception $e) { + // Something went wrong during this upgrade process. + $results['success'] = FALSE; + $results['message'] = $e->getMessage(); + return $results; + } + } +?> + diff --git a/build/portal/html/install/upgrade.php b/build/portal/html/install/upgrade.php index 296782ff..837c5ff6 100644 --- a/build/portal/html/install/upgrade.php +++ b/build/portal/html/install/upgrade.php @@ -33,7 +33,7 @@ $common = new common(); // The most current stable release. - $thisVersion = "2.8.4"; + $thisVersion = "2.8.5"; // Begin the upgrade process if this release is newer than what is installed. if ($common->getSetting("version") == $thisVersion) { @@ -222,6 +222,15 @@ $version = "2.8.4"; } + // UPGRADE TO V2.8.5 + if ($common->getSetting("version") == "2.8.4" && $success) { + $json = file_get_contents("http://localhost/install/upgrade-v2.8.5.php"); + $results = json_decode($json, TRUE); + $success = $results['success']; + $message = $results['message']; + $version = "2.8.5"; + } + require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php"); // Display the instalation wizard. diff --git a/install.sh b/install.sh index c850b0f6..bd8d69ac 100755 --- a/install.sh +++ b/install.sh @@ -34,12 +34,22 @@ # # ##################################################################################### + +## ASSIGN VARIABLE + +project_version="2.8.5" + +printf -v date_time '%(%Y-%m-%d_%H-%M-%S)T' -1 +log_file="adsb-installer_${date_time}.log" +logging_enabled="true" + + ## FUNCTIONS # Display the help message function DisplayHelp() { echo " " - echo "Usage: $0 [OPTION] [ARGUMENT] " + echo "Usage: $0 [OPTION] [ARGUMENT] " echo " " echo "-------------------------------------------------------------------------------------------" echo "Option GNU long option Description " @@ -48,6 +58,8 @@ function DisplayHelp() { echo "-d --development Skips local repository update so changes are not overwrote." echo "-h --help Shows this message. " echo "-m --mta= Specify which email MTA to use currently Exim or Postfix. " + echo "-n --no-logging Disables writing output to a log file. " + echo "-v --version Displays the version being used. " echo "-------------------------------------------------------------------------------------------" echo " " } @@ -58,22 +70,18 @@ function DisplayHelp() { while [[ $# > 0 ]] ; do case $1 in --branch*) - # The specified branch of github project_branch=`echo $1 | sed -e 's/^[^=]*=//g'` shift 1 ;; -b) - # The specified branch of github project_branch=$2 shift 2 ;; --development | -d) - # Skip adsb-receiver repository update development_mode="true" shift 1 ;; --help | -h) - # Display a help message DisplayHelp exit 0 ;; @@ -85,6 +93,10 @@ while [[ $# > 0 ]] ; do fi shift 1 ;; + --no-logging | -n) + logging_enabled="false" + shift 1 + ;; -m) # The MTA to use mta=${2^^} @@ -94,6 +106,11 @@ while [[ $# > 0 ]] ; do fi shift 2 ;; + --version | -v) + # Display the version + echo $project_version + exit 0 + ;; *) # Unknown options were set so exit echo -e "Error: Unknown option: $1" >&2 @@ -103,9 +120,9 @@ while [[ $# > 0 ]] ; do esac done -# Add any environmental variables needed by any child scripts export RECEIVER_PROJECT_BRANCH=$project_branch export RECEIVER_DEVELOPMENT_MODE=$development_mode +export RECEIVER_LOGGING_ENABLED=$logging_enabled export RECEIVER_MTA=$mta @@ -113,7 +130,7 @@ export RECEIVER_MTA=$mta project_branch="master" -export RECEIVER_PROJECT_TITLE="The ADS-B Receiver Project Preliminary Setup Process" +export RECEIVER_PROJECT_TITLE="ADS-B Receiver Installer v${project_version}" export RECEIVER_ROOT_DIRECTORY=$PWD export RECEIVER_BASH_DIRECTORY=$PWD/bash export RECEIVER_BUILD_DIRECTORY=$PWD/build @@ -122,24 +139,45 @@ export RECEIVER_BUILD_DIRECTORY=$PWD/build ## SOURCE EXTERNAL SCRIPTS source $RECEIVER_BASH_DIRECTORY/functions.sh +source $RECEIVER_BASH_DIRECTORY/variables.sh + + +## CREATE THE LOG DIRECTORY + +if [[ "${RECEIVER_LOGGING_ENABLED}" == "true" ]]; then + export RECEIVER_LOG_FILE=$PWD/logs/$log_file + if [ ! -d "$DIRECTORY" ]; then + log_message "Creating logs directory" + mkdir $PWD/logs + fi +fi ## UPDATE PACKAGE LISTS AND INSTALL DEPENDENCIES clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}\n" -echo -e "\e[92m ADS-B Receiver Project Package Dependency Check" -echo -e "\e[93m ------------------------------------------------------------------------------\e[97m\n" -echo -e "\e[94m Downloading the latest package lists for all enabled repositories and PPAs...\e[97m\n" -sudo apt-get update -echo -e "\n\e[94m Ensuring that all required packages are installed...\e[97m\n" -CheckPackage bc -CheckPackage git -CheckPackage lsb-base -CheckPackage lsb-release -CheckPackage whiptail -echo -e "\n\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m All required packages are installed.\e[39m\n" +log_project_title +log_title_heading "Starting ADS-B Receiver Installer package dependency check" +log_title_message "------------------------------------------------------------------------------" + +log_heading "Updating package lists for all enabled repositories and PPAs" + +log_message "Downloading the latest package lists for all enabled repositories and PPAs" +echo "" +sudo apt-get update 2>&1 | tee -a $RECEIVER_LOG_FILE + +log_heading "Ensuring that all required packages are installed" + +check_package bc +check_package git +check_package lsb-base +check_package lsb-release +check_package whiptail +echo "" + +log_title_message "------------------------------------------------------------------------------" +log_title_heading "ADS-B Receiver Installer package dependency check complete" +echo "" read -p "Press enter to continue..." discard @@ -156,82 +194,6 @@ export RECIEVER_CPU_ARCHITECTURE=`uname -m | tr -d "\n\r"` export RECEIVER_CPU_REVISION=`grep "^Revision" /proc/cpuinfo | awk '{print $3}'` -## FUNCTIONS - -# Display the help message -function DisplayHelp() { - echo " " - echo "Usage: $0 [OPTIONS] [ARGUMENTS] " - echo " " - echo "-------------------------------------------------------------------------------------------" - echo "Option GNU long option Description " - echo "-------------------------------------------------------------------------------------------" - echo "-b --branch= Specifies the repository branch to be used. " - echo "-d --development Skips local repository update so changes are not overwrote." - echo "-h --help Shows this message. " - echo "-m --mta= Specify which email MTA to use currently Exim or Postfix. " - echo "-------------------------------------------------------------------------------------------" - echo " " -} - - -## CHECK FOR OPTIONS AND ARGUMENTS - -while [[ $# > 0 ]] ; do - echo "SWITCH: ${1}" - case $1 in - --branch*) - # The specified branch of github - project_branch=`echo $1 | sed -e 's/^[^=]*=//g'` - shift 1 - ;; - -b) - # The specified branch of github - project_branch=$2 - shift 2 - ;; - --development | -d) - # Skip adsb-receiver repository update - development_mode="true" - shift 1 - ;; - --help | -h) - # Display a help message - DisplayHelp - exit 0 - ;; - --mta*) - mta=`echo ${1^^} | sed -e 's/^[^=]*=//g'` - if [[ "${mta}" != "EXIM" && "${mta}" != "POSTFIX" ]]; then - echo "MTA can only be either EXIM or POSTFIX." - exit 1 - fi - shift 1 - ;; - -m) - # The MTA to use - mta=${2^^} - if [[ "${mta}" != "EXIM" && "${mta}" != "POSTFIX" ]]; then - echo "MTA can only be either EXIM or POSTFIX." - exit 1 - fi - shift 2 - ;; - *) - # Unknown options were set so exit - echo -e "Error: Unknown option: $1" >&2 - DisplayHelp - exit 1 - ;; - esac -done - -# Add any environmental variables needed by any child scripts -export RECEIVER_PROJECT_BRANCH=$project_branch -export RECEIVER_DEVELOPMENT_MODE=$development_mode -export RECEIVER_MTA=$mta - - ## EXECUTE BASH/INIT.SH chmod +x $RECEIVER_BASH_DIRECTORY/init.sh @@ -240,14 +202,12 @@ $RECEIVER_BASH_DIRECTORY/init.sh ## CLEAN UP -# Remove any files created by whiptail. for choice in FEEDER_CHOICES EXTRAS_CHOICES ; do if [[ -f ${RECEIVER_ROOT_DIRECTORY}/${choice} ]] ; then rm -f ${RECEIVER_ROOT_DIRECTORY}/${choice} fi done -# Remove any global variables assigned by this script unset RECEIVER_PROJECT_TITLE unset RECEIVER_ROOT_DIRECTORY unset RECEIVER_BASH_DIRECTORY @@ -259,6 +219,8 @@ unset RECIEVER_CPU_ARCHITECTURE unset RECEIVER_CPU_REVISION unset RECEIVER_PROJECT_BRANCH unset RECEIVER_DEVELOPMENT_MODE +unset RECEIVER_LOGGING_ENABLED +unset RECEIVER_LOG_FILE unset RECEIVER_MTA # Check if any errors were encountered by any child scripts