Give each new input its own assert message so every refused-input case matches only its own input, and cover a negative count and a bad disk check schedule. Fire the pressure prune only above the threshold, as the inputs describe it. Name the disk check script apart from the pressure service, prefix the new registers as internal, and keep the new comments short. Refs #319 Assisted-by: Claude Code
19 lines
752 B
Bash
Executable File
19 lines
752 B
Bash
Executable File
#!/bin/sh
|
|
# Exit 0 when the filesystem holding the Docker root is more than $1 percent full (the pressure
|
|
# prune may run), 1 to skip. Every failure skips: the prune must not run when the state is unknown.
|
|
threshold="$1"
|
|
case "$threshold" in
|
|
'' | *[!0-9]*) echo "invalid threshold '$threshold'"; exit 1 ;;
|
|
esac
|
|
root=$(/usr/bin/docker info --format '{{.DockerRootDir}}') || { echo "docker info failed"; exit 1; }
|
|
use=$(df -P "$root" | awk 'NR == 2 { sub(/%$/, "", $5); print $5 }')
|
|
case "$use" in
|
|
'' | *[!0-9]*) echo "cannot read the use of '$root'"; exit 1 ;;
|
|
esac
|
|
if [ "$use" -gt "$threshold" ]; then
|
|
echo "$root is $use% full, above $threshold%: pruning"
|
|
exit 0
|
|
fi
|
|
echo "$root is $use% full, not above $threshold%: skipping the prune"
|
|
exit 1
|