Co-authored-by: openhands <openhands@all-hands.dev> Reviewed-on: https://codeberg.org/johba/harb/pulls/93
55 lines
1.1 KiB
Bash
Executable file
55 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Disk cleanup utility for Harb stack
|
|
# Use this to aggressively free up disk space
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
echo "=== Harb Stack Disk Cleanup ==="
|
|
echo ""
|
|
|
|
# Detect container runtime
|
|
if command -v docker &> /dev/null; then
|
|
RUNTIME_CMD="docker"
|
|
elif command -v podman &> /dev/null; then
|
|
RUNTIME_CMD="podman"
|
|
else
|
|
echo "Error: docker/podman not found"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Current disk usage:"
|
|
df -h / | tail -1
|
|
echo ""
|
|
|
|
# Stop the stack first
|
|
if [[ -f "./scripts/dev.sh" ]]; then
|
|
echo "Stopping stack..."
|
|
./scripts/dev.sh stop || true
|
|
fi
|
|
|
|
echo ""
|
|
echo "Pruning Docker resources..."
|
|
echo " - Stopped containers"
|
|
echo " - Unused volumes"
|
|
echo " - Dangling images"
|
|
echo " - Build cache"
|
|
echo ""
|
|
|
|
# Aggressive pruning
|
|
${RUNTIME_CMD} system prune -af --volumes
|
|
|
|
echo ""
|
|
echo "Cleaning npm caches..."
|
|
rm -rf ~/.npm ~/.cache 2>/dev/null || true
|
|
|
|
echo ""
|
|
echo "Cleaning journal logs..."
|
|
sudo journalctl --vacuum-size=500M 2>/dev/null || echo " (skipped: needs sudo)"
|
|
|
|
echo ""
|
|
echo "Final disk usage:"
|
|
df -h / | tail -1
|
|
echo ""
|
|
echo "[ok] Cleanup complete"
|