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

add remote input-config params to mlat-client (#13)

This commit is contained in:
kx1t 2023-05-04 15:26:19 -04:00 committed by GitHub
commit 3bb68ea796
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 102 additions and 51 deletions

View file

@ -281,6 +281,8 @@ The ULTRAFEEDER_CONFIG parameter can have multiple config strings, separated by
- ULTRAFEEDER_CONFIG=adsb,host,port,protocol[,uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX][,extra-arguments] - ULTRAFEEDER_CONFIG=adsb,host,port,protocol[,uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX][,extra-arguments]
...or... ...or...
- ULTRAFEEDER_CONFIG=mlat,host,port[,return_port][,uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX][,extra-arguments] - ULTRAFEEDER_CONFIG=mlat,host,port[,return_port][,uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX][,extra-arguments]
...or to retrieve MLAT data from a remote receiver...
- ULTRAFEEDER_CONFIG=mlat,host,port[,return_port][,uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX][,input_connect=remote-host:port,lat=xx.xxxx,lon=yy.yyyy,alt=zzz][,extra-arguments]
...or... ...or...
- ULTRAFEEDER_CONFIG=mlathub,host,port,protocol[,uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX][,extra-arguments] - ULTRAFEEDER_CONFIG=mlathub,host,port,protocol[,uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX][,extra-arguments]
``` ```
@ -300,6 +302,11 @@ In the above configuration strings:
- `vrs_out`: SBS-format output - `vrs_out`: SBS-format output
- `uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX` is an optional parameter that sets the UUID for this specific instance. It will override the global `UUID` parameter. This is only needed when you want to send different UUIDs to different aggregators. - `uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX` is an optional parameter that sets the UUID for this specific instance. It will override the global `UUID` parameter. This is only needed when you want to send different UUIDs to different aggregators.
- `extra-arguments` can be any additional command line argument you want to pass to readsb, mlathub, or mlat-client. Example: `--net-only`. Please make sure to only once pass in an extra argument for each of the adsb|mlat|mlathub service. - `extra-arguments` can be any additional command line argument you want to pass to readsb, mlathub, or mlat-client. Example: `--net-only`. Please make sure to only once pass in an extra argument for each of the adsb|mlat|mlathub service.
- To connect to a remote receiver and send MLAT data to a MLAT Server, create a `mlat` instance with these additional parameters - `input_connect=remote-host:port,lat=xx.xxxx,lon=yy.yyyy,alt=zzz`, where:
- `input_connect=remote-host:port` defines the remote receiver's hostname or IP address and the port number where BEAST output data is available
- `lat=xx.xxxx` defines the remote receiver's latitude
- `lon=yy.yyyy` defines the remote receiver's longitude
- `alt=zzz` defines the remote receiver's altitude in meters above the eliptoid (~above sea level)
##### Networking parameters ##### Networking parameters
@ -387,11 +394,12 @@ where:
- `port` is the port (TCP or UDP) of the target MLAT server (mandatory) - `port` is the port (TCP or UDP) of the target MLAT server (mandatory)
- `return_port` is the port at which the MLAT results are made available in BEAST format. We recommend to sequentially number them starting at 39000 (optional) - `return_port` is the port at which the MLAT results are made available in BEAST format. We recommend to sequentially number them starting at 39000 (optional)
- `uuid=xxxx` defines a unique user ID for this MLAT server instance. If included, the string must start with `uuid=` (optional) - `uuid=xxxx` defines a unique user ID for this MLAT server instance. If included, the string must start with `uuid=` (optional)
- `input_connect=hostname:port` / `lat=xxxx` / `lon=xxxx` / `alt=xxxx` defines a unique input connection/latitude/longitude/altitude. This can be used to connect to a remote Beast source and forward MLAT data to an MLAT server
- `extra-arguments` are any additional command line arguments that you would like to use for this MLAT Client instance (optional) - `extra-arguments` are any additional command line arguments that you would like to use for this MLAT Client instance (optional)
Note - the three optional parameters (`return_port`, `uuid=`, and `extra-arguments`) can be given in any order. Note - the three optional parameters (`return_port`, `uuid=`, and `extra-arguments`) can be given in any order.
If no UUID is specified with the `MLAT_CONFIG` parameter, it will use the value of the `UUID` parameter if it exists. If that fails, no UUID parameter is included with `mlat-client`. If no UUID is specified with the `MLAT_CONFIG` parameter, it will use the value of the `UUID` parameter if it exists. If that fails, a random UUID will be generated for each instance of `mlat-client` with format `00000000-ffff-aaaa-rrrr-tttttttttttt` where `rrrr` is a random hexadecimal number and `tttttttttttt` contains the UUID creation time (secs since epoch) in hexadecimal format.
### Web Gui (`tar1090`) Configuration ### Web Gui (`tar1090`) Configuration

View file

@ -20,4 +20,6 @@ source /scripts/common
# If not, see <https://www.gnu.org/licenses/>. # If not, see <https://www.gnu.org/licenses/>.
#--------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------
alias s6wrap='s6wrap --quiet'
[[ -f /.CONTAINER_VERSION ]] && s6wrap --prepend=01-print-container-version --timestamps --args echo "Container Version: $(cat /.CONTAINER_VERSION), build date $(stat -c '%y' /.CONTAINER_VERSION |sed 's|\(.*\)\.[0-9]* \(.*\)|\1 \2|g')" || true [[ -f /.CONTAINER_VERSION ]] && s6wrap --prepend=01-print-container-version --timestamps --args echo "Container Version: $(cat /.CONTAINER_VERSION), build date $(stat -c '%y' /.CONTAINER_VERSION |sed 's|\(.*\)\.[0-9]* \(.*\)|\1 \2|g')" || true

View file

@ -18,6 +18,8 @@
#--------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------
APPNAME="mlat-client" APPNAME="mlat-client"
alias s6wrap='s6wrap --quiet'
s6wrap --prepend="${APPNAME}" --timestamps --args echo "Started as an s6 service" s6wrap --prepend="${APPNAME}" --timestamps --args echo "Started as an s6 service"
source /scripts/common source /scripts/common
@ -74,9 +76,6 @@ do
# put individual params into the $params array: # put individual params into the $params array:
readarray -td "," params < <(printf '%s' "${instance}") readarray -td "," params < <(printf '%s' "${instance}")
uuid_arg=false
extra_args=""
# Check if the params array has values for the mandatory elements: # Check if the params array has values for the mandatory elements:
if [[ -z "${params[0]}" ]] || [[ -z "${params[1]}" ]] if [[ -z "${params[0]}" ]] || [[ -z "${params[1]}" ]]
then then
@ -86,31 +85,52 @@ do
sleep infinity sleep infinity
fi fi
# Now process the the arguments
# The order doesn't matter, we'll do pattern matching:
# If the argument is a number, then it must be the beast_results port
# If the argument starts with "uuid=", then it must be a UUID, etc.
# If the argument isn't any of the above, then it's an "extra argument"
unset uuid_arg lat_arg lon_arg alt_arg input_connect_arg return_port_arg extra_args
for ((i=2; i<${#params[*]}; i++))
do
if [[ -n "${params[i]}" ]] && [[ "${params[i]}" =~ ^[0-9]+$ ]]; then
# It's a number so it must be the return port
return_port_arg="${params[i]}"
elif header="${params[i]:0:5}" && [[ "${header,,}" == "uuid=" ]]; then
# It's a UUID
uuid_arg="${params[i]#*=}"
elif header="${params[i]:0:4}" && [[ "${header,,}" == "lat=" ]]; then
# It's a latitude
lat_arg="${params[i]#*=}"
elif header="${params[i]:0:4}" && [[ "${header,,}" == "lon=" ]]; then
# It's a longitude
lon_arg="${params[i]#*=}"
elif header="${params[i]:0:4}" && [[ "${header,,}" == "alt=" ]]; then
# It's a latitude
alt_arg="${params[i]#*=}"
elif header="${params[i]:0:14}" && [[ "${header,,}" == "input_connect=" ]]; then
#It's the input_connect parameter value
input_connect_arg="${params[i]#*=}"
else
# It's an Extra Args string
extra_args="$extra_args ${params[i]}"
fi
done
# ------------------------------------------------ # ------------------------------------------------
# Build the MLAT parameter string: # Build the MLAT parameter string:
MLAT_PARAM=(--input-type "${MLAT_INPUT_TYPE}") MLAT_PARAM=(--input-type "${MLAT_INPUT_TYPE:-auto}")
MLAT_PARAM+=(--input-connect localhost:30005)
MLAT_PARAM+=(--server "${params[0]}:${params[1]}") MLAT_PARAM+=(--server "${params[0]}:${params[1]}")
if [ -n "${LAT}" ]; then # add return port:
MLAT_PARAM+=(--lat "${LAT}") [ -n "${return_port_arg}" ] && MLAT_PARAM+=("--results beast,listen,${return_port_arg}") || true
elif [ -n "${READSB_LAT}" ]; then
MLAT_PARAM+=(--lat "${READSB_LAT}")
fi
if [ -n "${LONG}" ]; then # add input-connect to the param array:
MLAT_PARAM+=(--lon "${LONG}") MLAT_PARAM+=(--input-connect "${input_connect_arg:-localhost:30005}")
elif [ -n "${READSB_LON}" ]; then
MLAT_PARAM+=(--lon "${READSB_LON}")
fi
if [ -n "${ALT}" ]; then if [ -n "${MLAT_USER}" ]; then
MLAT_PARAM+=(--alt "${ALT}")
elif [ -n "${READSB_ALT}" ]; then
MLAT_PARAM+=(--alt "${READSB_ALT}")
fi
if [[ -n "${MLAT_USER}" ]]; then
MLAT_PARAM+=(--user "${MLAT_USER}") MLAT_PARAM+=(--user "${MLAT_USER}")
else else
rnd="${RANDOM}" rnd="${RANDOM}"
@ -118,33 +138,44 @@ do
MLAT_PARAM+=(--user "${rnd}") MLAT_PARAM+=(--user "${rnd}")
fi fi
# Now process the rest of the arguments # add LAT/LON/ALT to instance:
# The order doesn't matter, we'll do pattern matching: if [ -n "${lat_arg}" ]; then
# If the argument is a number, then it must be the beast_results port MLAT_PARAM+=(--lat "${lat_arg}")
# If the argument starts with "uuid=", then it must be a UUID elif [ -n "${LAT}" ]; then
# If the argument isn't any of the above, then it's an "extra argument" MLAT_PARAM+=(--lat "${LAT}")
elif [ -n "${READSB_LAT}" ]; then
MLAT_PARAM+=(--lat "${READSB_LAT}")
fi
for ((i=2; i<${#params[*]}; i++)) if [ -n "${lon_arg}" ]; then
do MLAT_PARAM+=(--lon "${lon_arg}")
if [[ -n "${params[i]}" ]] && [[ "${params[i]}" =~ ^[0-9]+$ ]]; then elif [ -n "${LONG}" ]; then
# It's a number so it must be the return port MLAT_PARAM+=(--lon "${LONG}")
MLAT_PARAM+=("--results beast,listen,${params[i]}") elif [ -n "${READSB_LON}" ]; then
MLAT_PARAM+=(--lon "${READSB_LON}")
fi
elif header="${params[i]:0:5}" && [[ "${header,,}" == "uuid=" ]]; then if [ -n "${alt_arg}" ]; then
# It's a UUID MLAT_PARAM+=(--alt "${alt_arg}")
MLAT_PARAM+=("--uuid ${params[i]:5}") elif [ -n "${ALT}" ]; then
uuid_arg=true MLAT_PARAM+=(--alt "${ALT}")
elif [ -n "${READSB_ALT}" ]; then
MLAT_PARAM+=(--alt "${READSB_ALT}")
fi
else # Add UUID to instance
# It's an Extra Args string if [ -n "$uuid_arg" ]; then
extra_args="$extra_args ${params[i]}" MLAT_PARAM+=("--uuid ${uuid_arg}")
elif [ -n "${UUID}" ]; then
fi MLAT_PARAM+=("--uuid ${UUID}")
done else
# If no UUID was set in the argument strings, check if we can use the generic UUID parameter # generate a random UUID
if [[ $uuid_arg == false ]] && [[ -n "${UUID}" ]]; then UUID="$(cat /proc/sys/kernel/random/uuid)"
[[ -z "${UUID}" ]] && UUID="$(printf '00000000-ffff-aaaa-%04x-%012x\n' "$RANDOM" "$(date +%s)")"
s6wrap --prepend="${APPNAME}" --timestamps --args echo "WARNING: UUID is not defined - using randomized uuid \"${UUID}\""
MLAT_PARAM+=("--uuid ${UUID}") MLAT_PARAM+=("--uuid ${UUID}")
fi fi
# Now add the extra_args, if any: # Now add the extra_args, if any:
[[ -n "${extra_args}" ]] && MLAT_PARAM+=("${extra_args}") || true [[ -n "${extra_args}" ]] && MLAT_PARAM+=("${extra_args}") || true
@ -169,9 +200,9 @@ do
#shellcheck disable=SC2069,SC2086 #shellcheck disable=SC2069,SC2086
if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
{ exec s6wrap --prepend="${APPNAME}" --timestamps --args ${execstring}; } & { exec s6wrap --prepend="${APPNAME}][${params[0]}" --timestamps --args ${execstring}; } &
elif [[ "${LOGLEVEL,,}" == "error" ]]; then elif [[ "${LOGLEVEL,,}" == "error" ]]; then
{ exec s6wrap --prepend="${APPNAME}" --timestamps --args ${execstring} 2>&1 >/dev/null; } & { exec s6wrap --prepend="${APPNAME}][${params[0]}" --timestamps --args ${execstring} 2>&1 >/dev/null; } &
elif [[ "${LOGLEVEL,,}" == "none" ]]; then elif [[ "${LOGLEVEL,,}" == "none" ]]; then
{ exec ${execstring} >/dev/null 2>/dev/null; } & { exec ${execstring} >/dev/null 2>/dev/null; } &
fi fi
@ -179,9 +210,10 @@ do
# pid_array is indexed by the PID of each mlat_client and contains the MLAT_PARAMs for that instance # pid_array is indexed by the PID of each mlat_client and contains the MLAT_PARAMs for that instance
# This is done so we can monitor them and restart them if needed # This is done so we can monitor them and restart them if needed
pid_array[$!]="${MLAT_PARAM[*]}" pid_array[$!]="${MLAT_PARAM[*]}"
sleep 5
done done
sleep 5
# All MLAT Clients are up, so set the flag. This flag is read by MLATHUB as a sign that it's # All MLAT Clients are up, so set the flag. This flag is read by MLATHUB as a sign that it's
# safe to start up # safe to start up
touch /run/mlathub_up touch /run/mlathub_up
@ -195,15 +227,18 @@ do
then then
# it exited - let's restart: # it exited - let's restart:
sleep "${RESTARTTIMER}" sleep "${RESTARTTIMER}"
[[ "${LOGLEVEL,,}" != "none" ]] && s6wrap --prepend="${APPNAME}" --timestamps --args echo "MLAT_Client $(awk '{print $6}' <<< "${pid_array[$mlat_pid]}") exited. Attempting to restart." || true servername="$(awk '{print $4}' <<< "${pid_array[$mlat_pid]}")"
servername="${servername%%:*}"
[[ "${LOGLEVEL,,}" != "none" ]] && s6wrap --prepend="${APPNAME}[${servername}" --timestamps --args echo "MLAT_Client ${servername} exited. Attempting to restart." || true
# shellcheck disable=SC2086 # shellcheck disable=SC2086
execstring="$(echo ${MLAT_CMD} ${pid_array[$mlat_pid]} | xargs)" execstring="$(echo ${MLAT_CMD} ${pid_array[$mlat_pid]} | xargs)"
#shellcheck disable=SC2069,SC2086 #shellcheck disable=SC2069,SC2086
if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
{ exec s6wrap --prepend="${APPNAME}" --timestamps --args ${execstring} 2>&1; } & { exec s6wrap --prepend="${APPNAME}][${servername}" --timestamps --args ${execstring} 2>&1; } &
elif [[ "${LOGLEVEL,,}" == "error" ]]; then elif [[ "${LOGLEVEL,,}" == "error" ]]; then
{ exec s6wrap --prepend="${APPNAME}" --timestamps --args ${execstring} 2>&1 >/dev/null; } & { exec s6wrap --prepend="${APPNAME}][${servername}" --timestamps --args ${execstring} 2>&1 >/dev/null; } &
elif [[ "${LOGLEVEL,,}" == "none" ]]; then elif [[ "${LOGLEVEL,,}" == "none" ]]; then
{ exec ${execstring} >/dev/null 2>/dev/null; } & { exec ${execstring} >/dev/null 2>/dev/null; } &
fi fi

View file

@ -4,6 +4,7 @@
APPNAME="mlathub" APPNAME="mlathub"
source /scripts/common source /scripts/common
source /scripts/interpret_ultrafeeder_config source /scripts/interpret_ultrafeeder_config
alias s6wrap='s6wrap --quiet'
if [[ -z "${MLAT_CONFIG}" ]] && [[ -z "$MLATHUB_NET_CONNECTOR" ]]; then if [[ -z "${MLAT_CONFIG}" ]] && [[ -z "$MLATHUB_NET_CONNECTOR" ]]; then
s6wrap --prepend="${APPNAME}" --timestamps --args echo "No MLAT servers have been defined in MLAT_CONFIG and no external sources have been defined in MLATHUB_NET_CONNECTOR - no need to start MLATHUB" s6wrap --prepend="${APPNAME}" --timestamps --args echo "No MLAT servers have been defined in MLAT_CONFIG and no external sources have been defined in MLATHUB_NET_CONNECTOR - no need to start MLATHUB"

View file

@ -5,6 +5,7 @@ APPNAME="readsb"
source /scripts/common source /scripts/common
source /scripts/interpret_ultrafeeder_config source /scripts/interpret_ultrafeeder_config
alias s6wrap='s6wrap --quiet'
mkdir -p /run/readsb mkdir -p /run/readsb

View file

@ -46,6 +46,10 @@
# `vrs_out`: SBS-format output # `vrs_out`: SBS-format output
# `uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX` is an optional parameter that sets the UUID for this specific instance. # `uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX` is an optional parameter that sets the UUID for this specific instance.
# It will override the global `UUID` parameter. This is only needed when you want to send different UUIDs to different aggregators. # It will override the global `UUID` parameter. This is only needed when you want to send different UUIDs to different aggregators.
# `input_connect=host:port is an optional parameter that sets the input_connect values for this instance`
# `lat=xxxx` is an optional parameter that sets the latitude for this specific instance
# `lon=xxxx` is an optional parameter that sets the longitude for this specific instance
# `alt=xxxx` is an optional parameter that sets the altitude for this specific instance
# `extra-arguments` can be any additional command line argument you want to pass to readsb, mlathub, or mlat-client # `extra-arguments` can be any additional command line argument you want to pass to readsb, mlathub, or mlat-client
# Example: `--net-only`. Please make sure to only once pass in an extra argument for each of the adsb|mlat|mlathub service. # Example: `--net-only`. Please make sure to only once pass in an extra argument for each of the adsb|mlat|mlathub service.