From 6c88cd0476e383bb61506449ddb7920f863e3ff9 Mon Sep 17 00:00:00 2001 From: jprochazka Date: Mon, 22 Jul 2024 17:57:59 -0400 Subject: [PATCH] Added file logging. --- .gitignore | 3 ++ CHANGELOG.md | 4 +- bash/decoders/dump1090-fa.sh | 81 ++++++++++++++++++---------------- bash/decoders/dump978-fa.sh | 20 ++++----- bash/extras/beastsplitter.sh | 14 +++--- bash/extras/duckdns.sh | 4 +- bash/feeders/adsbexchange.sh | 8 ++-- bash/feeders/airplaneslive.sh | 4 +- bash/feeders/flightradar24.sh | 4 +- bash/feeders/flyitalyadsb.sh | 6 +-- bash/feeders/openskynetwork.sh | 8 ++-- bash/feeders/piaware.sh | 39 +++++++++------- bash/feeders/planefinder.sh | 8 ++-- bash/functions.sh | 34 +++++++++++++- bash/init.sh | 16 ++++--- bash/main.sh | 3 +- build/.gitignore | 15 ------- install.sh | 35 +++++++++++---- 18 files changed, 182 insertions(+), 124 deletions(-) create mode 100644 .gitignore delete mode 100644 build/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..df354f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +logs/ +build/package-archive +build/dump1090* diff --git a/CHANGELOG.md b/CHANGELOG.md index cdcf04c..0bff24b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,9 @@ The following is a history of the changes made to this project. * The PiAware installation script now supports Ubuntu Noble Numbat. * The installation of PiAware is no longer required when choosing to install dump1090-fa. * The dump1090-fa installation script now mimics the current dump1090-fa installation instructions. -* Added logging functions which in the future will offer a way to log output to files. +* All scripts excluding those related to the portal now utilize the new logging functions. +* Logging to the logs directory is enabled by default but can be disabled with --no-log or -n. * Added variables which can be modified to adjust text colors used by the bash scripts. -* All installation scripts now utilize the new logging functions. * Added the --version and -v arguments in order to display the current project version. * Removed scripting used for image setup. diff --git a/bash/decoders/dump1090-fa.sh b/bash/decoders/dump1090-fa.sh index 54299de..73814a2 100755 --- a/bash/decoders/dump1090-fa.sh +++ b/bash/decoders/dump1090-fa.sh @@ -12,11 +12,11 @@ clear LogProjectTitle LogTitleHeading "Setting up the FlightAware Dump1090 decoder" LogTitleMessage "------------------------------------------------------------------------------" -echo "" if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "FlightAware Dump1090 Decoder Setup" \ --yesno "FlightAware Dump1090 is an ADS-B, Mode S, and Mode 3A/3C demodulator and decoder that will receive and decode aircraft transponder messages received via a directly connected software defined radio, or from data provided over a network connection.\n\nWebsite: https://www.flightaware.com/\nGitHub Repository: https://github.com/flightaware/dump1090\n\nWould you like to begin the setup process now?" \ 14 78; then +echo "" LogAlertHeading "INSTALLATION HALTED" LogAlertMessage "Setup has been halted at the request of the user" echo "" @@ -32,6 +32,7 @@ LogHeading "Installing packages needed to fulfill FlightAware Dump1090 decoder d CheckPackage build-essential CheckPackage debhelper +CheckPackage devscripts CheckPackage fakeroot CheckPackage libbladerf-dev CheckPackage libhackrf-dev @@ -45,7 +46,7 @@ CheckPackage pkg-config ## BLACKLIST UNWANTED RTL-SDR MODULES -LogHeading "Blacklist unwanted RTL-SDR kernel modules. +LogHeading "Blacklist unwanted RTL-SDR kernel modules." BlacklistModules @@ -54,24 +55,23 @@ BlacklistModules LogHeading "Preparing the FlightAware Dump1090 Git repository" -if [[ -d $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090 && -d $RECEIVER_BUILD_DIRECTORY/dump1090.fa/dump1090/.git ]]; then +if [[ -d $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090 && -d $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/.git ]]; then LogMessage "Entering the dump1090 git repository directory" cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090 LogMessage "Pulling the dump1090 git repository" echo "" - git pull + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE else LogMessage "Creating the FlightAware dump1090 Project build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/dump1090-fa + mkdir -v $RECEIVER_BUILD_DIRECTORY/dump1090-fa 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Entering the FlightAware dump1090 Project build directory" cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa LogMessage "Cloning the dump1090 git repository" echo "" - git clone https://github.com/flightaware/dump1090.git + git clone https://github.com/flightaware/dump1090.git 2>&1 | tee -a $RECEIVER_LOG_FILE fi -echo "" ## BUILD AND INSTALL THE DUMP1090-FA PACKAGE @@ -86,20 +86,24 @@ case $RECEIVER_OS_CODE_NAME in focal) distro="buster" ;; - bullseye | jammy) + bullseye|jammy|bookworm|noble) distro="bullseye" ;; - bookworm | noble) - distro="bookworm" - ;; esac -LogMessage "Entering the package/${distro} directory" -cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa/package/$distro +LogMessage "Preparing to build dump1090-fa for ${distro}" +echo "" +./prepare-build.sh $distro 2>&1 | tee -a $RECEIVER_LOG_FILE +echo "" +LogMessage "Entering the package-${distro} directory" +cd $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/package-$distro LogMessage "Building the dump1090-fa Debian package" -dpkg-buildpackage -b --no-sign - +echo "" +dpkg-buildpackage -b --no-sign 2>&1 | tee -a $RECEIVER_LOG_FILE +echo "" LogMessage "Installing the dump1090-fa Debian package" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/dump1090-fa_${DUMP1090_FA_VERSION}_*.deb +echo "" +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/dump1090-fa_$DUMP1090_FA_VERSION_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE +echo "" LogMessage "Checking that the dump1090-fa Debian package was installed" if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then @@ -119,13 +123,12 @@ fi if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then LogMessage "Creating the Debian package archive directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Copying the dump1090-fa Debian package into the Debian package archive directory" echo "" -cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ -echo "" +cp -vf $RECEIVER_BUILD_DIRECTORY/dump1090-fa/dump1090/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE ## POST INSTALLATION OPERATIONS @@ -137,50 +140,54 @@ if [[ ! -f "/usr/share/dump1090-fa/html/upintheair.json" ]]; then LogMessage "Asking the user if they want to add heywhatsthat maximum range rings" if (whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "Setup heywhaststhat Maximum Range Rings" \ - --yesno "Maximum range rings can be added to the FlightAware Dump1090 map usings data obtained from heywhatsthat. In order to add these rings to your FlightAware dump1090 map you will first need to visit http://www.heywhatsthat.com and generate a new panorama centered on the location of your receiver. Once your panorama has been generated a link to the panorama will be displayed in the top left hand portion of the page. You will need the view ID which is the series of letters and numbers after \"?view=\" in the URL.\n\nWould you like to add heywhatsthat maximum range rings to your map?" \ + --yesno "Maximum range rings can be added to the FlightAware Dump1090 map usings data obtained from heywhatsthat. In order to add these rings to your FlightAware dump1090 map you will first need to visit http://www.heywhatsthat.com and generate a new panorama centered on the location of your receiver. Once your panorama has been generated a link to the panorama will be displayed in the top left hand portion of the page. You will need the view ID which is the series of letters and numbers after ?view= in the URL.\n\nWould you like to add heywhatsthat maximum range rings to your map?" \ 16 78); then + LogMessage "Asking the user for the heywhatsthat panarama ID" heywhatsthat_panorama_id_title="Enter the heywhatsthat Panorama ID" while [[ -z $heywhatsthat_panorama_id ]] ; do heywhatsthat_panorama_id=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "${heywhatsthat_panorama_id_title}" \ - --inputbox "\nPlease enter your Heywhatsthat panorama ID." \ + --inputbox "Please enter your Heywhatsthat panorama ID." \ 8 78) whiptail_exit_status=$? if [[ $whiptail_exit_status == 0 ]]; then LogAlertMessage "Setup of heywhatsthat maximum range rings was cancelled" break - heywhatsthat_panorama_id_title="Enter the Heywhatsthat Panorama ID (REQUIRED)" + fi + heywhatsthat_panorama_id_title="Enter the Heywhatsthat Panorama ID [REQUIRED]" done if [[ $whiptail_exit_status != 0 ]]; then LogMessage "Asking the user what the altitude is for the first ring" heywhatsthat_ring_one_altitude_title="First heywhatsthat Ring Altitude" while [[ -z $heywhatsthat_ring_one_altitude ]] ; do heywhatsthat_ring_one_altitude=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${heywhatsthat_ring_one_title}" \ - --nocancel \ - --inputbox "\nEnter the first ring's altitude in meters.\n(default 3048 meters or 10000 feet)" \ - 8 78 \ - "3048") - heywhatsthat_ring_one_altitude_title="First heywhatsthat Ring Altitude (REQUIRED)" + --title "${heywhatsthat_ring_one_altitude_title}" \ + --nocancel \ + --inputbox "Enter the first ring's altitude in meters.\n(default 3048 meters or 10000 feet)" \ + 8 78 \ + "3048") + heywhatsthat_ring_one_altitude_title="First heywhatsthat Ring Altitude [REQUIRED]" done LogMessage "Asking the user what the altitude is for the second ring" heywhatsthat_ring_two_altitude_title="Second heywhatsthat Ring Altitude" - while [[ -z $heywhatsthat_ring_two ]] ; do + while [[ -z $heywhatsthat_ring_two_altitude ]] ; do heywhatsthat_ring_two_altitude=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ - --title "${heywhatsthat_ring_two_title}" \ - --nocancel \ - --inputbox "\nEnter the second ring's altitude in meters.\n(default 12192 meters or 40000 feet)" \ - 8 78 \ - "12192") - heywhatsthat_ring_two_altitude_title="Second heywhatsthat Ring Altitude (REQUIRED)" + --title "${heywhatsthat_ring_two_altitude_title}" \ + --nocancel \ + --inputbox "Enter the second ring's altitude in meters.\n(default 12192 meters or 40000 feet)" \ + 8 78 \ + "12192") + heywhatsthat_ring_two_altitude_title="Second heywhatsthat Ring Altitude [REQUIRED]" done LogMessage "Downloading JSON data file assigned to panorama ID ${heywhatsthat_panorama_id}" echo "" - sudo wget -O /usr/share/skyaware/html/upintheair.json "http://www.heywhatsthat.com/api/upintheair.json?id=${heywhatsthat_panarama_id}&refraction=0.25&alts=${heywhatsthat_ring_one_altitude},${heywhatsthat_ring_two_altitude}" + sudo wget -v -O /usr/share/skyaware/html/upintheair.json "http://www.heywhatsthat.com/api/upintheair.json?id=${heywhatsthat_panarama_id}&refraction=0.25&alts=${heywhatsthat_ring_one_altitude},${heywhatsthat_ring_two_altitude}" 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" - LogMessage " + LogMessage "Heywhatsthat configuration complete" fi + else + LogMessage "Heywhatsthat maximum range rings was skipped" fi fi diff --git a/bash/decoders/dump978-fa.sh b/bash/decoders/dump978-fa.sh index f60c509..856e8de 100755 --- a/bash/decoders/dump978-fa.sh +++ b/bash/decoders/dump978-fa.sh @@ -40,7 +40,7 @@ fi if [[ "${adsb_decoder_installed}" == "true" ]]; then LogMessage "Checking if dump978-fa has been configured" if grep -wq "driver=rtlsdr,serial=" /etc/default/dump978-fa; then - echo -e "The dump978-fa installation appears to have been configured" + LogMessage "The dump978-fa installation appears to have been configured" else whiptail --backtitle "FlightAware Dump978 Configuration" \ --title "RTL-SDR Dongle Assignments" \ @@ -114,17 +114,17 @@ if [[ -d $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978 && -d $RECEIVER_BUILD_DIRE cd $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978 LogMessage "Pulling the dump1090 git repository" echo "" - git pull + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE else LogMessage "Creating the FlightAware dump978 Project build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/dump1090-fa + mkdir -v $RECEIVER_BUILD_DIRECTORY/dump1090-fa 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Entering the ADS-B Receiver Project build directory" cd $RECEIVER_BUILD_DIRECTORY/dump978-fa LogMessage "Cloning the FlightAware dump978 git repository" echo "" - git clone https://github.com/flightaware/dump978.git + git clone https://github.com/flightaware/dump978.git 2>&1 | tee -a $RECEIVER_LOG_FILE fi echo "" @@ -138,13 +138,13 @@ cd $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978 LogMessage "Building the dump978-fa package" echo "" -dpkg-buildpackage -b +dpkg-buildpackage -b 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Installing the dump1090-fa Debian package" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978-fa_${DUMP978_FA_VERSION}_*.deb +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/dump978-fa/dump978-fa_${DUMP978_FA_VERSION}_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE LogMessage "Installing the skyaware978 Debian package" -sudo dpkg -i $$RECEIVER_BUILD_DIRECTORY/dump978-fa/skyaware978_${DUMP978_FA_VERSION}_*.deb +sudo dpkg -i $$RECEIVER_BUILD_DIRECTORY/dump978-fa/skyaware978_${DUMP978_FA_VERSION}_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE LogMessage "Checking that the dump978-fa Debian package was installed" if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then @@ -179,16 +179,16 @@ fi if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then LogMessage "Creating the Debian package archive directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Copying the dump978-fa Debian package into the Debian package archive directory" echo "" -cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ +cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Copying the skyaware978 Debian package into the Debian package archive directory" echo "" -cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ +cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" diff --git a/bash/extras/beastsplitter.sh b/bash/extras/beastsplitter.sh index cc2a9e7..5522844 100755 --- a/bash/extras/beastsplitter.sh +++ b/bash/extras/beastsplitter.sh @@ -87,17 +87,17 @@ if [[ -d $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter && -d $RECEIVER cd $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter LogMessage "Pulling the beast-splitter git repository" echo "" - git pull + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE else LogMessage "Creating the beast-splitter build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/beast-splitter + mkdir -v $RECEIVER_BUILD_DIRECTORY/beast-splitter 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Entering the beast-splitter build directory" cd $RECEIVER_BUILD_DIRECTORY/beast-splitter LogMessage "Cloning the FlightAware dump978 git repository" echo "" - git clone https://github.com/flightaware/beast-splitter.git + git clone https://github.com/flightaware/beast-splitter.git 2>&1 | tee -a $RECEIVER_LOG_FILE fi @@ -110,11 +110,11 @@ cd $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter LogMessage "Building the beast-splitter package" echo "" -dpkg-buildpackage -b +dpkg-buildpackage -b 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Installing the beast-splitter Debian package" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter_*.deb +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE LogMessage "Checking that the beast-splitter Debian package was installed" if [[ $(dpkg-query -W -f='${STATUS}' beast-splitter 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then @@ -134,12 +134,12 @@ fi if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then LogMessage "Creating the Debian package archive directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Copying the beast-splitter Debian package into the Debian package archive directory" echo "" -cp -vf $RECEIVER_BUILD_DIRECTORY/beast-splitter/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ +cp -vf $RECEIVER_BUILD_DIRECTORY/beast-splitter/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" diff --git a/bash/extras/duckdns.sh b/bash/extras/duckdns.sh index 5f1329d..b607030 100755 --- a/bash/extras/duckdns.sh +++ b/bash/extras/duckdns.sh @@ -80,7 +80,7 @@ LogHeading "Creating the Duck DNS script" if [[ ! -d $RECEIVER_BUILD_DIRECTORY/duckdns ]]; then LogMessage "Creating the Duck DNS build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/duckdns + mkdir -v $RECEIVER_BUILD_DIRECTORY/duckdns 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi @@ -91,7 +91,7 @@ EOF LogMessage "Adding execute permissions for only this user to the Duck DNS update script" echo "" -chmod -v 700 $RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh +chmod -v 700 $RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Creating the Duck DNS cron file" diff --git a/bash/feeders/adsbexchange.sh b/bash/feeders/adsbexchange.sh index 746d7f0..4ab4dee 100755 --- a/bash/feeders/adsbexchange.sh +++ b/bash/feeders/adsbexchange.sh @@ -37,7 +37,7 @@ whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ if [[ ! -d $RECEIVER_BUILD_DIRECTORY/adsbexchange ]]; then LogMessage "Creating the ADSBExchange build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/adsbexchange + mkdir -v $RECEIVER_BUILD_DIRECTORY/adsbexchange 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Entering the ADSBExchange build directory" @@ -52,9 +52,9 @@ fi LogMessage "Downloading the ADS-B Exchange client ${action_to_perform} script" echo "" if [[ "${action_to_perform}" = "install" ]]; then - wget -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh https://www.adsbexchange.com/feed.sh + wget -v -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh https://www.adsbexchange.com/feed.sh 2>&1 | tee -a $RECEIVER_LOG_FILE else - wget -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh https://www.adsbexchange.com/feed-update.sh + wget -v -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/feed-${action_to_perform}.sh https://www.adsbexchange.com/feed-update.sh 2>&1 | tee -a $RECEIVER_LOG_FILE fi echo "" @@ -75,7 +75,7 @@ if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ 12 78; then LogMessage "Downloading the ADS-B Exchange stats package installation script" echo "" - curl -L -o $RECEIVER_BUILD_DIRECTORY/adsbexchange/axstats.sh https://adsbexchange.com/stats.sh + wget -v -O $RECEIVER_BUILD_DIRECTORY/adsbexchange/axstats.sh https://adsbexchange.com/stats.sh 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" echo -e "Executing the ADS-B Exchange stats package installation script" echo "" diff --git a/bash/feeders/airplaneslive.sh b/bash/feeders/airplaneslive.sh index fddb4d3..eae4f00 100755 --- a/bash/feeders/airplaneslive.sh +++ b/bash/feeders/airplaneslive.sh @@ -37,7 +37,7 @@ whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ if [[ ! -d $RECEIVER_BUILD_DIRECTORY/airplaneslive ]]; then LogMessage "Creating the airplanes.live build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/airplaneslive + mkdir -v $RECEIVER_BUILD_DIRECTORY/airplaneslive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Entering the airplanes.live build directory" @@ -45,7 +45,7 @@ cd $RECEIVER_BUILD_DIRECTORY/airplaneslive LogMessage "Downloading the airplanes.live client installation script" echo "" -wget -v -O $RECEIVER_BUILD_DIRECTORY/airplaneslive/install.sh https://raw.githubusercontent.com/airplanes-live/feed/main/install.sh +wget -v -O $RECEIVER_BUILD_DIRECTORY/airplaneslive/install.sh https://raw.githubusercontent.com/airplanes-live/feed/main/install.sh 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Executing the airplanes.live client installation script" diff --git a/bash/feeders/flightradar24.sh b/bash/feeders/flightradar24.sh index e23c11a..46efc76 100755 --- a/bash/feeders/flightradar24.sh +++ b/bash/feeders/flightradar24.sh @@ -32,7 +32,7 @@ LogHeading "Begining the FlightRadar24 client installation process" if [[ ! -d $RECEIVER_BUILD_DIRECTORY/flightradar24 ]]; then LogMessage "Creating the FlightRadar24 build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/flightradar24 + mkdir -v $RECEIVER_BUILD_DIRECTORY/flightradar24 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Entering the FlightRadar24 build directory" @@ -40,7 +40,7 @@ cd $RECEIVER_BUILD_DIRECTORY/flightradar24 LogMessage "Downloading the airplanes.live client installation script" echo "" -wget -v -O $RECEIVER_BUILD_DIRECTORY/flightradar24/install.sh https://fr24.com/install.sh +wget -v -O $RECEIVER_BUILD_DIRECTORY/flightradar24/install.sh https://fr24.com/install.sh 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Executing the airplanes.live client installation script" diff --git a/bash/feeders/flyitalyadsb.sh b/bash/feeders/flyitalyadsb.sh index 200fdfc..e175442 100755 --- a/bash/feeders/flyitalyadsb.sh +++ b/bash/feeders/flyitalyadsb.sh @@ -37,7 +37,7 @@ whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ if [[ ! -d $RECEIVER_BUILD_DIRECTORY/flyitalyadsb ]]; then LogMessage "Creating the Fly Italy ADS-B build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/flyitalyadsb + mkdir -v $RECEIVER_BUILD_DIRECTORY/flyitalyadsb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Entering the Fly Italy ADS-B build directory" @@ -45,7 +45,7 @@ cd $RECEIVER_BUILD_DIRECTORY/flyitalyadsb LogMessage "Downloading the Fly Italy ADS-B installation script" echo "" -wget -v -O$RECEIVER_BUILD_DIRECTORY/flyitalyadsb/install.sh wget https://raw.githubusercontent.com/flyitalyadsb/mlat-client/master/scripts/install.sh +wget -v -O $RECEIVER_BUILD_DIRECTORY/flyitalyadsb/install.sh wget https://raw.githubusercontent.com/flyitalyadsb/mlat-client/master/scripts/install.sh 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Executing the Fly Italy ADS-B feeder installation script" echo "" @@ -59,7 +59,7 @@ if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ 12 78; LogMessage "Downloading the Fly Italy ADS-B updater script" echo "" - wget -v -O$RECEIVER_BUILD_DIRECTORY/flyitalyadsb/install_updater.sh wget https://raw.githubusercontent.com/flyitalyadsb/mlat-client/master/scripts/install_updater.sh + wget -v -O $RECEIVER_BUILD_DIRECTORY/flyitalyadsb/install_updater.sh wget https://raw.githubusercontent.com/flyitalyadsb/mlat-client/master/scripts/install_updater.sh 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Executing the Fly Italy ADS-B feeder updater script" echo "" diff --git a/bash/feeders/openskynetwork.sh b/bash/feeders/openskynetwork.sh index 1cd585d..f06986a 100755 --- a/bash/feeders/openskynetwork.sh +++ b/bash/feeders/openskynetwork.sh @@ -42,7 +42,7 @@ if ! grep -q "^deb .*opensky." /etc/apt/sources.list /etc/apt/sources.list.d/*; if [[ ! -d $RECEIVER_BUILD_DIRECTORY/openskynetwork ]]; then LogMessage "Creating the OpenSky Network build directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/openskynetwork + mkdir -v $RECEIVER_BUILD_DIRECTORY/openskynetwork 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Entering the OpenSky Network build directory" @@ -50,8 +50,8 @@ if ! grep -q "^deb .*opensky." /etc/apt/sources.list /etc/apt/sources.list.d/*; LogMessage "Downloading and adding the OpenSky Network apt repository GPG key" echo "" - wget -v -O $RECEIVER_BUILD_DIRECTORY/openskynetwork/opensky.gpg.pub https://opensky-network.org/files/firmware/opensky.gpg.pub - wget -q -O - https://opensky-network.org/files/firmware/opensky.gpg.pub | sudo apt-key add - + wget -v -O $RECEIVER_BUILD_DIRECTORY/openskynetwork/opensky.gpg.pub https://opensky-network.org/files/firmware/opensky.gpg.pub 2>&1 | tee -a $RECEIVER_LOG_FILE + wget -q -O - https://opensky-network.org/files/firmware/opensky.gpg.pub | sudo apt-key add - 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Adding the OpenSky Network apt repository" sudo bash -c "echo deb https://opensky-network.org/repos/debian opensky custom > /etc/apt/sources.list.d/opensky.list" @@ -66,7 +66,7 @@ LogHeading "Installing the OpenSky Network feeder package" LogMessage "Downloading the latest package lists for all enabled repositories and PPAs" echo "" -sudo apt-get update +sudo apt-get update 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Installing the OpenSky Network fedder package using apt" CheckPackage opensky-feeder diff --git a/bash/feeders/piaware.sh b/bash/feeders/piaware.sh index 6432f36..8455cd7 100755 --- a/bash/feeders/piaware.sh +++ b/bash/feeders/piaware.sh @@ -89,13 +89,17 @@ if [[ "${RECEIVER_OS_CODE_NAME}" == "focal" ]]; then cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild LogMessage "Updating the local tcltls-rebuild git repository" echo "" - git pull + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE else - LogMessage "Entering the ADS-B Receiver Project build directory" - cd $RECEIVER_BUILD_DIRECTORY + LogMessage "Creating the tcltls-rebuild build directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" + LogMessage "Entering the tcltls-rebuild build directory" + cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild LogMessage "Cloning the tcltls-rebuild git repository locally" echo "" - git clone https://github.com/flightaware/tcltls-rebuild + git clone https://github.com/flightaware/tcltls-rebuild 2>&1 | tee -a $RECEIVER_LOG_FILE fi echo "" @@ -110,11 +114,11 @@ if [[ "${RECEIVER_OS_CODE_NAME}" == "focal" ]]; then cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcltls-1.7.22 LogMessage "Building the tcltls-rebuild package" echo "" - dpkg-buildpackage -b + dpkg-buildpackage -b 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Installing the tcltls-rebuild package" echo "" - sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcl-tls_1.7.22-2+fa1_*.deb + sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcl-tls_1.7.22-2+fa1_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Checking that the FlightAware tcltls-rebuild package was installed properly" @@ -134,12 +138,12 @@ if [[ "${RECEIVER_OS_CODE_NAME}" == "focal" ]]; then if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then LogMessage "Creating the package archive directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Copying the FlightAware tcltls-rebuild Debian package into the archive directory" echo "" - cp -vf $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ + cp -vf $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE fi fi @@ -153,13 +157,17 @@ if [[ -d $RECEIVER_BUILD_DIRECTORY/piaware_builder && -d $RECEIVER_BUILD_DIRECTO cd $RECEIVER_BUILD_DIRECTORY/piaware_builder LogMessage "Updating the local piaware_builder git repository" echo "" - git pull + git pull 2>&1 | tee -a $RECEIVER_LOG_FILE else + LogMessage "Creating the FlightAware piaware_builder build directory" + echo "" + mkdir -v $RECEIVER_BUILD_DIRECTORY/piaware_builder 2>&1 | tee -a $RECEIVER_LOG_FILE + echo "" LogMessage "Entering the ADS-B Receiver Project build directory" cd $RECEIVER_BUILD_DIRECTORY LogMessage "Cloning the piaware_builder git repository locally" echo "" - git clone https://github.com/flightaware/dump978.git + git clone https://github.com/flightaware/dump978.git 2>&1 | tee -a $RECEIVER_LOG_FILE fi echo "" @@ -184,20 +192,21 @@ case $RECEIVER_OS_CODE_NAME in distro="bookworm" ;; esac +LogMessage "Setting distribution to build for to ${distro}" LogMessage "Executing the FlightAware PiAware client build script" echo "" -./sensible-build.sh $distro +./sensible-build.sh $distro 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Entering the FlightAware PiAware client build directory" cd $RECEIVER_BUILD_DIRECTORY/piaware_builder/package-${distro} LogMessage "Building the FlightAware PiAware client package" echo "" -dpkg-buildpackage -b +dpkg-buildpackage -b 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Installing the FlightAware PiAware client package" echo "" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/piaware_builder/piaware_*.deb 2>&1 +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/piaware_builder/piaware_*.deb 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Checking that the FlightAware PiAware client package was installed properly" @@ -216,12 +225,12 @@ else if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then LogMessage "Creating the package archive directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Copying the FlightAware PiAware client binary package into the archive directory" echo "" - cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ + cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi diff --git a/bash/feeders/planefinder.sh b/bash/feeders/planefinder.sh index 4d4693b..aad7e56 100755 --- a/bash/feeders/planefinder.sh +++ b/bash/feeders/planefinder.sh @@ -85,22 +85,22 @@ cd $RECEIVER_BUILD_DIRECTORY/planefinder LogMessage "Downloading the appropriate PlaneFinder client Debian package" echo "" -wget -v -O --no-check-certificate http://client.planefinder.net/$PACKAGE_NAME $RECEIVER_BUILD_DIRECTORY/planefinder/$PACKAGE_NAME +wget -v -O --no-check-certificate http://client.planefinder.net/$PACKAGE_NAME $RECEIVER_BUILD_DIRECTORY/planefinder/$PACKAGE_NAME 2>&1 | tee -a $RECEIVER_LOG_FILE LogMessage "Installing the PlaneFinder Client Debian package" echo -e "" -sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/planefinder/$package_name +sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/planefinder/$package_name 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then LogMessage "Creating the package archive directory" echo "" - mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive + mkdir -v $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi LogMessage "Copying the PlaneFinder client Debian package into the archive directory" echo "" -cp -vf $RECEIVER_BUILD_DIRECTORY/planefinder/$package_name $RECEIVER_BUILD_DIRECTORY/package-archive/ +cp -vf $RECEIVER_BUILD_DIRECTORY/planefinder/$package_name $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" diff --git a/bash/functions.sh b/bash/functions.sh index 89429ad..3e989d4 100755 --- a/bash/functions.sh +++ b/bash/functions.sh @@ -2,14 +2,36 @@ ## LOGGING FUNCTIONS +# LogToFile +function LogToFile { + if [[ "${RECEIVER_LOGGING_ENABLED}" == "true" ]]; then + time_stamp='' + if [[ -z $2 || "${2}" == "true" ]]; then + printf -v time_stamp '[%(%Y-%m-%d %H:%M:%S)T]' -1 + fi + + if [[ ! -z $3 && "${3}" == "inline" ]]; then + printf "${time_stamp} ${1}" >> $RECEIVER_LOG_FILE + else + echo "${time_stamp} ${1}" >> $RECEIVER_LOG_FILE + fi + fi +} + +function LogOutput { + LogToFile "${1}" +} + # Logs the "PROJECT TITLE" to the console function LogProjectTitle { + LogToFile "${RECEIVER_PROJECT_TITLE}" echo -e "${DISPLAY_PROJECT_NAME} ${RECEIVER_PROJECT_TITLE}${DISPLAY_DEFAULT}" echo "" } # Logs a "HEADING" to the console function LogHeading { + LogToFile "${1}" echo "" echo -e "${DISPLAY_HEADING} ${1}${DISPLAY_DEFAULT}" echo "" @@ -17,48 +39,58 @@ function LogHeading { # Logs a "MESSAGE" to the console function LogMessage { + LogToFile "${1}" echo -e "${DISPLAY_MESSAGE} ${1}${DISPLAY_DEFAULT}" } # Logs an alert "HEADING" to the console function LogAlertHeading { + LogToFile "${1}" echo -e "${DISPLAY_ALERT_HEADING} ${1}${DISPLAY_DEFAULT}" } # Logs an alert "MESSAGE" to the console function LogAlertMessage { + LogToFile "${1}" echo -e "${DISPLAY_ALERT_MESSAGE} ${1}${DISPLAY_DEFAULT}" } # Logs an title "HEADING" to the console function LogTitleHeading { + LogToFile "${1}" echo -e "${DISPLAY_TITLE_HEADING} ${1}${DISPLAY_DEFAULT}" } # Logs an title "MESSAGE" to the console function LogTitleMessage { + LogToFile "${1}" echo -e "${DISPLAY_TITLE_MESSAGE} ${1}${DISPLAY_DEFAULT}" } # Logs a warning "HEADING" to the console function LogWarningHeading { + LogToFile "${1}" echo -e "${DISPLAY_WARNING_HEADING} ${1}${DISPLAY_DEFAULT}" } # Logs a warning "MESSAGE" to the console function LogWarningMessage { + LogToFile "${1}" echo -e "${DISPLAY_WARNING_MESSAGE} ${1}${DISPLAY_DEFAULT}" } function LogMessageInline { + LogToFile "${1}" "true" "inline" printf "${DISPLAY_MESSAGE} ${1}${DISPLAY_DEFAULT}" } function LogFalseInline { + LogToFile "${1}" "false" echo -e "${DISPLAY_FALSE_INLINE} ${1}${DISPLAY_DEFAULT}" } function LogTrueInline { + LogToFile "${1}" "false" echo -e "${DISPLAY_TRUE_INLINE} ${1}${DISPLAY_DEFAULT}" } @@ -90,7 +122,7 @@ function CheckPackage { fi echo "" attempt=$((attempt+1)) - sudo apt-get install -y $1 + sudo apt-get install -y $1 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" else LogTrueInline "[OK]" diff --git a/bash/init.sh b/bash/init.sh index 3778a09..5c2f7fe 100755 --- a/bash/init.sh +++ b/bash/init.sh @@ -11,12 +11,14 @@ source $RECEIVER_BASH_DIRECTORY/functions.sh LogHeading "Displaying the welcome message" LogMessage "Displaying the welcome message to the user" +echo "" if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "The ADS-B Receiver Project" \ --yesno "Thanks for choosing The ADS-B Receiver Project to setup your receiver.\n\nMore information on this project as well as news, support, and discussions can be found on the projects official website located at:\n\n https://www.adsbreceiver.net\n\nWould you like to continue setup?" \ 14 78; then LogAlertHeading "INSTALLATION HALTED" LogAlertMessage "Setup has been halted at the request of the user" + echo "" exit 1 fi @@ -41,11 +43,12 @@ if [[ $RECEIVER_DEVELOPMENT_MODE != "true" ]]; then --yesno "There appears to be changes to the current branch. In order to switch to or fetch the ${current_branch} branch these changes will need to be stashed. Would you like to stash these changes now?" \ 14 78; then LogMessage "Stashing changes made to the ${current_branch} branch" - git stash + git stash 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" else LogAlertHeading "INSTALLATION HALTED" LogAlertMessage "Setup has been halted at the request of the user" + echo "" exit 1 fi fi @@ -53,14 +56,14 @@ if [[ $RECEIVER_DEVELOPMENT_MODE != "true" ]]; then if [[ "${current_branch}" != "${RECEIVER_PROJECT_BRANCH}" ]]; then LogMessage "Switching to branch ${RECEIVER_PROJECT_BRANCH}" echo "" - git checkout $RECEIVER_PROJECT_BRANCH + git checkout $RECEIVER_PROJECT_BRANCH 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" fi if [[ `git ls-remote --heads https://github.com/jprochazka/adsb-receiver.git refs/heads/$RECEIVER_PROJECT_BRANCH | wc -l` = 1 ]]; then LogMessage "Fetching branch ${RECEIVER_PROJECT_BRANCH} from origin" echo "" - git fetch origin + git fetch origin 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogMessage "Performing hard reset of branch ${RECEIVER_PROJECT_BRANCH} so it matches origin/${RECEIVER_PROJECT_BRANCH}" echo "" @@ -92,7 +95,7 @@ if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ echo "" LogMessage "Updating the operating system using apt-get" echo "" - sudo apt-get -y dist-upgrade + sudo apt-get -y dist-upgrade 2>&1 | tee -a $RECEIVER_LOG_FILE echo "" LogTitleMessage "------------------------------------------------------------------------" LogTitleHeading "Your operating system should now be up to date" @@ -124,6 +127,9 @@ whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \ --title "Software Installation Complete" \ --msgbox "INSTALLATION COMPLETE\n\nDO NOT DELETE THIS DIRECTORY!\n\nFiles needed for certain items to run properly are contained within this directory. Deleting this directory may result in your receiver not working properly.\n\nHopefully, these scripts and files were found useful while setting up your ADS-B Receiver. Feedback regarding this software is always welcome. If you have any issues or wish to submit feedback, feel free to do so on GitHub.\n\n https://github.com/jprochazka/adsb-receiver" \ 20 65 -LogProjectName "Installation complete" + +echo "" +LogAlertHeading "Installation complete" +echo "" exit 0 diff --git a/bash/main.sh b/bash/main.sh index 1bef520..9148f22 100755 --- a/bash/main.sh +++ b/bash/main.sh @@ -69,7 +69,6 @@ function InstallFlyItalyAdsb() { fi } - # Execute the OpenSky Network setup script. function InstallOpenSkyNetwork() { chmod +x ${RECEIVER_BASH_DIRECTORY}/feeders/openskynetwork.sh @@ -465,7 +464,7 @@ fi RUN_ADSBEXCHANGE_SCRIPT="false" RUN_PIAWARE_SCRIPT="false" RUN_FLIGHTRADAR24_SCRIPT="false" -RUN_FLYITALYADSB_SCRIPT +RUN_FLYITALYADSB_SCRIPT="false" RUN_OPENSKYNETWORK_SCRIPT="false" RUN_PLANEFINDER_SCRIPT="false" diff --git a/build/.gitignore b/build/.gitignore deleted file mode 100644 index 7a7f2dd..0000000 --- a/build/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# exclude build directories -AboveTustin/ -adsbexchange/ -acarsdec/ -dump1090* -gps/ -hab/ -mlat-client/ -mlat-client* -ogn/ -phantomjs* -piaware_builder/ -planefinder/ -portal/graphs/dump1090.pyc -portal/logging/ diff --git a/install.sh b/install.sh index e1a6cb5..d1a1a19 100755 --- a/install.sh +++ b/install.sh @@ -35,10 +35,15 @@ ##################################################################################### -## ASSIGN VERSION VARIABLE +## ASSIGN VARIABLE project_version="2.8.5" +printf -v date_time '%(%Y-%m-%d_%H-%M-%S)T' -1 +log_file="adsb-installer_${date_time}.log" +logging_enabled="true" + + ## FUNCTIONS # Display the help message @@ -53,6 +58,7 @@ function DisplayHelp() { echo "-d --development Skips local repository update so changes are not overwrote." echo "-h --help Shows this message. " echo "-m --mta= Specify which email MTA to use currently Exim or Postfix. " + echo "-n --no-logging Disables writing output to a log file. " echo "-v --version Displays the version being used. " echo "-------------------------------------------------------------------------------------------" echo " " @@ -64,22 +70,18 @@ function DisplayHelp() { while [[ $# > 0 ]] ; do case $1 in --branch*) - # The specified branch of github project_branch=`echo $1 | sed -e 's/^[^=]*=//g'` shift 1 ;; -b) - # The specified branch of github project_branch=$2 shift 2 ;; --development | -d) - # Skip adsb-receiver repository update development_mode="true" shift 1 ;; --help | -h) - # Display a help message DisplayHelp exit 0 ;; @@ -91,6 +93,10 @@ while [[ $# > 0 ]] ; do fi shift 1 ;; + --no-logging | -n) + logging_enabled="false" + shift 1 + ;; -m) # The MTA to use mta=${2^^} @@ -114,9 +120,9 @@ while [[ $# > 0 ]] ; do esac done -# Add any environmental variables needed by any child scripts export RECEIVER_PROJECT_BRANCH=$project_branch export RECEIVER_DEVELOPMENT_MODE=$development_mode +export RECEIVER_LOGGING_ENABLED=$logging_enabled export RECEIVER_MTA=$mta @@ -136,6 +142,17 @@ source $RECEIVER_BASH_DIRECTORY/functions.sh source $RECEIVER_BASH_DIRECTORY/variables.sh +## CREATE THE LOG DIRECTORY + +if [[ "${RECEIVER_LOGGING_ENABLED}" == "true" ]]; then + export RECEIVER_LOG_FILE=$PWD/logs/$log_file + if [ ! -d "$DIRECTORY" ]; then + LogMessage "Creating logs directory" + mkdir $PWD/logs + fi +fi + + ## UPDATE PACKAGE LISTS AND INSTALL DEPENDENCIES clear @@ -147,7 +164,7 @@ LogHeading "Updating package lists for all enabled repositories and PPAs" LogMessage "Downloading the latest package lists for all enabled repositories and PPAs" echo "" -sudo apt-get update +sudo apt-get update 2>&1 | tee -a $RECEIVER_LOG_FILE LogHeading "Ensuring that all required packages are installed" @@ -185,14 +202,12 @@ $RECEIVER_BASH_DIRECTORY/init.sh ## CLEAN UP -# Remove any files created by whiptail. for choice in FEEDER_CHOICES EXTRAS_CHOICES ; do if [[ -f ${RECEIVER_ROOT_DIRECTORY}/${choice} ]] ; then rm -f ${RECEIVER_ROOT_DIRECTORY}/${choice} fi done -# Remove any global variables assigned by this script unset RECEIVER_PROJECT_TITLE unset RECEIVER_ROOT_DIRECTORY unset RECEIVER_BASH_DIRECTORY @@ -204,6 +219,8 @@ unset RECIEVER_CPU_ARCHITECTURE unset RECEIVER_CPU_REVISION unset RECEIVER_PROJECT_BRANCH unset RECEIVER_DEVELOPMENT_MODE +unset RECEIVER_LOGGING_ENABLED +unset RECEIVER_LOG_FILE unset RECEIVER_MTA # Check if any errors were encountered by any child scripts