#!/usr/bin/env bash
set -euo pipefail
CID="$(
sudo docker ps --format '{{.ID}} {{.Names}}' \
| awk '/project-445/ && /-build/ {print $1; exit}'
)"
if [ -z "${CID}" ]; then
echo "MC141 build container not found"
echo
sudo docker ps --format 'table {{.ID}}\t{{.Names}}\t{{.Status}}'
exit 0
fi
echo "CID=${CID}"
echo
sudo docker exec "${CID}" bash -lc '
set +e
echo "date: $(date)"
echo
echo "git/ssh processes:"
ps -eo pid,etime,pcpu,pmem,args | grep -E "git fetch|index-pack|ssh" | grep -v grep || true
echo
PACK_DIR="$(find /builds -path "*/output/rk3568_elesy_evb/download/linux/git/.git/objects/pack" -type d -print -quit)"
if [ -z "${PACK_DIR}" ]; then
PACK_DIR="$(find /builds -path "*/download/linux/git/.git/objects/pack" -type d -print -quit)"
fi
echo "PACK_DIR=${PACK_DIR:-not found}"
echo
if [ -n "${PACK_DIR}" ]; then
du -sh "${PACK_DIR}" 2>/dev/null || true
echo
ls -lh "${PACK_DIR}" 2>/dev/null || true
fi
'