lakehouse/ops/systemd/install.sh
profit c85c55006d
Some checks failed
lakehouse/auditor 3 warnings — see review
ops: systemd units for auditor + context7 bridge
Promotes two previously manual-start Bun services to systemd
so they survive restarts + run continuously.

- ops/systemd/lakehouse-auditor.service — polls Gitea every 90s,
  runs 4 audit checks per PR head SHA, posts commit status + review
  comment. Runs as root to match existing lakehouse-* service
  conventions on this host; can read /home/profit/.git-credentials
  (0600 profit:profit).
- ops/systemd/lakehouse-context7-bridge.service — HTTP wrapper on
  :3900 for Phase 45 doc-drift detection. Decoupled from gateway;
  runs independently.
- ops/systemd/install.sh — idempotent installer (copy → daemon-reload
  → enable --now). Prints post-install active/enabled status.
- ops/systemd/README.md — run/stop/logs/pause docs.

Pause control stays per-service (bot.paused / auditor.paused files
at repo root). Not wired to branch protection yet — the auditor's
commit status is currently advisory, not enforcing. Flip via Gitea
branch_protections API when confident.
2026-04-22 04:15:58 -05:00

60 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install the lakehouse-auditor + lakehouse-context7-bridge systemd units.
# Idempotent: re-running just reloads + restarts.
#
# Usage (as root):
# bash ops/systemd/install.sh
#
# What it does:
# 1. Copies *.service to /etc/systemd/system/
# 2. systemctl daemon-reload
# 3. systemctl enable --now both services
# 4. Prints post-install status
set -euo pipefail
UNIT_DIR="$(dirname "$(readlink -f "$0")")"
TARGET_DIR=/etc/systemd/system
UNITS=(
lakehouse-auditor.service
lakehouse-context7-bridge.service
)
if [[ $EUID -ne 0 ]]; then
echo "install.sh: must run as root (writes to $TARGET_DIR)" >&2
exit 1
fi
for unit in "${UNITS[@]}"; do
src="$UNIT_DIR/$unit"
dst="$TARGET_DIR/$unit"
if [[ ! -f "$src" ]]; then
echo "install.sh: missing source $src" >&2
exit 1
fi
echo "→ copy $unit"
install -m 0644 "$src" "$dst"
done
echo "→ systemctl daemon-reload"
systemctl daemon-reload
for unit in "${UNITS[@]}"; do
echo "→ enable + (re)start $unit"
systemctl enable "$unit" >/dev/null
systemctl restart "$unit"
done
echo ""
echo "─── post-install status ───"
for unit in "${UNITS[@]}"; do
active=$(systemctl is-active "$unit" 2>/dev/null || true)
enabled=$(systemctl is-enabled "$unit" 2>/dev/null || true)
printf " %-40s active=%s enabled=%s\n" "$unit" "$active" "$enabled"
done
echo ""
echo "Live logs: journalctl -u lakehouse-auditor.service -f"
echo "Pause: touch /home/profit/lakehouse/auditor.paused"
echo "Resume: rm /home/profit/lakehouse/auditor.paused"