#!/usr/bin/env bash
# onx-terminal-status — ttyd servis durumu → JSON.
set -uo pipefail
cat >/dev/null 2>&1 || true
command -v jq >/dev/null 2>&1 || { printf '{"ok":false,"error":"jq yok"}\n'; exit 2; }
ACTIVE="$(systemctl is-active onoxsoft-ttyd 2>/dev/null || echo inactive)"
INSTALLED=false; [[ -x /usr/local/onoxsoft/bin/ttyd ]] && INSTALLED=true
jq -nc --arg a "$ACTIVE" --argjson i "$INSTALLED" '{ok:true,active:$a,installed:$i}'
exit 0
