mirror of
https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git
synced 2024-11-24 06:40:09 +00:00
move cleanup_globe_history from ultrafeeder container to tar1090 container
This commit is contained in:
parent
58465dd35d
commit
b775ea9dc6
6 changed files with 6 additions and 58 deletions
10
Dockerfile
10
Dockerfile
|
@ -21,7 +21,7 @@ ARG VERSION_REPO="sdr-enthusiasts/docker-adsb-ultrafeeder" \
|
|||
|
||||
SHELL ["/bin/bash", "-x", "-o", "pipefail", "-c"]
|
||||
RUN \
|
||||
--mount=type=bind,from=buildimage,source=/,target=/buildimage/ \
|
||||
--mount="type=bind,from=buildimage,source=/,target=/buildimage/" \
|
||||
TEMP_PACKAGES=() && \
|
||||
KEPT_PACKAGES=() && \
|
||||
# Needed to run the mlat_client:
|
||||
|
@ -42,18 +42,16 @@ RUN \
|
|||
cp -f /buildimage/distance /usr/local/bin/distance && \
|
||||
# Add Container Version
|
||||
[[ "${VERSION_BRANCH:0:1}" == "#" ]] && VERSION_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 && \
|
||||
# Clean up and install POST_PACKAGES:
|
||||
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 && \
|
||||
# Clean up:
|
||||
apt-get remove -q -y "${TEMP_PACKAGES[@]}" && \
|
||||
# apt-get install -o Dpkg::Options::="--force-confnew" -y --no-install-recommends -q \
|
||||
# ${POST_PACKAGES[@]} && \
|
||||
apt-get autoremove -q -o APT::Autoremove::RecommendsImportant=0 -o APT::Autoremove::SuggestsImportant=0 -y && \
|
||||
apt-get clean -q -y && \
|
||||
# test mlat-client
|
||||
/usr/bin/mlat-client --help > /dev/null && \
|
||||
# remove pycache introduced by testing mlat-client
|
||||
find /usr | grep -E "/__pycache__$" | xargs rm -rf || true && \
|
||||
rm -rf /src /tmp/* /var/lib/apt/lists/* /git /var/cache/* && \
|
||||
rm -rf /src "/tmp/*" "/var/lib/apt/lists/*" /git "/var/cache/*" && \
|
||||
#
|
||||
# Do some stuff for kx1t's convenience:
|
||||
echo "alias dir=\"ls -alsv\"" >> /root/.bashrc && \
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/sh
|
||||
exec /etc/s6-overlay/scripts/cleanup_globe_history
|
|
@ -1 +0,0 @@
|
|||
longrun
|
|
@ -1,47 +0,0 @@
|
|||
#!/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 -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
|
||||
|
||||
# delete empty year / month directories
|
||||
# make sure the directories haven't been touched for 3 days so freshly created directories aren't removed
|
||||
# this will also delay deletion of empty parent directories by 3 days after their contents have been removed but that's fine
|
||||
find /var/globe_history/ -mindepth 1 -maxdepth 2 -type d -empty -mtime +3 -delete
|
||||
|
||||
"${s6wrap[@]}" echo "Done - next purge will be in 24 hours"
|
||||
exec sleep 24h
|
Loading…
Reference in a new issue