From 736fdd9c34c75deb89ff64761bfd4733a86d4505 Mon Sep 17 00:00:00 2001 From: Joseph Prochazka Date: Fri, 19 Jul 2024 20:35:33 -0400 Subject: [PATCH 01/18] Work started on the ACARSDEC installer. --- bash/decoders/acarsdec.sh | 170 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 bash/decoders/acarsdec.sh diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh new file mode 100644 index 0000000..ae7fb5f --- /dev/null +++ b/bash/decoders/acarsdec.sh @@ -0,0 +1,170 @@ +#!/bin/bash + +# THE ACARSDECO DECODER SETUP SCRIPT + +## PRE INSTALLATION OPERATIONS + +source $RECEIVER_BASH_DIRECTORY/variables.sh +source $RECEIVER_BASH_DIRECTORY/functions.sh + +clear +LogProjectName ${RECEIVER_PROJECT_TITLE} +LogTitleHeading "Setting up the ACARSDEC decoder" +LogTitleMessage "------------------------------------------------------------------------------" +echo "" + +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ACARSDEC decoder Setup" --yesno "Continue setup?" 13 78; then + LogAlertHeading "INSTALLATION HALTED" + LogAlertMessage "Setup has been halted at the request of the user" + echo "" + LogTitleMessage "------------------------------------------------------------------------------" + LogTitleHeading "ACARSDEC decoder setup halted" + echo "" + exit 1 +fi + + +## PRE INSTALLATION OPERATIONS + +# TODO: Ask which device to build the ACARSDEC decoder for + + +## CHECK FOR PREREQUISITE PACKAGES + +LogHeading "Installing packages needed to fulfill dependencies for FlightAware PiAware client" + +CheckPackage cmake +CheckPackage zlib1g-dev +CheckPackage libxml2-dev +CheckPackage libjansson-dev +CheckPackage libusb-1.0-0-dev +CheckPackage pkg-config +CheckPackage libsndfile-dev +CheckPackage libpaho-mqtt-dev + +CheckPackage librtlsdr-dev +CheckPackage libairspy-dev +CheckPackage libmirisdr-dev + + +## CLONE OR PULL THE LIBACARS GIT REPOSITORY + +LogHeading "Preparing the libacars Git repository" + +if [[ -d $RECEIVER_BUILD_DIRECTORY/libacars && -d $RECEIVER_BUILD_DIRECTORY/libacars/.git ]]; then + LogMessage "Entering the libacars git repository directory" + cd $RECEIVER_BUILD_DIRECTORY/libacars + LogMessage "Updating the local libacars git repository" + echo "" + git pull +else + LogMessage "Entering the libacars build directory" + cd $RECEIVER_BUILD_DIRECTORY + LogMessage "Cloning the libacars git repository locally" + echo "" + git clone https://github.com/szpajder/libacars.git +fi +echo "" + + +## BUILD AND INSTALL THE LIBACARS LIBRARY + +LogHeading "Building the libacars library" + +if [[ ! -d $RECEIVER_BUILD_DIRECTORY/libacars/build ]]; then + LogMessage "Creating the libacars build directory" + echo "" + mkdir -vp $RECEIVER_BUILD_DIRECTORY/libacars/build + echo "" +fi +if [[ -n "$(ls -A $RECEIVER_BUILD_DIRECTORY/libacars/build 2>/dev/null)" ]] + LogMessage "Deleting all files currently residing in the libacars build directory" + rm -rf $RECEIVER_BUILD_DIRECTORY/libacars/build/* +fi +LogMessage "Entering the libacars build directory" +cd $RECEIVER_BUILD_DIRECTORY/libacars/build +LogMessage "Executing cmake" +echo "" +cmake ../ +echo "" +LogMessage "Executing make" +echo "" +make +echo "" +LogMessage "Executing make install" +echo "" +sudo make install +echo "" +LogMessage "Running ldconfig" +echo "" +sudo ldconfig +echo "" + + +## CLONE OR PULL THE ACARSDEC GIT REPOSITORY + +LogHeading "Preparing the ACARSDEC Git repository" + +if [[ -d $RECEIVER_BUILD_DIRECTORY/acarsdec && -d $RECEIVER_BUILD_DIRECTORY/acarsdec/.git ]]; then + LogMessage "Entering the ACARSDEC git repository directory" + cd $RECEIVER_BUILD_DIRECTORY/acarsdec + LogMessage "Updating the local ACARSDEC git repository" + echo "" + git pull +else + LogMessage "Entering the ACARSDEC build directory" + cd $RECEIVER_BUILD_DIRECTORY + LogMessage "Cloning the ACARSDEC git repository locally" + echo "" + git clone https://github.com/TLeconte/acarsdec.git +fi +echo "" + + +## BUILD AND INSTALL THE ACARSDEC BINARY + +LogHeading "Building the ACARSDEC binary" + +if [[ ! -d $RECEIVER_BUILD_DIRECTORY/acarsdec/build ]]; then + LogMessage "Creating the ACARSDEC build directory" + echo "" + mkdir -vp $RECEIVER_BUILD_DIRECTORY/acarsdec/build + echo "" +fi +if [[ -n "$(ls -A $RECEIVER_BUILD_DIRECTORY/acarsdec/build 2>/dev/null)" ]] + LogMessage "Deleting all files currently residing in the ACARSDEC build directory" + rm -rf $RECEIVER_BUILD_DIRECTORY/acarsdec/build/* +fi +LogMessage "Entering the ACARSDEC build directory" +cd $RECEIVER_BUILD_DIRECTORY/acarsdec/build +LogMessage "Executing cmake" +echo "" + +# TODO: Choose the proper parameters depending on the chosen device + +cmake .. -Drtl=ON or -Dairspy=ON or -Dsdrplay=ON +echo "" +LogMessage "Executing make" +echo "" +make +echo "" +LogMessage "Executing make install" +echo "" +sudo make install +echo "" + +# TODO: Configure the application to run + + +## SETUP COMPLETE + +LogMessage "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY + +echo "" +LogTitleMessage "------------------------------------------------------------------------------" +LogTitleHeading "ACARSDEC decoder setup is complete" +echo "" +read -p "Press enter to continue..." discard + +exit 0 \ No newline at end of file From a8fdf780dcf2f7133b83f7f9b0cc378dd6efbdb3 Mon Sep 17 00:00:00 2001 From: Joseph Prochazka Date: Tue, 23 Jul 2024 22:48:24 -0400 Subject: [PATCH 02/18] Updated function to match merged changes. --- bash/decoders/acarsdec.sh | 102 +++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh index ae7fb5f..0f9e9ef 100644 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -8,17 +8,19 @@ source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh clear -LogProjectName ${RECEIVER_PROJECT_TITLE} -LogTitleHeading "Setting up the ACARSDEC decoder" -LogTitleMessage "------------------------------------------------------------------------------" -echo "" - -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ACARSDEC decoder Setup" --yesno "Continue setup?" 13 78; then - LogAlertHeading "INSTALLATION HALTED" - LogAlertMessage "Setup has been halted at the request of the user" +log_project_title ${RECEIVER_PROJECT_TITLE} +log_title_heading "Setting up the ACARSDEC decoder" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "ACARSDEC decoder Setup" \ + --yesno "Continue setup?" \ + 13 78; then echo "" - LogTitleMessage "------------------------------------------------------------------------------" - LogTitleHeading "ACARSDEC decoder setup halted" + 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 "ACARSDEC decoder setup halted" echo "" exit 1 fi @@ -31,36 +33,36 @@ fi ## CHECK FOR PREREQUISITE PACKAGES -LogHeading "Installing packages needed to fulfill dependencies for FlightAware PiAware client" +log_heading "Installing packages needed to fulfill dependencies for FlightAware PiAware client" -CheckPackage cmake -CheckPackage zlib1g-dev -CheckPackage libxml2-dev -CheckPackage libjansson-dev -CheckPackage libusb-1.0-0-dev -CheckPackage pkg-config -CheckPackage libsndfile-dev -CheckPackage libpaho-mqtt-dev +check_package cmake +check_package zlib1g-dev +check_package libxml2-dev +check_package libjansson-dev +check_package libusb-1.0-0-dev +check_package pkg-config +check_package libsndfile-dev +check_package libpaho-mqtt-dev -CheckPackage librtlsdr-dev -CheckPackage libairspy-dev -CheckPackage libmirisdr-dev +check_package librtlsdr-dev +check_package libairspy-dev +check_package libmirisdr-dev ## CLONE OR PULL THE LIBACARS GIT REPOSITORY -LogHeading "Preparing the libacars Git repository" +log_heading "Preparing the libacars Git repository" if [[ -d $RECEIVER_BUILD_DIRECTORY/libacars && -d $RECEIVER_BUILD_DIRECTORY/libacars/.git ]]; then - LogMessage "Entering the libacars git repository directory" + log_message "Entering the libacars git repository directory" cd $RECEIVER_BUILD_DIRECTORY/libacars - LogMessage "Updating the local libacars git repository" + log_message "Updating the local libacars git repository" echo "" git pull else - LogMessage "Entering the libacars build directory" + log_message "Entering the libacars build directory" cd $RECEIVER_BUILD_DIRECTORY - LogMessage "Cloning the libacars git repository locally" + log_message "Cloning the libacars git repository locally" echo "" git clone https://github.com/szpajder/libacars.git fi @@ -69,33 +71,33 @@ echo "" ## BUILD AND INSTALL THE LIBACARS LIBRARY -LogHeading "Building the libacars library" +log_heading "Building the libacars library" if [[ ! -d $RECEIVER_BUILD_DIRECTORY/libacars/build ]]; then - LogMessage "Creating the libacars build directory" + log_message "Creating the libacars build directory" echo "" mkdir -vp $RECEIVER_BUILD_DIRECTORY/libacars/build echo "" fi if [[ -n "$(ls -A $RECEIVER_BUILD_DIRECTORY/libacars/build 2>/dev/null)" ]] - LogMessage "Deleting all files currently residing in the libacars build directory" + log_message "Deleting all files currently residing in the libacars build directory" rm -rf $RECEIVER_BUILD_DIRECTORY/libacars/build/* fi -LogMessage "Entering the libacars build directory" +log_message "Entering the libacars build directory" cd $RECEIVER_BUILD_DIRECTORY/libacars/build -LogMessage "Executing cmake" +log_message "Executing cmake" echo "" cmake ../ echo "" -LogMessage "Executing make" +log_message "Executing make" echo "" make echo "" -LogMessage "Executing make install" +log_message "Executing make install" echo "" sudo make install echo "" -LogMessage "Running ldconfig" +log_message "Running ldconfig" echo "" sudo ldconfig echo "" @@ -103,18 +105,18 @@ echo "" ## CLONE OR PULL THE ACARSDEC GIT REPOSITORY -LogHeading "Preparing the ACARSDEC Git repository" +log_heading "Preparing the ACARSDEC Git repository" if [[ -d $RECEIVER_BUILD_DIRECTORY/acarsdec && -d $RECEIVER_BUILD_DIRECTORY/acarsdec/.git ]]; then - LogMessage "Entering the ACARSDEC git repository directory" + log_message "Entering the ACARSDEC git repository directory" cd $RECEIVER_BUILD_DIRECTORY/acarsdec - LogMessage "Updating the local ACARSDEC git repository" + log_message "Updating the local ACARSDEC git repository" echo "" git pull else - LogMessage "Entering the ACARSDEC build directory" + log_message "Entering the ACARSDEC build directory" cd $RECEIVER_BUILD_DIRECTORY - LogMessage "Cloning the ACARSDEC git repository locally" + log_message "Cloning the ACARSDEC git repository locally" echo "" git clone https://github.com/TLeconte/acarsdec.git fi @@ -123,32 +125,32 @@ echo "" ## BUILD AND INSTALL THE ACARSDEC BINARY -LogHeading "Building the ACARSDEC binary" +log_heading "Building the ACARSDEC binary" if [[ ! -d $RECEIVER_BUILD_DIRECTORY/acarsdec/build ]]; then - LogMessage "Creating the ACARSDEC build directory" + log_message "Creating the ACARSDEC build directory" echo "" mkdir -vp $RECEIVER_BUILD_DIRECTORY/acarsdec/build echo "" fi if [[ -n "$(ls -A $RECEIVER_BUILD_DIRECTORY/acarsdec/build 2>/dev/null)" ]] - LogMessage "Deleting all files currently residing in the ACARSDEC build directory" + log_message "Deleting all files currently residing in the ACARSDEC build directory" rm -rf $RECEIVER_BUILD_DIRECTORY/acarsdec/build/* fi -LogMessage "Entering the ACARSDEC build directory" +log_message "Entering the ACARSDEC build directory" cd $RECEIVER_BUILD_DIRECTORY/acarsdec/build -LogMessage "Executing cmake" +log_message "Executing cmake" echo "" # TODO: Choose the proper parameters depending on the chosen device cmake .. -Drtl=ON or -Dairspy=ON or -Dsdrplay=ON echo "" -LogMessage "Executing make" +log_message "Executing make" echo "" make echo "" -LogMessage "Executing make install" +log_message "Executing make install" echo "" sudo make install echo "" @@ -158,12 +160,12 @@ echo "" ## SETUP COMPLETE -LogMessage "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" cd $RECEIVER_ROOT_DIRECTORY echo "" -LogTitleMessage "------------------------------------------------------------------------------" -LogTitleHeading "ACARSDEC decoder setup is complete" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "ACARSDEC decoder setup is complete" echo "" read -p "Press enter to continue..." discard From 365c6f35e6f4053114086bb09779c9948783413b Mon Sep 17 00:00:00 2001 From: jprochazka Date: Wed, 24 Jul 2024 15:13:05 -0400 Subject: [PATCH 03/18] Added device selection and acarserv install. --- bash/decoders/acarsdec.sh | 99 +++++++++++++++++++++++++++++++++------ 1 file changed, 84 insertions(+), 15 deletions(-) diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh index 0f9e9ef..ee2499b 100644 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -28,7 +28,24 @@ fi ## PRE INSTALLATION OPERATIONS -# TODO: Ask which device to build the ACARSDEC decoder for +device=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Device Type" \ + --menu "Choose an option" \ + 25 78 16 \ + "RTL-SDR" "" \ + "AirSpy" "" \ + "SDRPlay" "") +exit_status=$? +if [[ $exitstatus == 1 ]]; 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 "ACARSDEC decoder setup halted" + echo "" + exit 1 +fi ## CHECK FOR PREREQUISITE PACKAGES @@ -36,17 +53,26 @@ fi log_heading "Installing packages needed to fulfill dependencies for FlightAware PiAware client" check_package cmake -check_package zlib1g-dev -check_package libxml2-dev check_package libjansson-dev -check_package libusb-1.0-0-dev -check_package pkg-config -check_package libsndfile-dev check_package libpaho-mqtt-dev +check_package libsndfile-dev +check_package libsqlite3-dev +check_package libusb-1.0-0-dev +check_package libxml2-dev +check_package pkg-config +check_package zlib1g-dev -check_package librtlsdr-dev -check_package libairspy-dev -check_package libmirisdr-dev +case "${device}" in + "RTL-SDR") + check_package librtlsdr-dev + ;; + "AirSpy") + check_package libairspy-dev + ;; + "SDRPlay") + check_package libmirisdr-dev + ;; +esac ## CLONE OR PULL THE LIBACARS GIT REPOSITORY @@ -114,7 +140,7 @@ if [[ -d $RECEIVER_BUILD_DIRECTORY/acarsdec && -d $RECEIVER_BUILD_DIRECTORY/acar echo "" git pull else - log_message "Entering the ACARSDEC build directory" + log_message "Entering the build directory" cd $RECEIVER_BUILD_DIRECTORY log_message "Cloning the ACARSDEC git repository locally" echo "" @@ -139,13 +165,22 @@ if [[ -n "$(ls -A $RECEIVER_BUILD_DIRECTORY/acarsdec/build 2>/dev/null)" ]] fi log_message "Entering the ACARSDEC build directory" cd $RECEIVER_BUILD_DIRECTORY/acarsdec/build + log_message "Executing cmake" echo "" - -# TODO: Choose the proper parameters depending on the chosen device - -cmake .. -Drtl=ON or -Dairspy=ON or -Dsdrplay=ON +case "${device}" in + "RTL-SDR") + cmake .. -Drtl=ON + ;; + "AirSpy") + cmake .. -Dairspy=ON + ;; + "SDRPlay") + cmake .. -Dsdrplay=ON + ;; +esac echo "" + log_message "Executing make" echo "" make @@ -155,7 +190,41 @@ echo "" sudo make install echo "" -# TODO: Configure the application to run + +## CLONE OR PULL THE ACARSDEC GIT REPOSITORY + +log_heading "Preparing the acarsserv Git repository" + +if [[ -d $RECEIVER_BUILD_DIRECTORY/acarsserv && -d $RECEIVER_BUILD_DIRECTORY/acarsserv/.git ]]; then + log_message "Entering the acarsserv git repository directory" + cd $RECEIVER_BUILD_DIRECTORY/acarsserv + log_message "Updating the local acarsserv git repository" + echo "" + git pull +else + log_message "Entering the build directory" + cd $RECEIVER_BUILD_DIRECTORY + log_message "Cloning the acarsserv git repository locally" + echo "" + git clone https://github.com/TLeconte/acarsserv.git +fi +echo "" + + +## BUILD AND INSTALL THE ACARSDEC BINARY + +log_heading "Building the ACARSDEC binary" + +log_message "Entering the acarsserv build directory" +cd $RECEIVER_BUILD_DIRECTORY/acarsserv +log_message "Executing make" +echo "" +make -f Makefile + + +## RUN ACARSDECO AND ACARSSERV + +# TODO: Create a way to run the decoder and server automatically. ## SETUP COMPLETE From f23a4fedc239a91996b5849d0e55b84fc6bef231 Mon Sep 17 00:00:00 2001 From: jprochazka Date: Fri, 2 Aug 2024 12:43:58 -0400 Subject: [PATCH 04/18] Added ACARSDEC service script writing and decoder selection options. --- CHANGELOG.md | 4 + bash/decoders/acarsdec.sh | 169 ++++++++++++++++++++++++++++++++++- bash/decoders/dump1090-fa.sh | 110 +++++++++++++++++++++++ bash/decoders/dump978-fa.sh | 105 ++++++++++++++-------- 4 files changed, 348 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e6ed35..6505e97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ The following is a history of the changes made to this project. +## v2.8.5 *(in development)* + +* The ability to assign RTL-SDR devices to all decoder installation scripts has been added. + ## v2.8.5 *(July 23rd, 2024)* * The PiAware installation script now supports Ubuntu Noble Numbat. *(unofficial fix)* diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh index ee2499b..05de065 100644 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -48,6 +48,99 @@ if [[ $exitstatus == 1 ]]; then 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 + +log_message "Checking if a UAT decoder is installed" +uat_decoder_installed="false" +if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then + log_message "An ADS-B decoder appears to be installed" + uat_decoder_installed="true" +fi + +if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "true" ]]; then + log_message "Checking if ACARSDEC has been setup" + if [[ -f /etc/systemd/system/acarsdec.service ]]; then + log_message "An ACARSDEC systemd service script exists" + else + log_message "Informing the user that existing decoder(s) appears to be installed" + whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "RTL-SDR Dongle Assignments" \ + --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run ACARSDEC in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple RTL-SDR devices connected to your device." \ + 12 78 + + if [[ "${adsb_decoder_installed}" == "true" ]]; then + log_message "Asking the user to assign a RTL-SDR device number to the ADS-B decoder" + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number" + while [[ -z $adsb_device_number ]] ; do + adsb_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${adsb_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $adsb_device_number == 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 "ACARSDEC decoder setup halted" + exit 1 + fi + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number (REQUIRED)" + done + fi + + if [[ "${uat_decoder_installed}" == "true" ]]; then + log_message "Asking the user to assign a RTL-SDR device number to the UAT decoder" + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number" + while [[ -z $uat_device_number ]] ; do + uat_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${uat_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $uat_device_number == 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 "ACARSDEC decoder setup halted" + exit 1 + fi + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number (REQUIRED)" + done + fi + + log_message "Asking the user to assign a RTL-SDR device number to ACARSDEC" + acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number" + while [[ -z $acars_device_number ]] ; do + acars_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${acars_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ACARSDEC decoder." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $acars_device_number == 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 "ACARSDEC decoder setup halted" + exit 1 + fi + acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number (REQUIRED)" + done + fi +fi + +# TODO: CHOOSE DEVICE NUMBERS DUMP1090, DUMP978, ACARSDEC DEPENDING ON WHAT IS INSTALLED +# TODO: ASK FOR A LIST OF FREQUENCIES SEPARATED BY SPACES + + ## CHECK FOR PREREQUISITE PACKAGES log_heading "Installing packages needed to fulfill dependencies for FlightAware PiAware client" @@ -75,6 +168,13 @@ case "${device}" in esac +## BLACKLIST UNWANTED RTL-SDR MODULES + +log_heading "Blacklist unwanted RTL-SDR kernel modules" + +blacklist_modules + + ## CLONE OR PULL THE LIBACARS GIT REPOSITORY log_heading "Preparing the libacars Git repository" @@ -191,7 +291,7 @@ sudo make install echo "" -## CLONE OR PULL THE ACARSDEC GIT REPOSITORY +## CLONE OR PULL THE ACARSSERV GIT REPOSITORY log_heading "Preparing the acarsserv Git repository" @@ -224,7 +324,72 @@ make -f Makefile ## RUN ACARSDECO AND ACARSSERV -# TODO: Create a way to run the decoder and server automatically. +log_message "Creating the ACARSDEC systemd service script" +sudo tee /etc/systemd/system/acarsdec.service > /dev/null < /dev/null </dev/null | grep -c "ok installed") -eq 1 ]]; then + log_message "A UAT decoder appears to be installed" + uat_decoder_installed="true" +fi + +log_message "Checking if an ACARS decoder is installed" +acars_decoder_installed="false" +if [[ -f /usr/local/bin/acarsdec ]]; then + log_message "An ACARS decoder appears to be installed" + acars_decoder_installed="true" +fi + +if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "true" ]]; then + log_message "Checking if dump1090-fa has been configured" + if [[ -f /etc/default/dump978-fa ]]; then + log_message "A dump1090-fa configuration file exists" + else + log_message "Informing the user that existing decoder(s) appears to be installed" + whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "RTL-SDR Dongle Assignments" \ + --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run FlightAware dump1090 in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple RTL-SDR devices connected to your device." \ + 12 78 + + if [[ "${uat_decoder_installed}" == "true" ]]; then + log_message "Asking the user to assign a RTL-SDR device number to the UAT decoder" + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number" + while [[ -z $uat_device_serial ]] ; do + uat_device_number=$(whiptail --backtitle "FlightAware Dump1090 Decoder Configuration" \ + --title "${uat_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $uat_device_number == 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 Dump1090 decoder setup halted" + exit 1 + fi + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number (REQUIRED)" + done + fi + + if [[ "${acars_decoder_installed}" == "true" ]]; then + log_message "Asking the user to assign a RTL-SDR device number to the ACARS decoder" + acars_device_number_title="Enter the ACARS Decoder RTL-SDR Device Number" + while [[ -z $acars_device_number ]] ; do + acars_device_number=$(whiptail --backtitle "FlightAware Dump1090 Decoder Configuration" \ + --title "${acars_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ACARS decoder." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $acars_device_number == 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 Dump1090 decoder setup halted" + exit 1 + fi + acars_device_number_title="Enter the ACARS Decoder RTL-SDR Device Number (REQUIRED)" + done + fi + + log_message "Asking the user to assign a RTL-SDR device number to FlightAware Dump1090" + adsb_device_number_title="Enter the FlightAware Dump1090 RTL-SDR Device Number" + while [[ -z $adsb_device_number ]] ; do + adsb_device_number=$(whiptail --backtitle "FlightAware Dump1090 Decoder Configuration" \ + --title "${adsb_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your FlightAware Dump1090 decoder." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $adsb_device_number == 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 Dump1090 decoder setup halted" + exit 1 + fi + adsb_device_number_title="Enter the FlightAware Dump1090 RTL-SDR Device Number (REQUIRED)" + done + fi +fi + ## CHECK FOR PREREQUISITE PACKAGES log_heading "Installing packages needed to fulfill FlightAware Dump1090 decoder dependencies" @@ -131,6 +221,26 @@ echo "" cp -vf $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE +## CONFIGURATION + +if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "true" ]]; then + + log_heading "Configuring the decoders so they can work in tandem" + + log_message "Assigning RTL-SDR device with serial ${adsb_device_number} to the FlightAware Dump1090 decoder" + change_config "RECEIVER_SERIAL" $adsb_device_number "/etc/default/dump1090-fa" + log_message "Restarting dump1090-fa" + sudo systemctl restart dump1090-fa + + log_message "Assigning RTL-SDR device with serial ${uat_device_number} to dump978-fa" + sudo sed -i -e "s/driver=rtlsdr/driver=rtlsdr,serial=${uat_device_number}/g" /etc/default/dump978-fa + log_message "Restarting dump978-fa...\e[97m" + sudo systemctl restart dump978-fa + + # TODO: ADD ACARS CONFIGURATION +fi + + ## POST INSTALLATION OPERATIONS log_heading "Performing post installation operations" diff --git a/bash/decoders/dump978-fa.sh b/bash/decoders/dump978-fa.sh index 62c7118..fba7399 100755 --- a/bash/decoders/dump978-fa.sh +++ b/bash/decoders/dump978-fa.sh @@ -38,43 +38,72 @@ if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok insta adsb_decoder_installed="true" fi -if [[ "${adsb_decoder_installed}" == "true" ]]; then +log_message "Checking if an ACARS decoder is installed" +acars_decoder_installed="false" +if [[ -f /usr/local/bin/acarsdec ]]; then + log_message "An ACARS decoder appears to be installed" + acars_decoder_installed="true" +fi + +if [[ "${adsb_decoder_installed}" == "true" || "${acars_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" \ + log_message "Informing the user that existing decoder(s) appears to be installed" + whiptail --backtitle "FlightAware Dump978 Decoder 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." \ + --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run FlightAware Dump978 in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple 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." \ + if [[ "${adsb_decoder_installed}" == "true" ]]; then + log_message "Asking the user to assign a RTL-SDR device number to the ADS-B decoder" + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number" + while [[ -z $adsb_device_number ]] ; do + adsb_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${adsb_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ 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 + if [[ $adsb_device_number == 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 + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number (REQUIRED)" + done + fi - 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." \ + if [[ "${acars_decoder_installed}" == "true" ]]; then + log_message "Asking the user to assign a RTL-SDR device number to the ACARS decoder" + acars_device_number_title="Enter the ACARS Decoder RTL-SDR Device Number" + while [[ -z $acars_device_number ]] ; do + acars_device_number=$(whiptail --backtitle "FlightAware Dump1090 Decoder Configuration" \ + --title "${acars_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ACARS decoder." \ + 8 78 3>&1 1>&2 2>&3) + if [[ $acars_device_number == 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 + acars_device_number_title="Enter the ACARS Decoder RTL-SDR Device Number (REQUIRED)" + done + fi + + log_message "Asking the user to assign a RTL-SDR device number to FlightAware Dump978" + uat_device_number_title="Enter the FlightAware Dump978 RTL-SDR Device Number" + while [[ -z $uat_device_number ]] ; do + uat_device_number=$(whiptail --backtitle "FlightAware Dump978 Decoder Configuration" \ + --title "${uat_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your FlightAware Dump978 decoder." \ 8 78 3>&1 1>&2 2>&3) - if [[ $dump978_device_serial == 0 ]]; then + if [[ $uat_device_number == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -82,7 +111,7 @@ if [[ "${adsb_decoder_installed}" == "true" ]]; then log_title_heading "FlightAware Dump978 decoder setup halted" exit 1 fi - dump978_device_serial_title="Enter the Dump1090 RTL-SDR Device Serial (REQUIRED)" + uat_device_number_title="Enter the FlightAware Dump978 RTL-SDR Device Number (REQUIRED)" done fi fi @@ -200,21 +229,21 @@ cp -vf $RECEIVER_BUILD_DIRECTORY/dump978-fa/skyaware978_*.deb $RECEIVER_BUILD_DI ## CONFIGURATION -if [[ "${adsb_decoder_installed}" == "true" ]]; then +if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == "true" ]]; then - log_heading "Configuring the ADS-B decoder and dump978-fa so they can work in tandem" + log_heading "Configuring the decoders 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 "Assigning RTL-SDR device with serial ${uat_device_number} to dump978-fa" + sudo sed -i -e "s/driver=rtlsdr/driver=rtlsdr,serial=${uat_device_number}/g" /etc/default/dump978-fa log_message "Restarting dump978-fa...\e[97m" sudo systemctl restart dump978-fa - 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 + log_message "Assigning RTL-SDR device with serial ${adsb_device_number} to the FlightAware Dump1090 decoder" + change_config "RECEIVER_SERIAL" $adsb_device_number "/etc/default/dump1090-fa" + log_message "Restarting dump1090-fa" + sudo systemctl restart dump1090-fa + + # TODO: ADD ACARS CONFIGURATION fi From 72fdb27422ad70367c577e8ccb9ca4416c2d26ee Mon Sep 17 00:00:00 2001 From: jprochazka Date: Fri, 2 Aug 2024 16:11:23 -0400 Subject: [PATCH 05/18] Finished acarsdec installer but still needs tested. --- CHANGELOG.md | 3 +- CREDITS.md | 1 + README.md | 9 +-- bash/decoders/acarsdec.sh | 65 ++++++++++++++++------ bash/decoders/dump1090-fa.sh | 32 +++++++---- bash/decoders/dump978-fa.sh | 34 ++++++++---- bash/main.sh | 103 ++++++++++++++++++++++++++--------- 7 files changed, 175 insertions(+), 72 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6505e97..018ab64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ The following is a history of the changes made to this project. ## v2.8.5 *(in development)* -* The ability to assign RTL-SDR devices to all decoder installation scripts has been added. +* The option to install ACARSDEC and ACARSERV in now available as a decoder option. +* The ability to assign devices to additional decoder installations have been added to all scripts. ## v2.8.5 *(July 23rd, 2024)* diff --git a/CREDITS.md b/CREDITS.md index 89a6bb4..368351d 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -48,6 +48,7 @@ threads myself along with other contributors to the cause were able to add these I would like to thank the maintainers and contributors of the following projects. Without their hard work and dedication to their respective projects this project would not have been possible. +* ACARSDEC Decoder: https://github.com/TLeconte/acarsdec * ADS-B Exchange Client: https://github.com/adsbexchange/feedclient * Airplanes.live Client: https://github.com/airplanes-live/feed * Beast-Splitter: https://github.com/flightaware/beast-splitter diff --git a/README.md b/README.md index 355b876..622f1de 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # The ADS-B Receiver Project :airplane: -## Run ADS-B/UAT related applications without the overhead! +## Run ADS-B/UAT/ACARS related applications without the overhead! This project continues to realize that for some, Docker and premade images are not the most optimal solution. -It would seem as of late the move towards premade as well as Docker and other PaaS images with preinstalled software has become popular within the community. Docker images require additional software and overhead in order to run and premade images lack installation options. Most of these solutions come with preinstalled software you may never use as part of the image as well. This project offers the ability to choose and install only what you want or need across a wide range of devices with minimal command line experience. +It would seem as of late the move towards premade as well as Docker and other PaaS images with preinstalled software has become popular within the community. Docker images require additional software and overhead in order to run. Most of these solutions also come with preinstalled software you may never use as part of the image as well. This project offers the ability to choose and install only what you want or need across a wide range of devices with minimal command line experience. ## Obtaining And Using This Software @@ -50,6 +50,7 @@ When setting up the portal you will have to choose between a lite or advanced in * Dump1090 (FlightAware): https://github.com/flightaware/dump1090 * Dump978 (FlightAware): https://github.com/flightaware/dump978 +* ACARSDEC: https://github.com/TLeconte/acarsdec ### Feeders @@ -76,6 +77,6 @@ The project currently supports the following Linux distributions. * Rasbperry PI OS _(Bookworm and Bullseye)_ * Ubuntu _(Jammy Jellyfish, Focal Fossa and Noble Numbat)_ -_Support is available via this repository through the use of the issue tracker or discussions._ +Support is available via this repository through the use of the issue tracker or discussions. -_At this time support for PiAware on distributions based on Debian Trixie and Ubuntu Noble Numbat employ an unofficial fix._ +_Please Nnte that Debian Trixie and Ubuntu Noble Numbat employ an unofficial fix for PiAware._ diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh index 05de065..9c5b01a 100644 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -85,7 +85,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr --title "${adsb_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ 8 78 3>&1 1>&2 2>&3) - if [[ $adsb_device_number == 0 ]]; then + exitstatus=$? + if [[ $exitstatus == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -105,7 +106,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr --title "${uat_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ 8 78 3>&1 1>&2 2>&3) - if [[ $uat_device_number == 0 ]]; then + exitstatus=$? + if [[ $exitstatus == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -124,7 +126,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr --title "${acars_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your ACARSDEC decoder." \ 8 78 3>&1 1>&2 2>&3) - if [[ $acars_device_number == 0 ]]; then + exitstatus=$? + if [[ $exitstatus == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -137,8 +140,20 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr fi fi -# TODO: CHOOSE DEVICE NUMBERS DUMP1090, DUMP978, ACARSDEC DEPENDING ON WHAT IS INSTALLED -# TODO: ASK FOR A LIST OF FREQUENCIES SEPARATED BY SPACES +log_message "Asking the user for ACARS frequencies to monitor" +acars_fequencies=$(whiptail --backtitle "ACARS Frequencies" \ + --title "${acars_device_number_title}" \ + --inputbox "\nEnter the ACARS frequencies you would like to monitor." \ + 8 78 3>&1 1>&2 2>&3) +exitstatus=$? +if [[ $exitstatus == 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 "ACARSDEC decoder setup halted" + exit 1 +fi ## CHECK FOR PREREQUISITE PACKAGES @@ -331,7 +346,7 @@ Description=ARCARSDEC multi-channel acars decoder. After=network.target [Service] -ExecStart=/usr/local/bin/acarsdec -A -p 0 -r 0 -o 0 -j 127.0.0.1:5555 131.525 131.550 131.725 131.825 +ExecStart=/usr/local/bin/acarsdec -r 0 -A -p 0 -o 0 -j 127.0.0.1:5555 ${acars_fequencies} WorkingDirectory=/usr/local/bin StandardOutput=null StandardError=syslog @@ -346,7 +361,7 @@ WantedBy=multi-user.target EOF log_message "Creating the ACARSSERV systemd service script" -sudo tee /etc/systemd/system/acarsdeco.service > /dev/null < /dev/null <&1 1>&2 2>&3) - if [[ $uat_device_number == 0 ]]; then + exitstatus=$? + if [[ $exitstatus == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -84,7 +85,8 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t --title "${acars_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your ACARS decoder." \ 8 78 3>&1 1>&2 2>&3) - if [[ $acars_device_number == 0 ]]; then + exitstatus=$? + if [[ $exitstatus == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -103,7 +105,8 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t --title "${adsb_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your FlightAware Dump1090 decoder." \ 8 78 3>&1 1>&2 2>&3) - if [[ $adsb_device_number == 0 ]]; then + exitstatus=$? + if [[ $exitstatus == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -227,17 +230,24 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t log_heading "Configuring the decoders so they can work in tandem" - log_message "Assigning RTL-SDR device with serial ${adsb_device_number} to the FlightAware Dump1090 decoder" + if [[ "${uat_decoder_installed}" == "true" ]]; then + log_message "Assigning RTL-SDR device number ${uat_device_number} to the FlightAware Dump978 decoder" + sudo sed -i -e "s/driver=rtlsdr/driver=rtlsdr,serial=${uat_device_number}/g" /etc/default/dump978-fa + log_message "Restarting dump978-fa" + sudo systemctl restart dump978-fa + fi + + if [[ "${acars_decoder_installed}" == "true" ]]; then + log_message "Assigning RTL-SDR device number ${acars_device_number} to ACARSDEC" + sudo sed -i -e "s/\(.*-r \)\([0-9]\+\)\( .*\)/\1${acars_device_number}\3/g" /etc/systemd/system/acarsdec.service + log_message "Restarting ACARSDEC" + sudo systemctl restart acarsdec + fi + + log_message "Assigning RTL-SDR device number ${adsb_device_number} to the FlightAware Dump1090 decoder" change_config "RECEIVER_SERIAL" $adsb_device_number "/etc/default/dump1090-fa" log_message "Restarting dump1090-fa" sudo systemctl restart dump1090-fa - - log_message "Assigning RTL-SDR device with serial ${uat_device_number} to dump978-fa" - sudo sed -i -e "s/driver=rtlsdr/driver=rtlsdr,serial=${uat_device_number}/g" /etc/default/dump978-fa - log_message "Restarting dump978-fa...\e[97m" - sudo systemctl restart dump978-fa - - # TODO: ADD ACARS CONFIGURATION fi diff --git a/bash/decoders/dump978-fa.sh b/bash/decoders/dump978-fa.sh index fba7399..6d6f9db 100755 --- a/bash/decoders/dump978-fa.sh +++ b/bash/decoders/dump978-fa.sh @@ -64,7 +64,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " --title "${adsb_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ 8 78 3>&1 1>&2 2>&3) - if [[ $adsb_device_number == 0 ]]; then + exitstatus=$? + if [[ $exitstatus == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -84,7 +85,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " --title "${acars_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your ACARS decoder." \ 8 78 3>&1 1>&2 2>&3) - if [[ $acars_device_number == 0 ]]; then + exitstatus=$? + if [[ $exitstatus == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -103,7 +105,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " --title "${uat_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your FlightAware Dump978 decoder." \ 8 78 3>&1 1>&2 2>&3) - if [[ $uat_device_number == 0 ]]; then + exitstatus=$? + if [[ $exitstatus == 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -233,17 +236,24 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " log_heading "Configuring the decoders so they can work in tandem" - log_message "Assigning RTL-SDR device with serial ${uat_device_number} to dump978-fa" + if [[ "${adsb_decoder_installed}" == "true" ]]; then + log_message "Assigning RTL-SDR device number ${adsb_device_number} to the FlightAware Dump1090 decoder" + change_config "RECEIVER_SERIAL" $adsb_device_number "/etc/default/dump1090-fa" + log_message "Restarting dump1090-fa" + sudo systemctl restart dump1090-fa + fi + + if [[ "${acars_decoder_installed}" == "true" ]]; then + log_message "Assigning RTL-SDR device number ${acars_device_number} to ACARSDEC" + sudo sed -i -e "s/\(.*-r \)\([0-9]\+\)\( .*\)/\1${acars_device_number}\3/g" /etc/systemd/system/acarsdec.service + log_message "Restarting ACARSDEC" + sudo systemctl restart acarsdec + fi + + log_message "Assigning RTL-SDR device number ${uat_device_number} to the FlightAware Dump978 decoder" sudo sed -i -e "s/driver=rtlsdr/driver=rtlsdr,serial=${uat_device_number}/g" /etc/default/dump978-fa - log_message "Restarting dump978-fa...\e[97m" + log_message "Restarting dump978-fa" sudo systemctl restart dump978-fa - - log_message "Assigning RTL-SDR device with serial ${adsb_device_number} to the FlightAware Dump1090 decoder" - change_config "RECEIVER_SERIAL" $adsb_device_number "/etc/default/dump1090-fa" - log_message "Restarting dump1090-fa" - sudo systemctl restart dump1090-fa - - # TODO: ADD ACARS CONFIGURATION fi diff --git a/bash/main.sh b/bash/main.sh index 60e2d6c..b363f84 100755 --- a/bash/main.sh +++ b/bash/main.sh @@ -6,12 +6,12 @@ source ${RECEIVER_BASH_DIRECTORY}/variables.sh source ${RECEIVER_BASH_DIRECTORY}/functions.sh -## 1090MHZ DECODERS +## ADS-B DECODERS # FlightAware dump1090 -install_1090mhz_decoder="false" +install_adsb_decoder="false" if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") == 1 ]] ; then - chosen_1090mhz_decoder="dump1090-fa" + chosen_adsb_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" \ @@ -19,7 +19,7 @@ if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok insta --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" + install_adsb_decoder="true" fi fi else @@ -29,11 +29,11 @@ else --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" + install_adsb_decoder="true" fi fi -function install_dump1090-fa() { +function install_dump1090_fa() { ${RECEIVER_BASH_DIRECTORY}/decoders/dump1090-fa.sh if [[ $? != 0 ]] ; then exit 1 @@ -41,19 +41,19 @@ function install_dump1090-fa() { } -## 978MHZ DECODERS +## UAT DECODERS # Flightaware dump978 -install_978mhz_decoder="false" +install_uat_decoder="false" if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") == 1 ]]; then - chosen_978mhz_decoder="dump978-fa" + chosen_uat_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" + install_uat_decoder="true" fi fi else @@ -63,17 +63,48 @@ else --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" + install_uat_decoder="true" fi fi -function install_dump978-fa() { +function install_dump978_fa() { ${RECEIVER_BASH_DIRECTORY}/decoders/dump978-fa.sh if [[ $? != 0 ]] ; then exit 1 fi } +## ACARS DECODERS + +# ACARSDEC +install_acars_decoder="false" +if [[ -f /etc/systemd/system/acarsdec.service ]]; then + chosen_acars_decoder="acarsdec" + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Reinstall ACARSDEC Decoder" \ + --defaultno --yesno "The option to rebuild and reinstall ACARSDEC is available.\n\nWould you like to reinstall ACARSDEC?" \ + 16 65 + if [[ $? == 0 ]]; then + install_acars_decoder="true" + fi +else + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "ACARSDEC Decoder" \ + --defaultno \ + --yesno "ACARSDEC is a multi-channels acars decoder with built-in rtl_sdr, airspy front end or sdrplay device.\n\nGitHub Repository: https://github.com/TLeconte/acarsdec\n\nWould you like to install ACARSDEC?" \ + 10 65 + if [[ $? == 0 ]]; then + install_acars_decoder="true" + fi +fi + +function install_acarsdec() { + ${RECEIVER_BASH_DIRECTORY}/decoders/acarsdec.sh + if [[ $? != 0 ]] ; then + exit 1 + fi +} + ## AGGREGATE SITE CLIENTS @@ -304,7 +335,7 @@ whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ declare confirmation_message -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 +if [[ "${install_adsb_decoder}" == "false" && "${install_uat_decoder}" == "false" && "${install_acars_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." \ @@ -316,24 +347,33 @@ if [[ "${install_1090mhz_decoder}" == "false" && "${install_1090mhz_decoder}" == else confirmation_message="The following software will be installed:\n" - # 1090MHz decoders - if [[ "${install_1090mhz_decoder}" == "true" ]]; then - case ${chosen_1090mhz_decoder} in + # ADS-B decoders + if [[ "${install_adsb_decoder}" == "true" ]]; then + case ${chosen_adsb_decoder} in "dump1090-fa") confirmation_message="${confirmation_message}\n * FlightAware dump1090" ;; esac fi - # 978MHz decoders - if [[ "${install_978mhz_decoder}" = "true" ]]; then - case ${chosen_978mhz_decoder} in + # UAT decoders + if [[ "${install_uat_decoder}" = "true" ]]; then + case ${chosen_uat_decoder} in "dump978-fa") confirmation_message="${confirmation_message}\n * FlightAware dump978" ;; esac fi + # ACARS decoders + if [[ "${install_acars_decoder}" = "true" ]]; then + case ${chosen_acars_decoder} in + "acarsdec") + confirmation_message="${confirmation_message}\n * ACARSDEC" + ;; + esac + fi + # Aggragate site clients if [[ -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" ]]; then while read feeder_choice @@ -369,20 +409,29 @@ fi ## BEGIN SETUP -# 1090MHz Decoders -if [[ "${install_1090mhz_decoder}" == "true" ]]; then - case ${chosen_1090mhz_decoder} in +# ADS-B Decoders +if [[ "${install_adsb_decoder}" == "true" ]]; then + case ${chosen_adsb_decoder} in "dump1090-fa") - install_dump1090-fa + install_dump1090_fa ;; esac fi -# 978MHz Decoders -if [[ "${install_978mhz_decoder}" == "true" ]]; then - case ${chosen_978mhz_decoder} in +# UAT Decoders +if [[ "${install_uat_decoder}" == "true" ]]; then + case ${chosen_uat_decoder} in "dump978-fa") - install_dump978-fa + install_dump978_fa + ;; + esac +fi + +# ACARS Decoders +if [[ "${install_acars_decoder}" == "true" ]]; then + case ${chosen_acars_decoder} in + "acarsdec") + install_acarsdec ;; esac fi From 9a7eb4ee99690a8d8d6e1de29a52549186adf5a9 Mon Sep 17 00:00:00 2001 From: Joseph Prochazka Date: Fri, 2 Aug 2024 18:44:31 -0400 Subject: [PATCH 06/18] Work done to display ACARS data via the portal. --- CHANGELOG.md | 1 + CREDITS.md | 1 + README.md | 1 + build/portal/html/acars.php | 22 ++++++ build/portal/html/admin/index.php | 26 ++++++- build/portal/html/classes/acars.class.php | 29 ++++++++ build/portal/html/classes/template.class.php | 2 +- build/portal/html/install/index.php | 4 +- build/portal/html/install/upgrade-v2.8.6.php | 72 +++++++++++++++++++ build/portal/html/install/upgrade.php | 9 +++ build/portal/html/templates/default/acars.tpl | 13 ++++ .../portal/html/templates/default/master.tpl | 1 + install.sh | 2 +- 13 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 build/portal/html/acars.php create mode 100644 build/portal/html/classes/acars.class.php create mode 100644 build/portal/html/install/upgrade-v2.8.6.php create mode 100644 build/portal/html/templates/default/acars.tpl diff --git a/CHANGELOG.md b/CHANGELOG.md index 018ab64..d823ff3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The following is a history of the changes made to this project. ## v2.8.5 *(in development)* * The option to install ACARSDEC and ACARSERV in now available as a decoder option. +* The ability to view ACARS messages via the existing PHP portal has been added. * The ability to assign devices to additional decoder installations have been added to all scripts. ## v2.8.5 *(July 23rd, 2024)* diff --git a/CREDITS.md b/CREDITS.md index 368351d..036e976 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -49,6 +49,7 @@ I would like to thank the maintainers and contributors of the following projects hard work and dedication to their respective projects this project would not have been possible. * ACARSDEC Decoder: https://github.com/TLeconte/acarsdec +* ACARSSERV: https://github.com/TLeconte/acarsserv * ADS-B Exchange Client: https://github.com/adsbexchange/feedclient * Airplanes.live Client: https://github.com/airplanes-live/feed * Beast-Splitter: https://github.com/flightaware/beast-splitter diff --git a/README.md b/README.md index 622f1de..8d8977e 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ The following software can be installed using these scripts. Included is the option to install the ADS-B Portal which offers the following features. * Saves all flights seen as well as displays a plot for the flight. +* Saves all ACARS messages received as well as the ability to view these messages. * Control what is displayed online via a web based administration area. * A more uniform website site layout that can be easily navigated. * Web accessible dump1090 and system performance graphs. diff --git a/build/portal/html/acars.php b/build/portal/html/acars.php new file mode 100644 index 0000000..bb05aaf --- /dev/null +++ b/build/portal/html/acars.php @@ -0,0 +1,22 @@ +getAcarsMessages(25, 0); + + $template->display($pageData); +?> \ No newline at end of file diff --git a/build/portal/html/admin/index.php b/build/portal/html/admin/index.php index e3d09e8..bf41331 100644 --- a/build/portal/html/admin/index.php +++ b/build/portal/html/admin/index.php @@ -106,6 +106,10 @@ if (isset($_POST['enableBlog']) && $_POST['enableBlog'] == "TRUE") $enableBlog = TRUE; + $enableAcars = FALSE; + if (isset($_POST['enableAcars']) && $_POST['enableAcars'] == "TRUE") + $enableAcars = TRUE; + $enableInfo = FALSE; if (isset($_POST['enableInfo']) && $_POST['enableInfo'] == "TRUE") $enableInfo = TRUE; @@ -165,6 +169,7 @@ $common->updateSetting("dateFormat", $_POST['dateFormat']); $common->updateSetting("enableFlights", $enableFlights); $common->updateSetting("enableBlog", $enableBlog); + $common->updateSetting("enableAcars", $enableAcars); $common->updateSetting("enableInfo", $enableInfo); $common->updateSetting("enableGraphs", $enableGraphs); $common->updateSetting("enableLinks", $enableLinks); @@ -189,6 +194,7 @@ $common->updateSetting("hideNavbarAndFooter", $hideNavbarAndFooter); $common->updateSetting("purge_older_data", $purgeOlderData); $common->updateSetting("days_to_save", $_POST['daysToSave']); + $common->updateSetting("acarsserv_database", $_POST['acarsservDatabase']); // Purge older flight positions. if (isset($_POST['purgepositions'])) { @@ -240,6 +246,7 @@ // Get navigation settings. $enableFlights = $common->getSetting("enableFlights"); $enableBlog = $common->getSetting("enableBlog"); + $enableAcars = $common->getSetting("enableAcars"); $enableInfo = $common->getSetting("enableInfo"); $enableGraphs = $common->getSetting("enableGraphs"); $enableLinks = $common->getSetting("enableLinks"); @@ -258,6 +265,9 @@ $flightRadar24Id = $common->getSetting("flightRadar24Id"); $enableAdsbExchangeLink = $common->getSetting("enableAdsbExchangeLink"); + // ACARS settings. + $acarsservDatabase = $common->getSetting("acarsserv_database"); + // Get units of measurement settings. $measurementRange = $common->getSetting("measurementRange"); $measurementTemperature = $common->getSetting("measurementTemperature"); @@ -410,7 +420,7 @@
Flight Notifications
- +
@@ -441,6 +451,11 @@ > Enable blog link.
+
+ +
+
+
ACARS Settings
+
+
+ + +
+
+
diff --git a/build/portal/html/classes/acars.class.php b/build/portal/html/classes/acars.class.php new file mode 100644 index 0000000..5d1c7df --- /dev/null +++ b/build/portal/html/classes/acars.class.php @@ -0,0 +1,29 @@ +prepare($sql); + $sth->bindValue(':limit', $limit); + $sth->bindValue(':offset', $offset); + $sth->execute(); + $acarsMessages = $sth->fetchAll(PDO::FETCH_ASSOC); + $sth = NULL; + $dbh = NULL; + + return $acarsMessages; + } + } +?> \ No newline at end of file diff --git a/build/portal/html/classes/template.class.php b/build/portal/html/classes/template.class.php index 9fb9c45..9a761b8 100644 --- a/build/portal/html/classes/template.class.php +++ b/build/portal/html/classes/template.class.php @@ -9,7 +9,7 @@ // Check if the portal is installed or needs upgraded. - $thisVersion = "2.8.5"; + $thisVersion = "2.8.6"; 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 6880ecf..45c4a68 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.5"; + $thisVersion = "2.8.6"; // 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")) { @@ -419,6 +419,7 @@ EOF; $common->addSetting('defaultPage', 'blog.php'); $common->addSetting('dateFormat', 'F jS, Y g:i A'); $common->addSetting('enableBlog', TRUE); + $common->addSetting('enableAcars', FALSE); $common->addSetting('enableInfo', TRUE); $common->addSetting('enableLinks', FALSE); $common->addSetting('enableGraphs', TRUE); @@ -447,6 +448,7 @@ EOF; $common->addSetting("days_to_save", "30"); $common->addSetting("advancedMapCenterLatitude", "41.3683798"); $common->addSetting("advancedMapCenterLongitude", "-82.1076486"); + $common->addSetting('acarsserv_database', ""); if ($_POST['driver'] == "xml") $common->addSetting('enableFlights', FALSE); diff --git a/build/portal/html/install/upgrade-v2.8.6.php b/build/portal/html/install/upgrade-v2.8.6.php new file mode 100644 index 0000000..a5f9568 --- /dev/null +++ b/build/portal/html/install/upgrade-v2.8.6.php @@ -0,0 +1,72 @@ +addSetting('enableAcars', FALSE); + $common->addSetting('acarsserv_database', ""); + + // Update the version and patch settings + $common->updateSetting("version", "2.8.6"); + $common->updateSetting("patch", ""); + + // The upgrade process completed successfully + $results['success'] = TRUE; + $results['message'] = "Upgrade to v2.8.6 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 837c5ff..e8f2ae5 100644 --- a/build/portal/html/install/upgrade.php +++ b/build/portal/html/install/upgrade.php @@ -231,6 +231,15 @@ $version = "2.8.5"; } + // UPGRADE TO V2.8.6 + if ($common->getSetting("version") == "2.8.5" && $success) { + $json = file_get_contents("http://localhost/install/upgrade-v2.8.6.php"); + $results = json_decode($json, TRUE); + $success = $results['success']; + $message = $results['message']; + $version = "2.8.6"; + } + require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php"); // Display the instalation wizard. diff --git a/build/portal/html/templates/default/acars.tpl b/build/portal/html/templates/default/acars.tpl new file mode 100644 index 0000000..8a63e37 --- /dev/null +++ b/build/portal/html/templates/default/acars.tpl @@ -0,0 +1,13 @@ +{area:head/} +{area:contents} +
+

