From 28ef0b23e5298452cf9b59a1e473dac0004d5a68 Mon Sep 17 00:00:00 2001 From: Joe Prochazka Date: Tue, 26 Jun 2018 09:06:46 -0400 Subject: [PATCH] Added OpenSky Network feeder support. --- bash/feeders/openskynetwork.sh | 134 +++++++++++++++++++++++++++++++++ bash/main.sh | 101 +++++++++++++++++-------- example.config | 10 +++ 3 files changed, 212 insertions(+), 33 deletions(-) create mode 100755 bash/feeders/openskynetwork.sh diff --git a/bash/feeders/openskynetwork.sh b/bash/feeders/openskynetwork.sh new file mode 100755 index 0000000..788d5e7 --- /dev/null +++ b/bash/feeders/openskynetwork.sh @@ -0,0 +1,134 @@ +#!/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 OpenSky Network feeder client..." +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. + CONTINUE_SETUP=$(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) + 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 OpenSky Network feeder 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 + +### 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 "" + +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" + CheckPacakge apt-transport-https + echo -e "\e[94m Downloading the OpenSky Network apt repository GPG key...\e[97m" + wget -O - https://opensky-network.org/files/firmware/opensky.gpg.pub | sudo apt-key add - + echo -e "\e[94m Adding the OpenSky Network apt repository...\e[97m" + 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" +fi + +### INSTALL THE OPENSKY NETWORK FEEDER PACKAGE USING APT + +echo "" +echo -e "\e[95m Installing the OpenSky Network fedder package...\e[97m" +echo "" + +echo -e "\e[94m Downloading the latest package lists for all enabled repositories and PPAs...\e[97m" +echo "" +sudo apt-get update +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 + +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/main.sh b/bash/main.sh index a56b260..bc29667 100755 --- a/bash/main.sh +++ b/bash/main.sh @@ -111,19 +111,28 @@ function InstallAdsbExchange() { fi } -# Execute the PiAware setup script -function InstallPiAware() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/piaware.sh - ${RECEIVER_BASH_DIRECTORY}/feeders/piaware.sh +# 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 fi } -# Execute the Flightradar24 Feeder client setup script. -function InstallFlightradar24() { - chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/flightradar24.sh - ${RECEIVER_BASH_DIRECTORY}/feeders/flightradar24.sh +# 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 +} + +# 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 @@ -456,6 +465,21 @@ else 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. + if [[ ! "${RECEIVER_AUTOMATED_INSTALL}" = "true" ]] ; then + # 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 + # 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 + 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. @@ -566,7 +590,7 @@ fi if [[ ! "${RECEIVER_AUTOMATED_INSTALL}" = "true" ]] ; then 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." 13 65 4 "${FEEDER_LIST[@]}" 2>${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES + 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." 13 65 5 "${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 @@ -751,29 +775,32 @@ else while read FEEDER_CHOICE do case ${FEEDER_CHOICE} in + "ADS-B Exchange data export and MLAT Client") + CONFIRMATION="${CONFIRMATION}\n * ADS-B Exchange data export and MLAT Client" + ;; + "ADS-B Exchange data export and MLAT Client (upgrade)") + CONFIRMATION="${CONFIRMATION}\n * ADS-B Exchange data export and MLAT Client (upgrade)" + ;; "FlightAware PiAware") CONFIRMATION="${CONFIRMATION}\n * FlightAware PiAware" ;; "FlightAware PiAware (upgrade)") CONFIRMATION="${CONFIRMATION}\n * FlightAware PiAware (upgrade)" ;; - "Plane Finder Client") - CONFIRMATION="${CONFIRMATION}\n * Plane Finder Client" - ;; - "Plane Finder Client (upgrade)") - CONFIRMATION="${CONFIRMATION}\n * Plane Finder Client (upgrade)" - ;; "Flightradar24 Client") CONFIRMATION="${CONFIRMATION}\n * Flightradar24 Client" ;; "Flightradar24 Client (upgrade)") CONFIRMATION="${CONFIRMATION}\n * Flightradar24 Client (upgrade)" ;; - "ADS-B Exchange data export and MLAT Client") - CONFIRMATION="${CONFIRMATION}\n * ADS-B Exchange data export and MLAT Client" + "OpenSky Network Feeder") + CONFIRMATION="${CONFIRMATION}\n * OpenSky Network Feeder" ;; - "ADS-B Exchange data export and MLAT Client (upgrade)") - CONFIRMATION="${CONFIRMATION}\n * ADS-B Exchange data export and MLAT Client (upgrade)" + "Plane Finder Client") + CONFIRMATION="${CONFIRMATION}\n * Plane Finder Client" + ;; + "Plane Finder Client (upgrade)") + CONFIRMATION="${CONFIRMATION}\n * Plane Finder Client (upgrade)" ;; esac done < ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES @@ -854,45 +881,53 @@ fi # Moved execution of functions outside of while loop. # Inside the while loop the installation scripts are not stopping at reads. -RUN_PIAWARE_SCRIPT="false" -RUN_PLANEFINDER_SCRIPT="false" -RUN_FLIGHTRADAR24_SCRIPT="false" RUN_ADSBEXCHANGE_SCRIPT="false" +RUN_PIAWARE_SCRIPT="false" +RUN_FLIGHTRADAR24_SCRIPT="false" +RUN_OPENSKYNETWORK_SCRIPT="false" +RUN_PLANEFINDER_SCRIPT="false" if [[ -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" ]] ; then while read FEEDER_CHOICE do case ${FEEDER_CHOICE} in + "ADS-B Exchange data export and MLAT Client"|"ADS-B Exchange data export and MLAT Client (upgrade)") + RUN_ADSBEXCHANGE_SCRIPT="true" + ;; "FlightAware PiAware"|"FlightAware PiAware (upgrade)") RUN_PIAWARE_SCRIPT="true" ;; - "Plane Finder Client"|"Plane Finder Client (upgrade)") - RUN_PLANEFINDER_SCRIPT="true" - ;; "Flightradar24 Client"|"Flightradar24 Client (upgrade)") RUN_FLIGHTRADAR24_SCRIPT="true" ;; - "ADS-B Exchange data export and MLAT Client"|"ADS-B Exchange data export and MLAT Client (upgrade)") - RUN_ADSBEXCHANGE_SCRIPT="true" + "OpenSky Network Feeder") + RUN_OPENSKYNETWORK_SCRIPT="true" + ;; + "Plane Finder Client"|"Plane Finder Client (upgrade)") + RUN_PLANEFINDER_SCRIPT="true" ;; esac done < ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES fi +if [[ "${RUN_ADSBEXCHANGE_SCRIPT}" = "true" ]] ; then + InstallAdsbExchange +fi + if [[ "${RUN_PIAWARE_SCRIPT}" = "true" ]] || [[ "${FORCE_PIAWARE_INSTALL}" = "true" ]] ; then InstallPiAware fi -if [[ "${RUN_PLANEFINDER_SCRIPT}" = "true" ]] ; then - InstallPlaneFinder -fi - if [[ "${RUN_FLIGHTRADAR24_SCRIPT}" = "true" ]] ; then InstallFlightradar24 fi -if [[ "${RUN_ADSBEXCHANGE_SCRIPT}" = "true" ]] ; then - InstallAdsbExchange +if [[ "${RUN_OPENSKYNETWORK_SCRIPT}" = "true" ]] ; then + InstallOpenSkyNetwork +fi + +if [[ "${RUN_PLANEFINDER_SCRIPT}" = "true" ]] ; then + InstallPlaneFinder fi ## ADS-B Receiver Project Web Portal diff --git a/example.config b/example.config index e982e51..6c89f91 100644 --- a/example.config +++ b/example.config @@ -185,6 +185,16 @@ ADSBEXCHANGE_RECEIVER_USERNAME="I_DID_NOT_READ_THE_COMMENTS" FLIGHTRADAR24_INSTALL="false" +# --------------------------------------------------------------------------------- +# OPENSKY NETWORK FEEDER CLIENT +# --------------------------------------------------------------------------------- +# +# Installation includes the addition of the OpenSky Network apt repository to your +# device. After the repository has been added apt will be used to install and keep +# the client up to date. + +OPENSKY_NETWORK_INSTALL="false" + # --------------------------------------------------------------------------------- # PIAWARE # ---------------------------------------------------------------------------------