Skip to content

Commit 21e90ad

Browse files
committedMar 22, 2021
improve shell scripting for install
make it possible to update independent of configuring and vice versa
1 parent 6383617 commit 21e90ad

File tree

5 files changed

+524
-411
lines changed

5 files changed

+524
-411
lines changed
 

‎configure.sh

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
3+
#####################################################################################
4+
# ADS-B EXCHANGE SETUP SCRIPT #
5+
#####################################################################################
6+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
7+
# #
8+
# Copyright (c) 2020 ADSBx #
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+
set -e
31+
trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR
32+
renice 10 $$ &>/dev/null
33+
34+
IPATH=/usr/local/share/adsbexchange
35+
36+
function abort() {
37+
echo ------------
38+
echo "Setup canceled (probably using Esc button)!"
39+
echo "Please re-run this setup if this wasn't your intention."
40+
echo ------------
41+
exit 1
42+
}
43+
44+
## WHIPTAIL DIALOGS
45+
46+
BACKTITLETEXT="ADS-B Exchange Setup Script"
47+
48+
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 || abort
49+
50+
ADSBEXCHANGEUSERNAME=$(whiptail --backtitle "$BACKTITLETEXT" --title "Feeder MLAT Name" --nocancel --inputbox "\nPlease enter a unique name for the feeder to be shown on the MLAT matrix (http://adsbx.org/sync)\n\nText and Numbers only - everything else will be removed.\nExample: \"william34-london\", \"william34-jersey\", etc." 12 78 3>&1 1>&2 2>&3) || abort
51+
52+
NOSPACENAME="$(echo -n -e "${ADSBEXCHANGEUSERNAME}" | tr -c '[a-zA-Z0-9]_\- ' '_')"
53+
54+
whiptail --backtitle "$BACKTITLETEXT" --title "$BACKTITLETEXT" \
55+
--msgbox "For MLAT the precise location of your antenna is required.\
56+
\n\nA small error of 15m/45ft will cause issues with MLAT!\
57+
\n\nTo get your location, use any online map service or this website: https://www.mapcoordinates.net/en" 12 78 || abort
58+
59+
#((-90 <= RECEIVERLATITUDE <= 90))
60+
LAT_OK=0
61+
until [ $LAT_OK -eq 1 ]; do
62+
RECEIVERLATITUDE=$(whiptail --backtitle "$BACKTITLETEXT" --title "Receiver Latitude ${RECEIVERLATITUDE}" --nocancel --inputbox "\nEnter your receivers precise latitude in degrees with 5 decimal places.\n(Example: 32.36291)" 12 78 3>&1 1>&2 2>&3) || abort
63+
LAT_OK=`awk -v LAT="$RECEIVERLATITUDE" 'BEGIN {printf (LAT<90 && LAT>-90 ? "1" : "0")}'`
64+
done
65+
66+
67+
#((-180<= RECEIVERLONGITUDE <= 180))
68+
LON_OK=0
69+
until [ $LON_OK -eq 1 ]; do
70+
RECEIVERLONGITUDE=$(whiptail --backtitle "$BACKTITLETEXT" --title "Receiver Longitude ${RECEIVERLONGITUDE}" --nocancel --inputbox "\nEnter your receivers longitude in degrees with 5 decimal places.\n(Example: -64.71492)" 12 78 3>&1 1>&2 2>&3) || abort
71+
LON_OK=`awk -v LAT="$RECEIVERLONGITUDE" 'BEGIN {printf (LAT<180 && LAT>-180 ? "1" : "0")}'`
72+
done
73+
74+
until [[ $ALT =~ ^(.*)ft$ ]] || [[ $ALT =~ ^(.*)m$ ]]; do
75+
ALT=$(whiptail --backtitle "$BACKTITLETEXT" --title "Altitude above sea level (at the antenna):" \
76+
--nocancel --inputbox \
77+
"\nEnter your receivers altitude above sea level including the unit:\n\n\
78+
in feet like this: 255ft\n\
79+
or in meters like this: 78m\n" \
80+
12 78 3>&1 1>&2 2>&3) || abort
81+
done
82+
83+
if [[ $ALT =~ ^-(.*)ft$ ]]; then
84+
NUM=${BASH_REMATCH[1]}
85+
NEW_ALT=`echo "$NUM" "3.28" | awk '{printf "-%0.2f", $1 / $2 }'`
86+
ALT=$NEW_ALT
87+
fi
88+
if [[ $ALT =~ ^-(.*)m$ ]]; then
89+
NEW_ALT="-${BASH_REMATCH[1]}"
90+
ALT=$NEW_ALT
91+
fi
92+
93+
RECEIVERALTITUDE="$ALT"
94+
95+
#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)
96+
97+
98+
99+
tee /etc/default/adsbexchange >/dev/null <<EOF
100+
INPUT="127.0.0.1:30005"
101+
REDUCE_INTERVAL="0.5"
102+
103+
# feed name for checking MLAT sync (adsbx.org/sync)
104+
USER="$NOSPACENAME"
105+
106+
LATITUDE="$RECEIVERLATITUDE"
107+
LONGITUDE="$RECEIVERLONGITUDE"
108+
109+
ALTITUDE="$RECEIVERALTITUDE"
110+
111+
RESULTS="--results beast,connect,localhost:30104"
112+
RESULTS2="--results basestation,listen,31003"
113+
RESULTS3="--results beast,listen,30157"
114+
RESULTS4="--results beast,connect,localhost:30154"
115+
# add --privacy between the quotes below to disable having the feed name shown on the mlat map
116+
# (position is never shown accurately no matter the settings)
117+
PRIVACY=""
118+
INPUT_TYPE="dump1090"
119+
120+
MLATSERVER="feed.adsbexchange.com:31090"
121+
TARGET="--net-connector feed.adsbexchange.com,30004,beast_reduce_out,feed.adsbexchange.com,64004"
122+
NET_OPTIONS="--net-heartbeat 60 --net-ro-size 1280 --net-ro-interval 0.2 --net-ro-port 0 --net-sbs-port 0 --net-bi-port 30154 --net-bo-port 0 --net-ri-port 0"
123+
EOF
124+