ACARS Messages

+
+ {foreach page:acarsMessages as message} +
{message->Txt}
+ {/foreach} +
+{/area} +{area:scripts} + +{/area} \ No newline at end of file diff --git a/build/portal/html/templates/default/master.tpl b/build/portal/html/templates/default/master.tpl index 5639620..50fdf9e 100644 --- a/build/portal/html/templates/default/master.tpl +++ b/build/portal/html/templates/default/master.tpl @@ -48,6 +48,7 @@ {/area} From df3da90e81fd8dbf837b0335c0325edd25f18a4d Mon Sep 17 00:00:00 2001 From: jprochazka Date: Mon, 5 Aug 2024 16:03:31 -0400 Subject: [PATCH 10/18] Tested and debugged acarsdec installer. --- .gitignore | 1 + README.md | 2 +- bash/decoders/acarsdec.sh | 246 +++++++++++++++++++---------------- bash/decoders/dump1090-fa.sh | 12 +- bash/decoders/dump978-fa.sh | 12 +- bash/functions.sh | 8 +- bash/main.sh | 24 +++- 7 files changed, 173 insertions(+), 132 deletions(-) mode change 100644 => 100755 bash/decoders/acarsdec.sh diff --git a/.gitignore b/.gitignore index cbf6ce6..9336596 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ build/dump1090-fa build/dump978-fa build/flightradar24 build/flyitalyadsb +build/libacars build/piaware_builder build/planefinder build/package-archive diff --git a/README.md b/README.md index 796c202..65aa2ea 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This project continues to realize that for some, Docker and premade images are not the most optimal solution. -It would seem as of late the move towards premade as well as Docker and other PaaS images with preinstalled software has become popular within the community. Docker images require additional software and in some cases result in additional overhead when running. Most of these solutions also come with preinstalled software one may never use as part of the image as well. This project offers the ability to choose and install only what you want or need across a wide range of devices with minimal command line experience. +It would seem as of late the move towards premade as well as Docker and other PaaS images with preinstalled software has become popular within the community. Docker images require additional software and in some cases result in additional overhead when running. Most of these solutions also come with preinstalled software one may never use as part of the image as well. This project offers the ability to choose and install only what you want or need natively across a wide range of devices with minimal command line experience. ## Obtaining And Using This Software diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh old mode 100644 new mode 100755 index 28e5995..d08fe54 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -6,35 +6,13 @@ source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh clear -log_project_title ${RECEIVER_PROJECT_TITLE} +log_project_title log_title_heading "Setting up the ACARSDEC decoder" log_title_message "------------------------------------------------------------------------------" if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "ACARSDEC decoder Setup" \ - --yesno "Continue setup?" \ - 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 "ACARSDEC decoder setup halted" - echo "" - exit 1 -fi - - -## PRE INSTALLATION OPERATIONS - -device=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "Device Type" \ - --menu "Choose an option" \ - 25 78 16 \ - "RTL-SDR" "" \ - "AirSpy" "" \ - "SDRPlay" "") -exit_status=$? -if [[ $exitstatus == 1 ]]; then + --yesno "ACARSDEC is a multi-channels acars decoder with built-in rtl_sdr, airspy front end or sdrplay device. Since 3.0, It comes with a database backend : acarsserv to store received acars messages.\n\nWould you like to begin the setup process now?" \ + 11 78; then echo "" log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted at the request of the user" @@ -48,6 +26,29 @@ fi ## GATHER REQUIRED INFORMATION FROM THE USER +log_heading "Determine the device type to build ACARSDEC for" + +log_message "Asking which type of device will be used by ACARSDEC" +device=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Device Type" \ + --menu "Please choose the RTL-SDR device type which is to be used by ACARSDEC." \ + 11 78 3 \ + "RTL-SDR" "" \ + "AirSpy" "" \ + "SDRPlay" "" \ + 3>&1 1>&2 2>&3) +exit_status=$? +if [[ $exit_status != 0 ]]; 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 "ACARSDEC decoder setup halted" + echo "" + exit 1 +fi + 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" @@ -65,67 +66,27 @@ if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok instal fi if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "true" ]]; then - log_message "Checking if ACARSDEC has been setup" - if [[ -f /etc/systemd/system/acarsdec.service ]]; then - log_message "An ACARSDEC systemd service script exists" - else - log_message "Informing the user that existing decoder(s) appears to be installed" - whiptail --backtitle "ACARSDEC Decoder Configuration" \ - --title "RTL-SDR Dongle Assignments" \ - --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run ACARSDEC in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple RTL-SDR devices connected to your device." \ - 12 78 - - if [[ "${adsb_decoder_installed}" == "true" ]]; then - log_message "Asking the user to assign a RTL-SDR device number to the ADS-B decoder" - adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number" - while [[ -z $adsb_device_number ]] ; do - adsb_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ - --title "${adsb_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ - 8 78 3>&1 1>&2 2>&3) - exitstatus=$? - if [[ $exitstatus == 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 "ACARSDEC decoder setup halted" - exit 1 - fi - adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number (REQUIRED)" - done + log_message "Informing the user that existing decoder(s) appears to be installed" + whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "RTL-SDR Dongle Assignments" \ + --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run ACARSDEC in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple RTL-SDR devices connected to your device." \ + 12 78 + if [[ "${adsb_decoder_installed}" == "true" ]]; then + current_adsb_device_number="" + if [[ -f /etc/systemd/system/acarsdec.service ]]; then + log_message "Determining which device is currently assigned to the ADS-B decoder" + current_adsb_device_number=`get_config "RECEIVER_SERIAL" "/etc/default/dump1090-fa"` fi - - if [[ "${uat_decoder_installed}" == "true" ]]; then - log_message "Asking the user to assign a RTL-SDR device number to the UAT decoder" - uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number" - while [[ -z $uat_device_number ]] ; do - uat_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ - --title "${uat_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ - 8 78 3>&1 1>&2 2>&3) - exitstatus=$? - if [[ $exitstatus == 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 "ACARSDEC decoder setup halted" - exit 1 - fi - uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number (REQUIRED)" - done - fi - - log_message "Asking the user to assign a RTL-SDR device number to ACARSDEC" - acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number" - while [[ -z $acars_device_number ]] ; do - acars_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ - --title "${acars_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your ACARSDEC decoder." \ - 8 78 3>&1 1>&2 2>&3) - exitstatus=$? - if [[ $exitstatus == 0 ]]; then + log_message "Asking the user to assign a RTL-SDR device number to the ADS-B decoder" + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number" + while [[ -z $adsb_device_number ]] ; do + adsb_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${adsb_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ + 8 78 \ + "${current_adsb_device_number}" 3>&1 1>&2 2>&3) + exit_status=$? + if [[ $exit_status != 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -133,25 +94,90 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr log_title_heading "ACARSDEC decoder setup halted" exit 1 fi - acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number (REQUIRED)" + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number (REQUIRED)" done fi + + if [[ "${uat_decoder_installed}" == "true" ]]; then + current_uat_device_number="" + if [[ -f /etc/systemd/system/acarsdec.service ]]; then + log_message "Determining which device is currently assigned to the UAT decoder" + receiver_options=`get_config "RECEIVER_OPTIONS" "/etc/default/dump978-fa"` + current_uat_device_number=$receiver_options | grep -o -P '(?<=serial=).*(?= --)' + fi + log_message "Asking the user to assign a RTL-SDR device number to the UAT decoder" + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number" + while [[ -z $uat_device_number ]] ; do + uat_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${uat_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ + 8 78 \ + "${current_uat_device_number}" 3>&1 1>&2 2>&3) + exit_status=$? + if [[ $exit_status != 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 "ACARSDEC decoder setup halted" + exit 1 + fi + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number (REQUIRED)" + done + fi + + current_acars_device_number="" + if [[ -f /etc/systemd/system/acarsdec.service ]]; then + log_message "Determining which device is currently assigned to the UAT decoder" + exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` + current_acars_device_number=`echo $exec_start | grep -o -P '(?<=-r ).*(?= -A)'` + fi + log_message "Asking the user to assign a RTL-SDR device number to ACARSDEC" + acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number" + while [[ -z $acars_device_number ]] ; do + acars_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${acars_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ACARSDEC decoder." \ + 8 78 \ + "${current_acars_device_number}" 3>&1 1>&2 2>&3) + exit_status=$? + if [[ $exit_status != 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 "ACARSDEC decoder setup halted" + exit 1 + fi + acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number (REQUIRED)" + done fi -log_message "Asking the user for ACARS frequencies to monitor" -acars_fequencies=$(whiptail --backtitle "ACARS Frequencies" \ - --title "${acars_device_number_title}" \ - --inputbox "\nEnter the ACARS frequencies you would like to monitor." \ - 8 78 3>&1 1>&2 2>&3) -exitstatus=$? -if [[ $exitstatus == 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 "ACARSDEC decoder setup halted" - exit 1 +current_acars_frequencies="" +if [[ -f /etc/systemd/system/acarsdec.service ]]; then + log_message "Determining which frequencies are currently assigned" + exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` + current_acars_frequencies=`sed -e 's#.*:5555 \(\)#\1#' <<< "${exec_start}"` fi +log_message "Asking the user for ACARS frequencies to monitor" +acars_fequencies_title="Enter ACARS Frequencies" +while [[ -z $acars_fequencies ]] ; do + acars_fequencies=$(whiptail --backtitle "ACARS Frequencies" \ + --title "${acars_fequencies_title}" \ + --inputbox "\nEnter the ACARS frequencies you would like to monitor." \ + 8 78 \ + "${current_acars_frequencies}" 3>&1 1>&2 2>&3) + exit_status=$? + if [[ $exit_status != 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 "ACARSDEC decoder setup halted" + exit 1 + fi + acars_fequencies_title="Enter ACARS Frequencies (REQUIRED)" +done ## CHECK FOR PREREQUISITE PACKAGES @@ -161,7 +187,7 @@ log_heading "Installing packages needed to fulfill dependencies for FlightAware check_package cmake check_package libjansson-dev check_package libpaho-mqtt-dev -check_package libsndfile-dev +check_package libsndfile1-dev check_package libsqlite3-dev check_package libusb-1.0-0-dev check_package libxml2-dev @@ -205,7 +231,6 @@ else echo "" git clone https://github.com/szpajder/libacars.git fi -echo "" ## BUILD AND INSTALL THE LIBACARS LIBRARY @@ -218,7 +243,7 @@ if [[ ! -d $RECEIVER_BUILD_DIRECTORY/libacars/build ]]; then mkdir -vp $RECEIVER_BUILD_DIRECTORY/libacars/build echo "" fi -if [[ -n "$(ls -A $RECEIVER_BUILD_DIRECTORY/libacars/build 2>/dev/null)" ]] +if [[ -n "$(ls -A $RECEIVER_BUILD_DIRECTORY/libacars/build 2>/dev/null)" ]]; then log_message "Deleting all files currently residing in the libacars build directory" rm -rf $RECEIVER_BUILD_DIRECTORY/libacars/build/* fi @@ -237,9 +262,7 @@ echo "" sudo make install echo "" log_message "Running ldconfig" -echo "" sudo ldconfig -echo "" ## CLONE OR PULL THE ACARSDEC GIT REPOSITORY @@ -259,7 +282,6 @@ else echo "" git clone https://github.com/TLeconte/acarsdec.git fi -echo "" ## BUILD AND INSTALL THE ACARSDEC BINARY @@ -272,7 +294,7 @@ if [[ ! -d $RECEIVER_BUILD_DIRECTORY/acarsdec/build ]]; then mkdir -vp $RECEIVER_BUILD_DIRECTORY/acarsdec/build echo "" fi -if [[ -n "$(ls -A $RECEIVER_BUILD_DIRECTORY/acarsdec/build 2>/dev/null)" ]] +if [[ -n "$(ls -A $RECEIVER_BUILD_DIRECTORY/acarsdec/build 2>/dev/null)" ]]; then log_message "Deleting all files currently residing in the ACARSDEC build directory" rm -rf $RECEIVER_BUILD_DIRECTORY/acarsdec/build/* fi @@ -301,7 +323,6 @@ echo "" log_message "Executing make install" echo "" sudo make install -echo "" ## CLONE OR PULL THE ACARSSERV GIT REPOSITORY @@ -321,7 +342,6 @@ else echo "" git clone https://github.com/TLeconte/acarsserv.git fi -echo "" ## BUILD AND INSTALL THE ACARSDEC BINARY @@ -333,6 +353,7 @@ cd $RECEIVER_BUILD_DIRECTORY/acarsserv log_message "Executing make" echo "" make -f Makefile +echo "" ## RUN ACARSDECO AND ACARSSERV @@ -381,7 +402,6 @@ EOF log_message "Enabling then starting the ACARSDEC service" sudo systemctl enable --now acarsdec.service - log_message "Enabling then starting the acarsserv service" sudo systemctl enable --now acarsserv.service @@ -401,13 +421,15 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr if [[ "${uat_decoder_installed}" == "true" ]]; then log_message "Assigning RTL-SDR device number ${uat_device_number} to the FlightAware Dump978 decoder" - sudo sed -i -e "s/driver=rtlsdr/driver=rtlsdr,serial=${uat_device_number}/g" /etc/default/dump978-fa + sudo sed -i -e "s|driver=rtlsdr|driver=rtlsdr,serial=${uat_device_number}|g" /etc/default/dump978-fa log_message "Restarting dump978-fa" sudo systemctl restart dump978-fa fi log_message "Assigning RTL-SDR device number ${acars_device_number} to ACARSDEC" - sudo sed -i -e "s/\(.*-r \)\([0-9]\+\)\( .*\)/\1${acars_device_number}\3/g" /etc/systemd/system/acarsdec.service + sudo sed -i -e "s|\(.*-r \)\([0-9]\+\)\( .*\)|\1${acars_device_number}\3|g" /etc/systemd/system/acarsdec.service + log_message "Reload systemd units" + sudo systemctl daemon-reload log_message "Restarting ACARSDEC" sudo systemctl restart acarsdec fi @@ -432,4 +454,4 @@ log_title_heading "ACARSDEC decoder setup is complete" echo "" read -p "Press enter to continue..." discard -exit 0 \ No newline at end of file +exit 0 diff --git a/bash/decoders/dump1090-fa.sh b/bash/decoders/dump1090-fa.sh index 2bba27a..c641173 100755 --- a/bash/decoders/dump1090-fa.sh +++ b/bash/decoders/dump1090-fa.sh @@ -64,8 +64,8 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t --title "${uat_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ 8 78 3>&1 1>&2 2>&3) - exitstatus=$? - if [[ $exitstatus == 0 ]]; then + exit_status=$? + if [[ $exit_status != 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -85,8 +85,8 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t --title "${acars_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your ACARS decoder." \ 8 78 3>&1 1>&2 2>&3) - exitstatus=$? - if [[ $exitstatus == 0 ]]; then + exit_status=$? + if [[ $exit_status != 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -105,8 +105,8 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t --title "${adsb_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your FlightAware Dump1090 decoder." \ 8 78 3>&1 1>&2 2>&3) - exitstatus=$? - if [[ $exitstatus == 0 ]]; then + exit_status=$? + if [[ $exit_status != 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" diff --git a/bash/decoders/dump978-fa.sh b/bash/decoders/dump978-fa.sh index 6d6f9db..45fe0df 100755 --- a/bash/decoders/dump978-fa.sh +++ b/bash/decoders/dump978-fa.sh @@ -64,8 +64,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " --title "${adsb_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ 8 78 3>&1 1>&2 2>&3) - exitstatus=$? - if [[ $exitstatus == 0 ]]; then + exit_status=$? + if [[ $exit_status != 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -85,8 +85,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " --title "${acars_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your ACARS decoder." \ 8 78 3>&1 1>&2 2>&3) - exitstatus=$? - if [[ $exitstatus == 0 ]]; then + exit_status=$? + if [[ $exit_status != 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" @@ -105,8 +105,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " --title "${uat_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your FlightAware Dump978 decoder." \ 8 78 3>&1 1>&2 2>&3) - exitstatus=$? - if [[ $exitstatus == 0 ]]; then + exit_status=$? + if [[ $exit_status != 0 ]]; then log_alert_heading "INSTALLATION HALTED" log_alert_message "Setup has been halted due to lack of required information" echo "" diff --git a/bash/functions.sh b/bash/functions.sh index 4fc072b..4b8c2dd 100755 --- a/bash/functions.sh +++ b/bash/functions.sh @@ -161,5 +161,9 @@ function change_config() { # Use sed to locate the "KEY" then read the "VALUE", the portion after the equals sign, in the specified "FILE" # This function should work with any configuration file with settings formated as KEY="VALUE" function get_config() { - echo `sed -n "/^$1 *= *\"\(.*\)\"$/s//\1/p" $2` -} \ No newline at end of file + setting=`sed -n "/^$1 *= *\"\(.*\)\"$/s//\1/p" $2` + if [[ "${setting}" == "" ]]; then + setting=`sed -n "/^$1 *= *\(.*\)$/s//\1/p" $2` + fi + echo $setting +} diff --git a/bash/main.sh b/bash/main.sh index b363f84..7e8a0f6 100755 --- a/bash/main.sh +++ b/bash/main.sh @@ -30,10 +30,12 @@ else 10 65 if [[ $? == 0 ]]; then install_adsb_decoder="true" + chosen_adsb_decoder="dump1090-fa" fi fi function install_dump1090_fa() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/decoders/dump1090-fa.sh ${RECEIVER_BASH_DIRECTORY}/decoders/dump1090-fa.sh if [[ $? != 0 ]] ; then exit 1 @@ -64,10 +66,12 @@ else 10 65 if [[ $? == 0 ]]; then install_uat_decoder="true" + chosen_uat_decoder="dump978-fa" fi fi function install_dump978_fa() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/decoders/dump978-fa.sh ${RECEIVER_BASH_DIRECTORY}/decoders/dump978-fa.sh if [[ $? != 0 ]] ; then exit 1 @@ -82,8 +86,8 @@ if [[ -f /etc/systemd/system/acarsdec.service ]]; then chosen_acars_decoder="acarsdec" whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "Reinstall ACARSDEC Decoder" \ - --defaultno --yesno "The option to rebuild and reinstall ACARSDEC is available.\n\nWould you like to reinstall ACARSDEC?" \ - 16 65 + --defaultno --yesno "The option to rebuild and reinstall ACARSDEC is available.\n\nWould you like to rebuild and reinstall ACARSDEC?" \ + 9 65 if [[ $? == 0 ]]; then install_acars_decoder="true" fi @@ -95,10 +99,12 @@ else 10 65 if [[ $? == 0 ]]; then install_acars_decoder="true" + chosen_acars_decoder="acarsdec" fi fi function install_acarsdec() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/decoders/acarsdec.sh ${RECEIVER_BASH_DIRECTORY}/decoders/acarsdec.sh if [[ $? != 0 ]] ; then exit 1 @@ -120,6 +126,7 @@ else feeder_list=("${feeder_list[@]}" 'ADS-B Exchange Feed Client' '' OFF) fi function install_adsbexchange_client() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/adsbexchange.sh ${RECEIVER_BASH_DIRECTORY}/feeders/adsbexchange.sh if [[ $? != 0 ]] ; then exit 1 @@ -136,6 +143,7 @@ else fi function install_airplaneslive_client() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/airplaneslive.sh ${RECEIVER_BASH_DIRECTORY}/feeders/airplaneslive.sh if [[ $? != 0 ]] ; then exit 1 @@ -154,6 +162,7 @@ else fi function install_flightaware_client() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/piaware.sh ${RECEIVER_BASH_DIRECTORY}/feeders/piaware.sh if [[ $? != 0 ]] ; then exit 1 @@ -172,6 +181,7 @@ else fi function install_flightradar24_client() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/flightradar24.sh ${RECEIVER_BASH_DIRECTORY}/feeders/flightradar24.sh if [[ $? != 0 ]] ; then exit 1 @@ -188,6 +198,7 @@ else fi function install_flyitalyadsb_client() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/flyitalyadsb.sh ${RECEIVER_BASH_DIRECTORY}/feeders/flyitalyadsb.sh if [[ $? != 0 ]] ; then exit 1 @@ -204,6 +215,7 @@ else fi function install_openskynetwork_client() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/openskynetwork.sh ${RECEIVER_BASH_DIRECTORY}/feeders/openskynetwork.sh if [[ $? != 0 ]] ; then exit 1 @@ -250,6 +262,7 @@ else fi function install_planefinder_client() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/planefinder.sh ${RECEIVER_BASH_DIRECTORY}/feeders/planefinder.sh if [[ $? != 0 ]] ; then exit 1 @@ -272,12 +285,13 @@ 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 + 12 78 if [[ $? == 0 ]]; then install_portal="true" fi function install_adsb-portal() { + chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/install.sh ${RECEIVER_BASH_DIRECTORY}/portal/install.sh if [[ $? != 0 ]] ; then exit 1 @@ -327,7 +341,7 @@ whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --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 + 11 65 4 "${extras_list[@]}" 2>${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES @@ -339,7 +353,7 @@ if [[ "${install_adsb_decoder}" == "false" && "${install_uat_decoder}" == "false 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 + 8 65 echo "" log_alert_heading "Nothing was selected to do or be installed" echo "" From 824f228eb38d15c53f09b9a822b353e55fe14806 Mon Sep 17 00:00:00 2001 From: jprochazka Date: Mon, 5 Aug 2024 16:58:58 -0400 Subject: [PATCH 11/18] Tested and debugged dump1090-fa installer. --- bash/decoders/acarsdec.sh | 20 +++-- bash/decoders/dump1090-fa.sh | 142 ++++++++++++++++++++--------------- bash/decoders/dump978-fa.sh | 142 ++++++++++++++++++++--------------- bash/main.sh | 24 +++++- 4 files changed, 200 insertions(+), 128 deletions(-) diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh index d08fe54..7d493a4 100755 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -49,7 +49,7 @@ if [[ $exit_status != 0 ]]; then exit 1 fi -log_heading "Gather information required to configure the ADS-B decoder and dump978-fa if needed" +log_heading "Gather information required to configure the decoder(s)" log_message "Checking if an ADS-B decoder is installed" adsb_decoder_installed="false" @@ -65,15 +65,23 @@ if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok instal uat_decoder_installed="true" fi +log_message "Checking if an ACARS decoder is installed" +acars_decoder_installed="false" +if [[ -f /usr/local/bin/acarsdec ]]; then + log_message "An ACARS decoder appears to be installed" + acars_decoder_installed="true" +fi + if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "true" ]]; then log_message "Informing the user that existing decoder(s) appears to be installed" whiptail --backtitle "ACARSDEC Decoder Configuration" \ --title "RTL-SDR Dongle Assignments" \ --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run ACARSDEC in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple RTL-SDR devices connected to your device." \ 12 78 + if [[ "${adsb_decoder_installed}" == "true" ]]; then current_adsb_device_number="" - if [[ -f /etc/systemd/system/acarsdec.service ]]; then + if [[ "${acars_decoder_installed}" == "true" ]]; then log_message "Determining which device is currently assigned to the ADS-B decoder" current_adsb_device_number=`get_config "RECEIVER_SERIAL" "/etc/default/dump1090-fa"` fi @@ -100,7 +108,7 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr if [[ "${uat_decoder_installed}" == "true" ]]; then current_uat_device_number="" - if [[ -f /etc/systemd/system/acarsdec.service ]]; then + if [[ "${acars_decoder_installed}" == "true" ]]; then log_message "Determining which device is currently assigned to the UAT decoder" receiver_options=`get_config "RECEIVER_OPTIONS" "/etc/default/dump978-fa"` current_uat_device_number=$receiver_options | grep -o -P '(?<=serial=).*(?= --)' @@ -127,7 +135,7 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr fi current_acars_device_number="" - if [[ -f /etc/systemd/system/acarsdec.service ]]; then + if [[ "${acars_decoder_installed}" == "true" ]]; then log_message "Determining which device is currently assigned to the UAT decoder" exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` current_acars_device_number=`echo $exec_start | grep -o -P '(?<=-r ).*(?= -A)'` @@ -154,7 +162,7 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr fi current_acars_frequencies="" -if [[ -f /etc/systemd/system/acarsdec.service ]]; then +if [[ "${acars_decoder_installed}" == "true" ]]; then log_message "Determining which frequencies are currently assigned" exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` current_acars_frequencies=`sed -e 's#.*:5555 \(\)#\1#' <<< "${exec_start}"` @@ -428,7 +436,7 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr log_message "Assigning RTL-SDR device number ${acars_device_number} to ACARSDEC" sudo sed -i -e "s|\(.*-r \)\([0-9]\+\)\( .*\)|\1${acars_device_number}\3|g" /etc/systemd/system/acarsdec.service - log_message "Reload systemd units" + log_message "Reloading systemd units" sudo systemctl daemon-reload log_message "Restarting ACARSDEC" sudo systemctl restart acarsdec diff --git a/bash/decoders/dump1090-fa.sh b/bash/decoders/dump1090-fa.sh index c641173..72a3a77 100755 --- a/bash/decoders/dump1090-fa.sh +++ b/bash/decoders/dump1090-fa.sh @@ -29,7 +29,14 @@ fi ## GATHER REQUIRED INFORMATION FROM THE USER -log_heading "Gather information required to configure the ADS-B decoder and dump978-fa if needed" +log_heading "Gather information required to configure the decoder(s)" + +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 log_message "Checking if a UAT decoder is installed" uat_decoder_installed="false" @@ -46,65 +53,27 @@ if [[ -f /usr/local/bin/acarsdec ]]; then fi if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "true" ]]; then - log_message "Checking if dump1090-fa has been configured" - if [[ -f /etc/default/dump978-fa ]]; then - log_message "A dump1090-fa configuration file exists" - else - log_message "Informing the user that existing decoder(s) appears to be installed" - whiptail --backtitle "ACARSDEC Decoder Configuration" \ - --title "RTL-SDR Dongle Assignments" \ - --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run FlightAware dump1090 in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple RTL-SDR devices connected to your device." \ - 12 78 + log_message "Informing the user that existing decoder(s) appears to be installed" + whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "RTL-SDR Dongle Assignments" \ + --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run ACARSDEC in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple RTL-SDR devices connected to your device." \ + 12 78 - if [[ "${uat_decoder_installed}" == "true" ]]; then - log_message "Asking the user to assign a RTL-SDR device number to the UAT decoder" - uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number" - while [[ -z $uat_device_serial ]] ; do - uat_device_number=$(whiptail --backtitle "FlightAware Dump1090 Decoder Configuration" \ - --title "${uat_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ - 8 78 3>&1 1>&2 2>&3) - exit_status=$? - if [[ $exit_status != 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 Dump1090 decoder setup halted" - exit 1 - fi - uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number (REQUIRED)" - done + if [[ "${uat_decoder_installed}" == "true" ]]; then + current_uat_device_number="" + if [[ "${adsb_decoder_installed}" == "true" ]]; then + log_message "Determining which device is currently assigned to the UAT decoder" + receiver_options=`get_config "RECEIVER_OPTIONS" "/etc/default/dump978-fa"` + current_uat_device_number=$receiver_options | grep -o -P '(?<=serial=).*(?= --)' fi - - if [[ "${acars_decoder_installed}" == "true" ]]; then - log_message "Asking the user to assign a RTL-SDR device number to the ACARS decoder" - acars_device_number_title="Enter the ACARS Decoder RTL-SDR Device Number" - while [[ -z $acars_device_number ]] ; do - acars_device_number=$(whiptail --backtitle "FlightAware Dump1090 Decoder Configuration" \ - --title "${acars_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your ACARS decoder." \ - 8 78 3>&1 1>&2 2>&3) - exit_status=$? - if [[ $exit_status != 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 Dump1090 decoder setup halted" - exit 1 - fi - acars_device_number_title="Enter the ACARS Decoder RTL-SDR Device Number (REQUIRED)" - done - fi - - log_message "Asking the user to assign a RTL-SDR device number to FlightAware Dump1090" - adsb_device_number_title="Enter the FlightAware Dump1090 RTL-SDR Device Number" - while [[ -z $adsb_device_number ]] ; do - adsb_device_number=$(whiptail --backtitle "FlightAware Dump1090 Decoder Configuration" \ - --title "${adsb_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your FlightAware Dump1090 decoder." \ - 8 78 3>&1 1>&2 2>&3) + log_message "Asking the user to assign a RTL-SDR device number to the UAT decoder" + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number" + while [[ -z $uat_device_number ]] ; do + uat_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${uat_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ + 8 78 \ + "${current_uat_device_number}" 3>&1 1>&2 2>&3) exit_status=$? if [[ $exit_status != 0 ]]; then log_alert_heading "INSTALLATION HALTED" @@ -114,9 +83,62 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t log_title_heading "FlightAware Dump1090 decoder setup halted" exit 1 fi - adsb_device_number_title="Enter the FlightAware Dump1090 RTL-SDR Device Number (REQUIRED)" + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number (REQUIRED)" done fi + + if [[ "${acars_decoder_installed}" == "true" ]]; then + current_acars_device_number="" + if [[ "${adsb_decoder_installed}" == "true" ]]; then + log_message "Determining which device is currently assigned to the UAT decoder" + exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` + current_acars_device_number=`echo $exec_start | grep -o -P '(?<=-r ).*(?= -A)'` + fi + log_message "Asking the user to assign a RTL-SDR device number to ACARSDEC" + acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number" + while [[ -z $acars_device_number ]] ; do + acars_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${acars_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ACARSDEC decoder." \ + 8 78 \ + "${current_acars_device_number}" 3>&1 1>&2 2>&3) + exit_status=$? + if [[ $exit_status != 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 Dump1090 decoder setup halted" + exit 1 + fi + acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number (REQUIRED)" + done + fi + + current_adsb_device_number="" + if [[ -f /etc/systemd/system/acarsdec.service ]]; then + log_message "Determining which device is currently assigned to the ADS-B decoder" + current_adsb_device_number=`get_config "RECEIVER_SERIAL" "/etc/default/dump1090-fa"` + fi + log_message "Asking the user to assign a RTL-SDR device number to the ADS-B decoder" + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number" + while [[ -z $adsb_device_number ]] ; do + adsb_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${adsb_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ + 8 78 \ + "${current_adsb_device_number}" 3>&1 1>&2 2>&3) + exit_status=$? + if [[ $exit_status != 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 Dump1090 decoder setup halted" + exit 1 + fi + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number (REQUIRED)" + done fi @@ -241,6 +263,8 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t if [[ "${acars_decoder_installed}" == "true" ]]; then log_message "Assigning RTL-SDR device number ${acars_device_number} to ACARSDEC" sudo sed -i -e "s/\(.*-r \)\([0-9]\+\)\( .*\)/\1${acars_device_number}\3/g" /etc/systemd/system/acarsdec.service + log_message "Reloading systemd units" + sudo systemctl daemon-reload log_message "Restarting ACARSDEC" sudo systemctl restart acarsdec fi diff --git a/bash/decoders/dump978-fa.sh b/bash/decoders/dump978-fa.sh index 45fe0df..1830967 100755 --- a/bash/decoders/dump978-fa.sh +++ b/bash/decoders/dump978-fa.sh @@ -29,7 +29,7 @@ fi ## GATHER REQUIRED INFORMATION FROM THE USER -log_heading "Gather information required to configure the ADS-B decoder and dump978-fa if needed" +log_heading "Gather information required to configure the decoder(s)" log_message "Checking if an ADS-B decoder is installed" adsb_decoder_installed="false" @@ -38,6 +38,13 @@ if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok insta adsb_decoder_installed="true" fi +log_message "Checking if a UAT decoder is installed" +uat_decoder_installed="false" +if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then + log_message "An ADS-B decoder appears to be installed" + uat_decoder_installed="true" +fi + log_message "Checking if an ACARS decoder is installed" acars_decoder_installed="false" if [[ -f /usr/local/bin/acarsdec ]]; then @@ -46,65 +53,26 @@ if [[ -f /usr/local/bin/acarsdec ]]; then fi if [[ "${adsb_decoder_installed}" == "true" || "${acars_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 that existing decoder(s) appears to be installed" - whiptail --backtitle "FlightAware Dump978 Decoder Configuration" \ - --title "RTL-SDR Dongle Assignments" \ - --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run FlightAware Dump978 in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple RTL-SDR devices connected to your device." \ - 12 78 + log_message "Informing the user that existing decoder(s) appears to be installed" + whiptail --backtitle "FlightAware Dump978 Decoder Configuration" \ + --title "RTL-SDR Dongle Assignments" \ + --msgbox "It appears that existing decoder(s) have been installed on this device. In order to run FlightAware Dump978 in tandem with other decoders you will need to specifiy which RTL-SDR dongle each decoder is to use.\n\nKeep in mind in order to run multiple decoders on a single device you will need to have multiple RTL-SDR devices connected to your device." \ + 12 78 - if [[ "${adsb_decoder_installed}" == "true" ]]; then - log_message "Asking the user to assign a RTL-SDR device number to the ADS-B decoder" - adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number" - while [[ -z $adsb_device_number ]] ; do - adsb_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ - --title "${adsb_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ - 8 78 3>&1 1>&2 2>&3) - exit_status=$? - if [[ $exit_status != 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 - adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number (REQUIRED)" - done + if [[ "${adsb_decoder_installed}" == "true" ]]; then + current_adsb_device_number="" + if [[ "${uat_decoder_installed}" == "true" ]]; then + log_message "Determining which device is currently assigned to the ADS-B decoder" + current_adsb_device_number=`get_config "RECEIVER_SERIAL" "/etc/default/dump1090-fa"` fi - - if [[ "${acars_decoder_installed}" == "true" ]]; then - log_message "Asking the user to assign a RTL-SDR device number to the ACARS decoder" - acars_device_number_title="Enter the ACARS Decoder RTL-SDR Device Number" - while [[ -z $acars_device_number ]] ; do - acars_device_number=$(whiptail --backtitle "FlightAware Dump1090 Decoder Configuration" \ - --title "${acars_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your ACARS decoder." \ - 8 78 3>&1 1>&2 2>&3) - exit_status=$? - if [[ $exit_status != 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 - acars_device_number_title="Enter the ACARS Decoder RTL-SDR Device Number (REQUIRED)" - done - fi - - log_message "Asking the user to assign a RTL-SDR device number to FlightAware Dump978" - uat_device_number_title="Enter the FlightAware Dump978 RTL-SDR Device Number" - while [[ -z $uat_device_number ]] ; do - uat_device_number=$(whiptail --backtitle "FlightAware Dump978 Decoder Configuration" \ - --title "${uat_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your FlightAware Dump978 decoder." \ - 8 78 3>&1 1>&2 2>&3) + log_message "Asking the user to assign a RTL-SDR device number to the ADS-B decoder" + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number" + while [[ -z $adsb_device_number ]] ; do + adsb_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${adsb_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ + 8 78 \ + "${current_adsb_device_number}" 3>&1 1>&2 2>&3) exit_status=$? if [[ $exit_status != 0 ]]; then log_alert_heading "INSTALLATION HALTED" @@ -114,9 +82,63 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " log_title_heading "FlightAware Dump978 decoder setup halted" exit 1 fi - uat_device_number_title="Enter the FlightAware Dump978 RTL-SDR Device Number (REQUIRED)" + adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number (REQUIRED)" done fi + + if [[ "${acars_decoder_installed}" == "true" ]]; then + current_acars_device_number="" + if [[ "${uat_decoder_installed}" == "true" ]]; then + log_message "Determining which device is currently assigned to the UAT decoder" + exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` + current_acars_device_number=`echo $exec_start | grep -o -P '(?<=-r ).*(?= -A)'` + fi + log_message "Asking the user to assign a RTL-SDR device number to ACARSDEC" + acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number" + while [[ -z $acars_device_number ]] ; do + acars_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${acars_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your ACARSDEC decoder." \ + 8 78 \ + "${current_acars_device_number}" 3>&1 1>&2 2>&3) + exit_status=$? + if [[ $exit_status != 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 + acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number (REQUIRED)" + done + fi + + current_uat_device_number="" + if [[ -f /etc/systemd/system/acarsdec.service ]]; then + log_message "Determining which device is currently assigned to the UAT decoder" + receiver_options=`get_config "RECEIVER_OPTIONS" "/etc/default/dump978-fa"` + current_uat_device_number=$receiver_options | grep -o -P '(?<=serial=).*(?= --)' + fi + log_message "Asking the user to assign a RTL-SDR device number to the UAT decoder" + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number" + while [[ -z $uat_device_number ]] ; do + uat_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ + --title "${uat_device_number_title}" \ + --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ + 8 78 \ + "${current_uat_device_number}" 3>&1 1>&2 2>&3) + exit_status=$? + if [[ $exit_status != 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 + uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number (REQUIRED)" + done fi @@ -246,6 +268,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " if [[ "${acars_decoder_installed}" == "true" ]]; then log_message "Assigning RTL-SDR device number ${acars_device_number} to ACARSDEC" sudo sed -i -e "s/\(.*-r \)\([0-9]\+\)\( .*\)/\1${acars_device_number}\3/g" /etc/systemd/system/acarsdec.service + log_message "Reload systemd units" + sudo systemctl daemon-reload log_message "Restarting ACARSDEC" sudo systemctl restart acarsdec fi diff --git a/bash/main.sh b/bash/main.sh index 7e8a0f6..3ed8c44 100755 --- a/bash/main.sh +++ b/bash/main.sh @@ -21,6 +21,14 @@ if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok insta if [[ $? == 0 ]]; then install_adsb_decoder="true" fi + else + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Reinstall FlightAware dump1090" \ + --defaultno --yesno "The option to rebuild and reinstall FlightAware dump1090 is available.\n\nWould you like to rebuild and reinstall FlightAware dump1090?" \ + 9 65 + if [[ $? == 0 ]]; then + install_adsb_decoder="true" + fi fi else whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ @@ -50,10 +58,18 @@ install_uat_decoder="false" if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") == 1 ]]; then chosen_uat_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 + 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_uat_decoder="true" + fi + else + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Reinstall FlightAware dump978" \ + --defaultno --yesno "The option to rebuild and reinstall FlightAware dump978 is available.\n\nWould you like to rebuild and reinstall FlightAware dump978?" \ + 9 65 if [[ $? == 0 ]]; then install_uat_decoder="true" fi From b4c22caca0cc9947a622798c723291e74011ffb0 Mon Sep 17 00:00:00 2001 From: jprochazka Date: Mon, 5 Aug 2024 17:18:59 -0400 Subject: [PATCH 12/18] Tested and debugged dump978-fa installer. --- CHANGELOG.md | 5 +++-- bash/decoders/acarsdec.sh | 16 +++++----------- bash/decoders/dump1090-fa.sh | 20 +++++++------------- bash/decoders/dump978-fa.sh | 22 ++++++++-------------- 4 files changed, 23 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e65593..7a700b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,9 @@ The following is a history of the changes made to this project. ## v2.8.6 *(in development)* * The option to install ACARSDEC and ACARSERV is now available as a decoder option. -* The ability to view ACARS messages via the existing PHP portal has been added. -* All scripts now ask that devices be assigned when additional decoder installations are executed. +* ACARS data can be viewed via the existing PHP portal has been added. +* Added the ability to reconfigure, rebuild, and reinstall both dump1090-fa and dump978.fa. +* Decoder scripts now ask for device assignments when additional decoders are being installed. * Added "Contributors" to the copyright notice in the software license. ## v2.8.5 *(July 23rd, 2024)* diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh index 7d493a4..5b4eb3f 100755 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -80,11 +80,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr 12 78 if [[ "${adsb_decoder_installed}" == "true" ]]; then - current_adsb_device_number="" - if [[ "${acars_decoder_installed}" == "true" ]]; then - log_message "Determining which device is currently assigned to the ADS-B decoder" - current_adsb_device_number=`get_config "RECEIVER_SERIAL" "/etc/default/dump1090-fa"` - fi + log_message "Determining which device is currently assigned to the ADS-B decoder" + current_adsb_device_number=`get_config "RECEIVER_SERIAL" "/etc/default/dump1090-fa"` log_message "Asking the user to assign a RTL-SDR device number to the ADS-B decoder" adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number" while [[ -z $adsb_device_number ]] ; do @@ -107,12 +104,9 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr fi if [[ "${uat_decoder_installed}" == "true" ]]; then - current_uat_device_number="" - if [[ "${acars_decoder_installed}" == "true" ]]; then - log_message "Determining which device is currently assigned to the UAT decoder" - receiver_options=`get_config "RECEIVER_OPTIONS" "/etc/default/dump978-fa"` - current_uat_device_number=$receiver_options | grep -o -P '(?<=serial=).*(?= --)' - fi + log_message "Determining which device is currently assigned to the UAT decoder" + receiver_options=`get_config "RECEIVER_OPTIONS" "/etc/default/dump978-fa"` + current_uat_device_number=$receiver_options | grep -o -P '(?<=serial=).*(?= --)' log_message "Asking the user to assign a RTL-SDR device number to the UAT decoder" uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number" while [[ -z $uat_device_number ]] ; do diff --git a/bash/decoders/dump1090-fa.sh b/bash/decoders/dump1090-fa.sh index 72a3a77..a021f0f 100755 --- a/bash/decoders/dump1090-fa.sh +++ b/bash/decoders/dump1090-fa.sh @@ -60,12 +60,9 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t 12 78 if [[ "${uat_decoder_installed}" == "true" ]]; then - current_uat_device_number="" - if [[ "${adsb_decoder_installed}" == "true" ]]; then - log_message "Determining which device is currently assigned to the UAT decoder" - receiver_options=`get_config "RECEIVER_OPTIONS" "/etc/default/dump978-fa"` - current_uat_device_number=$receiver_options | grep -o -P '(?<=serial=).*(?= --)' - fi + log_message "Determining which device is currently assigned to the UAT decoder" + receiver_options=`get_config "RECEIVER_OPTIONS" "/etc/default/dump978-fa"` + current_uat_device_number=$receiver_options | grep -o -P '(?<=serial=).*(?= --)' log_message "Asking the user to assign a RTL-SDR device number to the UAT decoder" uat_device_number_title="Enter the UAT Decoder RTL-SDR Device Number" while [[ -z $uat_device_number ]] ; do @@ -88,12 +85,9 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t fi if [[ "${acars_decoder_installed}" == "true" ]]; then - current_acars_device_number="" - if [[ "${adsb_decoder_installed}" == "true" ]]; then - log_message "Determining which device is currently assigned to the UAT decoder" - exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` - current_acars_device_number=`echo $exec_start | grep -o -P '(?<=-r ).*(?= -A)'` - fi + log_message "Determining which device is currently assigned to the UAT decoder" + exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` + current_acars_device_number=`echo $exec_start | grep -o -P '(?<=-r ).*(?= -A)'` log_message "Asking the user to assign a RTL-SDR device number to ACARSDEC" acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number" while [[ -z $acars_device_number ]] ; do @@ -116,7 +110,7 @@ if [[ "${uat_decoder_installed}" == "true" || "${acars_decoder_installed}" == "t fi current_adsb_device_number="" - if [[ -f /etc/systemd/system/acarsdec.service ]]; then + if [[ "${absb_decoder_installed}" == "true" ]]; then log_message "Determining which device is currently assigned to the ADS-B decoder" current_adsb_device_number=`get_config "RECEIVER_SERIAL" "/etc/default/dump1090-fa"` fi diff --git a/bash/decoders/dump978-fa.sh b/bash/decoders/dump978-fa.sh index 1830967..6abe20a 100755 --- a/bash/decoders/dump978-fa.sh +++ b/bash/decoders/dump978-fa.sh @@ -60,11 +60,8 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " 12 78 if [[ "${adsb_decoder_installed}" == "true" ]]; then - current_adsb_device_number="" - if [[ "${uat_decoder_installed}" == "true" ]]; then - log_message "Determining which device is currently assigned to the ADS-B decoder" - current_adsb_device_number=`get_config "RECEIVER_SERIAL" "/etc/default/dump1090-fa"` - fi + log_message "Determining which device is currently assigned to the ADS-B decoder" + current_adsb_device_number=`get_config "RECEIVER_SERIAL" "/etc/default/dump1090-fa"` log_message "Asking the user to assign a RTL-SDR device number to the ADS-B decoder" adsb_device_number_title="Enter the ADS-B Decoder RTL-SDR Device Number" while [[ -z $adsb_device_number ]] ; do @@ -87,12 +84,9 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " fi if [[ "${acars_decoder_installed}" == "true" ]]; then - current_acars_device_number="" - if [[ "${uat_decoder_installed}" == "true" ]]; then - log_message "Determining which device is currently assigned to the UAT decoder" - exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` - current_acars_device_number=`echo $exec_start | grep -o -P '(?<=-r ).*(?= -A)'` - fi + log_message "Determining which device is currently assigned to the UAT decoder" + exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` + current_acars_device_number=`echo $exec_start | grep -o -P '(?<=-r ).*(?= -A)'` log_message "Asking the user to assign a RTL-SDR device number to ACARSDEC" acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number" while [[ -z $acars_device_number ]] ; do @@ -115,7 +109,7 @@ if [[ "${adsb_decoder_installed}" == "true" || "${acars_decoder_installed}" == " fi current_uat_device_number="" - if [[ -f /etc/systemd/system/acarsdec.service ]]; then + if [[ "${uat_decoder_installed}" == "true" ]]; then log_message "Determining which device is currently assigned to the UAT decoder" receiver_options=`get_config "RECEIVER_OPTIONS" "/etc/default/dump978-fa"` current_uat_device_number=$receiver_options | grep -o -P '(?<=serial=).*(?= --)' @@ -200,11 +194,11 @@ echo "" log_message "Installing the dump978-fa Debian package" echo "" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978-fa_${DUMP978_FA_VERSION}_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978-fa_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" log_message "Installing the skyaware978 Debian package" echo "" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/skyaware978_${DUMP978_FA_VERSION}_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/skyaware978_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" log_message "Checking that the dump978-fa Debian package was installed" From 9dcf3fbb9d867319433bbf7067e65b221d60544d Mon Sep 17 00:00:00 2001 From: Joseph Prochazka Date: Mon, 5 Aug 2024 19:15:27 -0400 Subject: [PATCH 13/18] Possible fixes. --- bash/decoders/acarsdec.sh | 12 +++++++----- bash/portal/install.sh | 4 +--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh index 5b4eb3f..5c147d4 100755 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -136,7 +136,7 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr fi log_message "Asking the user to assign a RTL-SDR device number to ACARSDEC" acars_device_number_title="Enter the ACARSDEC RTL-SDR Device Number" - while [[ -z $acars_device_number ]] ; do + while [[ -z $acars_device_number ]]; do acars_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ --title "${acars_device_number_title}" \ --inputbox "\nEnter the RTL-SDR device number to assign your ACARSDEC decoder." \ @@ -155,11 +155,15 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr done fi +if [[ -z $acars_device_number ]]; then + acars_device_number="0" +fi + current_acars_frequencies="" if [[ "${acars_decoder_installed}" == "true" ]]; then log_message "Determining which frequencies are currently assigned" exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` - current_acars_frequencies=`sed -e 's#.*:5555 \(\)#\1#' <<< "${exec_start}"` + current_acars_frequencies=`sed -e "s#.*-r ${acars_device_number} \(\)#\1#" <<< "${exec_start}"` fi log_message "Asking the user for ACARS frequencies to monitor" acars_fequencies_title="Enter ACARS Frequencies" @@ -367,10 +371,9 @@ Description=ARCARSDEC multi-channel acars decoder. After=network.target [Service] -ExecStart=/usr/local/bin/acarsdec -r 0 -A -p 0 -o 0 -j 127.0.0.1:5555 ${acars_fequencies} +ExecStart=/usr/local/bin/acarsdec -j 127.0.0.1:5555 -o2 -g280 -r 0 130.025 130.425 130.450 131.125 131.550 WorkingDirectory=/usr/local/bin StandardOutput=null -StandardError=syslog TimeoutSec=30 Restart=on-failure RestartSec=30 @@ -391,7 +394,6 @@ After=network.target ExecStart=${RECEIVER_BUILD_DIRECTORY}/acarsserv/acarsserv -j 127.0.0.1:5555 WorkingDirectory=${RECEIVER_BUILD_DIRECTORY}/acarsserv StandardOutput=null -StandardError=syslog TimeoutSec=30 Restart=on-failure RestartSec=30 diff --git a/bash/portal/install.sh b/bash/portal/install.sh index 64ff58b..2afd3bf 100755 --- a/bash/portal/install.sh +++ b/bash/portal/install.sh @@ -17,9 +17,7 @@ echo -e "" echo -e "\e[92m Setting up the ADS-B Receiver Project Portal..." echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" echo -e "" -whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B ADS-B Receiver Project Portal Setup" --yesno "The ADS-B ADS-B Receiver Project Portal adds a web accessable portal to your receiver. The portal contains allows you to view performance graphs, system information, and live maps containing the current aircraft being tracked.\n\nBy enabling the portal's advanced features you can also view historical data on flight that have been seen in the past as well as view more detailed information on each of these aircraft.\n\nTHE ADVANCED PORTAL FEATURES ARE STILL IN DEVELOPMENT\n\nIt is recomended that only those wishing to contribute to the development of these features or those wishing to test out the new features enable them. Do not be surprised if you run into any major bugs after enabling the advanced features at this time!\n\nDo you wish to continue with the ADS-B Receiver Project Portal setup?" 23 78 -CONTINUE_SETUP=$? -if [[ "${CONTINUE_SETUP}" = 1 ]] ; then +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B ADS-B Receiver Project Portal Setup" --yesno "The ADS-B ADS-B Receiver Project Portal adds a web accessable portal to your receiver. The portal contains allows you to view performance graphs, system information, and live maps containing the current aircraft being tracked.\n\nBy enabling the portal's advanced features you can also view historical data on flight that have been seen in the past as well as view more detailed information on each of these aircraft.\n\nTHE ADVANCED PORTAL FEATURES ARE STILL IN DEVELOPMENT\n\nIt is recomended that only those wishing to contribute to the development of these features or those wishing to test out the new features enable them. Do not be surprised if you run into any major bugs after enabling the advanced features at this time!\n\nDo you wish to continue with the ADS-B Receiver Project Portal setup?" 23 78; 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." From 402593ee2a17fbe4f5b25eb36aa17814217fd24f Mon Sep 17 00:00:00 2001 From: Joseph Prochazka Date: Mon, 5 Aug 2024 19:50:34 -0400 Subject: [PATCH 14/18] Lite portal fixes. --- bash/main.sh | 2 +- bash/portal/install.sh | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 3ed8c44..5fc2022 100755 --- a/bash/main.sh +++ b/bash/main.sh @@ -413,7 +413,7 @@ else fi # Portals - if [[ "${WEBPORTAL_DO_INSTALL}" == "true" ]]; then + if [[ "${install_portal}" == "true" ]]; then confirmation_message="${confirmation_message}\n * ADS-B Receiver Project Web Portal" fi diff --git a/bash/portal/install.sh b/bash/portal/install.sh index 2afd3bf..3298e7f 100755 --- a/bash/portal/install.sh +++ b/bash/portal/install.sh @@ -218,7 +218,7 @@ esac # Install PHP. check_package php${DISTRO_PHP_VERSION}-cgi -if (( $(echo "${DISTRO_PHP_VERSION} < 8" | bc -l) )); then +if [[ ! "${DISTRO_PHP_VERSION}" == "" && "${DISTRO_PHP_VERSION}" < "8" ]]; then check_package php${DISTRO_PHP_VERSION}-json fi @@ -253,9 +253,7 @@ if [[ "${ADVANCED}" = "true" ]] ; then ;; esac else - if [ ! $DISTRO_PHP_VERSION == "5" ]; then - check_package php${DISTRO_PHP_VERSION}-xml - fi + check_package php${DISTRO_PHP_VERSION}-xml fi # Reload Lighttpd after installing the prerequisite packages. From 13cdf96bdb2421853209132123ae65690d1b2864 Mon Sep 17 00:00:00 2001 From: jprochazka Date: Tue, 6 Aug 2024 14:50:24 -0400 Subject: [PATCH 15/18] Troubleshooting portal install --- bash/main.sh | 12 +- bash/portal/install.sh | 659 +++++++++++++++++++++++------------------ 2 files changed, 376 insertions(+), 295 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 5fc2022..ccb9f4d 100755 --- a/bash/main.sh +++ b/bash/main.sh @@ -102,7 +102,8 @@ if [[ -f /etc/systemd/system/acarsdec.service ]]; then chosen_acars_decoder="acarsdec" whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "Reinstall ACARSDEC Decoder" \ - --defaultno --yesno "The option to rebuild and reinstall ACARSDEC is available.\n\nWould you like to rebuild and reinstall ACARSDEC?" \ + --defaultno \ + --yesno "The option to rebuild and reinstall ACARSDEC is available.\n\nWould you like to rebuild and reinstall ACARSDEC?" \ 9 65 if [[ $? == 0 ]]; then install_acars_decoder="true" @@ -306,7 +307,7 @@ if [[ $? == 0 ]]; then install_portal="true" fi -function install_adsb-portal() { +function install_adsb_portal() { chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/install.sh ${RECEIVER_BASH_DIRECTORY}/portal/install.sh if [[ $? != 0 ]] ; then @@ -360,7 +361,6 @@ whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ 11 65 4 "${extras_list[@]}" 2>${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES - ## Setup Confirmation declare confirmation_message @@ -466,6 +466,7 @@ if [[ "${install_acars_decoder}" == "true" ]]; then esac fi +# Aggragate site clients run_adsbexchange_script="false" run_airplaneslive_script="false" run_flightaware_script="false" @@ -474,7 +475,6 @@ 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 do @@ -534,7 +534,7 @@ fi # Portals if [[ "${install_portal}" == "true" ]]; then - install_adsb-portal + install_adsb_portal fi # Extras @@ -556,7 +556,7 @@ if [[ -s "${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES" ]]; then done < ${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES fi -if [[ "${run_adsbexchange_script}" == "true" ]]; then +if [[ "${run_beastsplitter_script}" == "true" ]]; then install_beastsplitter fi diff --git a/bash/portal/install.sh b/bash/portal/install.sh index 3298e7f..be29fea 100755 --- a/bash/portal/install.sh +++ b/bash/portal/install.sh @@ -1,240 +1,304 @@ #!/bin/bash -## VARIABLES +## PRE INSTALLATION OPERATIONS -PORTAL_BUILD_DIRECTORY="${RECEIVER_BUILD_DIRECTORY}/portal" - -## INCLUDE EXTERNAL SCRIPTS - -source ${RECEIVER_BASH_DIRECTORY}/variables.sh -source ${RECEIVER_BASH_DIRECTORY}/functions.sh - -## BEGIN SETUP +source $RECEIVER_BASH_DIRECTORY/variables.sh +source $RECEIVER_BASH_DIRECTORY/functions.sh clear -echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" -echo -e "" -echo -e "\e[92m Setting up the ADS-B Receiver Project Portal..." -echo -e "\e[93m ------------------------------------------------------------------------------\e[96m" -echo -e "" -if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B ADS-B Receiver Project Portal Setup" --yesno "The ADS-B ADS-B Receiver Project Portal adds a web accessable portal to your receiver. The portal contains allows you to view performance graphs, system information, and live maps containing the current aircraft being tracked.\n\nBy enabling the portal's advanced features you can also view historical data on flight that have been seen in the past as well as view more detailed information on each of these aircraft.\n\nTHE ADVANCED PORTAL FEATURES ARE STILL IN DEVELOPMENT\n\nIt is recomended that only those wishing to contribute to the development of these features or those wishing to test out the new features enable them. Do not be surprised if you run into any major bugs after enabling the advanced features at this time!\n\nDo you wish to continue with the ADS-B Receiver Project Portal setup?" 23 78; 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 ADS-B Receiver Project Portal setup halted.\e[39m" - echo -e "" - if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then - read -p "Press enter to continue..." CONTINUE - fi +log_project_title +log_title_heading "Setting up The ADS-B Portal" +log_title_message "------------------------------------------------------------------------------" +if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "The ADS-B Portal Setup" \ + --yesno "The ADS-B Portal adds a web accessable portal to your receiver. The portal contains allows you to view performance graphs, system information, and live maps containing the current aircraft being tracked.\n\nBy enabling the portal's advanced features you can also view historical data on flight that have been seen in the past as well as view more detailed information on each of these aircraft.\n\nTHE ADVANCED PORTAL FEATURES ARE STILL IN DEVELOPMENT\n\nIt is recomended that only those wishing to contribute to the development of these features or those wishing to test out the new features enable them. Do not be surprised if you run into any major bugs after enabling the advanced features at this time!\n\nDo you wish to continue with the ADS-B Receiver Project Portal setup?" \ + 23 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 "The ADS-B Portal setup halted" + echo "" exit 1 fi -## GATHER NEEDED INFORMATION FROM THE USER -# 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 "" -check_package lighttpd +## GATHER REQUIRED INFORMATION -# 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` -LIGHTTPD_DOCUMENT_ROOT=`sed 's/.*"\(.*\)"[^"]*$/\1/' <<< ${RAW_DOCUMENT_ROOT}` +log_heading "Gather information required to configure the portal" -# Check if there is already an existing portal installation. -if [[ -f "${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php" ]] ; then +log_message "Determining if a portal installation exists" +if [[ -f "${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php" ]]; then + log_message "An instance of The ADS-B Portal is installed" RECEIVER_PORTAL_INSTALLED="true" else + log_message "The ADS-B Portal is not installed" RECEIVER_PORTAL_INSTALLED="false" fi -if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" ]] ; then - # Assign needed variables using the driver setting in settings.class.php. +if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" ]]; then + log_message "Gathering information needed to proceed with setup" DATABASEENGINE=`grep 'db_driver' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` - if [[ "${DATABASEENGINE}" = "xml" ]] ; then + if [[ "${DATABASEENGINE}" = "xml" ]]; then + log_message "This is a lite installation of the portal" ADVANCED="false" else + log_message "This is an advanced installation of the portal" ADVANCED="true" fi - if [[ "${ADVANCED}" = "true" ]] ; then + if [[ "${ADVANCED}" = "true" ]]; then case "${DATABASEENGINE}" in - "mysql") DATABASEENGINE="MySQL" ;; - "sqlite") DATABASEENGINE="SQLite" ;; + "mysql") + log_message "The MySQL database engine is being used" + DATABASEENGINE="MySQL" + ;; + "sqlite") + log_message "The SQLite database engine is being used" + DATABASEENGINE="SQLite" + ;; esac DATABASEHOSTNAME=`grep 'db_host' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` DATABASEUSER=`grep 'db_username' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` DATABASEPASSWORD1=`grep 'db_password' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` DATABASENAME=`grep 'db_database' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2` fi - - else - # Ask if advanced features should be enabled. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B Receiver Portal Selection" --defaultno --yesno "NOTE THAT THE ADVANCED FEATURES ARE STILL IN DEVELOPMENT AT THIS TIME\nADVANCED FEATURES SHOULD ONLY BE ENABLED BY DEVELOPERS AND TESTERS ONLY\n\nBy enabling advanced features the portal will log all flights seen as well as the path of the flight. This data is stored in either a MySQL or SQLite database. This will result in a lot more data being stored on your devices hard drive. Keep this and your devices hardware capabilities in mind before selecting to enable these features.\n\nENABLING ADVANCED FEATURES ON DEVICES USING SD CARDS CAN SHORTEN THE LIFE OF THE SD CARD IMMENSELY\n\nDo you wish to enable the portal advanced features?" 19 78 - RESPONSE=$? - case ${RESPONSE} in - 0) ADVANCED="true" ;; - 1) ADVANCED="false" ;; - esac + log_message "Asking if advanced features should be utilized" + if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Portal Type Selection" \ + --defaultno \ + --yesno "NOTE THAT THE ADVANCED FEATURES ARE STILL IN DEVELOPMENT AT THIS TIME\nADVANCED FEATURES SHOULD ONLY BE ENABLED BY DEVELOPERS AND TESTERS ONLY\n\nBy enabling advanced features the portal will log all flights seen as well as the path of the flight. This data is stored in either a MySQL or SQLite database. This will result in a lot more data being stored on your devices hard drive. Keep this and your devices hardware capabilities in mind before selecting to enable these features.\n\nENABLING ADVANCED FEATURES ON DEVICES USING SD CARDS CAN SHORTEN THE LIFE OF THE SD CARD IMMENSELY\n\nDo you wish to enable the portal advanced features?" \ + 19 78; then + log_message "Advanced features will be setup" + ADVANCED="true" + else + log_message "Lite features will be setup" + ADVANCED="false" + fi - if [[ "${ADVANCED}" = "true" ]] ; then - # Ask which type of database to use. - DATABASEENGINE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Choose Database Type" --nocancel --menu "\nChoose which type of database to use." 11 80 2 "MySQL" "" "SQLite" "" 3>&1 1>&2 2>&3) - - if [[ "${DATABASEENGINE}" = "MySQL" ]] ; then - # Ask if the database server will be installed locally. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "MySQL Database Location" --yesno "Will the database be hosted locally on this device?" 7 80 - RESPONSE=$? - case ${RESPONSE} in - 0) LOCALMYSQLSERVER="true" ;; - 1) LOCALMYSQLSERVER="false" ;; - esac - if [[ "${LOCALMYSQLSERVER}" = "false" ]] ; then - # Ask for the remote MySQL servers hostname. - DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname" - while [[ -z "${DATABASEHOSTNAME}" ]] ; do - DATABASEHOSTNAME=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEHOSTNAME_TITLE}" --nocancel --inputbox "\nWhat is the remote MySQL server's hostname?" 10 60 3>&1 1>&2 2>&3) - DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname (REQUIRED)" - done - - # Ask if the remote MySQL database already exists. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Does MySQL Database Exist" --yesno "Has the database already been created?" 7 80 - RESPONSE=$? - case ${RESPONSE} in - 0) DATABASEEXISTS="true" ;; - 1) DATABASEEXISTS="false" ;; - esac + if [[ "${ADVANCED}" = "true" ]]; then + log_message "Asking for the location of the MySQL server" + DATABASEENGINE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Choose Database Type" \ + --nocancel \ + --menu "Choose which database engine to use." 11 80 2 \ + "MySQL" "" "SQLite" "" 3>&1 1>&2 2>&3) + if [[ "${DATABASEENGINE}" = "MySQL" ]]; then + if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "MySQL Database Location" \ + --yesno "Will the database be hosted locally on this device?" \ + 7 80; then + log_message "A local MySQL database server will be used" + LOCALMYSQLSERVER="true" 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 - 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 - echo "" - fi - - # Since this is a local installation assume the MySQL database does not already exist. - DATABASEEXISTS="false" - - # Since the MySQL database server will run locally assign localhost as it's hostname. - DATABASEHOSTNAME="localhost" + log_message "A remote MySQL database server will be used" fi - # Ask for the MySQL administrator credentials if the database does not already exist. - if [[ "${LOCALMYSQLSERVER}" = "true" ]] || [[ "${DATABASEEXISTS}" = "false" ]] ; then - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Create Remote MySQL Database" --msgbox "This script can attempt to create the MySQL database for you.\nYou will now be asked for the credentials for a MySQL user who has the ability to create a database on the MySQL server." 9 78 - DATABASEADMINUSER_TITLE="MySQL Administrator User" - while [[ -z "${DATABASEADMINUSER}" ]] ; do - DATABASEADMINUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINUSER_TITLE}" --nocancel --inputbox "\nEnter the MySQL administrator user." 8 78 "root" 3>&1 1>&2 2>&3) + if [[ "${LOCALMYSQLSERVER}" = "false" ]]; then + log_message "Asking for the remote MySQL server's hostname" + DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname" + while [[ -z "${DATABASEHOSTNAME}" ]]; do + DATABASEHOSTNAME=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEHOSTNAME_TITLE}" \ + --nocancel \ + --inputbox "What is the remote MySQL server's hostname?" \ + 10 60 3>&1 1>&2 2>&3) + DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname (REQUIRED)" + done + log_message "Asking for the database already exists remotly" + if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Does MySQL Database Exist" \ + --yesno "Has the database already been created?" \ + 7 80; then + log_message "The database exists on the remote server" + DATABASEEXISTS="true" + else + log_message "The database does not exist on the remote server" + DATABASEEXISTS="false" + fi + fi + + if [[ "${LOCALMYSQLSERVER}" = "true" || "${DATABASEEXISTS}" = "false" ]]; then + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Create Remote MySQL Database" \ + --msgbox "This script can attempt to create the MySQL database for you.\nYou will now be asked for the credentials for a MySQL user who has the ability to create a database on the MySQL server." \ + 9 78 + + log_message "Asking for the MySQL administrator username" + DATABASEADMINUSER_TITLE="MySQL Administrator Username" + while [[ -z "${DATABASEADMINUSER}" ]]; do + DATABASEADMINUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINUSER_TITLE}" \ + --nocancel \ + --inputbox "Enter the MySQL adminitrator username." \ + 8 78 \ + "root" 3>&1 1>&2 2>&3) DATABASEADMINUSER_TITLE="MySQL Administrator User (REQUIRED)" done + + log_message "Asking for the MySQL administrator password" DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password" - DATABASEADMINPASSWORD1_MESSAGE="\nEnter the password for the MySQL adminitrator user." - while [[ -z "${DATABASEADMINPASSWORD1}" ]] ; do - DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINPASSWORD1_TITLE}" --nocancel --passwordbox "${DATABASEADMINPASSWORD1_MESSAGE}" 8 78 3>&1 1>&2 2>&3) + while [[ -z "${DATABASEADMINPASSWORD1}" ]]; do + DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINPASSWORD1_TITLE}" \ + --nocancel \ + --passwordbox "Enter the password for the MySQL adminitrator user." \ + 8 78 3>&1 1>&2 2>&3) DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)" done + log_message "Asking the user to confirm the MySQL administrator password" DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password" - DATABASEADMINPASSWORD2_MESSAGE="\nConfirm the password for the MySQL adminitrator user." - while [[ -z "${DATABASEADMINPASSWORD2}" ]] ; do - DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINPASSWORD2_TITLE}" --nocancel --passwordbox "${DATABASEADMINPASSWORD2_MESSAGE}" 8 78 3>&1 1>&2 2>&3) + while [[ -z "${DATABASEADMINPASSWORD2}" ]]; do + DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINPASSWORD2_TITLE}" \ + --nocancel \ + --passwordbox "Confirm the password for the MySQL adminitrator user." \ + 8 78 3>&1 1>&2 2>&3) DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)" done - while [[ ! "${DATABASEADMINPASSWORD1}" = "${DATABASEADMINPASSWORD2}" ]] ; do + while [[ ! "${DATABASEADMINPASSWORD1}" = "${DATABASEADMINPASSWORD2}" ]]; do + log_message "The supplied MySQL administrator passwords did not match" DATABASEADMINPASSWORD1="" DATABASEADMINPASSWORD2="" - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Passwords Did Not Match" --msgbox "Passwords did not match.\nPlease enter your password again." 9 78 + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Passwords Did Not Match" \ + --msgbox "Passwords did not match.\nPlease enter the MySQL administrator password again." \ + 9 78 + log_message "Asking for the MySQL administrator password" DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password" - while [[ -z "${DATABASEADMINPASSWORD1}" ]] ; do - DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINPASSWORD1_TITLE}" --nocancel --passwordbox "DATABASEADMINPASSWORD1_MESSAGE" 8 78 3>&1 1>&2 2>&3) + while [[ -z "${DATABASEADMINPASSWORD1}" ]]; do + DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINPASSWORD1_TITLE}" \ + --nocancel \ + --passwordbox "DATABASEADMINPASSWORD1_MESSAGE" \ + 8 78 3>&1 1>&2 2>&3) DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)" done + log_message "Asking the user to confirm the MySQL administrator password" DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password" - while [[ -z "${DATABASEADMINPASSWORD2}" ]] ; do - DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINPASSWORD2_TITLE}" --nocancel --passwordbox "DATABASEADMINPASSWORD2_MESSAGE" 8 78 3>&1 1>&2 2>&3) + while [[ -z "${DATABASEADMINPASSWORD2}" ]]; do + DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINPASSWORD2_TITLE}" \ + --nocancel \ + --passwordbox "DATABASEADMINPASSWORD2_MESSAGE" \ + 8 78 3>&1 1>&2 2>&3) DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)" done done fi - # Get the login information pertaining to the MySQL database itself. - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Create Remote MySQL Database" --msgbox "You will now be asked to supply the name of the database which will store the portal data as well as the login credentials for the MySQL user that has access to this database." 9 78 + log_message "Asking for the name of the ADS-B Portal database" + DATABASENAME_TITLE="The ADS-B Portal Database Name" + while [[ -z "${DATABASENAME}" ]]; do + DATABASENAME=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASENAME_TITLE}" \ + --nocancel \ + --inputbox "Enter your ADS-B Receiver Portal database name." \ + 8 78 3>&1 1>&2 2>&3) + DATABASENAME_TITLE="The ADS-B Portal Database Name (REQUIRED)" + done - DATABASENAME_TITLE="ADS-B Receiver Portal Database Name" - while [[ -z "${DATABASENAME}" ]] ; do - DATABASENAME=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASENAME_TITLE}" --nocancel --inputbox "\nEnter your ADS-B Receiver Portal database name." 8 78 3>&1 1>&2 2>&3) - DATABASENAME_TITLE="ADS-B Receiver Portal Database Name (REQUIRED)" + log_message "Asking for the ADS-B Portal database username" + DATABASEUSER_TITLE="The ADS-B Portal Database User" + while [[ -z "${DATABASEUSER}" ]]; do + DATABASEUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEUSER_TITLE}" \ + --nocancel \ + --inputbox "Enter the user for the ADS-B Receiver Portal database." \ + 8 78 3>&1 1>&2 2>&3) + DATABASEUSER_TITLE="The ADS-B Portal Database User (REQUIRED)" done - DATABASEUSER_TITLE="ADS-B Receiver Portal Database User" - while [[ -z "${DATABASEUSER}" ]] ; do - DATABASEUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEUSER_TITLE}" --nocancel --inputbox "\nEnter the user for the ADS-B Receiver Portal database." 8 78 3>&1 1>&2 2>&3) - DATABASEUSER_TITLE="ADS-B Receiver Portal Database User (REQUIRED)" + + log_message "Asking for the ADS-B Portal database password" + DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password" + while [[ -z "${DATABASEPASSWORD1}" ]]; do + DATABASEPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEPASSWORD1_TITLE}" \ + --nocancel \ + --passwordbox "Enter the ADS-B Portal database password." \ + 8 78 3>&1 1>&2 2>&3) + DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password (REQUIRED)" done - DATABASEPASSWORD1_TITLE="ADS-B Receiver Portal Password" - DATABASEPASSWORD1_MESSAGE="\nEnter your ADS-B Receiver Portal database password." - while [[ -z "${DATABASEPASSWORD1}" ]] ; do - DATABASEPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEPASSWORD1_TITLE}" --nocancel --passwordbox "${DATABASEPASSWORD1_MESSAGE}" 8 78 3>&1 1>&2 2>&3) - DATABASEPASSWORD1_TITLE="ADS-B Receiver Portal Password (REQUIRED)" + log_message "Asking the user to confirm the ADS-B Portal database password" + DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password" + while [[ -z "${DATABASEPASSWORD2}" ]]; do + DATABASEPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEPASSWORD2_TITLE}" \ + --nocancel \ + --passwordbox "Confirm the ADS-B Portal database password." \ + 8 78 3>&1 1>&2 2>&3) + DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password (REQUIRED)" done - DATABASEPASSWORD2_TITLE="Confirm The ADS-B Receiver Portal Password" - DATABASEPASSWORD2_MESSAGE="\nConfirm your ADS-B Receiver Portal database password." - while [[ -z "${DATABASEPASSWORD2}" ]] ; do - DATABASEPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEPASSWORD2_TITLE}" --nocancel --passwordbox "${DATABASEPASSWORD2_MESSAGE}" 8 78 3>&1 1>&2 2>&3) - DATABASEPASSWORD2_TITLE="Confirm The ADS-B Receiver Portal Password (REQUIRED)" - done - while [[ ! "${DATABASEPASSWORD1}" = "${DATABASEPASSWORD2}" ]] ; do + + while [[ ! "${DATABASEPASSWORD1}" = "${DATABASEPASSWORD2}" ]]; do + log_message "The supplied ADS-B Portal database passwords did not match" DATABASEPASSWORD1="" DATABASEPASSWORD2="" - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Passwords Did Not Match" --msgbox "Passwords did not match.\nPlease enter your password again." 9 78 - DATABASEPASSWORD1_TITLE="ADS-B Receiver Portal Password" - while [[ -z "${DATABASEPASSWORD1}" ]] ; do - DATABASEPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEPASSWORD1_TITLE}" --nocancel --passwordbox "${DATABASEPASSWORD1_MESSAGE}" 8 78 3>&1 1>&2 2>&3) - DATABASEPASSWORD1_TITLE="ADS-B Receiver Portal Password (REQUIRED)" + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Passwords Did Not Match" \ + --msgbox "Passwords did not match.\nPlease enter the ADS-B Portal password again." \ + 9 78 + log_message "Asking for the ADS-B Portal database password" + DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password" + while [[ -z "${DATABASEPASSWORD1}" ]]; do + DATABASEPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEPASSWORD1_TITLE}" \ + --nocancel \ + --passwordbox "${DATABASEPASSWORD1_MESSAGE}" \ + 8 78 3>&1 1>&2 2>&3) + DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password (REQUIRED)" done - DATABASEPASSWORD2_TITLE="Confirm The ADS-B Receiver Portal Password" - while [[ -z "${DATABASEPASSWORD2}" ]] ; do - DATABASEPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEPASSWORD2_TITLE}" --nocancel --passwordbox "${DATABASEPASSWORD2_MESSAGE}" 8 78 3>&1 1>&2 2>&3) - DATABASEPASSWORD2_TITLE="Confirm The ADS-B Receiver Portal Password (REQUIRED)" + log_message "Asking the user to confirm the ADS-B Portal database password" + DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password" + while [[ -z "${DATABASEPASSWORD2}" ]]; do + DATABASEPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEPASSWORD2_TITLE}" \ + --nocancel \ + --passwordbox "${DATABASEPASSWORD2_MESSAGE}" \ + 8 78 3>&1 1>&2 2>&3) + DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password (REQUIRED)" done done fi fi fi -## CHECK FOR PREREQUISITE PACKAGES -DISTRO_PHP_VERSION="5" +## INSTALL PREREQUISITE PACAKGES + +if [[ "${LOCALMYSQLSERVER}" = "true" ]]; then + DATABASEEXISTS="false" + DATABASEHOSTNAME="localhost" + + check_package mariadb-server + log_message "Executing the mysql_secure_installation script" + sudo mysql_secure_installation +fi + +check_package collectd-core +check_package rrdtool +check_package libpython3-stdlib + +if [[ "$RECEIVER_MTA" == "POSTFIX" || -z "$RECEIVER_MTA" ]]; then + check_package postfix +fi + case $RECEIVER_OS_DISTRIBUTION in ubuntu) DISTRO_PHP_VERSION="" ;; debian) - if [[ $RECEIVER_OS_CODE_NAME = "bookworm" ]]; then DISTRO_PHP_VERSION="8.2"; fi - if [[ $RECEIVER_OS_CODE_NAME = "bullseye" ]]; then DISTRO_PHP_VERSION="7.4"; fi + if [[ "${RECEIVER_OS_CODE_NAME}" == "bookworm" ]]; then DISTRO_PHP_VERSION="8.2"; fi + if [[ "${RECEIVER_OS_CODE_NAME}" == "bullseye" ]]; then DISTRO_PHP_VERSION="7.4"; fi ;; esac - -# Install PHP. check_package php${DISTRO_PHP_VERSION}-cgi if [[ ! "${DISTRO_PHP_VERSION}" == "" && "${DISTRO_PHP_VERSION}" < "8" ]]; then check_package php${DISTRO_PHP_VERSION}-json fi -# Performance graph dependencies. -check_package collectd-core -check_package rrdtool - -# Portal dependencies. -if [ "$RECEIVER_MTA" == "POSTFIX" ] || [ -z "$RECEIVER_MTA" ]; then - check_package postfix -fi - -check_package libpython3-stdlib - -# Install packages needed for advanced portal setups. -if [[ "${ADVANCED}" = "true" ]] ; then +if [[ "${ADVANCED}" = "true" ]]; then check_package python3-pyinotify check_package python3-apt case "${DATABASEENGINE}" in @@ -245,100 +309,89 @@ if [[ "${ADVANCED}" = "true" ]] ; then ;; "SQLite") check_package sqlite3 - if [ `bc -l <<< "$DISTRO_PHP_VERSION >= 7.0"` -eq 1 ]; then - check_package php${DISTRO_PHP_VERSION}-sqlite3 - else - check_package php${DISTRO_PHP_VERSION}-sqlite - fi + check_package php${DISTRO_PHP_VERSION}-sqlite3 ;; esac else check_package php${DISTRO_PHP_VERSION}-xml fi -# Reload Lighttpd after installing the prerequisite packages. -echo -e "\e[94m Reloading Lighttpd...\e[97m" +log_message "Reloading the Lighttpd server" sudo service lighttpd force-reload echo "" -## SETUP THE PORTAL WEBSITE -echo -e "\e[95m Setting up the web portal...\e[97m" -echo -e "" +## SETUP THE ADS-B PORTAL -# If this is an existing Lite installation being upgraded backup the XML data files. -if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" ]] && [[ "${ADVANCED}" = "false" ]] ; then - echo -e "\e[94m Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.backup.xml - echo -e "\e[94m Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.backup.xml - echo -e "\e[94m Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.backup.xml - echo -e "\e[94m Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.backup.xml - echo -e "\e[94m Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/links.backup.xml - echo -e "\e[94m Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.backup.xml +log_heading "Begining ADS-B Portal setup" + +if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" && "${ADVANCED}" = "false" ]]; then + log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/administrators.xml $LIGHTTPD_DOCUMENT_ROOT/data/administrators.backup.xml + log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.xml $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.backup.xml + log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.xml $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.backup.xml + log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/settings.xml $LIGHTTPD_DOCUMENT_ROOT/data/settings.backup.xml + log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/links.xml $LIGHTTPD_DOCUMENT_ROOT/data/links.backup.xml + log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/notifications.xml $LIGHTTPD_DOCUMENT_ROOT/data/notifications.backup.xml fi -if [ -f ${LIGHTTPD_DOCUMENT_ROOT}/index.lighttpd.html ]; then - echo -e "\e[94m Removing default Lighttpd index file from document root...\e[97m" - sudo rm ${LIGHTTPD_DOCUMENT_ROOT}/index.lighttpd.html +if [ -f $LIGHTTPD_DOCUMENT_ROOT/index.lighttpd.html ]; then + log_message "Removing default Lighttpd index file from document root" + sudo rm $LIGHTTPD_DOCUMENT_ROOT/index.lighttpd.html fi -echo -e "\e[94m Placing portal files in Lighttpd's root directory...\e[97m" -sudo cp -R ${PORTAL_BUILD_DIRECTORY}/html/* ${LIGHTTPD_DOCUMENT_ROOT} +log_message "Placing portal files in Lighttpd's root directory" +sudo cp -R $PORTAL_BUILD_DIRECTORY/html/* $LIGHTTPD_DOCUMENT_ROOT -# If this is an existing installation being upgraded restore the original XML data files. -if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" ]] && [[ "${ADVANCED}" = "false" ]] ; then - echo -e "\e[94m Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.backup.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml - echo -e "\e[94m Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.backup.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml - echo -e "\e[94m Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.backup.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml - echo -e "\e[94m Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.backup.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml - echo -e "\e[94m Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/links.backup.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml - echo -e "\e[94m Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml...\e[97m" - sudo mv ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.backup.xml ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml +if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" && "${ADVANCED}" = "false" ]]; then + log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/administrators.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/administrators.xml + log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.xml + log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.xml + log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/settings.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/settings.xml + log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/links.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/links.xml + log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml" + sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/notifications.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/notifications.xml fi -# Set the proper permissions on certain portal directories. -echo -e "\e[94m Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/graphs/ writable...\e[97m" -sudo chmod 777 ${LIGHTTPD_DOCUMENT_ROOT}/graphs/ -echo -e "\e[94m Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/classes/ writable...\e[97m" -sudo chmod 777 ${LIGHTTPD_DOCUMENT_ROOT}/classes/ -echo -e "\e[94m Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/data/ writable...\e[97m" -sudo chmod 777 ${LIGHTTPD_DOCUMENT_ROOT}/data/ -echo -e "\e[94m Making the files contained within the directory ${LIGHTTPD_DOCUMENT_ROOT}/data/ writable...\e[97m" -sudo chmod 666 ${LIGHTTPD_DOCUMENT_ROOT}/data/* +log_message "Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/graphs/ writable" +sudo chmod 777 $LIGHTTPD_DOCUMENT_ROOT/graphs/ +log_message "Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/classes/ writable" +sudo chmod 777 $LIGHTTPD_DOCUMENT_ROOT/classes/ +log_message "Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/data/ writable" +sudo chmod 777 $LIGHTTPD_DOCUMENT_ROOT/data/ +log_message "Making the files contained within the directory ${LIGHTTPD_DOCUMENT_ROOT}/data/ writable" +sudo chmod 666 $LIGHTTPD_DOCUMENT_ROOT/data/* -# Check if dump978 was setup. -echo -e "\e[94m Checking if dump978 was set up...\e[97m" if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then - # Check if a heywhatsthat.com range file exists in the dump1090 HTML folder. - echo -e "\e[94m Checking for the file upintheair.json in the dump1090 HTML folder...\e[97m" - if [[ -f "/usr/share/dump1090-mutability/html/upintheair.json" ]] || [[ -f "/usr/share/dump1090-fa/html/upintheair.json" ]] ; then - echo -e "\e[94m Copying the file upintheair.json from the dump1090 HTML folder to the dump978 HTML folder...\e[97m" - if [[ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then + log_message "Checking for the file upintheair.json in the dump1090 HTML folder" + if [[ -f "/usr/share/dump1090-mutability/html/upintheair.json" || -f "/usr/share/dump1090-fa/html/upintheair.json" ]]; then + log_message "Copying the file upintheair.json from the dump1090 HTML folder to the dump978 HTML folder" + if [[ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then sudo cp /usr/share/dump1090-mutability/html/upintheair.json ${LIGHTTPD_DOCUMENT_ROOT}/dump978/ fi - if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then + if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then sudo cp /usr/share/dump1090-fa/html/upintheair.json ${LIGHTTPD_DOCUMENT_ROOT}/dump978/ fi fi fi -# Add to the Lighttpd configuration. -echo -e "\e[94m Adding the Lighttpd portal configuration file...\e[97m" if [[ -f "/etc/lighttpd/conf-available/87-adsb-portal.conf" ]] ; then + log_message "Removing the existing Lighttpd ADS-B Portal configuration file" sudo rm -f /etc/lighttpd/conf-available/87-adsb-portal.conf fi +log_message "Adding the Lighttpd portal configuration file" sudo touch /etc/lighttpd/conf-available/87-adsb-portal.conf -if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then +if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then sudo tee -a /etc/lighttpd/conf-available/87-adsb-portal.conf > /dev/null < /dev/null; then - echo -e "\e[94m Reloading Lighttpd...\e[97m" + log_message "Reloading Lighttpd" sudo service lighttpd force-reload else - echo -e "\e[94m Starting Lighttpd...\e[97m" + log_message "Starting Lighttpd" sudo service lighttpd start fi -## SETUP THE MYSQL DATABASE -if [[ "${RECEIVER_PORTAL_INSTALLED}" = "false" ]] && [[ "${ADVANCED}" = "true" ]] && [[ "${DATABASEENGINE}" = "MySQL" ]] && [[ "${DATABASEEXISTS}" = "false" ]] ; then - # If MariaDB is being used we will switch the plugin from unix_socket to mysql_native_password to keep things on the same page as MySQL setups. +## SETUP THE ADS-B PORTAL MYSQL DATABASE + +if [[ "${RECEIVER_PORTAL_INSTALLED}" = "false" && "${ADVANCED}" = "true" && "${DATABASEENGINE}" = "MySQL" && "${DATABASEEXISTS}" = "false" ]]; then if [[ $(dpkg-query -W -f='${STATUS}' mariadb-server-10.1 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then - echo -e "\e[94m Switching the default MySQL plugin from unix_socket to mysql_native_password...\e[97m" + log_message "Switching the default MySQL plugin from unix_socket to mysql_native_password" sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';" - echo -e "\e[94m Flushing privileges on the MySQL (MariaDB) server...\e[97m" + log_message "Flushing privileges on the MySQL (MariaDB) server" sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "FLUSH PRIVILEGES;" - echo -e "\e[94m Reloading MySQL (MariaDB)...\e[97m" + log_message "Reloading MySQL (MariaDB)" sudo service mysql force-reload fi - # Attempt to login with the supplied MySQL administrator credentials. - echo -e "\e[94m Attempting to log into the MySQL server using the supplied administrator credentials...\e[97m" - while ! sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e ";" ; do - echo -e "\e[94m Unable to log into the MySQL server using the supplied administrator credentials...\e[97m" - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Create Remote MySQL Database" --msgbox "The script was not able to log into the MySQL server using the administrator credentials you supplied. You will now be asked to reenter the MySQL server administrator credentials." 9 78 + log_message "Attempting to log into the MySQL server using the supplied administrator credentials" + while ! sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e ";"; do + log_message "Unable to log into the MySQL server using the supplied administrator credentials" + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Create MySQL Database" \ + --msgbox "The script was not able to log into the MySQL server using the administrator credentials you supplied. You will now be asked to reenter the MySQL server administrator credentials." \ + 9 78 DATABASEADMINPASSWORD1="" DATABASEADMINPASSWORD2="" + log_message "Asking for the MySQL administrator username" DATABASEADMINUSER_TITLE="MySQL Administrator User" - while [[ -z "${DATABASEADMINUSER}" ]] ; do - DATABASEADMINUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINUSER_TITLE}" --nocancel --inputbox "\nEnter the MySQL administrator user." 8 78 "${DATABASEADMINUSER}" 3>&1 1>&2 2>&3) + while [[ -z "${DATABASEADMINUSER}" ]]; do + DATABASEADMINUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINUSER_TITLE}" \ + --nocancel \ + --inputbox "Enter the MySQL administrator user." \ + 8 78 \ + "${DATABASEADMINUSER}" 3>&1 1>&2 2>&3) DATABASEADMINUSER_TITLE="MySQL Administrator User (REQUIRED)" done + log_message "Asking for the MySQL administrator password" DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password" - DATABASEADMINPASSWORD1_MESSAGE="\nEnter the password for the MySQL adminitrator user." - while [[ -z "${DATABASEADMINPASSWORD1}" ]] ; do - DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINPASSWORD1_TITLE}" --nocancel --passwordbox "${DATABASEADMINPASSWORD1_MESSAGE}" 8 78 3>&1 1>&2 2>&3) + DATABASEADMINPASSWORD1_MESSAGE="Enter the password for the MySQL adminitrator user." + while [[ -z "${DATABASEADMINPASSWORD1}" ]]; do + DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINPASSWORD1_TITLE}" \ + --nocancel \ + --passwordbox "${DATABASEADMINPASSWORD1_MESSAGE}" \ + 8 78 3>&1 1>&2 2>&3) DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)" done + log_message "Asking to confirm the MySQL administrator password" DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password" DATABASEADMINPASSWORD2_MESSAGE="\nConfirm the password for the MySQL adminitrator user." while [[ -z "${DATABASEADMINPASSWORD2}" ]] ; do - DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINPASSWORD2_TITLE}" --nocancel --passwordbox "${DATABASEADMINPASSWORD2_MESSAGE}" 8 78 3>&1 1>&2 2>&3) + DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINPASSWORD2_TITLE}" \ + --nocancel \ + --passwordbox "${DATABASEADMINPASSWORD2_MESSAGE}" \ + 8 78 3>&1 1>&2 2>&3) DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)" done - while [[ ! "${DATABASEADMINPASSWORD1}" = "${DATABASEADMINPASSWORD2}" ]] ; do + while [[ ! "${DATABASEADMINPASSWORD1}" == "${DATABASEADMINPASSWORD2}" ]]; do + log_message "Failed to log into MySQL using the supplied credentials" DATABASEADMINPASSWORD1="" DATABASEADMINPASSWORD2="" - whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Passwords Did Not Match" --msgbox "Passwords did not match.\nPlease enter your password again." 9 78 + whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Passwords Did Not Match" \ + --msgbox "Passwords did not match.\nPlease enter your password again." \ + 9 78 + log_message "Asking for the MySQL administrator password" DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password" while [[ -z "${DATABASEADMINPASSWORD1}" ]] ; do - DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINPASSWORD1_TITLE}" --nocancel --passwordbox "DATABASEADMINPASSWORD1_MESSAGE" 8 78 3>&1 1>&2 2>&3) + DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINPASSWORD1_TITLE}" \ + --nocancel \ + --passwordbox "DATABASEADMINPASSWORD1_MESSAGE" \ + 8 78 3>&1 1>&2 2>&3) DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)" done + log_message "Asking to confirm the MySQL administrator password" DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password" while [[ -z "${DATABASEADMINPASSWORD2}" ]] ; do - DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DATABASEADMINPASSWORD2_TITLE}" --nocancel --passwordbox "DATABASEADMINPASSWORD2_MESSAGE" 8 78 3>&1 1>&2 2>&3) + DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${DATABASEADMINPASSWORD2_TITLE}" \ + --nocancel \ + --passwordbox "DATABASEADMINPASSWORD2_MESSAGE" \ + 8 78 3>&1 1>&2 2>&3) DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)" done done - echo -e "\e[94m Attempting to log into the MySQL server using the new administrator credentials...\e[97m" + log_message "Attempting to log into the MySQL server using the new administrator credentials" done + log_message "Successfully logged into the MySQL server using the new administrator credentials" - # Create the database use and database using the information supplied by the user. - echo -e "\e[94m Creating the MySQL database \"${DATABASENAME}\"...\e[97m" + log_message "Creating the MySQL database ${DATABASENAME}" sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "CREATE DATABASE ${DATABASENAME};" - echo -e "\e[94m Creating the MySQL user \"${DATABASEUSER}\"...\e[97m" - + log_message "Creating the MySQL user ${DATABASEUSER}" if [[ "${LOCALMYSQLSERVER}" = "false" ]] ; then - # If the databse resides on a remote server be sure to allow the newly created user access to it remotly. sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "CREATE USER '${DATABASEUSER}'@'%' IDENTIFIED BY \"${DATABASEPASSWORD1}\";" else - # Since this is a local database we will restrict this login to localhost logins only. sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "CREATE USER '${DATABASEUSER}'@'localhost' IDENTIFIED BY \"${DATABASEPASSWORD1}\";" fi - echo -e "\e[94m Granting priviledges on the MySQL database \"DATABASENAME\" to the user \"${DATABASEUSER}\"...\e[97m" + log_message "Granting priviledges on the MySQL database ${DATABASENAME} to the user ${DATABASEUSER}" sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "GRANT ALL PRIVILEGES ON ${DATABASENAME}.* TO '${DATABASEUSER}'@'localhost';" - echo -e "\e[94m Flushing priviledges on the MySQL database server...\e[97m" + log_message "Flushing priviledges on the MySQL database server" sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "FLUSH PRIVILEGES;" fi + ## SETUP THE PERFORMANCE GRAPHS USING THE SCRIPT GRAPHS.SH -chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/graphs.sh -${RECEIVER_BASH_DIRECTORY}/portal/graphs.sh +chmod +x $RECEIVER_BASH_DIRECTORY/portal/graphs.sh +$RECEIVER_BASH_DIRECTORY/portal/graphs.sh if [[ $? -ne 0 ]] ; then - echo -e "" - echo -e "\e[91m THE SCRIPT GRAPHS.SH ENCOUNTERED AN ERROR" - echo -e "" + echo "" + log_alert_message "THE SCRIPT GRAPHS.SH ENCOUNTERED AN ERROR" + echo "" exit 1 fi + ## SETUP COMMON PORTAL FEATURES -# Export variables needed by logging.sh. if [ "${DATABASEENGINE}" = "MySQL" ]; then export ADSB_DATABASEENGINE=${DATABASEENGINE} export ADSB_DATABASEHOSTNAME=${DATABASEHOSTNAME} @@ -493,56 +575,55 @@ else export ADSB_DATABASENAME="" fi -# Execute the core setup script. chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/core.sh ${RECEIVER_BASH_DIRECTORY}/portal/core.sh if [[ $? -ne 0 ]] ; then - echo -e "" - echo -e " \e[91m THE SCRIPT CORE.SH ENCOUNTERED AN ERROR" - echo -e "" + echo "" + log_alert_message "THE SCRIPT CORE.SH ENCOUNTERED AN ERROR" + echo "" exit 1 fi + ## SETUP ADVANCED PORTAL FEATURES if [ "${ADVANCED}" = "true" ] ; then chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/logging.sh ${RECEIVER_BASH_DIRECTORY}/portal/logging.sh if [[ $? -ne 0 ]] ; then - echo -e "" - echo -e " \e[91m THE SCRIPT LOGGING.SH ENCOUNTERED AN ERROR" - echo -e "" + echo "" + log_alert_message "THE SCRIPT LOGGING.SH ENCOUNTERED AN ERROR" + echo "" exit 1 fi fi -# Remove exported variables that are no longer needed. + +## POST INSTALLATION OPERATIONS + unset ADSB_DATABASEENGINE unset ADSB_DATABASEHOSTNAME unset ADSB_DATABASEUSER unset ADSB_DATABASEPASSWORD1 unset ADSB_DATABASENAME -## ADS-B RECEIVER PROJECT PORTAL SETUP COMPLETE - -# This assigns the first IP address in the list to the $IPADDRESS variable. IPADDRESS=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` -# Display final portal setup instructions to the user. -whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "ADS-B Receiver Project Portal Setup" --msgbox "NOTE THAT PORTAL SETUP IS NOT YET COMPLETE!\n\nIn order to complete the portal setup process visit the following URL in your favorite web browser.\n\nhttp://${IPADDRESS}/install/\n\nFollow the instructions and enter the requested information to complete the ADS-B Receiver Project Portal setup." 12 78 +whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "ADS-B Receiver Project Portal Setup" \ + --msgbox "NOTE THAT PORTAL SETUP IS NOT YET COMPLETE!\n\nIn order to complete the portal setup process visit the following URL in your favorite web browser.\n\nhttp://${IPADDRESS}/install/\n\nFollow the instructions and enter the requested information to complete the ADS-B Receiver Project Portal setup." \ + 12 78 -### 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 -echo -e "" -echo -e "\e[93m ------------------------------------------------------------------------------" -echo -e "\e[92m ADS-B Receiver Project Portal setup is complete.\e[39m" -echo -e "" -if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then - read -p "Press enter to continue..." CONTINUE -fi +log_message "Returning to ${RECEIVER_PROJECT_TITLE} root directory" +cd $RECEIVER_ROOT_DIRECTORY + +echo "" +log_title_message "------------------------------------------------------------------------------" +log_title_heading "The ADS-B Portal setup is complete" +echo "" +read -p "Press enter to continue..." discard exit 0 From 67e24fc5e540cbfe75f8b99c1c6d5153a102123e Mon Sep 17 00:00:00 2001 From: jprochazka Date: Thu, 8 Aug 2024 12:55:00 -0400 Subject: [PATCH 16/18] ACARS portal fixes. --- CHANGELOG.md | 1 + bash/decoders/acarsdec.sh | 12 ++++++++++++ bash/functions.sh | 2 +- bash/portal/install.sh | 13 ++++++++++++- build/portal/html/acars.php | 3 ++- build/portal/html/classes/acars.class.php | 17 +++++------------ 6 files changed, 33 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a700b0..ee256c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The following is a history of the changes made to this project. * Added the ability to reconfigure, rebuild, and reinstall both dump1090-fa and dump978.fa. * Decoder scripts now ask for device assignments when additional decoders are being installed. * Added "Contributors" to the copyright notice in the software license. +* Had to remove logging of check_package output due to whiptail issue encountered with pipe. ## v2.8.5 *(July 23rd, 2024)* diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh index 5c147d4..56ee911 100755 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -200,6 +200,18 @@ check_package libxml2-dev check_package pkg-config check_package zlib1g-dev +case $RECEIVER_OS_DISTRIBUTION in + ubuntu) + distro_php_version="" + ;; + debian) + if [[ "${RECEIVER_OS_CODE_NAME}" == "bookworm" ]]; then distro_php_version="8.2"; fi + if [[ "${RECEIVER_OS_CODE_NAME}" == "bullseye" ]]; then distro_php_version="7.4"; fi + ;; +esac +check_package sqlite3 +check_package php${distro_php_version}-sqlite3 + case "${device}" in "RTL-SDR") check_package librtlsdr-dev diff --git a/bash/functions.sh b/bash/functions.sh index 4b8c2dd..43bb101 100755 --- a/bash/functions.sh +++ b/bash/functions.sh @@ -118,7 +118,7 @@ function check_package() { fi echo "" attempt=$((attempt+1)) - sudo apt-get install -y $1 2>&1 | tee -a $RECEIVER_LOG_FILE + sudo apt-get install -y $1 #2>&1 | tee -a $RECEIVER_LOG_FILE echo "" else log_true_inline "[OK]" diff --git a/bash/portal/install.sh b/bash/portal/install.sh index be29fea..b48ad02 100755 --- a/bash/portal/install.sh +++ b/bash/portal/install.sh @@ -24,6 +24,17 @@ if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ fi +## INSTALL LIGHTTPD IF IT IS NOT ALREADY INSTALLED + +log_heading "Installing Lighttpd if not already installed" + +check_package lighttpd + +log_message "Determining the lighttpd document root" +RAW_DOCUMENT_ROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root` +LIGHTTPD_DOCUMENT_ROOT=`sed 's/.*"\(.*\)"[^"]*$/\1/' <<< ${RAW_DOCUMENT_ROOT}` + + ## GATHER REQUIRED INFORMATION log_heading "Gather information required to configure the portal" @@ -346,7 +357,7 @@ if [ -f $LIGHTTPD_DOCUMENT_ROOT/index.lighttpd.html ]; then fi log_message "Placing portal files in Lighttpd's root directory" -sudo cp -R $PORTAL_BUILD_DIRECTORY/html/* $LIGHTTPD_DOCUMENT_ROOT +sudo cp -R $RECEIVER_BUILD_DIRECTORY/portal//html/* $LIGHTTPD_DOCUMENT_ROOT if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" && "${ADVANCED}" = "false" ]]; then log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml" diff --git a/build/portal/html/acars.php b/build/portal/html/acars.php index bb05aaf..bbb9e3d 100644 --- a/build/portal/html/acars.php +++ b/build/portal/html/acars.php @@ -9,6 +9,7 @@ $common = new common(); $template = new template(); + $acars = new acars(); $pageData = array(); @@ -19,4 +20,4 @@ $acarsMessages = $acars->getAcarsMessages(25, 0); $template->display($pageData); -?> \ No newline at end of file +?> diff --git a/build/portal/html/classes/acars.class.php b/build/portal/html/classes/acars.class.php index 5ec94e8..9d78fca 100644 --- a/build/portal/html/classes/acars.class.php +++ b/build/portal/html/classes/acars.class.php @@ -2,20 +2,12 @@ class acars { function getAcarsMessages($limit = 100, $offset = 0) { - require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php"); - $settings = new settings(); - require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php"); $common = new common(); - $dsn = "sqlite:".$settings::acarsserv_database; - $dbh = new PDO($dsn); - $sql = " - SELECT * FROM Messages - JOIN Flights USING(FlightID) - JOIN Stations USING(StID) - ORDER BY LastTime DESC LIMIT 100 OFFSET 0 - "; + $dsn = "sqlite:".$common->getSetting('acarsserv_database'); + $dbh = new PDO($dsn, null, null, [PDO::SQLITE_ATTR_OPEN_FLAGS => PDO::SQLITE_OPEN_READONLY]); + $sql = "SELECT * FROM Messages JOIN Flights USING(FlightID) JOIN Stations USING(StID) ORDER BY LastTime DESC LIMIT :limit OFFSET :offset"; $sth = $dbh->prepare($sql); $sth->bindValue(':limit', $limit); $sth->bindValue(':offset', $offset); @@ -23,8 +15,9 @@ $acarsMessages = $sth->fetchAll(PDO::FETCH_ASSOC); $sth = NULL; $dbh = NULL; + $dsn = NULL; return $acarsMessages; } } -?> \ No newline at end of file +?> From 6f8c727cedbd61e979bbacbb1b264fe8b0ad4032 Mon Sep 17 00:00:00 2001 From: jprochazka Date: Mon, 12 Aug 2024 11:52:25 -0400 Subject: [PATCH 17/18] ACARS display fixes. --- bash/decoders/acarsdec.sh | 8 ++++---- build/portal/html/acars.php | 11 ++++++++++- build/portal/html/classes/acars.class.php | 17 +++++++++++++++++ build/portal/html/templates/default/acars.tpl | 9 +++++++-- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/bash/decoders/acarsdec.sh b/bash/decoders/acarsdec.sh index 56ee911..f61fa57 100755 --- a/bash/decoders/acarsdec.sh +++ b/bash/decoders/acarsdec.sh @@ -87,7 +87,7 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr while [[ -z $adsb_device_number ]] ; do adsb_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ --title "${adsb_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your ADS-B decoder." \ + --inputbox "Enter the RTL-SDR device number to assign your ADS-B decoder." \ 8 78 \ "${current_adsb_device_number}" 3>&1 1>&2 2>&3) exit_status=$? @@ -112,7 +112,7 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr while [[ -z $uat_device_number ]] ; do uat_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ --title "${uat_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your UAT decoder." \ + --inputbox "Enter the RTL-SDR device number to assign your UAT decoder." \ 8 78 \ "${current_uat_device_number}" 3>&1 1>&2 2>&3) exit_status=$? @@ -139,7 +139,7 @@ if [[ "${adsb_decoder_installed}" == "true" || "${uat_decoder_installed}" == "tr while [[ -z $acars_device_number ]]; do acars_device_number=$(whiptail --backtitle "ACARSDEC Decoder Configuration" \ --title "${acars_device_number_title}" \ - --inputbox "\nEnter the RTL-SDR device number to assign your ACARSDEC decoder." \ + --inputbox "Enter the RTL-SDR device number to assign your ACARSDEC decoder." \ 8 78 \ "${current_acars_device_number}" 3>&1 1>&2 2>&3) exit_status=$? @@ -159,7 +159,7 @@ if [[ -z $acars_device_number ]]; then acars_device_number="0" fi -current_acars_frequencies="" +current_acars_frequencies="130.025 130.425 130.450 131.125 131.550" if [[ "${acars_decoder_installed}" == "true" ]]; then log_message "Determining which frequencies are currently assigned" exec_start=`get_config "ExecStart" "/etc/systemd/system/acarsdec.service"` diff --git a/build/portal/html/acars.php b/build/portal/html/acars.php index bbb9e3d..ae211c3 100644 --- a/build/portal/html/acars.php +++ b/build/portal/html/acars.php @@ -16,8 +16,17 @@ // The title of this page. $pageData['title'] = "ACARS Messages"; + // Pagination. + $items_per_page = 15; + $page = (isset($_GET['page']) ? $_GET['page'] : 1); + $message_count = $acars->getAcarsMessageCount(); + // Get most recent ACARS messages. - $acarsMessages = $acars->getAcarsMessages(25, 0); + $messages = $acars->getAcarsMessages($items_per_page, ($items_per_page * $page)); + $pageData['acarsMessages'] = $messages; + + // Calculate the number of pagination links to show. + $pageData['pageLinks'] = ceil($message_count / $items_per_page); $template->display($pageData); ?> diff --git a/build/portal/html/classes/acars.class.php b/build/portal/html/classes/acars.class.php index 9d78fca..2b6083b 100644 --- a/build/portal/html/classes/acars.class.php +++ b/build/portal/html/classes/acars.class.php @@ -19,5 +19,22 @@ return $acarsMessages; } + + function getAcarsMessageCount() { + require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php"); + $common = new common(); + + $dsn = "sqlite:".$common->getSetting('acarsserv_database'); + $dbh = new PDO($dsn, null, null, [PDO::SQLITE_ATTR_OPEN_FLAGS => PDO::SQLITE_OPEN_READONLY]); + $sql = "SELECT COUNT(*) FROM Messages"; + $sth = $dbh->prepare($sql); + $sth->execute(); + $number_of_rows = $sth->fetchColumn(); + $sth = NULL; + $dbh = NULL; + $dsn = NULL; + + return $number_of_rows; + } } ?> diff --git a/build/portal/html/templates/default/acars.tpl b/build/portal/html/templates/default/acars.tpl index 25be8da..e85e538 100644 --- a/build/portal/html/templates/default/acars.tpl +++ b/build/portal/html/templates/default/acars.tpl @@ -4,7 +4,7 @@

