#!/bin/bash
# Silent on success: cron mails all output to root, so mail arrives only when the prune fails.
set -u

output=$(docker system prune -af --filter "until=168h" 2>&1)
rc=$?

if [ "$rc" -ne 0 ]; then
    printf '%s\n' "$output"
    echo "docker system prune exited with rc=$rc"
    exit "$rc"
fi
