Files
derp/tools/status
user 3afeace6e7 feat: container management tools in tools/
Shell scripts for build, start, stop, restart, nuke, logs, status.
Shared helpers in _common.sh (colours, compose detection, project root).
Updated CHEATSHEET.md with new tool references.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 11:40:53 +01:00

47 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Show container and image state.
# Usage: tools/status
# shellcheck source=tools/_common.sh
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_common.sh"
# -- Container ----------------------------------------------------------------
printf '%b%s%b\n' "$BLU" "Container" "$RST"
state=$(podman inspect "$CONTAINER_NAME" --format '{{.State.Status}}' 2>/dev/null || true)
if [[ -z "$state" ]]; then
dim "absent"
elif [[ "$state" == "running" ]]; then
uptime=$(podman inspect "$CONTAINER_NAME" --format '{{.State.StartedAt}}' 2>/dev/null || true)
info "running (since ${uptime%.*})"
else
info "$state"
fi
echo
# -- Image --------------------------------------------------------------------
printf '%b%s%b\n' "$BLU" "Image" "$RST"
if podman image exists "$IMAGE_NAME" 2>/dev/null; then
img_info=$(podman image inspect "$IMAGE_NAME" --format '{{.Created}} {{.Size}}' 2>/dev/null || true)
created="${img_info%% *}"
size="${img_info##* }"
human=$(numfmt --to=iec-i --suffix=B "$size" 2>/dev/null || echo "${size}B")
info "$IMAGE_NAME ($human, ${created%T*})"
else
dim "no image"
fi
echo
# -- Volumes ------------------------------------------------------------------
printf '%b%s%b\n' "$BLU" "Mounts" "$RST"
mounts=(src plugins config/derp.toml data secrets)
for m in "${mounts[@]}"; do
path="$PROJECT_DIR/$m"
if [[ -e "$path" ]]; then
info "$m"
else
err "$m (missing)"
fi
done