From 9d0e79a391a7cb720e69efbb08da0685a6d0fd18 Mon Sep 17 00:00:00 2001 From: wiedehopf Date: Mon, 4 Nov 2024 16:13:18 +0100 Subject: [PATCH] add easy option to write traces (#240) and move tar1090 files to /run/tar1090 --- Dockerfile | 2 -- README.md | 3 ++- rootfs/etc/s6-overlay/s6-rc.d/tar1090/finish | 2 ++ .../etc/s6-overlay/scripts/cleanup_globe_history | 14 ++++++++------ rootfs/etc/s6-overlay/scripts/readsb | 5 +++++ rootfs/etc/s6-overlay/scripts/tar1090 | 6 +++--- .../etc/s6-overlay/startup.d/04-tar1090-configure | 3 ++- 7 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/tar1090/finish diff --git a/Dockerfile b/Dockerfile index 3ddf31a..385f6ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,8 +63,6 @@ RUN \ rm /etc/nginx/sites-enabled/default && \ # tar1090: install using project copy of original script bash /app/rootfs/tar1090-install.sh /run/readsb webroot "${TAR1090_INSTALL_DIR}" && \ - # change some /run/tar1090-webroot to /run/readsb to make work with existing docker scripting - sed -i -e 's#/run/tar1090-webroot/#/run/readsb/#' /usr/local/share/tar1090/nginx-tar1090-webroot.conf && \ # tar1090-db: document version echo "tar1090-db $(cat ${TAR1090_UPDATE_DIR}/git-db/version)" >> VERSIONS && \ # tar1090: document version diff --git a/README.md b/README.md index c4e0952..bd52a26 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,7 @@ All of the variables below are optional. | `TAR1090_IMAGE_CONFIG_TEXT` | Text to display for the config link | `null` | | `TAR1090_DISABLE` | Set to `true` to disable the web server and all websites (including the map, `graphs1090`, `heatmap`, `pTracks`, etc.) | Unset | | `READSB_ENABLE_HEATMAP` | Set to `true` or leave unset to enable the HeatMap function available at `http://myip/?Heatmap`; set to `false` to disable the HeapMap function | `true` (enabled) | +| `READSB_ENABLE_TRACES` | Save detailed globe history traces (1 gzip compressed json file per day and airframe, use MAX_GLOBE_HISTORY so you don't run out of inodes / diskspace) | `false` | | `TAR1090_ENABLE_ACTUALRANGE` | Set to `true` or leave unset to enable the outline of the actual range of your station on the map; set to `false` to disable the this outline | `true` (enabled) | | `TAR1090_AISCATCHER_SERVER` | If you want to show vessels from your AIS-Catcher instance on the map, put the (externally reachable) URL of your AIS-Catcher or ShipFeeder website in this parameter (incl. `https://`). Note - if you are using "barebones" AIS-Catcher you should add `GEOJSON on` after the `-N` parameter on the `AIS-Catcher` command line. If you use [docker-shipfeeder](https://github.com/sdr-enthusiasts/docker-shipfeeder), no change is needed for that container | Empty | | `TAR1090_AISCATCHER_REFRESH` | Refresh rate (in seconds) of reading vessels from your AIS-Catcher instance. Defaults to 15 (secs) if omitted | `15` | @@ -458,7 +459,7 @@ Where the default value is "Unset", `readsb`'s default will be used. | `READSB_STATS_EVERY` | Number of seconds between showing and resetting stats. | `--stats-every=` | Unset | | `READSB_STATS_RANGE` | Set this to any value 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` | -| `MAX_GLOBE_HISTORY` | Maximum number of days that `globe_history` data (used to produce heatmaps and ptracks) is retained. Note - this parameter doesn't affect the data used to produce `graphs1090` statistics | | Unset | +| `MAX_GLOBE_HISTORY` | Maximum number of days that `globe_history` data (used to produce heatmaps and replay) is retained. Note - this parameter doesn't affect the data used to produce `graphs1090` statistics | | Unset | ### AutoGain for RTLSDR Devices diff --git a/rootfs/etc/s6-overlay/s6-rc.d/tar1090/finish b/rootfs/etc/s6-overlay/s6-rc.d/tar1090/finish new file mode 100644 index 0000000..dd201e0 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/tar1090/finish @@ -0,0 +1,2 @@ +#!/bin/sh +rm -rf /run/tar1090 diff --git a/rootfs/etc/s6-overlay/scripts/cleanup_globe_history b/rootfs/etc/s6-overlay/scripts/cleanup_globe_history index 5496f86..ac9488b 100755 --- a/rootfs/etc/s6-overlay/scripts/cleanup_globe_history +++ b/rootfs/etc/s6-overlay/scripts/cleanup_globe_history @@ -31,12 +31,14 @@ fi cutoffepoch="$(date -d"-${MAX_GLOBE_HISTORY} days" +%s)" "${s6wrap[@]}" echo "Purging globe_history older than $MAX_GLOBE_HISTORY days (before $(date -d"-${MAX_GLOBE_HISTORY} days" +%d-%b-%Y))" -for dir in $(find /var/globe_history -maxdepth 3 -mindepth 3 -type d | grep -o -E -e '[0-9]{4}/[0-9]{2}/[0-9]{2}$'); do - if (( $(date -d "$dir" +%s) < cutoffepoch )); then - "${s6wrap[@]}" echo Removing "/var/globe_history/$dir" - rm -rf "/var/globe_history/$dir" - fi -done + +find /var/globe_history -maxdepth 3 -mindepth 3 -type d | grep -o -E -e '[0-9]{4}/[0-9]{2}/[0-9]{2}$' | \ + while read -r dir; do + if (( $(date -d "$dir" +%s) < cutoffepoch )); then + "${s6wrap[@]}" echo Removing "/var/globe_history/$dir" + rm -rf "/var/globe_history/$dir" + fi + done # delete empty year / month directories # make sure the directories haven't been touched for 3 days so freshly created directories aren't removed diff --git a/rootfs/etc/s6-overlay/scripts/readsb b/rootfs/etc/s6-overlay/scripts/readsb index ca184fd..7c5b149 100755 --- a/rootfs/etc/s6-overlay/scripts/readsb +++ b/rootfs/etc/s6-overlay/scripts/readsb @@ -61,6 +61,11 @@ if chk_enabled "${READSB_ENABLE_HEATMAP:-true}"; then READSB_CMD+=("--heatmap=${READSB_HEATMAP_INTERVAL:-15}") fi +if chk_enabled "${READSB_ENABLE_TRACES}"; then + READSB_CMD+=("--write-globe-history=/var/globe_history") +fi + + if chk_enabled "${READSB_FORWARD_MLAT}"; then "${s6wrap[@]}" echo "WARNING -- READSB_FORWARD_MLAT has been set! Do not feed the output of this container to any aggregators!" READSB_CMD+=("--forward-mlat") diff --git a/rootfs/etc/s6-overlay/scripts/tar1090 b/rootfs/etc/s6-overlay/scripts/tar1090 index 8fca336..d6915da 100755 --- a/rootfs/etc/s6-overlay/scripts/tar1090 +++ b/rootfs/etc/s6-overlay/scripts/tar1090 @@ -7,17 +7,17 @@ if chk_enabled "${TAR1090_DISABLE}"; then stop_service fi -mkdir -p /run/tar1090 +rundir="/run/tar1090" +mkdir -p "$rundir" sleep 5 # shellcheck source=/dev/null #source "${TAR1090_INSTALL_DIR}/default" srcdir=/run/readsb -service=readsb exec s6wrap --quiet --prepend=tar1090 --timestamps --args bash /usr/local/share/tar1090/tar1090.sh \ - "/run/$service" \ + "$rundir" \ "$srcdir" # "$INTERVAL" \ diff --git a/rootfs/etc/s6-overlay/startup.d/04-tar1090-configure b/rootfs/etc/s6-overlay/startup.d/04-tar1090-configure index 7e1211f..901bbf3 100755 --- a/rootfs/etc/s6-overlay/startup.d/04-tar1090-configure +++ b/rootfs/etc/s6-overlay/startup.d/04-tar1090-configure @@ -32,10 +32,11 @@ else fi # Add in CORS header for tar1090 data/aircraft.json file +# adjust the tar1090 runtime directory to /run/tar1090 sed -i \ -e 's/location ~ aircraft\\.json$ {/location ~ aircraft\.json$ {\n add_header Access-Control-Allow-Origin "\*";/g' \ - -e 's#/run/tar1090-webroot/#/run/readsb/#' \ + -e 's#/run/tar1090-webroot/#/run/tar1090/#' \ "${TAR1090_INSTALL_DIR}/nginx-tar1090-webroot.conf"