#!/bin/bash
# One-line Orbit status for a static slot.
set -euo pipefail

: "${SLOT_SRC:?}"
: "${SLOT_RUN:?}"

STATIC_ROOT=@@STATIC_ROOT@@
if [[ $STATIC_ROOT == . ]]; then
    ROOT=$SLOT_SRC
else
    ROOT=$SLOT_SRC/$STATIC_ROOT
fi

if [[ ! -f $SLOT_RUN/Caddyfile ]]; then
    printf 'stopped\n'
    exit 1
fi
if [[ ! -d $ROOT ]]; then
    printf 'unhealthy missing-root\n'
    exit 1
fi
printf 'healthy\n'
exit 0
