diff --git a/bash/feeders/adsbhub.sh b/bash/feeders/adsbhub.sh new file mode 100644 index 0000000..a8ac540 --- /dev/null +++ b/bash/feeders/adsbhub.sh @@ -0,0 +1,189 @@ +#!/bin/bash + +##################################################################################### +# ADS-B RECEIVER # +##################################################################################### +# # +# This script is not meant to be executed directly. # +# Instead execute install.sh to begin the installation process. # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# 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 + +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 + +## SET INSTALLATION VARIABLES + +# Source the automated install configuration file if this is an automated installation. +if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "true" ]] && [[ -s "${RECEIVER_CONFIGURATION_FILE}" ]] ; then + source ${RECEIVER_CONFIGURATION_FILE} +fi + +### BEGIN SETUP + +if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then + clear + echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" +fi +echo -e "" +echo -e "\e[92m Setting up ADSBHub feeder client..." +echo -e "" +echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" +echo -e "" + +# Confirm component installation. +if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then + # Interactive install. + CONTINUE_SETUP=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADSBHub client Setup" --yesno "There are many Web sites tracking aircraft and all of them rely on data shared by ADS-B fans. However, the access to aggregated ADS-B worldwide data is limited. The main goal of ADSBHub is to become a ADS-B data sharing centre and valuable data source for all enthusiasts and professionals interested in development of ADS-B related software. For more information please see their website:\n\n http://www.adsbhub.org/howtofeed.php\n\nContinue setup by installing the ADSBHub client?" 13 78 3>&1 1>&2 2>&3) + if [[ ${CONTINUE_SETUP} -eq 1 ]] ; then + # Setup has been halted by the user. + echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" + echo -e " Setup has been halted at the request of the user." + echo -e "" + echo -e "\e[93m ------------------------------------------------------------------------------" + echo -e "\e[92m ADSBHub client setup halted.\e[39m" + echo -e "" + read -p "Press enter to continue..." CONTINUE + exit 1 + fi +else + # Warn that automated installation is not supported. + echo -e "\e[92m Automated installation of this script is not yet supported...\e[39m" + echo -e "" + exit 1 +fi + +### INSTALL REQUIRED PACKAGES IF THEY ARE NOT ALREADY INSTALLED + +CheckPackage wget +CheckPackage netcat + +### ENABLE THE USE OF /ETC/RC.LOCAL IF THE FILE DOES NOT EXIST + +if [ ! -f /etc/rc.local ]; then + echo "" + echo -e "\e[95m Enabling the use of the /etc/rc.local file...\e[97m" + echo "" + + # In Debian Stretch /etc/rc.local has been removed. + # However at this time we can bring this file back into play. + # As to if in future releases this will work remains to be seen... + + echo -e "\e[94m Creating the file /etc/rc.local...\e[97m" + sudo tee /etc/rc.local > /dev/null <0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i $RECEIVER_BUILD_DIRECTORY/adsbhub/adsbhub.sh &\n" /etc/rc.local +fi + +### START THE ADSBHUB CLIENT + +echo "" +echo -e "\e[95m Starting the ADSBHub client...\e[97m" +echo "" + +# Kill any currently running instances of the adsbexchange-socat_maint.sh script. +echo -e "\e[94m Checking for any running adsbexchange-socat_maint.sh processes...\e[97m" +if [[ $(ps -aux | grep '[a]dsbhub.sh' | awk '{print $2}') ]]; then + echo -e "\e[94m Killing the current adsbhub.sh process...\e[97m" + sudo kill -9 $(ps -aux | grep '[a]dsbhub.sh' | awk '{print $2}') &> /dev/null +fi + +echo -e "\e[94m Executing the ADSBHub client script...\e[97m" +sudo nohup $RECEIVER_BUILD_DIRECTORY/adsbhub/adsbhub.sh > /dev/null 2>&1 & + +### INFORM THE USER THERE IS MORE TO DO + +whiptail --title "Complete Setup at ADSBHub.org" --msgbox "IMPORTANT!!!\n\nIn order to complete the ADSBHub setup process you will need to create/login to your ADSBHub account at http://www.adsbhub.com. After logining into your account click on the \"Settings\" button then next to your \"Profile\" tab click on \"New Station\" and fill out the form." 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 + +echo -e "" +echo -e "\e[93m ------------------------------------------------------------------------------" +echo -e "\e[92m OpenSky Network feeder client setup is complete.\e[39m" +echo -e "" +if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then + read -p "Press enter to continue..." CONTINUE +fi + +exit 0 diff --git a/bash/feeders/openskynetwork.sh b/bash/feeders/openskynetwork.sh index 788d5e7..95daefe 100755 --- a/bash/feeders/openskynetwork.sh +++ b/bash/feeders/openskynetwork.sh @@ -61,11 +61,6 @@ echo -e "" echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" echo -e "" -# Check for existing component install. -if [[ $(dpkg-query -W -f='${STATUS}' fr24feed 2>/dev/null | grep -c "ok installed") -eq 0 ]] ; then - COMPONENT_FIRST_INSTALL="true" -fi - # Confirm component installation. if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then # Interactive install. diff --git a/bash/main.sh b/bash/main.sh index f5694dc..e238e28 100755 --- a/bash/main.sh +++ b/bash/main.sh @@ -111,6 +111,15 @@ function InstallAdsbExchange() { fi } +# Execute the ADSBHub setup script. +function InstallAdsbhub() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/adsbhub.sh + ${RECEIVER_BASH_DIRECTORY}/feeders/adsbhub.sh + if [[ $? -ne 0 ]] ; then + exit 1 + fi +} + # Execute the Flightradar24 Feeder client setup script. function InstallFlightradar24() { chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/flightradar24.sh @@ -465,6 +474,21 @@ else fi fi +# Check if the ADSBHuub client script has been set up. +if ! grep -q "${BUILDDIR}/adsbexchange/adsbexchange-maint.sh &" /etc/rc.local; then + # The ADSBHub client script does not appear to be executed on start up. + if [[ ! "${RECEIVER_AUTOMATED_INSTALL}" = "true" ]] ; then + # Add this choice to the FEEDER_LIST array to be used by the whiptail menu. + FEEDER_LIST=("${FEEDERLIST[@]}" 'ADSBHub Client Script' '' OFF) + else + # Check the installation configuration file to see if the ADSBHub client is to be installed. + if [[ -z "${ADSBHUB_INSTALL}" ]] && [[ "${ADSBHUB_INSTALL}" = "true" ]] ; then + # Since the menu will be skipped add this choice directly to the FEEDER_CHOICES file. + echo "ADSBHub Client Script" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES + fi + fi +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. @@ -472,8 +496,8 @@ if [[ $(dpkg-query -W -f='${STATUS}' opensky-feeder 2>/dev/null | grep -c "ok in # Add this choice to the FEEDER_LIST array to be used by the whiptail menu. FEEDER_LIST=("${FEEDER_LIST[@]}" 'OpenSky Network Feeder' '' OFF) else - # Check the installation configuration file to see if PiAware is to be installed. - if [[ -z "${OPENSKY_NETWORK_INSTALL}" ]] && [[ "${{OPENSKY_NETWORK_INSTALL}" = "true" ]] ; then + # Check the installation configuration file to see if the OpenSky Network package is to be installed. + if [[ -z "${OPENSKY_NETWORK_INSTALL}" ]] && [[ "${OPENSKY_NETWORK_INSTALL}" = "true" ]] ; then # Since the menu will be skipped add this choice directly to the FEEDER_CHOICES file. echo "OpenSky Network Feeder" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES fi @@ -781,6 +805,9 @@ else "ADS-B Exchange data export and MLAT Client (upgrade)") CONFIRMATION="${CONFIRMATION}\n * ADS-B Exchange data export and MLAT Client (upgrade)" ;; + "ADSBHub Client Script") + CONFIRMATION="${CONFIRMATION}\n * ADSBHub Client Script" + ;; "FlightAware PiAware") CONFIRMATION="${CONFIRMATION}\n * FlightAware PiAware" ;; @@ -894,6 +921,9 @@ if [[ -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" ]] ; then "ADS-B Exchange data export and MLAT Client"|"ADS-B Exchange data export and MLAT Client (upgrade)") RUN_ADSBEXCHANGE_SCRIPT="true" ;; + "ADSBHub Client Script") + RUN_ADSBHUB_SCRIPT="true" + ;; "FlightAware PiAware"|"FlightAware PiAware (upgrade)") RUN_PIAWARE_SCRIPT="true" ;; @@ -914,6 +944,10 @@ if [[ "${RUN_ADSBEXCHANGE_SCRIPT}" = "true" ]] ; then InstallAdsbExchange fi +if [[ "${RUN_ADSBHUB_SCRIPT}" = "true" ]] ; then + InstallAdsbhub +fi + if [[ "${RUN_PIAWARE_SCRIPT}" = "true" ]] || [[ "${FORCE_PIAWARE_INSTALL}" = "true" ]] ; then InstallPiAware fi diff --git a/example.config b/example.config index 6c89f91..b44e585 100644 --- a/example.config +++ b/example.config @@ -167,6 +167,12 @@ DUMP978_DEVICE_ID="1" ADSBEXCHANGE_INSTALL="false" ADSBEXCHANGE_UPGRADE="false" +# --------------------------------------------------------------------------------- +# ADSBHub +# --------------------------------------------------------------------------------- + +ADSBHUB_INSTALL="false" + # The receiver name should be a unique name specific to this receiver which you can # use to identify your receiver on the ADS-B Exchange MLAT status pages. This # variable is required in order to setup the MLAT client to feed ADS-B Exchange