#!/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-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. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## INCLUDE EXTERNAL SCRIPTS source ${RECEIVER_BASH_DIRECTORY}/variables.sh source ${RECEIVER_BASH_DIRECTORY}/functions.sh # Source the automated install configuration file if this is an automated installation. if [[ ${RECEIVER_AUTOMATED_INSTALL} = "true" ]] ; 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 RTL-SDR OGN..." echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[96m" echo -e "" if [[ ${RECEIVER_AUTOMATED_INSTALL} = "false" ]] ; then whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "RTL-SDR OGN Setup" --yesno "The objective of the Open Glider Network is to create and maintain a unified tracking platform for gliders and other GA aircraft. Currently OGN focuses on tracking aircraft equipped with FLARM, FLARM-compatible devices or OGN tracker.\n\nPlease note you will need a dedicated RTL-SDR dongle to use this software.\n\n http://wiki.glidernet.org\n\nContinue setup by installing RTL-SDR OGN?" 14 78 if [[ $? -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 RTL-SDR OGN setup halted.\e[39m" echo -e "" read -p "Press enter to continue..." CONTINUE exit 1 fi fi ## ASK FOR DEVICE ASSIGNMENTS # Check if the dump1090-mutability package is installed. echo -e "\e[95m Checking for existing decoders...\e[97m" echo -e "" # Check if the dump1090-mutability package is installed. echo -e "\e[94m Checking if the dump1090-mutability package is installed...\e[97m" if [[ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then DUMP1090_IS_INSTALLED="true" else DUMP1090_IS_INSTALLED="false" fi # Check if the dump978 binaries exist. echo -e "\e[94m Checking if the dump978 binaries exist on this device...\e[97m" if [[ -f ${RECEIVER_BUILD_DIRECTORY}/dump978/dump978 ]] && [[ -f ${RECEIVER_BUILD_DIRECTORY}/dump978/uat2text ]] && [[ -f ${RECEIVER_BUILD_DIRECTORY}/dump978/uat2esnt ]] && [[ -f ${RECEIVER_BUILD_DIRECTORY}/dump978/uat2json ]] ; then DUMP978_IS_INSTALLED="true" else DUMP978_IS_INSTALLED="false" fi # If either dump1090 or dump978 is installed we must assign RTL-SDR dongles for each of these decoders. if [[ ${DUMP1090_IS_INSTALLED} = "true" ]] || [[${DUMP978_IS_INSTALLED} = "true" ]] ; then # Check if Dump1090 is installed. if [[ ${DUMP1090_IS_INSTALLED} = "true" ]] ; then # The dump1090-mutability package appear to be installed. if [[ ${RECEIVER_AUTOMATED_INSTALL} = "false" ]] ; then # Ask the user which USB device is to be used for dump1090. DUMP1090_USB_DEVICE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump1090 RTL-SDR Dongle" --nocancel --inputbox "\nEnter the ID for your dump1090 RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) while [[ -z ${DUMP1090_USB_DEVICE} ]] ; do DUMP1090_USB_DEVICE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump1090 RTL-SDR Dongle (REQUIRED)" --nocancel --inputbox "\nEnter the ID for your dump1090 RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) done else ### GET DONGLE ID FROM THE INSTALLATION CONFIGURATION FILE... true fi fi # Check if Dump978 is installed. if [[ ${DUMP978_IS_INSTALLED} = "true" ]] ; then # The dump978 binaries appear to exist on this device. if [[ ${RECEIVER_AUTOMATED_INSTALL} = "false" ]] ; then # Ask the user which USB device is to be use for dump978. DUMP978_USB_DEVICE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump978 RTL-SDR Dongle" --nocancel --inputbox "\nEnter the ID for your dump978 RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) while [[ -z ${DUMP978_USB_DEVICE} ]] ; do DUMP978_USB_DEVICE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Dump978 RTL-SDR Dongle (REQUIRED)" --nocancel --inputbox "\nEnter the ID for your dump978 RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) done else ### GET DONGLE ID FROM THE INSTALLATION CONFIGURATION FILE... true fi fi # if [[ ${RECEIVER_AUTOMATED_INSTALL} = "false" ]] ; then # Ask the user which USB device is to be use for RTL-SDR OGN. RTLSDROGN_USB_DEVICE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "RTL-SDR OGN RTL-SDR Dongle" --nocancel --inputbox "\nEnter the ID for your RTL-SDR OGN RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) while [[ -z ${DUMP978_USB_DEVICE} ]] ; do RTLSDROGN_USB_DEVICE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "RTL-SDR OGN RTL-SDR Dongle (REQUIRED)" --nocancel --inputbox "\nEnter the ID for your RTL-SDR OGN RTL-SDR dongle." 8 78 3>&1 1>&2 2>&3) done else ### GET DONGLE ID FROM THE INSTALLATION CONFIGURATION FILE... true fi # Assign the specified RTL-SDR dongle to dump1090. if [[ ${DUMP1090_IS_INSTALLED} = "true" ]] && [[ -n ${DUMP1090_USB_DEVICE} ]] ; then echo -e "\e[94m Assigning RTL-SDR dongle \"DUMP1090_USB_DEVICE\" to dump1090-mutability...\e[97m" ChangeConfig "DEVICE" ${DUMP1090_USB_DEVICE} "/etc/default/dump1090-mutability" echo -e "\e[94m Reloading dump1090-mutability...\e[97m" echo -e "" sudo /etc/init.d/dump1090-mutability force-reload echo -e "" fi # Assign the specified RTL-SDR dongle to dump978 if [[ ${DUMP978_IS_INSTALLED} = "true" ]] && [[ -n ${DUMP978_USB_DEVICE} ]] ; then echo -e "\e[94m Assigning RTL-SDR dongle \"${DUMP978_USB_DEVICE}\" to dump978...\e[97m" ### ADD DEVICE TO MAINTENANCE SCRIPT... echo -e "\e[94m Reloading dump978...\e[97m" ### KILL EXISTING DUMP978 PROCESSES... echo -e "" ### RESTART DUMP978... echo -e "" fi fi ### ASSIGN RTL-SDR DONGLE FOR RTL-SDR OGN... ## CHECK FOR PREREQUISITE PACKAGES echo -e "\e[95m Installing packages needed to fulfill dependencies...\e[97m" echo -e "" CheckPackage git CheckPackage rtl-sdr CheckPackage librtlsdr-dev CheckPackage libusb-1.0-0-dev CheckPackage libconfig-dev CheckPackage libfftw3-dev CheckPackage libjpeg8 CheckPackage libjpeg-dev CheckPackage libconfig9 CheckPackage procserv CheckPackage telnet CheckPackage wget CheckPackage lynx echo -e "\e[95m Configuring this device to run the RTL-SDR OGN binaries...\e[97m" echo -e "" ## BLACKLIST UNWANTED RTL-SDR MODULES FROM BEING LOADED if [[ ! -f /etc/modprobe.d/rtlsdr-blacklist.conf ]] ; then echo -e "\e[94m Stopping unwanted kernel modules from being loaded...\e[97m" echo -e "" sudo tee /etc/modprobe.d/rtlsdr-blacklist.conf > /dev/null < /dev/null < #Syntax: #port user directory command args 50000 pi ${BUILDDIRECTORY_RTLSDROGN}/rtlsdr-ogn ./ogn-rf rtlsdr-ogn.conf 50001 pi ${BUILDDIRECTORY_RTLSDROGN}/rtlsdr-ogn ./ogn-decode rtlsdr-ogn.conf EOF echo -e "\e[94m Setting up rtlsdr-ogn as a service...\e[97m" echo -e "" sudo update-rc.d rtlsdr-ogn defaults echo -e "\e[94m Starting the rtlsdr-ogn service...\e[97m" echo -e "" sudo service rtlsdr-ogn start ## RTL-SDR OGN SETUP COMPLETE # Enter into the project root directory. echo -e "\e[94m Entering the ADS-B Receiver Project root directory...\e[97m" cd ${RECEIVER_ROOT_DIRECTORY} echo -e "" echo -e "\e[93m----------------------------------------------------------------------------------------------------" echo -e "\e[92m RTL-SDR OGN setup is complete.\e[39m" echo -e "" read -p "Press enter to continue..." CONTINUE exit 0