├── LICENSE.md ├── README.md └── setup.sh /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2016 Joe Prochazka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ADS-B Exchange Setup Scripts :airplane: 2 | 3 | ## This repository was created before ADS-B Exchange supplied thier own installation scripts thus no longer maintained. 4 | 5 | These scripts aid in setting up your current ADS-B receiver to feed ADS-B Exchange. 6 | 7 | ### Obtaining And Using The Scripts 8 | 9 | Running the following commands will download the contents of this repository and begin setup. 10 | 11 | sudo apt-get install git 12 | git clone https://github.com/jprochazka/adsb-exchange.git 13 | cd adsb-exchange 14 | chmod +x setup.sh 15 | sudo ./setup.sh 16 | 17 | **After completing the setup do not delete this repository.** 18 | 19 | The script creates two files, one named adsbexchange-mlat_maint.sh and another named adsbexchange-netcat_maint.sh which will reside in this folder containing a clone of this repository. The path to execute these scripts after each reboot has been set to this location. Deleting this folder will result in both the adsbexchange-mlat_maint.sh and adsbexchange-netcat_maint.sh scripts to not be executed thus not enabling your receiver to feed ADS-B Exchange after your device has been rebooted. 20 | 21 | ### Reporting Issues 22 | 23 | Feel free to report any issues you encounter to one of the following locations: 24 | 25 | http://adsbreceiver.net/forum/cat/ads-b-exchange-setup-script/ 26 | https://github.com/jprochazka/adsb-exchange_setup/issues 27 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ##################################################################################### 4 | # ADS-B EXCHANGE SETUP SCRIPT # 5 | ##################################################################################### 6 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 7 | # # 8 | # Copyright (c) 2015-2016 Joseph A. Prochazka # 9 | # # 10 | # Permission is hereby granted, free of charge, to any person obtaining a copy # 11 | # of this software and associated documentation files (the "Software"), to deal # 12 | # in the Software without restriction, including without limitation the rights # 13 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 14 | # copies of the Software, and to permit persons to whom the Software is # 15 | # furnished to do so, subject to the following conditions: # 16 | # # 17 | # The above copyright notice and this permission notice shall be included in all # 18 | # copies or substantial portions of the Software. # 19 | # # 20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # 21 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # 22 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # 23 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # 24 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # 25 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # 26 | # SOFTWARE. # 27 | # # 28 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 29 | 30 | 31 | ## CHECK IF SCRIPT WAS RAN USING SUDO 32 | 33 | if [ "$(id -u)" != "0" ]; then 34 | echo -e "\033[33m" 35 | echo "This script must be ran using sudo or as root." 36 | echo -e "\033[37m" 37 | exit 1 38 | fi 39 | 40 | ## CHECK FOR PACKAGES NEEDED BY THIS SCRIPT 41 | 42 | echo -e "\033[33m" 43 | echo "Checking for packages needed to run this script..." 44 | 45 | if [ $(dpkg-query -W -f='${STATUS}' curl 2>/dev/null | grep -c "ok installed") -eq 0 ]; then 46 | echo "Installing the curl package..." 47 | echo -e "\033[37m" 48 | sudo apt-get update 49 | sudo apt-get install -y curl 50 | fi 51 | echo -e "\033[37m" 52 | 53 | ## ASSIGN VARIABLES 54 | 55 | LOGDIRECTORY="$PWD/logs" 56 | MLATCLIENTVERSION="0.2.6" 57 | MLATCLIENTTAG="v0.2.6" 58 | 59 | ## WHIPTAIL DIALOGS 60 | 61 | BACKTITLETEXT="ADS-B Exchange Setup Script" 62 | 63 | whiptail --backtitle "$BACKTITLETEXT" --title "$BACKTITLETEXT" --yesno "Thanks for choosing to share your data with ADS-B Exchange!\n\nADSBexchange.com is a co-op of ADS-B/Mode S/MLAT feeders from around the world. This script will configure your current your ADS-B receiver to share your feeders data with ADS-B Exchange.\n\nWould you like to continue setup?" 13 78 64 | CONTINUESETUP=$? 65 | if [ $CONTINUESETUP = 1 ]; then 66 | exit 0 67 | fi 68 | 69 | ADSBEXCHANGEUSERNAME=$(whiptail --backtitle "$BACKTITLETEXT" --title "ADS-B Exchange User Name" --nocancel --inputbox "\nPlease enter your ADS-B Exchange user name.\n\nIf you have more than one receiver, this username should be unique.\nExample: \"username-01\", \"username-02\", etc." 12 78 3>&1 1>&2 2>&3) 70 | RECEIVERLATITUDE=$(whiptail --backtitle "$BACKTITLETEXT" --title "Receiver Latitude" --nocancel --inputbox "\nEnter your receivers latitude." 9 78 3>&1 1>&2 2>&3) 71 | RECEIVERLONGITUDE=$(whiptail --backtitle "$BACKTITLETEXT" --title "Receiver Longitude" --nocancel --inputbox "\nEnter your receivers longitude." 9 78 3>&1 1>&2 2>&3) 72 | RECEIVERALTITUDE=$(whiptail --backtitle "$BACKTITLETEXT" --title "Receiver Altitude" --nocancel --inputbox "\nEnter your receivers altitude." 9 78 "`curl -s https://maps.googleapis.com/maps/api/elevation/json?locations=$RECEIVERLATITUDE,$RECEIVERLONGITUDE | python -c "import json,sys;obj=json.load(sys.stdin);print obj['results'][0]['elevation'];"`" 3>&1 1>&2 2>&3) 73 | RECEIVERPORT=$(whiptail --backtitle "$BACKTITLETEXT" --title "Receiver Feed Port" --nocancel --inputbox "\nChange only if you were assigned a custom feed port.\nFor most all users it is required this port remain set to port 30005." 10 78 "30005" 3>&1 1>&2 2>&3) 74 | 75 | whiptail --backtitle "$BACKTITLETEXT" --title "$BACKTITLETEXT" --yesno "We are now ready to begin setting up your receiver to feed ADS-B Exchange.\n\nDo you wish to proceed?" 9 78 76 | CONTINUESETUP=$? 77 | if [ $CONTINUESETUP = 1 ]; then 78 | exit 0 79 | fi 80 | 81 | ## BEGIN SETUP 82 | 83 | { 84 | 85 | # Make a log directory if it does not already exist. 86 | if [ ! -d "$LOGDIRECTORY" ]; then 87 | mkdir $LOGDIRECTORY 88 | fi 89 | LOGFILE="$LOGDIRECTORY/image_setup-$(date +%F_%R)" 90 | touch $LOGFILE 91 | 92 | echo 4 93 | sleep 0.25 94 | 95 | # BUILD AND CONFIGURE THE MLAT-CLIENT PACKAGE 96 | 97 | echo "INSTALLING PREREQUISITE PACKAGES" >> $LOGFILE 98 | echo "--------------------------------------" >> $LOGFILE 99 | echo "" >> $LOGFILE 100 | 101 | 102 | # Check that the prerequisite packages needed to build and install mlat-client are installed. 103 | if [ $(dpkg-query -W -f='${STATUS}' build-essential 2>/dev/null | grep -c "ok installed") -eq 0 ]; then 104 | sudo apt-get install -y build-essential >> $LOGFILE 2>&1 105 | fi 106 | 107 | echo 10 108 | sleep 0.25 109 | 110 | if [ $(dpkg-query -W -f='${STATUS}' debhelper 2>/dev/null | grep -c "ok installed") -eq 0 ]; then 111 | sudo apt-get install -y debhelper >> $LOGFILE 2>&1 112 | fi 113 | 114 | echo 16 115 | sleep 0.25 116 | 117 | if [ $(dpkg-query -W -f='${STATUS}' python 2>/dev/null | grep -c "ok installed") -eq 0 ]; then 118 | sudo apt-get install -y python >> $LOGFILE 2>&1 119 | fi 120 | 121 | if [ $(dpkg-query -W -f='${STATUS}' python3-dev 2>/dev/null | grep -c "ok installed") -eq 0 ]; then 122 | sudo apt-get install -y python3-dev >> $LOGFILE 2>&1 123 | fi 124 | 125 | echo 22 126 | sleep 0.25 127 | 128 | if [ $(dpkg-query -W -f='${STATUS}' socat 2>/dev/null | grep -c "ok installed") -eq 0 ]; then 129 | sudo apt-get install -y socat >> $LOGFILE 2>&1 130 | fi 131 | 132 | echo 28 133 | sleep 0.25 134 | 135 | echo "" >> $LOGFILE 136 | echo " BUILD AND INSTALL MLAT-CLIENT" >> $LOGFILE 137 | echo "-----------------------------------" >> $LOGFILE 138 | echo "" >> $LOGFILE 139 | 140 | # Check if the mlat-client git repository already exists. 141 | if [ -d mlat-client ] && [ -d mlat-client/.git ]; then 142 | # If the mlat-client repository exists update the source code contained within it. 143 | cd mlat-client >> $LOGFILE 144 | git pull >> $LOGFILE 2>&1 145 | git checkout tags/$MLATCLIENTTAG >> $LOGFILE 2>&1 146 | else 147 | # Download a copy of the mlat-client repository since the repository does not exist locally. 148 | git clone https://github.com/mutability/mlat-client.git >> $LOGFILE 2>&1 149 | cd mlat-client >> $LOGFILE 2>&1 150 | git checkout tags/$MLATCLIENTTAG >> $LOGFILE 2>&1 151 | fi 152 | 153 | echo 34 154 | sleep 0.25 155 | 156 | # Build and install the mlat-client package. 157 | dpkg-buildpackage -b -uc >> $LOGFILE 2>&1 158 | cd .. >> $LOGFILE 159 | sudo dpkg -i mlat-client_${MLATCLIENTVERSION}*.deb >> $LOGFILE 160 | 161 | echo 40 162 | sleep 0.25 163 | 164 | echo "" >> $LOGFILE 165 | echo " CREATE AND CONFIGURE MLAT-CLIENT STARTUP SCRIPTS" >> $LOGFILE 166 | echo "------------------------------------------------------" >> $LOGFILE 167 | echo "" >> $LOGFILE 168 | 169 | # Create the mlat-client maintenance script. 170 | tee adsbexchange-mlat_maint.sh > /dev/null <> $LOGFILE 184 | 185 | echo 52 186 | sleep 0.25 187 | 188 | # Add a line to execute the mlat-client maintenance script to /etc/rc.local so it is started after each reboot if one does not already exist. 189 | if ! grep -Fxq "$PWD/adsbexchange-mlat_maint.sh &" /etc/rc.local; then 190 | LINENUMBER=($(sed -n '/exit 0/=' /etc/rc.local)) 191 | ((LINENUMBER>0)) && sudo sed -i "${LINENUMBER[$((${#LINENUMBER[@]}-1))]}i $PWD/adsbexchange-mlat_maint.sh &\n" /etc/rc.local >> $LOGFILE 192 | fi 193 | 194 | echo 58 195 | sleep 0.25 196 | 197 | echo "" >> $LOGFILE 198 | echo " CREATE AND CONFIGURE NETCAT STARTUP SCRIPTS" >> $LOGFILE 199 | echo "-------------------------------------------------" >> $LOGFILE 200 | echo "" >> $LOGFILE 201 | 202 | # Kill any currently running instances of the adsbexchange-mlat_maint.sh script. 203 | PIDS=`ps -efww | grep -w "adsbexchange-mlat_maint.sh" | awk -vpid=$$ '$2 != pid { print $2 }'` 204 | if [ ! -z "$PIDS" ]; then 205 | sudo kill $PIDS >> $LOGFILE 206 | sudo kill -9 $PIDS >> $LOGFILE 207 | fi 208 | 209 | echo 64 210 | sleep 0.25 211 | 212 | # Execute the mlat-client maintenance script. 213 | sudo nohup $PWD/adsbexchange-mlat_maint.sh > /dev/null 2>&1 & >> $LOGFILE 214 | 215 | echo 70 216 | sleep 0.25 217 | 218 | # SETUP NETCAT TO SEND DUMP1090 DATA TO ADS-B EXCHANGE 219 | 220 | # Create the netcat maintenance script. 221 | tee adsbexchange-netcat_maint.sh > /dev/null <> $LOGFILE 235 | 236 | echo 82 237 | sleep 0.25 238 | 239 | # Add a line to execute the netcat maintenance script to /etc/rc.local so it is started after each reboot if one does not already exist. 240 | if ! grep -Fxq "$PWD/adsbexchange-netcat_maint.sh &" /etc/rc.local; then 241 | lnum=($(sed -n '/exit 0/=' /etc/rc.local)) 242 | ((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i $PWD/adsbexchange-netcat_maint.sh &\n" /etc/rc.local >> $LOGFILE 243 | fi 244 | 245 | echo 88 246 | sleep 0.25 247 | 248 | # Kill any currently running instances of the adsbexchange-netcat_maint.sh script. 249 | PIDS=`ps -efww | grep -w "adsbexchange-netcat_maint.sh" | awk -vpid=$$ '$2 != pid { print $2 }'` 250 | if [ ! -z "$PIDS" ]; then 251 | sudo kill $PIDS >> $LOGFILE 252 | sudo kill -9 $PIDS >> $LOGFILE 253 | fi 254 | 255 | echo 94 256 | sleep 0.25 257 | 258 | # Execute the netcat maintenance script. 259 | sudo nohup $PWD/adsbexchange-netcat_maint.sh > /dev/null 2>&1 & >> $LOGFILE 260 | echo 100 261 | sleep 0.25 262 | 263 | } | whiptail --backtitle "$BACKTITLETEXT" --title "Setting Up ADS-B Exchange Feed" --gauge "\nSetting up your receiver to feed ADS-B Exchange.\nThe setup process may take awhile to complete..." 8 60 0 264 | 265 | ## SETUP COMPLETE 266 | 267 | # Display the thank you message box. 268 | whiptail --title "ADS-B Exchange Setup Script" --msgbox "\nSetup is now complete.\n\nYour feeder should now be feeding data to ADS-B Exchange.\nThanks again for choosing to share your data with ADS-B Exchange!\n\nIf you have questions or encountered any issues while using this script feel free to post them to one of the following places.\n\nhttps://github.com/jprochazka/adsb-exchange\nhttp://www.adsbexchange.com/forums/topic/ads-b-exchange-setup-script/" 17 73 269 | 270 | exit 0 271 | --------------------------------------------------------------------------------