mirror of
https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git
synced 2024-11-21 21:30:11 +00:00
add purging option for globe_history
with MAX_GLOBE_HISTORY
parameter (#115)
* 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 * Dockerfile building optimization * typo * typo * add cleanup_globe_history * minor update * better logging
This commit is contained in:
parent
07ce818b2e
commit
be5df3e3de
8 changed files with 71 additions and 17 deletions
34
Dockerfile
34
Dockerfile
|
@ -1,4 +1,12 @@
|
||||||
FROM ghcr.io/sdr-enthusiasts/docker-baseimage:mlatclient as mlatclient
|
FROM ghcr.io/sdr-enthusiasts/docker-baseimage:mlatclient as buildimage
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-x", "-o", "pipefail", "-c"]
|
||||||
|
RUN \
|
||||||
|
--mount=type=bind,source=./,target=/app/ \
|
||||||
|
apt-get update -q -y && \
|
||||||
|
apt-get install -o Dpkg::Options::="--force-confnew" -y --no-install-recommends -q \
|
||||||
|
build-essential && \
|
||||||
|
gcc -static /app/downloads/distance-in-meters.c -o /distance -lm -O2
|
||||||
|
|
||||||
FROM ghcr.io/sdr-enthusiasts/docker-tar1090:latest
|
FROM ghcr.io/sdr-enthusiasts/docker-tar1090:latest
|
||||||
|
|
||||||
|
@ -8,19 +16,17 @@ ENV URL_MLAT_CLIENT_REPO="https://github.com/wiedehopf/mlat-client.git" \
|
||||||
PRIVATE_MLAT="false" \
|
PRIVATE_MLAT="false" \
|
||||||
MLAT_INPUT_TYPE="auto"
|
MLAT_INPUT_TYPE="auto"
|
||||||
|
|
||||||
|
ARG VERSION_REPO="sdr-enthusiasts/docker-adsb-ultrafeeder" \
|
||||||
|
VERSION_BRANCH="##BRANCH##"
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-x", "-o", "pipefail", "-c"]
|
SHELL ["/bin/bash", "-x", "-o", "pipefail", "-c"]
|
||||||
RUN \
|
RUN \
|
||||||
--mount=type=bind,source=./,target=/app/ \
|
--mount=type=bind,from=buildimage,source=/,target=/buildimage/ \
|
||||||
--mount=type=bind,from=mlatclient,source=/,target=/mlatclient/ \
|
|
||||||
TEMP_PACKAGES=() && \
|
TEMP_PACKAGES=() && \
|
||||||
KEPT_PACKAGES=() && \
|
KEPT_PACKAGES=() && \
|
||||||
# Needed to run the mlat_client:
|
# Needed to run the mlat_client:
|
||||||
KEPT_PACKAGES+=(python3-minimal) && \
|
KEPT_PACKAGES+=(python3-minimal) && \
|
||||||
KEPT_PACKAGES+=(python3-pkg-resources) && \
|
KEPT_PACKAGES+=(python3-pkg-resources) && \
|
||||||
# needed to compile distance
|
|
||||||
TEMP_PACKAGES+=(build-essential) && \
|
|
||||||
# needed for container version
|
|
||||||
TEMP_PACKAGES+=(git) && \
|
|
||||||
#
|
#
|
||||||
# packages needed for debugging - these can stay out in production builds:
|
# packages needed for debugging - these can stay out in production builds:
|
||||||
#KEPT_PACKAGES+=(procps nano aptitude psmisc) && \
|
#KEPT_PACKAGES+=(procps nano aptitude psmisc) && \
|
||||||
|
@ -30,17 +36,13 @@ RUN \
|
||||||
"${KEPT_PACKAGES[@]}" \
|
"${KEPT_PACKAGES[@]}" \
|
||||||
"${TEMP_PACKAGES[@]}" && \
|
"${TEMP_PACKAGES[@]}" && \
|
||||||
# Get mlat-client
|
# Get mlat-client
|
||||||
tar zxf /mlatclient/mlatclient.tgz -C / && \
|
tar zxf /buildimage/mlatclient.tgz -C / && \
|
||||||
ln -s /usr/local/bin/mlat-client /usr/bin/mlat-client && \
|
ln -s /usr/local/bin/mlat-client /usr/bin/mlat-client && \
|
||||||
# Compile distance binary
|
# Get distance binary
|
||||||
gcc -static /app/downloads/distance-in-meters.c -o /usr/local/bin/distance -lm -O2 && \
|
cp -f /buildimage/distance /usr/local/bin/distance && \
|
||||||
# Add Container Version
|
# Add Container Version
|
||||||
branch="##BRANCH##" && \
|
[[ "${VERSION_BRANCH:0:1}" == "#" ]] && VERSION_BRANCH="main" || true && \
|
||||||
[[ "${branch:0:1}" == "#" ]] && branch="main" || true && \
|
echo "$(TZ=UTC date +%Y%m%d-%H%M%S)_$(curl -ssL https://api.github.com/repos/$VERSION_REPO/commits/$VERSION_BRANCH | awk '{if ($1=="\"sha\":") {print substr($2,2,7); exit}}')_$VERSION_BRANCH" > /.CONTAINER_VERSION && \
|
||||||
git clone --depth=1 -b "$branch" https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git /tmp/clone && \
|
|
||||||
pushd /tmp/clone && \
|
|
||||||
echo "$(TZ=UTC date +%Y%m%d-%H%M%S)_$(git rev-parse --short HEAD)_$(git branch --show-current)" > /.CONTAINER_VERSION && \
|
|
||||||
popd && \
|
|
||||||
# Clean up and install POST_PACKAGES:
|
# Clean up and install POST_PACKAGES:
|
||||||
apt-get remove -q -y "${TEMP_PACKAGES[@]}" && \
|
apt-get remove -q -y "${TEMP_PACKAGES[@]}" && \
|
||||||
# apt-get install -o Dpkg::Options::="--force-confnew" -y --no-install-recommends -q \
|
# apt-get install -o Dpkg::Options::="--force-confnew" -y --no-install-recommends -q \
|
||||||
|
|
|
@ -211,6 +211,7 @@ The following parameters must be set (mandatory) for the container to function:
|
||||||
| `S6_SERVICES_GRACETIME` | Optional, set to 30000 when saving traces / globe_history | | `3000` |
|
| `S6_SERVICES_GRACETIME` | Optional, set to 30000 when saving traces / globe_history | | `3000` |
|
||||||
| `LOGLEVEL` | `verbose` (all messages), `error` (errors only), `none` (minimal) | | `verbose` |
|
| `LOGLEVEL` | `verbose` (all messages), `error` (errors only), `none` (minimal) | | `verbose` |
|
||||||
| `MLAT_STARTUP_STAGGER` | mlat-client startup staggering for tidy logs (reduce for quicker startup) | | `15` |
|
| `MLAT_STARTUP_STAGGER` | mlat-client startup staggering for tidy logs (reduce for quicker startup) | | `15` |
|
||||||
|
| `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 |
|
||||||
|
|
||||||
`READSB_EXTRA_ARGS` just passes arguments to the commandline, you can check this file for more options for wiedehopf's readsb fork: <https://github.com/wiedehopf/readsb/blob/dev/help.h>
|
`READSB_EXTRA_ARGS` just passes arguments to the commandline, you can check this file for more options for wiedehopf's readsb fork: <https://github.com/wiedehopf/readsb/blob/dev/help.h>
|
||||||
|
|
||||||
|
|
2
rootfs/etc/s6-overlay/s6-rc.d/cleanup_globe_history/run
Executable file
2
rootfs/etc/s6-overlay/s6-rc.d/cleanup_globe_history/run
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
exec /etc/s6-overlay/scripts/cleanup_globe_history
|
1
rootfs/etc/s6-overlay/s6-rc.d/cleanup_globe_history/type
Normal file
1
rootfs/etc/s6-overlay/s6-rc.d/cleanup_globe_history/type
Normal file
|
@ -0,0 +1 @@
|
||||||
|
longrun
|
0
rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/cleanup_globe_history
Executable file
0
rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/cleanup_globe_history
Executable file
40
rootfs/etc/s6-overlay/scripts/cleanup_globe_history
Executable file
40
rootfs/etc/s6-overlay/scripts/cleanup_globe_history
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/command/with-contenv bash
|
||||||
|
# shellcheck shell=bash disable=SC2015,SC2016,SC1091,SC2001,SC2154
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------------------
|
||||||
|
# Script to remove Globe_History files older than xxx days - this to ensure that the disk
|
||||||
|
# doesn't fill up with (unwanted) history files)
|
||||||
|
|
||||||
|
# Copyright (C) 2023-2024, Ramon F. Kolb (kx1t) and contributors
|
||||||
|
# Core script copyright and provided by Matthias Wirth (wiedehopf), used with permission
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
source /scripts/common
|
||||||
|
|
||||||
|
if [[ -z "$MAX_GLOBE_HISTORY" ]]; then
|
||||||
|
"${s6wrap[@]}" echo "MAX_GLOBE_HISTORY not set - we will not expire any globe_history files"
|
||||||
|
exec sleep infinity
|
||||||
|
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 | grep -o -E -e '[0-9]{4}/[0-9]{2}/[0-9]{2}$'); do
|
||||||
|
if (( $(date -d "$dir" +%s) < cutoffepoch )); then
|
||||||
|
rm -rf "/var/globe_history/$dir"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
"${s6wrap[@]}" echo "Done - next purge will be in 24 hours"
|
||||||
|
exec sleep 24h
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
|
|
||||||
# shellcheck shell=bash disable=SC2015
|
# shellcheck shell=bash disable=SC2015,SC2154
|
||||||
#
|
#
|
||||||
# This scripts should be sourced by the /etc/services.d/xxx/run modules for
|
# This scripts should be sourced by the /etc/services.d/xxx/run modules for
|
||||||
# readsb, mlat-client, and mlathub. It interprets the ULTRAFEEDER_CONFIG / ULTRAFEEDER_NET_CONNECTOR parameter
|
# readsb, mlat-client, and mlathub. It interprets the ULTRAFEEDER_CONFIG / ULTRAFEEDER_NET_CONNECTOR parameter
|
||||||
|
@ -97,6 +97,14 @@ do
|
||||||
done
|
done
|
||||||
# Now add $readsb_str to the READSB_CONF_ARR() as --net-connector argument:
|
# Now add $readsb_str to the READSB_CONF_ARR() as --net-connector argument:
|
||||||
READSB_CONF_ARR+=("--net-connector=${readsb_str}")
|
READSB_CONF_ARR+=("--net-connector=${readsb_str}")
|
||||||
|
|
||||||
|
if [[ ${param[1],,} == "in.adsb.lol" ]]; then
|
||||||
|
myadsblol="$(curl -sLD - https://my.adsb.lol -o /dev/null -w '%{url_effective}' 2>&1 | sed '/location: /h;g;$!d;s/^.* \(.*\)$/\1/')"
|
||||||
|
if [[ -n "$myadsblol" ]] && [[ ! $myadsblol =~ sorry-but-i-could-not-find-your-receiver ]]; then
|
||||||
|
"${s6wrap[@]}" echo "ADSB.LOL station map available at $myadsblol"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
mlat)
|
mlat)
|
||||||
|
|
Loading…
Reference in a new issue