ACARS Messages


{foreach page:acarsMessages as message} -

{message->FlightNumber}

+

{message->FlightNumber}

Aircarft Registration: {message->Registration}
The first message was received on {message->StartTime} with the last seen {message->LastTime}.
@@ -26,8 +26,13 @@

{/foreach} +
    + {for pageNumber eq 1 to page:pageLinks} +
  • {pageNumber}
  • + {/for} +
{/area} {area:scripts} -{/area} \ No newline at end of file +{/area} From b73b8ea016767612a65f0261e5c85b11e0089682 Mon Sep 17 00:00:00 2001 From: jprochazka Date: Tue, 13 Aug 2024 12:27:56 -0400 Subject: [PATCH 18/18] Script clean up. --- .gitignore | 1 + CHANGELOG.md | 6 +- bash/decoders/dump1090-fa.sh | 3 - bash/decoders/dump978-fa.sh | 3 - bash/portal/core.sh | 64 +---- bash/portal/graphs.sh | 31 -- bash/portal/install.sh | 536 +++++++++++++++++------------------ bash/portal/logging.sh | 7 +- 8 files changed, 287 insertions(+), 364 deletions(-) diff --git a/.gitignore b/.gitignore index 9336596..7d35a54 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ build/libacars build/piaware_builder build/planefinder build/package-archive +build/portal/graphs/__pycache__/ logs diff --git a/CHANGELOG.md b/CHANGELOG.md index ee256c4..e887185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,10 @@ The following is a history of the changes made to this project. -## v2.8.6 *(in development)* +## v2.8.6 *(August 13th, 2024)* -* The option to install ACARSDEC and ACARSERV is now available as a decoder option. -* ACARS data can be viewed via the existing PHP portal has been added. +* The option to install ACARSDEC and ACARSSERV is now available as a decoder option. +* ACARS data stored by ACARSSERV can be viewed via the existing PHP portal. * Added the ability to reconfigure, rebuild, and reinstall both dump1090-fa and dump978.fa. * Decoder scripts now ask for device assignments when additional decoders are being installed. * Added "Contributors" to the copyright notice in the software license. diff --git a/bash/decoders/dump1090-fa.sh b/bash/decoders/dump1090-fa.sh index a021f0f..d2feb2b 100755 --- a/bash/decoders/dump1090-fa.sh +++ b/bash/decoders/dump1090-fa.sh @@ -5,9 +5,6 @@ source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear log_project_title log_title_heading "Setting up the FlightAware Dump1090 decoder" diff --git a/bash/decoders/dump978-fa.sh b/bash/decoders/dump978-fa.sh index 6abe20a..e78235b 100755 --- a/bash/decoders/dump978-fa.sh +++ b/bash/decoders/dump978-fa.sh @@ -5,9 +5,6 @@ source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/functions.sh - -## BEGIN SETUP - clear log_project_title log_title_heading "Setting up the FlightAware Dump978 decoder" diff --git a/bash/portal/core.sh b/bash/portal/core.sh index c339623..d483195 100755 --- a/bash/portal/core.sh +++ b/bash/portal/core.sh @@ -1,79 +1,41 @@ #!/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-2024 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 PORTAL_BUILD_DIRECTORY="${RECEIVER_BUILD_DIRECTORY}/portal" PORTAL_PYTHON_DIRECTORY="${PORTAL_BUILD_DIRECTORY}/python" -DATABASEENGINE=${ADSB_DATABASEENGINE} -DATABASEHOSTNAME=${ADSB_DATABASEHOSTNAME} -DATABASEUSER=${ADSB_DATABASEUSER} -DATABASEPASSWORD1=${ADSB_DATABASEPASSWORD1} -DATABASENAME=${ADSB_DATABASENAME} ## SETUP FLIGHT LOGGING -echo -e "" -echo -e "\e[95m Setting up core advanced portal features...\e[97m" -echo -e "" +log_heading "Setting up core advanced portal features" -case ${DATABASEENGINE} in +case $ADSB_PORTAL_DATABASE_ENGINE in "MySQL") - echo -e "\e[94m Creating the flight Python configuration file for MySQL...\e[97m" + log_message "Creating the flight Python configuration file for MySQL" tee ${PORTAL_PYTHON_DIRECTORY}/config.json > /dev/null < /dev/null <&1 1>&2 2>&3) - if [[ "${DATABASEENGINE}" = "MySQL" ]]; then + database_engine=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "Choose Database Type" \ + --nocancel \ + --menu "Choose which database engine to use." 11 80 2 \ + "MySQL" "" "SQLite" "" 3>&1 1>&2 2>&3) + if [[ "${database_engine}" = "MySQL" ]]; then if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "MySQL Database Location" \ --yesno "Will the database be hosted locally on this device?" \ 7 80; then log_message "A local MySQL database server will be used" - LOCALMYSQLSERVER="true" + local_mysql_server="true" else log_message "A remote MySQL database server will be used" fi - if [[ "${LOCALMYSQLSERVER}" = "false" ]]; then + if [[ "${local_mysql_server}" = "false" ]]; then log_message "Asking for the remote MySQL server's hostname" - DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname" - while [[ -z "${DATABASEHOSTNAME}" ]]; do - DATABASEHOSTNAME=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEHOSTNAME_TITLE}" \ - --nocancel \ - --inputbox "What is the remote MySQL server's hostname?" \ - 10 60 3>&1 1>&2 2>&3) - DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname (REQUIRED)" + database_hostname_title="MySQL Database Server Hostname" + while [[ -z $database_hostname ]]; do + database_hostname=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_hostname_title}" \ + --nocancel \ + --inputbox "What is the remote MySQL server's hostname?" \ + 10 60 3>&1 1>&2 2>&3) + database_hostname_title="MySQL Database Server Hostname (REQUIRED)" done log_message "Asking for the database already exists remotly" if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ @@ -123,152 +123,152 @@ else --yesno "Has the database already been created?" \ 7 80; then log_message "The database exists on the remote server" - DATABASEEXISTS="true" + database_exists="true" else log_message "The database does not exist on the remote server" - DATABASEEXISTS="false" + database_exists="false" fi fi - if [[ "${LOCALMYSQLSERVER}" = "true" || "${DATABASEEXISTS}" = "false" ]]; then + if [[ "${local_mysql_server}" = "true" || "${database_exists}" = "false" ]]; then whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "Create Remote MySQL Database" \ --msgbox "This script can attempt to create the MySQL database for you.\nYou will now be asked for the credentials for a MySQL user who has the ability to create a database on the MySQL server." \ 9 78 log_message "Asking for the MySQL administrator username" - DATABASEADMINUSER_TITLE="MySQL Administrator Username" - while [[ -z "${DATABASEADMINUSER}" ]]; do - DATABASEADMINUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINUSER_TITLE}" \ + database_admin_user_title="MySQL Administrator Username" + while [[ -z $database_admin_user ]]; do + database_admin_user=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_user_title}" \ --nocancel \ --inputbox "Enter the MySQL adminitrator username." \ 8 78 \ "root" 3>&1 1>&2 2>&3) - DATABASEADMINUSER_TITLE="MySQL Administrator User (REQUIRED)" + database_admin_user_title="MySQL Administrator User (REQUIRED)" done log_message "Asking for the MySQL administrator password" - DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password" - while [[ -z "${DATABASEADMINPASSWORD1}" ]]; do - DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINPASSWORD1_TITLE}" \ + database_admin_password1_title="MySQL Administrator Password" + while [[ -z $database_admin_password1 ]]; do + database_admin_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_password1_title}" \ --nocancel \ --passwordbox "Enter the password for the MySQL adminitrator user." \ 8 78 3>&1 1>&2 2>&3) - DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)" + database_admin_password1_title="MySQL Administrator Password (REQUIRED)" done log_message "Asking the user to confirm the MySQL administrator password" - DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password" - while [[ -z "${DATABASEADMINPASSWORD2}" ]]; do - DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINPASSWORD2_TITLE}" \ - --nocancel \ - --passwordbox "Confirm the password for the MySQL adminitrator user." \ - 8 78 3>&1 1>&2 2>&3) - DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)" + database_admin_password2_title="Confirm The MySQL Administrator Password" + while [[ -z $database_admin_password2 ]]; do + database_admin_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_password2_title}" \ + --nocancel \ + --passwordbox "Confirm the password for the MySQL adminitrator user." \ + 8 78 3>&1 1>&2 2>&3) + database_admin_password2_title="Confirm The MySQL Administrator Password (REQUIRED)" done - while [[ ! "${DATABASEADMINPASSWORD1}" = "${DATABASEADMINPASSWORD2}" ]]; do + while [[ ! "${database_admin_password1}" = "${database_admin_password2}" ]]; do log_message "The supplied MySQL administrator passwords did not match" - DATABASEADMINPASSWORD1="" - DATABASEADMINPASSWORD2="" + database_admin_password1="" + database_admin_password2="" whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "Passwords Did Not Match" \ --msgbox "Passwords did not match.\nPlease enter the MySQL administrator password again." \ 9 78 log_message "Asking for the MySQL administrator password" - DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password" - while [[ -z "${DATABASEADMINPASSWORD1}" ]]; do - DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINPASSWORD1_TITLE}" \ + database_admin_password1_title="MySQL Administrator Password" + while [[ -z $database_admin_password1 ]]; do + database_admin_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_password1_title}" \ --nocancel \ - --passwordbox "DATABASEADMINPASSWORD1_MESSAGE" \ + --passwordbox "Enter the password for the MySQL adminitrator user." \ 8 78 3>&1 1>&2 2>&3) - DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)" + database_admin_password1_title="MySQL Administrator Password (REQUIRED)" done log_message "Asking the user to confirm the MySQL administrator password" - DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password" - while [[ -z "${DATABASEADMINPASSWORD2}" ]]; do - DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINPASSWORD2_TITLE}" \ - --nocancel \ - --passwordbox "DATABASEADMINPASSWORD2_MESSAGE" \ - 8 78 3>&1 1>&2 2>&3) - DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)" + database_admin_password2_title="Confirm The MySQL Administrator Password" + while [[ -z $database_admin_password2 ]]; do + database_admin_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_password2_title}" \ + --nocancel \ + --passwordbox "Confirm the password for the MySQL adminitrator user." \ + 8 78 3>&1 1>&2 2>&3) + database_admin_password2_title="Confirm The MySQL Administrator Password (REQUIRED)" done done fi log_message "Asking for the name of the ADS-B Portal database" - DATABASENAME_TITLE="The ADS-B Portal Database Name" - while [[ -z "${DATABASENAME}" ]]; do - DATABASENAME=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASENAME_TITLE}" \ - --nocancel \ - --inputbox "Enter your ADS-B Receiver Portal database name." \ - 8 78 3>&1 1>&2 2>&3) - DATABASENAME_TITLE="The ADS-B Portal Database Name (REQUIRED)" + database_name_title="The ADS-B Portal Database Name" + while [[ -z $database_name ]]; do + database_name=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_name_title}" \ + --nocancel \ + --inputbox "Enter your ADS-B Receiver Portal database name." \ + 8 78 3>&1 1>&2 2>&3) + database_name_title="The ADS-B Portal Database Name (REQUIRED)" done log_message "Asking for the ADS-B Portal database username" - DATABASEUSER_TITLE="The ADS-B Portal Database User" - while [[ -z "${DATABASEUSER}" ]]; do - DATABASEUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEUSER_TITLE}" \ - --nocancel \ - --inputbox "Enter the user for the ADS-B Receiver Portal database." \ - 8 78 3>&1 1>&2 2>&3) - DATABASEUSER_TITLE="The ADS-B Portal Database User (REQUIRED)" + database_user_title="The ADS-B Portal Database User" + while [[ -z $database_user ]]; do + database_user=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_user_title}" \ + --nocancel \ + --inputbox "Enter the user for the ADS-B Receiver Portal database." \ + 8 78 3>&1 1>&2 2>&3) + database_user_title="The ADS-B Portal Database User (REQUIRED)" done log_message "Asking for the ADS-B Portal database password" - DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password" - while [[ -z "${DATABASEPASSWORD1}" ]]; do - DATABASEPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEPASSWORD1_TITLE}" \ - --nocancel \ - --passwordbox "Enter the ADS-B Portal database password." \ - 8 78 3>&1 1>&2 2>&3) - DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password (REQUIRED)" + database_password1_title="The ADS-B Portal Database Password" + while [[ -z $database_password1 ]]; do + database_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_password1_title}" \ + --nocancel \ + --passwordbox "Enter the ADS-B Portal database password." \ + 8 78 3>&1 1>&2 2>&3) + database_password1_title="The ADS-B Portal Database Password (REQUIRED)" done log_message "Asking the user to confirm the ADS-B Portal database password" - DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password" - while [[ -z "${DATABASEPASSWORD2}" ]]; do - DATABASEPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEPASSWORD2_TITLE}" \ - --nocancel \ - --passwordbox "Confirm the ADS-B Portal database password." \ - 8 78 3>&1 1>&2 2>&3) - DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password (REQUIRED)" + database_password2_title="Confirm The ADS-B Portal Database Password" + while [[ -z database_password2 ]]; do + database_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_password2_title}" \ + --nocancel \ + --passwordbox "Confirm the ADS-B Portal database password." \ + 8 78 3>&1 1>&2 2>&3) + database_password2_title="Confirm The ADS-B Portal Database Password (REQUIRED)" done - while [[ ! "${DATABASEPASSWORD1}" = "${DATABASEPASSWORD2}" ]]; do + while [[ ! "${database_password1}" = "${database_password2}" ]]; do log_message "The supplied ADS-B Portal database passwords did not match" - DATABASEPASSWORD1="" - DATABASEPASSWORD2="" + database_password1="" + database_password2="" whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "Passwords Did Not Match" \ --msgbox "Passwords did not match.\nPlease enter the ADS-B Portal password again." \ 9 78 log_message "Asking for the ADS-B Portal database password" - DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password" - while [[ -z "${DATABASEPASSWORD1}" ]]; do - DATABASEPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEPASSWORD1_TITLE}" \ - --nocancel \ - --passwordbox "${DATABASEPASSWORD1_MESSAGE}" \ - 8 78 3>&1 1>&2 2>&3) - DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password (REQUIRED)" + database_password1_title="The ADS-B Portal Database Password" + while [[ -z $database_password1 ]]; do + database_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_password1_title}" \ + --nocancel \ + --passwordbox "Enter the ADS-B Portal database password." \ + 8 78 3>&1 1>&2 2>&3) + database_password1_title="The ADS-B Portal Database Password (REQUIRED)" done log_message "Asking the user to confirm the ADS-B Portal database password" - DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password" - while [[ -z "${DATABASEPASSWORD2}" ]]; do - DATABASEPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEPASSWORD2_TITLE}" \ - --nocancel \ - --passwordbox "${DATABASEPASSWORD2_MESSAGE}" \ - 8 78 3>&1 1>&2 2>&3) - DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password (REQUIRED)" + database_password2_title="Confirm The ADS-B Portal Database Password" + while [[ -z $database_password2 ]]; do + database_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_password2_title}" \ + --nocancel \ + --passwordbox "Confirm the ADS-B Portal database password." \ + 8 78 3>&1 1>&2 2>&3) + database_password2_title="Confirm The ADS-B Portal Database Password (REQUIRED)" done done fi @@ -278,9 +278,9 @@ fi ## INSTALL PREREQUISITE PACAKGES -if [[ "${LOCALMYSQLSERVER}" = "true" ]]; then - DATABASEEXISTS="false" - DATABASEHOSTNAME="localhost" +if [[ "${local_mysql_server}" = "true" ]]; then + database_exists="false" + database_hostname="localhost" check_package mariadb-server log_message "Executing the mysql_secure_installation script" @@ -297,34 +297,34 @@ fi case $RECEIVER_OS_DISTRIBUTION in ubuntu) - DISTRO_PHP_VERSION="" + php_version="" ;; debian) - if [[ "${RECEIVER_OS_CODE_NAME}" == "bookworm" ]]; then DISTRO_PHP_VERSION="8.2"; fi - if [[ "${RECEIVER_OS_CODE_NAME}" == "bullseye" ]]; then DISTRO_PHP_VERSION="7.4"; fi + if [[ "${RECEIVER_OS_CODE_NAME}" == "bookworm" ]]; then php_version="8.2"; fi + if [[ "${RECEIVER_OS_CODE_NAME}" == "bullseye" ]]; then php_version="7.4"; fi ;; esac -check_package php${DISTRO_PHP_VERSION}-cgi -if [[ ! "${DISTRO_PHP_VERSION}" == "" && "${DISTRO_PHP_VERSION}" < "8" ]]; then - check_package php${DISTRO_PHP_VERSION}-json +check_package php${php_version}-cgi +if [[ ! "${php_version}" == "" && "${php_version}" < "8" ]]; then + check_package php${php_version}-json fi -if [[ "${ADVANCED}" = "true" ]]; then +if [[ "${advanced_installation}" = "true" ]]; then check_package python3-pyinotify check_package python3-apt - case "${DATABASEENGINE}" in + case "${database_engine}" in "MySQL") check_package mariadb-client check_package python3-mysqldb - check_package php${DISTRO_PHP_VERSION}-mysql + check_package php${php_version}-mysql ;; "SQLite") check_package sqlite3 - check_package php${DISTRO_PHP_VERSION}-sqlite3 + check_package php${php_version}-sqlite3 ;; esac else - check_package php${DISTRO_PHP_VERSION}-xml + check_package php${php_version}-xml fi log_message "Reloading the Lighttpd server" @@ -336,62 +336,62 @@ echo "" log_heading "Begining ADS-B Portal setup" -if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" && "${ADVANCED}" = "false" ]]; then - log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/administrators.xml $LIGHTTPD_DOCUMENT_ROOT/data/administrators.backup.xml - log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.xml $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.backup.xml - log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.xml $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.backup.xml - log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/settings.xml $LIGHTTPD_DOCUMENT_ROOT/data/settings.backup.xml - log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/links.xml $LIGHTTPD_DOCUMENT_ROOT/data/links.backup.xml - log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/notifications.xml $LIGHTTPD_DOCUMENT_ROOT/data/notifications.backup.xml +if [[ "${portal_installed}" = "true" && "${advanced_installation}" = "false" ]]; then + log_message "Backing up the file ${lighttpd_document_root}/data/administrators.xml" + sudo mv $lighttpd_document_root/data/administrators.xml $lighttpd_document_root/data/administrators.backup.xml + log_message "Backing up the file ${lighttpd_document_root}/data/blogPosts.xml" + sudo mv $lighttpd_document_root/data/blogPosts.xml $lighttpd_document_root/data/blogPosts.backup.xml + log_message "Backing up the file ${lighttpd_document_root}/data/flightNotifications.xml" + sudo mv $lighttpd_document_root/data/flightNotifications.xml $lighttpd_document_root/data/flightNotifications.backup.xml + log_message "Backing up the file ${lighttpd_document_root}/data/settings.xml" + sudo mv $lighttpd_document_root/data/settings.xml $lighttpd_document_root/data/settings.backup.xml + log_message "Backing up the file ${lighttpd_document_root}/data/links.xml" + sudo mv $lighttpd_document_root/data/links.xml $lighttpd_document_root/data/links.backup.xml + log_message "Backing up the file ${lighttpd_document_root}/data/notifications.xml" + sudo mv $lighttpd_document_root/data/notifications.xml $lighttpd_document_root/data/notifications.backup.xml fi -if [ -f $LIGHTTPD_DOCUMENT_ROOT/index.lighttpd.html ]; then +if [ -f $lighttpd_document_root/index.lighttpd.html ]; then log_message "Removing default Lighttpd index file from document root" - sudo rm $LIGHTTPD_DOCUMENT_ROOT/index.lighttpd.html + sudo rm $lighttpd_document_root/index.lighttpd.html fi log_message "Placing portal files in Lighttpd's root directory" -sudo cp -R $RECEIVER_BUILD_DIRECTORY/portal//html/* $LIGHTTPD_DOCUMENT_ROOT +sudo cp -R $RECEIVER_BUILD_DIRECTORY/portal//html/* $lighttpd_document_root -if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" && "${ADVANCED}" = "false" ]]; then - log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/administrators.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/administrators.xml - log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.xml - log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.xml - log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/settings.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/settings.xml - log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/links.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/links.xml - log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml" - sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/notifications.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/notifications.xml +if [[ "${portal_installed}" = "true" && "${advanced_installation}" = "false" ]]; then + log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/administrators.xml" + sudo mv $lighttpd_document_root/data/administrators.backup.xml $lighttpd_document_root/data/administrators.xml + log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/blogPosts.xml" + sudo mv $lighttpd_document_root/data/blogPosts.backup.xml $lighttpd_document_root/data/blogPosts.xml + log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/flightNotifications.xml" + sudo mv $lighttpd_document_root/data/flightNotifications.backup.xml $lighttpd_document_root/data/flightNotifications.xml + log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/settings.xml" + sudo mv $lighttpd_document_root/data/settings.backup.xml $lighttpd_document_root/data/settings.xml + log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/links.xml" + sudo mv $lighttpd_document_root/data/links.backup.xml $lighttpd_document_root/data/links.xml + log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/notifications.xml" + sudo mv $lighttpd_document_root/data/notifications.backup.xml $lighttpd_document_root/data/notifications.xml fi -log_message "Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/graphs/ writable" -sudo chmod 777 $LIGHTTPD_DOCUMENT_ROOT/graphs/ -log_message "Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/classes/ writable" -sudo chmod 777 $LIGHTTPD_DOCUMENT_ROOT/classes/ -log_message "Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/data/ writable" -sudo chmod 777 $LIGHTTPD_DOCUMENT_ROOT/data/ -log_message "Making the files contained within the directory ${LIGHTTPD_DOCUMENT_ROOT}/data/ writable" -sudo chmod 666 $LIGHTTPD_DOCUMENT_ROOT/data/* +log_message "Making the directory ${lighttpd_document_root}/graphs/ writable" +sudo chmod 777 $lighttpd_document_root/graphs/ +log_message "Making the directory ${lighttpd_document_root}/classes/ writable" +sudo chmod 777 $lighttpd_document_root/classes/ +log_message "Making the directory ${lighttpd_document_root}/data/ writable" +sudo chmod 777 $lighttpd_document_root/data/ +log_message "Making the files contained within the directory ${lighttpd_document_root}/data/ writable" +sudo chmod 666 $lighttpd_document_root/data/* if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then log_message "Checking for the file upintheair.json in the dump1090 HTML folder" if [[ -f "/usr/share/dump1090-mutability/html/upintheair.json" || -f "/usr/share/dump1090-fa/html/upintheair.json" ]]; then log_message "Copying the file upintheair.json from the dump1090 HTML folder to the dump978 HTML folder" if [[ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then - sudo cp /usr/share/dump1090-mutability/html/upintheair.json ${LIGHTTPD_DOCUMENT_ROOT}/dump978/ + sudo cp /usr/share/dump1090-mutability/html/upintheair.json $lighttpd_document_root/dump978/ fi if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then - sudo cp /usr/share/dump1090-fa/html/upintheair.json ${LIGHTTPD_DOCUMENT_ROOT}/dump978/ + sudo cp /usr/share/dump1090-fa/html/upintheair.json $lighttpd_document_root/dump978/ fi fi fi @@ -425,7 +425,7 @@ if [[ ! -L "/etc/lighttpd/conf-enabled/87-adsb-portal.conf" ]] ; then sudo ln -s /etc/lighttpd/conf-available/87-adsb-portal.conf /etc/lighttpd/conf-enabled/87-adsb-portal.conf fi -if [[ "${RECEIVER_PORTAL_INSTALLED}" = "false" ]] ; then +if [[ "${portal_installed}" = "false" ]] ; then log_message "Enabling the Lighttpd fastcgi-php module" echo "" sudo lighty-enable-mod fastcgi-php @@ -443,103 +443,101 @@ fi ## SETUP THE ADS-B PORTAL MYSQL DATABASE -if [[ "${RECEIVER_PORTAL_INSTALLED}" = "false" && "${ADVANCED}" = "true" && "${DATABASEENGINE}" = "MySQL" && "${DATABASEEXISTS}" = "false" ]]; then +if [[ "${portal_installed}" = "false" && "${advanced_installation}" = "true" && "${database_engine}" = "MySQL" && "${database_exists}" = "false" ]]; then if [[ $(dpkg-query -W -f='${STATUS}' mariadb-server-10.1 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then log_message "Switching the default MySQL plugin from unix_socket to mysql_native_password" - sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';" + sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';" log_message "Flushing privileges on the MySQL (MariaDB) server" - sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "FLUSH PRIVILEGES;" + sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "FLUSH PRIVILEGES;" log_message "Reloading MySQL (MariaDB)" sudo service mysql force-reload fi log_message "Attempting to log into the MySQL server using the supplied administrator credentials" - while ! sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e ";"; do + while ! sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e ";"; do log_message "Unable to log into the MySQL server using the supplied administrator credentials" whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "Create MySQL Database" \ --msgbox "The script was not able to log into the MySQL server using the administrator credentials you supplied. You will now be asked to reenter the MySQL server administrator credentials." \ 9 78 - DATABASEADMINPASSWORD1="" - DATABASEADMINPASSWORD2="" + database_admin_password1="" + database_admin_password2="" log_message "Asking for the MySQL administrator username" - DATABASEADMINUSER_TITLE="MySQL Administrator User" - while [[ -z "${DATABASEADMINUSER}" ]]; do - DATABASEADMINUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINUSER_TITLE}" \ - --nocancel \ - --inputbox "Enter the MySQL administrator user." \ - 8 78 \ - "${DATABASEADMINUSER}" 3>&1 1>&2 2>&3) - DATABASEADMINUSER_TITLE="MySQL Administrator User (REQUIRED)" + database_admin_user_title="MySQL Administrator User" + while [[ -z $database_admin_user ]]; do + database_admin_user=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_user_title}" \ + --nocancel \ + --inputbox "Enter the MySQL administrator user." \ + 8 78 \ + "${database_admin_user}" 3>&1 1>&2 2>&3) + database_admin_user_title="MySQL Administrator User (REQUIRED)" done log_message "Asking for the MySQL administrator password" - DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password" - DATABASEADMINPASSWORD1_MESSAGE="Enter the password for the MySQL adminitrator user." - while [[ -z "${DATABASEADMINPASSWORD1}" ]]; do - DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINPASSWORD1_TITLE}" \ - --nocancel \ - --passwordbox "${DATABASEADMINPASSWORD1_MESSAGE}" \ - 8 78 3>&1 1>&2 2>&3) - DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)" + database_admin_password1_title="MySQL Administrator Password" + while [[ -z $database_admin_password1 ]]; do + database_admin_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_password1_title}" \ + --nocancel \ + --passwordbox "Enter the password for the MySQL adminitrator user." \ + 8 78 3>&1 1>&2 2>&3) + database_admin_password1_title="MySQL Administrator Password (REQUIRED)" done log_message "Asking to confirm the MySQL administrator password" - DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password" - DATABASEADMINPASSWORD2_MESSAGE="\nConfirm the password for the MySQL adminitrator user." - while [[ -z "${DATABASEADMINPASSWORD2}" ]] ; do - DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINPASSWORD2_TITLE}" \ - --nocancel \ - --passwordbox "${DATABASEADMINPASSWORD2_MESSAGE}" \ - 8 78 3>&1 1>&2 2>&3) - DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)" + database_admin_password2_title="Confirm The MySQL Administrator Password" + while [[ -z $database_admin_password2 ]] ; do + database_admin_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_password2_title}" \ + --nocancel \ + --passwordbox "Confirm the password for the MySQL adminitrator user." \ + 8 78 3>&1 1>&2 2>&3) + database_admin_password2_title="Confirm The MySQL Administrator Password (REQUIRED)" done - while [[ ! "${DATABASEADMINPASSWORD1}" == "${DATABASEADMINPASSWORD2}" ]]; do + while [[ ! "${database_admin_password1}" == "${database_admin_password2}" ]]; do log_message "Failed to log into MySQL using the supplied credentials" - DATABASEADMINPASSWORD1="" - DATABASEADMINPASSWORD2="" + database_admin_password1="" + database_admin_password2="" whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "Passwords Did Not Match" \ --msgbox "Passwords did not match.\nPlease enter your password again." \ 9 78 log_message "Asking for the MySQL administrator password" - DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password" - while [[ -z "${DATABASEADMINPASSWORD1}" ]] ; do - DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINPASSWORD1_TITLE}" \ + database_admin_password1_title="MySQL Administrator Password" + while [[ -z $database_admin_password1 ]] ; do + database_admin_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_password1_title}" \ --nocancel \ - --passwordbox "DATABASEADMINPASSWORD1_MESSAGE" \ + --passwordbox "Enter the password for the MySQL adminitrator user." \ 8 78 3>&1 1>&2 2>&3) - DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)" + database_admin_password1_title="MySQL Administrator Password (REQUIRED)" done log_message "Asking to confirm the MySQL administrator password" - DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password" - while [[ -z "${DATABASEADMINPASSWORD2}" ]] ; do - DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${DATABASEADMINPASSWORD2_TITLE}" \ - --nocancel \ - --passwordbox "DATABASEADMINPASSWORD2_MESSAGE" \ - 8 78 3>&1 1>&2 2>&3) - DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)" + database_admin_password2_title="Confirm The MySQL Administrator Password" + while [[ -z $database_admin_password2 ]] ; do + database_admin_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ + --title "${database_admin_password2_title}" \ + --nocancel \ + --passwordbox "Confirm the password for the MySQL adminitrator user." \ + 8 78 3>&1 1>&2 2>&3) + database_admin_password2_title="Confirm The MySQL Administrator Password (REQUIRED)" done done log_message "Attempting to log into the MySQL server using the new administrator credentials" done log_message "Successfully logged into the MySQL server using the new administrator credentials" - log_message "Creating the MySQL database ${DATABASENAME}" - sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "CREATE DATABASE ${DATABASENAME};" - log_message "Creating the MySQL user ${DATABASEUSER}" - if [[ "${LOCALMYSQLSERVER}" = "false" ]] ; then - sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "CREATE USER '${DATABASEUSER}'@'%' IDENTIFIED BY \"${DATABASEPASSWORD1}\";" + log_message "Creating the MySQL database ${database_name}" + sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "CREATE DATABASE ${database_name};" + log_message "Creating the MySQL user ${database_user}" + if [[ "${local_mysql_server}" = "false" ]] ; then + sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "CREATE USER '${database_user}'@'%' IDENTIFIED BY \"${database_password1}\";" else - sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "CREATE USER '${DATABASEUSER}'@'localhost' IDENTIFIED BY \"${DATABASEPASSWORD1}\";" + sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "CREATE USER '${database_user}'@'localhost' IDENTIFIED BY \"${database_password1}\";" fi - log_message "Granting priviledges on the MySQL database ${DATABASENAME} to the user ${DATABASEUSER}" - sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "GRANT ALL PRIVILEGES ON ${DATABASENAME}.* TO '${DATABASEUSER}'@'localhost';" + log_message "Granting priviledges on the MySQL database ${database_name} to the user ${database_user}" + sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "GRANT ALL PRIVILEGES ON ${database_name}.* TO '${database_user}'@'localhost';" log_message "Flushing priviledges on the MySQL database server" - sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "FLUSH PRIVILEGES;" + sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "FLUSH PRIVILEGES;" fi @@ -557,33 +555,33 @@ fi ## SETUP COMMON PORTAL FEATURES -if [ "${DATABASEENGINE}" = "MySQL" ]; then - export ADSB_DATABASEENGINE=${DATABASEENGINE} - export ADSB_DATABASEHOSTNAME=${DATABASEHOSTNAME} - export ADSB_DATABASEUSER=${DATABASEUSER} - export ADSB_DATABASEPASSWORD1=${DATABASEPASSWORD1} - export ADSB_DATABASENAME=${DATABASENAME} -elif [ "${DATABASEENGINE}" = "SQLite" ]; then - if [ -z "${DATABASENAME}" ] ; then - if [ ! -f ${LIGHTTPD_DOCUMENT_ROOT}/data/portal.sqlite ]; then +if [ "${database_engine}" = "MySQL" ]; then + export ADSB_PORTAL_DATABASE_ENGINE=$database_engine + export ADSB_PORTAL_DATABASE_HOSTNAME=$database_hostname + export ADSB_PORTAL_DATABASE_USER=$database_user + export ADSB_PORTAL_DATABASE_PASSWORD1=$database_password1 + export ADSB_PORTAL_DATABASE_NAME=$database_name +elif [ "${database_engine}" = "SQLite" ]; then + if [ -z $database_name ] ; then + if [ ! -f $lighttpd_document_root/data/portal.sqlite ]; then echo -e "\e[94m Creating an empty SQLite database file...\e[97m" - sudo touch ${LIGHTTPD_DOCUMENT_ROOT}/data/portal.sqlite + sudo touch $lighttpd_document_root/data/portal.sqlite echo -e "\e[94m Setting write permissions on the empty SQLite database file...\e[97m" - sudo chmod 666 ${LIGHTTPD_DOCUMENT_ROOT}/data/portal.sqlite + sudo chmod 666 $lighttpd_document_root/data/portal.sqlite fi - DATABASENAME="${LIGHTTPD_DOCUMENT_ROOT}/data/portal.sqlite" + database_name="${lighttpd_document_root}/data/portal.sqlite" fi - export ADSB_DATABASEENGINE=${DATABASEENGINE} - export ADSB_DATABASEHOSTNAME="" - export ADSB_DATABASEUSER="" - export ADSB_DATABASEPASSWORD1="" - export ADSB_DATABASENAME=${DATABASENAME} + export ADSB_PORTAL_DATABASE_ENGINE=$database_engine + export ADSB_PORTAL_DATABASE_HOSTNAME="" + export ADSB_PORTAL_DATABASE_USER="" + export ADSB_PORTAL_DATABASE_PASSWORD1="" + export ADSB_PORTAL_DATABASE_NAME=$database_name else - export ADSB_DATABASEENGINE="xml" - export ADSB_DATABASEHOSTNAME="" - export ADSB_DATABASEUSER="" - export ADSB_DATABASEPASSWORD1="" - export ADSB_DATABASENAME="" + export ADSB_PORTAL_DATABASE_ENGINE="xml" + export ADSB_PORTAL_DATABASE_HOSTNAME="" + export ADSB_PORTAL_DATABASE_USER="" + export ADSB_PORTAL_DATABASE_PASSWORD1="" + export ADSB_PORTAL_DATABASE_NAME="" fi chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/core.sh @@ -598,7 +596,7 @@ fi ## SETUP ADVANCED PORTAL FEATURES -if [ "${ADVANCED}" = "true" ] ; then +if [ "${advanced_installation}" = "true" ] ; then chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/logging.sh ${RECEIVER_BASH_DIRECTORY}/portal/logging.sh if [[ $? -ne 0 ]] ; then @@ -612,17 +610,17 @@ fi ## POST INSTALLATION OPERATIONS -unset ADSB_DATABASEENGINE -unset ADSB_DATABASEHOSTNAME -unset ADSB_DATABASEUSER -unset ADSB_DATABASEPASSWORD1 -unset ADSB_DATABASENAME +unset ADSB_PORTAL_DATABASE_ENGINE +unset ADSB_PORTAL_DATABASE_HOSTNAME +unset ADSB_PORTAL_DATABASE_USER +unset ADSB_PORTAL_DATABASE_PASSWORD1 +unset ADSB_PORTAL_DATABASE_NAME -IPADDRESS=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` +pi_address=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "ADS-B Receiver Project Portal Setup" \ - --msgbox "NOTE THAT PORTAL SETUP IS NOT YET COMPLETE!\n\nIn order to complete the portal setup process visit the following URL in your favorite web browser.\n\nhttp://${IPADDRESS}/install/\n\nFollow the instructions and enter the requested information to complete the ADS-B Receiver Project Portal setup." \ + --msgbox "NOTE THAT PORTAL SETUP IS NOT YET COMPLETE!\n\nIn order to complete the portal setup process visit the following URL in your favorite web browser.\n\nhttp://${ip_address}/install/\n\nFollow the instructions and enter the requested information to complete the ADS-B Receiver Project Portal setup." \ 12 78 diff --git a/bash/portal/logging.sh b/bash/portal/logging.sh index e2d0020..43361b8 100755 --- a/bash/portal/logging.sh +++ b/bash/portal/logging.sh @@ -4,14 +4,13 @@ python_path=`which python3` + ## SETUP FLIGHT LOGGING -echo -e "" -echo -e "\e[95m Setting up portal flight logging and maintenance...\e[97m" -echo -e "" +log_heading "Setting up portal flight logging and maintenance" # Create the cron jobs responsible for logging and maintenance. -echo -e "\e[94m Creating the portal script cron file...\e[97m" +log_message "Creating the portal script cron file" sudo tee /etc/cron.d/adsb-receiver-flight-logging > /dev/null <