#!/usr/bin/env bash
# system/services -- read-only service status board
set -o pipefail
SELF=$(readlink -f "${BASH_SOURCE[0]}")
NV_BASE=$(cd "$(dirname "$SELF")/../../.." && pwd)
export NV_BASE
# shellcheck source=/dev/null
. "$NV_BASE/lib/core/bootstrap.sh"

ui_header "$(t mod_sys_services)"
printf '  %-18s %-10s %s\n' "$(t svc_name)" "$(t svc_state)" "$(t svc_enabled)"
for s in nginx php8.3-fpm mariadb redis-server fail2ban cron; do
    state=$(svc_status_word "$s" 2>/dev/null || echo missing)
    if svc_is_active "$s"; then ui_ok "$(printf '%-18s %-10s' "$s" "$state")"
    else ui_warn "$(printf '%-18s %-10s' "$s" "$state")"; fi
done
ui_blank
exit 0
