From 2df7a7f88a98c21c7591b4f19ff6b32451438255 Mon Sep 17 00:00:00 2001 From: Joe Prochazka Date: Fri, 8 Jan 2016 14:16:21 -0500 Subject: [PATCH] Set LAT, LON, and BEAST_INPUT_PORT for dump1090. --- CHANGELOG.md | 3 +++ bash/decoders/dump1090-mutability.sh | 38 ++++++++++++++++++++-------- bash/feeders/piaware.sh | 20 +++------------ bash/functions.sh | 16 ++++++++++++ 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b8f529..218d2d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ The following is a history of the changes made to this project. ## January 8th, 2016 +* Now asks user for the latitude and longitude of the feeder. +* Dump1090-mutability is now set to listen for BEAST input on port 30104. +* PiAware is no longer configured to send MLAT data over port 30001. * Behind the scenes work mainly dealling with cleaning up the scripting a little. * Consolidated software version variables into a single file. * The CheckPackage function is no longer repeatative throughout all the scripts needing it. diff --git a/bash/decoders/dump1090-mutability.sh b/bash/decoders/dump1090-mutability.sh index 6ae4a76..db786b2 100755 --- a/bash/decoders/dump1090-mutability.sh +++ b/bash/decoders/dump1090-mutability.sh @@ -112,13 +112,6 @@ if [ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "o exit 1 fi -## START DUMP1090-MUTABILITY - -echo -e "\033[33m" -echo "Starting dump1090-mutability..." -echo -e "\033[37m" -sudo /etc/init.d/dump1090-mutability start - ## CONFIGURE LIGHTTPD echo -e "\033[33m" @@ -127,12 +120,30 @@ echo -e "\033[37m" sudo lighty-enable-mod dump1090 sudo /etc/init.d/lighttpd force-reload -## START DUMP1090-MUTABILITY +## DUMP1090-MUTABILITY POST INSTALLATION CONFIGURATION +# Set latitude and longitude. +echo -e "\033[31m" +echo "SET THE LATITUDE AND LONGITUDE OF YOUR FEEDER" echo -e "\033[33m" -echo "Startng dump1090-mutability..." +echo "In order for some performance graphs to work properly you will need to" +echo "set the latitude and longitude of your feeder. If you do not know the" +echo "latitude and longitude of your feeder you can find out this information" +echo "by using Geocode by Address tool found on my web site." +echo "" +echo " https://www.swiftbyte.com/toolbox/geocode" echo -e "\033[37m" -sudo /etc/init.d/dump1090-mutability start +read -p "Feeder Latitude: " FEEDERLAT +read -p "Feeder Longitude: " FEEDERLON +echo "" +ChangeConfig "LAT" $FEEDERLAT "/etc/default/dump1090-mutability" +ChangeConfig "LON" $FEEDERLON "/etc/default/dump1090-mutability" + +# Set dump190-mutability's BEAST_INPUT_PORT to 30104. +echo -e "\033[33m" +echo "Configuring dump1090-mutability to listen for BEAST input on port 30104..." +echo -e "\033[37m" +ChangeConfig "BEAST_INPUT_PORT" "30104" "/etc/default/dump1090-mutability" ## HEYWHATSTHAT.COM TERRAIN LIMIT RINGS @@ -184,6 +195,13 @@ else echo -e "Skipping terrain limit ring setup...\033[37m" fi +## START DUMP1090-MUTABILITY + +echo -e "\033[33m" +echo "Startng dump1090-mutability..." +echo -e "\033[37m" +sudo /etc/init.d/dump1090-mutability start + ## DISPLAY MESSAGE STATING DUMP1090-MUTABILITY SETUP IS COMPLETE echo -e "\033[33m" diff --git a/bash/feeders/piaware.sh b/bash/feeders/piaware.sh index 67acc89..8f65ebf 100755 --- a/bash/feeders/piaware.sh +++ b/bash/feeders/piaware.sh @@ -133,29 +133,17 @@ fi ## CONFIGURE FLIGHTAWARE +echo -e "\033[31m" +echo "CLAIM YOUR PIAWARE DEVICE" echo -e "\033[33m" echo "Please supply your FlightAware login in order to claim this device." echo "After supplying your login PiAware will ask you to enter your password for verification." +echo "If you decide not to supply a login and password you should still be able to claim your" +echo "feeder by visting the page http://flightaware.com/adsb/piaware/claim." echo -e "\033[37m" read -p "Your FlightAware Login: " FALOGIN sudo piaware-config -user $FALOGIN -password -echo -e "\033[33m" -printf "Remapping MLAT results to use port 30004..." -ORIGINALFORMAT=`sudo piaware-config -show | grep mlatResultsFormat | sed 's/mlatResultsFormat //g'` -MLATRESULTS=`sed 's/[{}]//g' <<< $ORIGINALFORMAT` -CLEANFORMAT=`sed 's/beast,connect,localhost:30004//g' <<< $MLATRESULTS` -FINALFORMAT="${CLEANFORMAT} beast,connect,localhost:30004" | sed -e 's/^[ \t]*//' - -# Make sure that the mlatResultsFormat setting is not left blank if no other settings exist. -if [ -n "$FINALFORMAT" ]; then - sudo piaware-config -mlatResultsFormat "${FINALFORMAT}" -else - sudo piaware-config -mlatResultsFormat "beast,connect,localhost:30004" -fi - -echo -e "\033[32m [OK]" - echo -e "\e[33m" echo "Restarting PiAware to ensure all changes are applied..." echo -e "\033[37m" diff --git a/bash/functions.sh b/bash/functions.sh index 77345ed..fa2a642 100755 --- a/bash/functions.sh +++ b/bash/functions.sh @@ -81,3 +81,19 @@ function CheckPackage { done } +################################################################################# +# Change a setting in a configuration file. +# The function expects 3 parameters to be passed to it in the following order. +# ChangeConfig KEY VALUE FILE + +function ChangeConfig { + # For clearity I am assigning the parameters to named variables. + KEY=$1 + VALUE=$2 + FILE=$3 + + # Use sed to locate the "KEY" then replace the "VALUE", the portion after the equals sign, in the specified "FILE". + # This function should work with any configuration file formated KEY="VALUE". + echo -e "\033[33mChanging the value for $KEY to $VALUE in the file $FILE...\033[37m" + sudo sed -i "s/\($1 *= *\).*/\1\"$2\"/" $3 +}