Files
ssh-monitor/scripts/pilot-verify-exclusive.sh
T
PTah 3a1c9655ca feat: exclusive pilot — spool flush and verify script
Replay spool on each monitor loop; sac_post_payload refactor;
pilot-verify-exclusive.sh and --check-sac hints for exclusive mode.
2026-05-27 13:25:47 +10:00

42 lines
1.3 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Проверка готовности хоста к пилоту UseSAC=exclusive (фаза 2.1).
set -euo pipefail
CONFIG="${CONFIG_FILE:-/etc/ssh-monitor.conf}"
MONITOR="${SSH_MONITOR_BIN:-/usr/local/bin/ssh-monitor}"
if [ -f "$CONFIG" ]; then
# shellcheck disable=SC1090
. "$CONFIG"
fi
fail=0
ok() { printf '[OK] %s\n' "$1"; }
bad() { printf '[FAIL] %s\n' "$1"; fail=1; }
mode="$(printf '%s' "${UseSAC:-off}" | tr '[:upper:]' '[:lower:]')"
[ "$mode" = "exclusive" ] || bad "UseSAC должен быть exclusive (сейчас: ${UseSAC:-off})"
[ -n "${SAC_URL:-}" ] && [ -n "${SAC_API_KEY:-}" ] || bad "Задайте SAC_URL и SAC_API_KEY"
[ -x "$MONITOR" ] || bad "Не найден $MONITOR"
[ -f "${MONITOR%/*}/sac-client.sh" ] || bad "Нет sac-client.sh рядом с ssh-monitor"
if "$MONITOR" --check-sac; then
ok "--check-sac"
else
bad "--check-sac"
fi
spool="${SAC_SPOOL_DIR:-/var/lib/ssh-monitor/sac-spool}"
pending=0
if [ -d "$spool" ]; then
pending=$(find "$spool" -maxdepth 1 -name '*.json' 2>/dev/null | wc -l)
fi
printf ' Spool %s: %s файл(ов)\n' "$spool" "$pending"
if [ "$fail" -eq 0 ]; then
printf '\nПилот exclusive: хост готов. Сгенерируйте SSH/sudo событие и проверьте только в SAC UI.\n'
exit 0
fi
printf '\nИсправьте ошибки выше.\n'
exit 1