‎install.sh

100644100755
+36-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
11
#!/bin/bash
2-
TMP=/tmp/adsbexchange-git
3-
if ! command -v git; then
4-
apt-get update
5-
apt-get install -y git
6-
fi
7-
rm -rf "$TMP"
82
set -e
9-
git clone https://github.com/adsbxchange/adsb-exchange.git "$TMP"
10-
cd "$TMP"
11-
bash setup.sh
3+
4+
REPO="https://github.com/adsbxchange/adsb-exchange.git"
5+
BRANCH="master"
6+
IPATH=/usr/local/share/adsbexchange
7+
mkdir -p $IPATH
8+
9+
if [ "$(id -u)" != "0" ]; then
10+
echo -e "\033[33m"
11+
echo "This script must be ran using sudo or as root."
12+
echo -e "\033[37m"
13+
exit 1
14+
fi
15+
16+
if ! command -v git &>/dev/null; then
17+
apt-get update || true
18+
apt-get install -y git || true
19+
fi
20+
21+
function getGIT() {
22+
# getGIT $REPO $BRANCH $TARGET-DIR
23+
if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then
24+
echo "getGIT wrong usage, check your script or tell the author!" 1>&2
25+
return 1
26+
fi
27+
if ! cd "$3" &>/dev/null || ! git fetch origin "$2" || ! git reset --hard FETCH_HEAD; then
28+
if ! rm -rf "$3" || ! git clone --depth 2 --single-branch --branch "$2" "$1" "$3"; then
29+
return 1
30+
fi
31+
fi
32+
return 0
33+
}
34+
35+
getGIT "$REPO" "$BRANCH" "$IPATH/git"
36+
37+
cd "$IPATH/git"
38+
bash "$IPATH/git/setup.sh"

0 commit comments

Comments
 (0)
Please sign in to comment.