1
0
Fork 0
mirror of https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git synced 2024-11-21 13:20:11 +00:00

Add script to register for AussieADSB feed (#103)

* add AussieADSB registration script

* update readme

* make independent of container run

* update

* update readme

* minor update

* fix typo

* Update aussieadsb.sh

* Update aussieadsb.sh

* Update aussieadsb.sh

* Add netcat-traditional and net-tools to install check

* Update README.md

* Update aussieadsb.sh

* Update aussieadsb.sh
This commit is contained in:
kx1t 2024-06-16 07:43:21 -04:00 committed by GitHub
parent 9b6a51e27b
commit 1e6f694d80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 292 additions and 0 deletions

View file

@ -343,9 +343,16 @@ There are several aggregators, both non-profit and commercial, that can directly
| ADSB Exchange | C | Large aggregator owned by JetNet | adsb:`feed1.adsbexchange.com` port `30004`<br/>mlat: `feed.adsbexchange.com` port `31090` | | ADSB Exchange | C | Large aggregator owned by JetNet | adsb:`feed1.adsbexchange.com` port `30004`<br/>mlat: `feed.adsbexchange.com` port `31090` |
| RadarPlane | N | Run by a few aviation enthusiasts in Canada and Portugal | adsb: `feed.radarplane.com` port `30001`<br/>mlat: `feed.radarplane.com` port `31090` | | RadarPlane | N | Run by a few aviation enthusiasts in Canada and Portugal | adsb: `feed.radarplane.com` port `30001`<br/>mlat: `feed.radarplane.com` port `31090` |
| Fly Italy ADSB | N | Run by a few aviation enthusiasts in Italy | adsb: `dati.flyitalyadsb.com` port `4905`<br/>mlat: `dati.flyitalyadsb.com` port `30100` | | Fly Italy ADSB | N | Run by a few aviation enthusiasts in Italy | adsb: `dati.flyitalyadsb.com` port `4905`<br/>mlat: `dati.flyitalyadsb.com` port `30100` |
| AussieADSB | C | Small semi-commercial aggregator focused uniquely on Australia/Oceania. See <https://aussieadsb.com>. See below on how to configure a feed to them | adsb: `aussieadsb.com` port (varies)<br/>mlat: `aussieadsb.com` port `30000` |
When feeding AdsbExchange, Ultrafeeder will send statistics to adsbexchange.com by default. See the description of the `ADSBX_STATS` parameter on how to disable this. When feeding AdsbExchange, Ultrafeeder will send statistics to adsbexchange.com by default. See the description of the `ADSBX_STATS` parameter on how to disable this.
To feed AussieADSB (Australia/Oceania only!), execute this command on your host and follow the instructions. You can also use this command to de-register your feeder, or to see its status:
```bash
bash <(wget -qO - https://raw.githubusercontent.com/sdr-enthusiasts/docker-adsb-ultrafeeder/dev/aussieadsb.sh)
```
##### Alternate Configuration Method with `READSB_NET_CONNECTOR` ##### Alternate Configuration Method with `READSB_NET_CONNECTOR`
Instead of (or in addition to) using `BEASTHOST`, you can also define ADSB data ingests using the `READSB_NET_CONNECTOR` parameter. This is the preferred way if you have multiple sources or destinations for your ADSB data. This variable allows you to configure incoming and outgoing connections. The variable takes a semicolon (`;`) separated list of `host,port,protocol[,uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX]`, see the section [All-in-One Configuration using `ULTRAFEEDER_CONFIG`](#all-in-one-configuration-using-ultrafeeder_config) for explanation of these parameters. Instead of (or in addition to) using `BEASTHOST`, you can also define ADSB data ingests using the `READSB_NET_CONNECTOR` parameter. This is the preferred way if you have multiple sources or destinations for your ADSB data. This variable allows you to configure incoming and outgoing connections. The variable takes a semicolon (`;`) separated list of `host,port,protocol[,uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX]`, see the section [All-in-One Configuration using `ULTRAFEEDER_CONFIG`](#all-in-one-configuration-using-ultrafeeder_config) for explanation of these parameters.

285
aussieadsb.sh Executable file
View file

@ -0,0 +1,285 @@
#!/bin/bash
# shellcheck shell=bash disable=SC2015,SC2162
#
# Registration and query utility for aussieadsb,
# Meant for those who want to feed AussieADSB with Ultrafeeder
#
# AussieADSB is an Australian aggregator focused on feeders in Australia/Oceania.
# If you are in this region and are interested in feeding to them, please see:
# http://aussieadsb.com/
#
# You can run this script from any modern Debian Linux machine with this command:
# bash <(wget -qO - https://raw.githubusercontent.com/sdr-enthusiasts/docker-adsb-ultrafeeder/main/aussieadsb.sh)
#
#---------------------------------------------------------------------------------------------
# Copyright (C) 2024 Ramon F. Kolb (kx1t) and contributors
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#---------------------------------------------------------------------------------------------
#
AAClientVersion="1.2.0"
argv="${1,,}"
if [[ "${argv:0:1}" != "-" ]]; then argv="-$argv"; fi
while [[ "$argv" == "-" ]]; do
echo "AussieADSB registration utility"
echo "Visit https://aussieadsb.com for info"
echo
echo "Select an option:"
echo "(r)egister -- register a new receiver"
echo "(d)e-register -- deregister a receiver"
echo "(u)pdateinfo -- update your registration info"
echo "(s)tatus -- show the feeding status"
read -n 1 argv
echo
argv="${argv,,}"
case "$argv" in
r) argv="-register" ;;
d) argv="-deregister" ;;
u) argv="-updateinfo" ;;
s) argv="-status" ;;
*) echo "invalid selection, try again" ;;
esac
done
if [[ "$argv" == "-help" ]]; then
echo "Usage: $0 <option> [key]"
echo "Where <option> is one of the following:"
echo "-register -- register a new receiver"
echo "-deregister -- deregister a receiver"
echo "-updateinfo -- update your registration info"
echo "-status -- show the feeding status"
echo "-help -- show this help text"
echo
echo "The AussieADSB registration key is optional (and cannot be used with the -register option)"
echo "If you omit it, we'll ask you for it when doing -deregister, -updateinfo, or -status"
echo "You can also pass in the key using the AUSSIEADSB_KEY environment variable"
exit 0
fi
AUSSIEADSB_KEY="${AUSSIEADSB_KEY:-$2}"
if ! which jq >/dev/null 2>&1 || ! which netcat >/dev/null 2>&1 || ! which ifconfig >/dev/null 2>&1; then
echo "For registration to work, we need to do a one-time installation of JQ, NetCat, and ifconfig to your system"
echo "Please be patient..."
if (( UID == 0 )); then
apt-get update -qq
apt-get install -o Dpkg::Options::="--force-confnew" -y --no-install-recommends -qq jq netcat-traditional net-tools
else
sudo apt-get update -qq
sudo apt-get install -o Dpkg::Options::="--force-confnew" -y --no-install-recommends -qq jq netcat-traditional net-tools
fi
echo ""
echo ""
fi
case "$argv" in
"-register")
if [[ -n "$AUSSIEADSB_KEY" ]]; then
echo "Error - your station is already registered. Try \"$0 -status\""
exit 1
fi
echo ""
echo "AussieADSB Registration"
echo ""
echo "Which suburb is this receiver located in?"
echo "This will be used by the admins to set the receiver name on the site"
read suburb
while ! [[ $postcode =~ ^[0-9][0-9]{3}$ ]]; do
read -p "Please enter a valid 4-digit Australian postcode for the suburb: " postcode
done
read -p "Please enter your email address: " email
read -p "Please enter your first and last name: " name
echo ""
echo "We will attempt to register your receiver with this information:"
echo "Name: $name"
echo "Email: $email"
echo "Location: $suburb $postcode"
read -n 1 -p "Is this correct? (Y/n) " yesno
echo ""
if [[ "${yesno,,}" == "n" ]]; then
echo "Please run the command \"$0 $1\" again with the correct information!"
exit 1
fi
echo ""
echo "Registering receiver..."
response="$(printf '{"ReceiverToken":null,"ClientVersion":"%s","MessageType":"register","Data":{"LocalSourcePort":30005,"OSDescription":"%s","MacAddress":"%s","Suburb":"%s","Email":"%s","Name":"%s"}}' \
"$AAClientVersion" \
"$(uname -s -r -v)" \
"$(ifconfig -a | sed -n 's/^\s*ether \([0-9a-f:]\+\) .*$/\1/p' | head -1)" \
"$suburb $postcode" \
"$email" \
"$name" \
| nc aussieadsb.com 5000)"
rcvr_token="$(jq -r .Data.ReceiverToken <<< "$response" 2>/dev/null)"
rcvr_name="$(jq -r .Data.ReceiverName <<< "$response" 2>/dev/null)"
port="$(jq -r .Data.Port <<< "$response" 2>/dev/null)"
if [[ "$rcvr_token" == "null" ]] || [[ "$rcvr_name" == "null" ]] || [[ "$port" == "null" ]]; then
echo "Something went wrong. The registration engine returned this:"
jq -r . <<< "$response"
echo ""
echo "Try again later!"
exit 1
fi
echo "Your receiver is registered! Please add the following to your Ultrafeeder environment parameters in docker-compose.yml:"
echo
echo "In ULTRAFEEDER_CONFIG, add this line:"
echo " adsb,aussieadsb.com,$port,beast_reduce_plus_out;"
echo " mlat,aussieadsb.com,30000;"
echo
echo "Add the following parameter as well:"
echo "- AUSSIEADSB_KEY='$rcvr_token'"
echo
echo "After adding these, please recreate your Ultrafeeder container to start feeding AussieADSB!"
echo
echo "Visit http://aussieadsb.com/status to check feeding status"
echo "Currently, your receiver name is \"$rcvr_name\", but it will soon be renamed by the admins to your location."
echo
echo "Please keep your AUSSIEADSB_KEY value ($rcvr_token) and Port Number ($port) in a safe place - you will need it to reinstate your station if you ever update your system"
echo
;;
"-deregister")
echo ""
echo "AussieADSB De-registration"
echo ""
while [[ -z "$AUSSIEADSB_KEY" ]]; do
read -rp "Please enter your AussieADSB Registration Key: " AUSSIEADSB_KEY
done
response="$(printf '{"ReceiverToken":"%s","ClientVersion":"%s","MessageType":"status","Data":null}' "$AUSSIEADSB_KEY" "$AAClientVersion" | nc aussieadsb.com 5000)"
msg_type="$(jq -r .MessageType <<< "$response")"
rcvr_name="$(jq -r .Data.Name <<< "$response")"
if [[ "$msg_type" != "statusresponse" ]] || [[ "$rcvr_name" == "null" ]]; then
echo "Cannot find a receiver with Registration Key \"$AUSSIEADSB_KEY\"!"
echo "Please check the key and try again!"
exit 1
fi
read -n 1 -p "Are you sure you want to deregister station \"$rcvr_name\"? (y/N) " yesno
echo ""
if [[ "$yesno" != "y" ]]; then
echo "Aborting deregistration!"
exit 0
fi
echo "Deregistering station $rcvr_name with key $AUSSIEADSB_KEY..."
response="$(printf '{"ReceiverToken":"%s","ClientVersion":"%s","MessageType":"deregister","Data":"User"}' "$AUSSIEADSB_KEY" "$AAClientVersion" | nc aussieadsb.com 5000)"
if [[ "$(jq -r .MessageType <<< "$response" 2>/dev/null)" == "deregisterresponse" ]]; then
echo "De-registration complete!"
exit 0
else
echo "Something went wrong. The registration engine returned this:"
jq -r . <<< "$response"
echo ""
echo "Try again later!"
exit 1
fi
;;
"-status")
echo ""
echo "AussieADSB Feeder Status"
echo ""
while [[ -z "$AUSSIEADSB_KEY" ]]; do
read -rp "Please enter your AussieADSB Registration Key: " AUSSIEADSB_KEY
done
response="$(printf '{"ReceiverToken":"%s","ClientVersion":"%s","MessageType":"status","Data":null}' "$AUSSIEADSB_KEY" "$AAClientVersion" | nc aussieadsb.com 5000)"
msg_type="$(jq -r .MessageType <<< "$response" 2>/dev/null)"
rcvr_name="$(jq -r .Data.Name <<< "$response" 2>/dev/null)"
connected="$(jq -r .Data.Connected <<< "$response" 2>/dev/null)"
rcvr_ip="$(jq -r .Data.ConnectedIP <<< "$response" 2>/dev/null)"
if [[ "$msg_type" != "statusresponse" ]] || [[ "$rcvr_name" == "null" ]]; then
echo "Cannot find a receiver with Registration Key \"$AUSSIEADSB_KEY\"!"
echo "Please check the key and try again!"
exit 1
fi
if [[ "$connected" == true ]]; then connected="connected"; else connected="not connected"; fi
echo "Status for AUSSIEADSB_KEY \"$AUSSIEADSB_KEY\":"
echo "Registered Receiver Name: $rcvr_name"
echo "Connection status: $connected"
echo "Public IP address: $rcvr_ip"
echo ""
exit 0
;;
"-updateinfo")
echo ""
echo "AussieADSB Registration Update"
echo ""
while [[ -z "$AUSSIEADSB_KEY" ]]; do
read -rp "Please enter your AussieADSB Registration Key: " AUSSIEADSB_KEY
done
echo "Enter all information again. Your registration will be updated with the info you entered below."
echo "Please do not leave any fields empty."
echo ""
echo "In which suburb is this receiver located?"
echo "This will be used by the admins to set the receiver name on the site"
read suburb
while ! [[ $postcode =~ ^[0-9][0-9]{3}$ ]]; do
read -p "Please enter a valid 4-digit Australian postcode for the suburb: " postcode
done
read -p "Please enter your email address: " email
read -p "Please enter your first and last name: " name
echo ""
echo "We will attempt to register your receiver with this information:"
echo "Name: $name"
echo "Email: $email"
echo "Location: $suburb $postcode"
read -n 1 -p "Is this correct? (Y/n) " yesno
echo ""
if [[ "${yesno,,}" == "n" ]]; then
echo "Please run the command \"$0 $1\" again with the correct information!"
exit 1
fi
echo ""
echo "Updating receiver..."
response="$(printf '{"ReceiverToken":"%s","ClientVersion":"%s","MessageType":"update","Data":{"LocalSourcePort":30005,"OSDescription":"%s","MacAddress":"%s","Suburb":"%s","Email":"%s","Name":"%s"}}' \
"$AUSSIEADSB_KEY" \
"$AAClientVersion" \
"$(uname -s -r -v)" \
"$(ifconfig -a | sed -n 's/^\s*ether \([0-9a-f:]\+\) .*$/\1/p' | head -1)" \
"$suburb $postcode" \
"$email" \
"$name" \
| nc aussieadsb.com 5000)"
status="$(jq -r .MessageType <<< "$response" 2>/dev/null)"
if [[ "$status" != "updateresponse" ]]; then
echo "Something went wrong. The registration engine returned this:"
jq -r . <<< "$response"
echo ""
echo "Try again later!"
exit 1
fi
;;
*)
echo "Unknown option \"$1\". Please check and try again"
exit 1
;;
esac