1
0
Fork 0
mirror of https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git synced 2024-10-16 05:50:44 +00:00

add common script functions

This commit is contained in:
kx1t 2023-04-08 17:07:11 -04:00
parent bcce55269c
commit 6ca51216c8
8 changed files with 73 additions and 44 deletions

View file

@ -101,6 +101,11 @@ Aircraft.json:
The sections below describe how to configure each part of the container functionality. Each section describes what's needed to come up with a minimally viable configuration, followed by additional / optional parameters that can also be set.
Note:
- to enable a parameter, you can set it to any of `1`, `true`, `on`, `enabled`, `enable`, `yes`, or `y`. In the table below, we'll simply use `true` for convenience.
- to disable a parameter, you can set it to anything else or simply leave it undefined.
### General Configuration
You need to make sure that the USB device can be accessed by the container. The best way to do so, is by adding the following to you `docker-compose.yml` file:
@ -132,17 +137,17 @@ The following parameters must be set (mandatory) for the container to function:
| Variable | Description | Controls which `readsb` option | Default |
|----------|-------------|--------------------------------|---------|
| `ENABLE_TIMELAPSE1090` | Optional / Legacy. Set to any value to enable timelapse1090. Once enabled, can be accessed via <http://dockerhost:port/timelapse/>. | Unset |
| `ENABLE_TIMELAPSE1090` | Optional / Legacy. Set to `true` to enable timelapse1090. Once enabled, can be accessed via <http://dockerhost:port/timelapse/>. | Unset |
| `READSB_EXTRA_ARGS` | Optional, allows to specify extra parameters for readsb | Unset |
| `READSB_DEBUG` | Optional, used to set debug mode. `n`: network, `P`: CPR, `S`: speed check | Unset |
| `S6_SERVICES_GRACETIME` | Optional, set to 30000 when saving traces / globe_history | `3000` |
| `READSB_MAX_RANGE` | Optional. Maximum range (in nautical miles). | `300` |
| `READSB_ENABLE_BIASTEE` | Set to any value to enable bias tee on supporting interfaces | | Unset |
| `READSB_ENABLE_BIASTEE` | Set to `true` to enable bias tee on supporting interfaces | | Unset |
| `READSB_RX_LOCATION_ACCURACY` | Accuracy of receiver location in metadata: 0=no location, 1=approximate, 2=exact | `--rx-location-accuracy=<n>` | `2` |
| `READSB_HEATMAP_INTERVAL` | Per plane interval for heatmap and replay (if you want to lower this, also lower json-trace-interval to this or a lower value) | `--heatmap=<sec>` | `15` |
| `READSB_MAX_RANGE` | Absolute maximum range for position decoding (in nm) | `--max-range=<dist>` | `300` |
| `READSB_STATS_EVERY` | Number of seconds between showing and resetting stats. | `--stats-every=<sec>` | Unset |
| `READSB_STATS_RANGE` | Set this to any value to collect range statistics for polar plot. | `--stats-range` | Unset |
| `READSB_STATS_RANGE` | Set this to `true` to collect range statistics for polar plot. | `--stats-range` | Unset |
| `READSB_RANGE_OUTLINE_HOURS` | Change which past timeframe the range outline is based on | `--range-outline-hours` | `24` |
| `READSB_EXTRA_ARGS` | Optional, allows to specify extra parameters for readsb | | Unset |
| `S6_SERVICES_GRACETIME` | Optional, set to 30000 when saving traces / globe_history | | `3000` |
@ -271,7 +276,7 @@ There are many optional parameters relating to the ingestion of data and the gen
| `READSB_NET_SBS_INPUT_PORT` | TCP BaseStation input listen ports. | `--net-sbs-in-port=<ports>` | Unset |
| `READSB_NET_SBS_OUTPUT_PORT` | TCP BaseStation output listen ports. | `--net-sbs-port=<ports>` | `30003` |
| `READSB_NET_SBS_DISABLE_REDUCE` | Disable application of "reduce" logic to SBS/BaseStation output. (By default, this is enabled) | `--net-sbs-reduce` | Unset |
| `REASSB_NET_VERBATIM` | Set this to any value to forward messages unchanged. | `--net-verbatim` | Unset |
| `REASSB_NET_VERBATIM` | Set this to `true` to forward messages unchanged. | `--net-verbatim` | Unset |
| `READSB_NET_VRS_PORT` | TCP VRS JSON output listen ports. | `--net-vrs-port=<ports>` | Unset |
| `READSB_WRITE_STATE_ONLY_ON_EXIT` | if set to anything, it will only write the status range outlines, etc. upon termination of `readsb` | `--write-state-only-on-exit` | Unset |
| `READSB_JSON_INTERVAL` | Update interval for the webinterface in seconds / interval between aircraft.json writes | `--write-json-every=<sec>` | `1.0` |
@ -300,7 +305,7 @@ Note - due to design limitations of `readsb`, the `tar1090` graphical interface
| `URL_978` | The URL needs to point at where you would normally find the skyview978 webinterface, for example `http://192.168.0.29/skyaware978`. Note -- do not use `localhost` or `127.0.0.1 | |
| `GZIP_LVL` | `1`-`9` are valid, lower lvl: less CPU usage, higher level: less network bandwidth used when loading the page | `3` |
| `PTRACKS` | Shows the last `$PTRACKS` hours of traces you have seen at the `?pTracks` URL | `8` |
| `TAR1090_FLIGHTAWARELINKS` | Set to any value to enable FlightAware links in the web interface | `null` |
| `TAR1090_FLIGHTAWARELINKS` | Set to `true` to enable FlightAware links in the web interface | `null` |
| `TAR1090_ENABLE_AC_DB` | Set to `true` to enable extra information, such as aircraft type and registration, to be included in in `aircraft.json` output. Will use more memory; use caution on older Pis or similar devices. | `false` |
| `HEYWHATSTHAT_PANORAMA_ID` | Your `heywhatsthat.com` panorama ID. See <https://github.com/wiedehopf/tar1090#heywhatsthatcom-range-outline> | |
| `HEYWHATSTHAT_ALTS` | Comma separated altitudes for multiple outlines. Use no units or `ft` for feet, `m` for meters, or `km` for kilometers. Only integer numbers are accepted, no decimals please | `12192m` (=40000 ft) |
@ -365,12 +370,12 @@ Note - due to design limitations of `readsb`, the `tar1090` graphical interface
| Variable | Description | Default |
|----------|-------------|---------|
| `GRAPHS1090_DARKMODE` | If set to any value, `graphs1090` will be rendered in "dark mode". | Unset |
| `GRAPHS1090_DARKMODE` | If set to `true`, `graphs1090` will be rendered in "dark mode". | Unset |
| `GRAPHS1090_RRD_STEP` | Interval in seconds to feed data into RRD files. | `60` |
| `GRAPHS1090_SIZE` | Set graph size, possible values: `small`, `default`, `large`, `huge`, `custom`. | `default` |
| `GRAPHS1090_ALL_LARGE` | Make the small graphs as large as the big ones by setting to `yes`. | `no` |
| `GRAPHS1090_FONT_SIZE` | Font size (relative to graph size). | `10.0` |
| `GRAPHS1090_MAX_MESSAGES_LINE` | Set to any value to draw a reference line at the maximum message rate. | Unset |
| `GRAPHS1090_MAX_MESSAGES_LINE` | Set to `true` to draw a reference line at the maximum message rate. | Unset |
| `GRAPHS1090_LARGE_WIDTH` | Defines the width of the larger graphs. | `1096` |
| `GRAPHS1090_LARGE_HEIGHT` | Defines the height of the larger graphs. | `235` |
| `GRAPHS1090_SMALL_WIDTH` | Defines the width of the smaller graphs. | `619` |
@ -378,7 +383,7 @@ Note - due to design limitations of `readsb`, the `tar1090` graphical interface
| `GRAPHS1090_DISK_DEVICE` | Defines which disk device (`mmc0`, `sda`, `sdc`, etc) is shown. Leave empty for default device | Unset |
| `GRAPHS1090_ETHERNET_DEVICE` | Defines which (wired) ethernet device (`eth0`, `enp0s`, etc) is shown. Leave empty for default device | Unset |
| `GRAPHS1090_WIFI_DEVICE` | Defines which (wireless) WiFi device (`wlan0`, `wlp3s0`, etc) is shown. Leave empty for default device | Unset |
| `GRAPHS1090_DISABLE` | Set to any value to disable the GRAPHS1090 web page and data collection | Unset |
| `GRAPHS1090_DISABLE` | Set to `true` to disable the GRAPHS1090 web page and data collection | Unset |
| `ENABLE_AIRSPY` | Optional, set to any non-empty value if you want to enable the special AirSpy graphs. See below for additional configuration requirements | Unset |
#### Enabling UAT data
@ -469,7 +474,7 @@ Legacy: **We recommend AGAINST enabling this feature** as it has been replaced w
| Environment Variable | Purpose | Default |
|----------------------|---------|---------|
| `ENABLE_TIMELAPSE1090` | Optional / Legacy. Set to any value to enable timelapse1090. Once enabled, can be accessed via <http://dockerhost:port/timelapse/> | Unset |
| `ENABLE_TIMELAPSE1090` | Optional / Legacy. Set to `true` to enable timelapse1090. Once enabled, can be accessed via <http://dockerhost:port/timelapse/> | Unset |
| `TIMELAPSE1090_INTERVAL` | Snapshot interval in seconds | `10` |
| `TIMELAPSE1090_HISTORY` | Time saved in hours | `24` |

View file

@ -1,4 +1,6 @@
#!/usr/bin/with-contenv bash
#shellcheck shell=bash
# shellcheck shell=bash disable=SC1091
source /scripts/common
rm -f /run/readsb-prometheus.prom || true

View file

@ -1,5 +1,7 @@
#!/usr/bin/with-contenv bash
#shellcheck shell=bash disable=SC2015
# shellcheck shell=bash disable=SC1091,SC2015
source /scripts/common
# Print container version
#---------------------------------------------------------------------------------------------

View file

@ -1,5 +1,7 @@
#!/usr/bin/with-contenv bash
#shellcheck shell=bash disable=SC2015
#shellcheck shell=bash disable=SC2015,SC1091
source /scripts/common
# Write UUID to file
#---------------------------------------------------------------------------------------------

View file

@ -1,6 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash disable=SC2015,SC2016
# shellcheck shell=bash disable=SC1091,SC2015,SC2016
source /scripts/common
#---------------------------------------------------------------------------------------------
# Copyright (C) 2023, Ramon F. Kolb (kx1t)
@ -38,6 +39,20 @@ then
sleep infinity
fi
if [[ -z "$LAT$READSB_LAT" ]]; then
echo "[$(date)][${APPNAME}] ERROR: READSB_LAT or LAT must be defined - MLAT will be disabled."
sleep infinity
fi
if [[ -z "$LONG$READSB_LON" ]]; then
echo "[$(date)][${APPNAME}] ERROR: READSB_LON or LONG must be defined - MLAT will be disabled."
sleep infinity
fi
if [[ -z "$ALT$READSB_ALT" ]]; then
echo "[$(date)][${APPNAME}] ERROR: READSB_ALT or ALT must be defined - MLAT will be disabled."
sleep infinity
fi
# MLAT_CONFIG has the following format:
# MLAT_CONFIG=mlatserver_1,mlatserver_port_1[,results_port_1[,extra_params_1]];mlatserver_2,mlatserver_port_2[,results_port_2[,extra_params_2]] etc
@ -125,7 +140,7 @@ do
then
# it exited - let's restart:
sleep "${RESTARTTIMER}"
[[ "$LOGLEVEL,," != "none" ]] && echo "[$(date)][${APPNAME}] MLAT_Client $(awk '{print $6}' <<< "${pid_array[$mlat_pid]}") exited. Attempting to restart." || true
[[ "${LOGLEVEL,,}" != "none" ]] && echo "[$(date)][${APPNAME}] MLAT_Client $(awk '{print $6}' <<< "${pid_array[$mlat_pid]}") exited. Attempting to restart." || true
# shellcheck disable=SC2086
execstring="$(echo ${MLAT_CMD} ${pid_array[$mlat_pid]} | xargs)"

View file

@ -1,14 +1,14 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash disable=SC2016
# shellcheck shell=bash disable=SC1091,SC2016
if [[ -z "${MLAT_CONFIG}" ]] && [[ -z "$MLATHUB_NET_CONNECTOR" ]]
then
source /scripts/common
if [[ -z "${MLAT_CONFIG}" ]] && [[ -z "$MLATHUB_NET_CONNECTOR" ]]; then
echo "[$(date)][mlathub] 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"
sleep infinity
fi
if [[ -n "${MLATHUB_DISABLED}" ]]
then
if chk_enabled "${MLATHUB_DISABLED}"; then
echo "[$(date)][mlathub] MLATHUB is disabled."
sleep infinity
fi
@ -70,7 +70,7 @@ if [[ -n "$MLATHUB_NET_CONNECTOR" ]]; then
done
fi
if [ -n "${READSB_DEBUG}" ]; then
if chk_enabled "${READSB_DEBUG}"; then
MLATHUB_CMD+=("--debug=$READSB_DEBUG")
fi

View file

@ -1,7 +1,9 @@
#!/usr/bin/with-contenv bash
#shellcheck shell=bash
# shellcheck shell=bash disable=SC1091
if [[ -n "$PROMETHEUS_ENABLE" ]]; then
source /scripts/common
if chk_enabled "$PROMETHEUS_ENABLE"; then
while [[ ! -f /run/readsb-prometheus.prom ]]
do
sleep 1

View file

@ -1,5 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash disable=SC2016
# shellcheck shell=bash disable=SC2016,SC1091
source /scripts/common
mkdir -p /run/readsb
@ -9,7 +11,7 @@ READSB_BIN="/usr/local/bin/readsb"
READSB_CMD=("--net")
READSB_CMD+=("--quiet")
if [ -n "${READSB_NET_ONLY}" ]; then
if chk_enabled "${READSB_NET_ONLY}"; then
READSB_CMD+=("--net-only")
fi
@ -33,7 +35,7 @@ if [ -n "${BEASTHOST}" ]; then
READSB_CMD+=("--net-connector=${BEASTHOST},${BEASTPORT},beast_in")
fi
if [ -n "${UUID}" ]; then
if chk_enabled "${UUID}"; then
READSB_CMD+=("--uuid-file=/run/uuid")
fi
@ -54,16 +56,16 @@ READSB_CMD+=("--net-json-port=30047")
READSB_CMD+=(--net-api-port=30152)
READSB_CMD+=(--net-sbs-in-port=32006)
if [[ -z "$READSB_NET_SBS_DISABLE_REDUCE" ]]; then
if ! chk_enabled "$READSB_NET_SBS_DISABLE_REDUCE"; then
READSB_CMD+=("--net-sbs-reduce")
fi
if [[ -n "${READSB_FORWARD_MLAT}" ]]; then
if chk_enabled "${READSB_FORWARD_MLAT}"; then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][readsb] WARNING -- READSB_FORWARD_MLAT has been set! Do not feed the output of this container to any aggregators!"
READSB_CMD+=("--forward-mlat")
fi
if [[ -n "${READSB_FORWARD_MLAT_SBS}" ]]; then
if chk_enabled "${READSB_FORWARD_MLAT_SBS}"; then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][readsb] WARNING -- READSB_FORWARD_MLAT_SBS has been set! Do not feed the SBS (BaseStation) output of this container to any aggregators!"
READSB_CMD+=("--forward-mlat-sbs")
fi
@ -81,7 +83,7 @@ if [ -n "${READSB_DEBUG}" ]; then
fi
# Handle --write-state-only-on-exit
if [ -n "${READSB_WRITE_STATE_ONLY_ON_EXIT}" ]; then
if chk_enabled "${READSB_WRITE_STATE_ONLY_ON_EXIT}"; then
READSB_CMD+=("--write-state-only-on-exit")
fi
@ -91,12 +93,12 @@ if [[ -n "$READSB_MAX_RANGE" ]]; then
fi
# Handle "--mlat"
if [[ -n "$READSB_MLAT" ]]; then
if chk_enabled "$READSB_MLAT"; then
READSB_CMD+=("--mlat")
fi
# Handle "--modeac"
if [[ -n "$READSB_MODEAC" ]]; then
if chk_enabled "$READSB_MODEAC"; then
READSB_CMD+=("--modeac")
fi
@ -106,7 +108,7 @@ if [[ -n "$READSB_STATS_EVERY" ]]; then
fi
# Handle "--stats-range"
if [[ -n "$READSB_STATS_RANGE" ]]; then
if chk_enabled "$READSB_STATS_RANGE"; then
READSB_CMD+=("--stats-range")
fi
@ -130,7 +132,7 @@ if [[ -n "$READSB_NET_BEAST_REDUCE_OUT_PORT" ]]; then
READSB_CMD+=("--net-beast-reduce-out-port=$READSB_NET_BEAST_REDUCE_OUT_PORT")
fi
if [[ -n "$READSB_NET_SBS_REDUCE" ]]; then
if chk_enabled "$READSB_NET_SBS_REDUCE"; then
READSB_CMD+=("--net-sbs-reduce")
fi
@ -213,7 +215,7 @@ if [[ -n "$READSB_NET_SBS_OUTPUT_PORT" ]]; then
fi
# Handle "--net-verbatim"
if [[ -n "$REASSB_NET_VERBATIM" ]]; then
if chk_enabled "$REASSB_NET_VERBATIM"; then
READSB_CMD+=("--net-verbatim")
fi
@ -238,11 +240,10 @@ fi
if [[ -n "$READSB_GAIN" ]]; then
if [[ "${READSB_GAIN,,}" == "autogain" ]] && [[ -f /var/globe_history/autogain/gain ]]; then
read -r gain < /var/globe_history/autogain/gain
READSB_CMD+=("--gain=$gain")
elif [[ -n "$READSB_GAIN" ]]; then
else
[[ "${READSB_GAIN,,}" == "autogain" ]] && gain="49.6" || gain="${READSB_GAIN}"
READSB_CMD+=("--gain=$gain")
fi
READSB_CMD+=("--gain=$gain")
fi
##### RTL-SDR OPTIONS #####
@ -265,32 +266,32 @@ fi
##### MODE-S BEAST OPTIONS #####
# Handle "--beast-crc-off"
if [[ -n "$READSB_BEAST_CRC_OFF" ]]; then
if chk_enabled "$READSB_BEAST_CRC_OFF"; then
READSB_CMD+=("--beast-crc-off")
fi
# Handle "--beast-df045-on"
if [[ -n "$READSB_BEAST_DF045_ON" ]]; then
if chk_enabled "$READSB_BEAST_DF045_ON"; then
READSB_CMD+=("--beast-df045-on")
fi
# Handle "--beast-df1117-on"
if [[ -n "$READSB_BEAST_DF1117_ON" ]]; then
if chk_enabled "$READSB_BEAST_DF1117_ON"; then
READSB_CMD+=("--beast-df1117-on")
fi
# Handle "--beast-fec-off"
if [[ -n "$READSB_BEAST_FEC_OFF" ]]; then
if chk_enabled "$READSB_BEAST_FEC_OFF"; then
READSB_CMD+=("--beast-fec-off")
fi
# Handle "--beast-mlat-off"
if [[ -n "$READSB_BEAST_MLAT_OFF" ]]; then
if chk_enabled "$READSB_BEAST_MLAT_OFF"; then
READSB_CMD+=("--beast-mlat-off")
fi
# Handle "--beast-modeac"
if [[ -n "$READSB_BEAST_MODEAC" ]]; then
if chk_enabled "$READSB_BEAST_MODEAC"; then
READSB_CMD+=("--beast-modeac")
fi
@ -305,7 +306,7 @@ fi
#####################
# Handle --write-prom=<filepath>
if [[ -n "$PROMETHEUS_ENABLE" ]]; then
if chk_enabled "$PROMETHEUS_ENABLE"; then
READSB_CMD+=("--write-prom=/run/readsb-prometheus.prom")
fi