Files
AvianVisitors/scripts/disk_check.sh
T
mcguirepr89 ef43b81cb6 this will now update the disk_check_exclude.txt file
before doing any deleting
2022-05-09 14:41:30 -04:00

39 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -x
used="$(df -h / | tail -n1 | awk '{print $5}')"
if [ "${used//%}" -ge 95 ]; then
source /etc/birdnet/birdnet.conf
case $FULL_DISK in
purge) echo "Removing oldest data"
cd ${EXTRACTED}/By_Date/
curl localhost/views.php?view=Species%20Stats &>/dev/null
iter=0
for i in */*/*; do
if [ $iter -ge 250 ]; then
break
fi
if ! grep -qxFe "$i" $HOME/BirdNET-Pi/scripts/disk_check_exclude.txt; then
rm "$i"
fi
((iter++))
done
find ${EXTRACTED}/By_Date/ -empty -type d -delete;;
#rm -drfv "$(find ${EXTRACTED}/By_Date/* -maxdepth 1 -type d -prune \
# | sort -r | tail -n1)";;
keep) echo "Stopping Core Services"
/usr/local/bin/stop_core_services.sh;;
esac
fi
sleep 1
if [ "${used//%}" -ge 95 ]; then
case $FULL_DISK in
purge) echo "Removing more data"
rm -rfv ${PROCESSED}/*;;
keep) echo "Stopping Core Services"
/usr/local/bin/stop_core_services.sh;;
esac
fi