Skip to content

Commit

Permalink
max_globe_history: slightly cleanup bash loop
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Nov 4, 2024
1 parent 096d338 commit a5ffc53
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions rootfs/etc/s6-overlay/scripts/cleanup_globe_history
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down

0 comments on commit a5ffc53

Please sign in to comment.