generated from coulomb/repo-seed
T1: systemd --user units (ops-warden-worker.{service,timer}) + scripts/install-worker-timer.sh
(--enable opt-in, cron fallback documented) + examples/worker.env.example. Kill switch:
`systemctl --user disable --now ops-warden-worker.timer` or WORKER_ENABLED=0. Installed and
ENABLED — verified a real systemd run (Result=success, used the llm brain) and the timer is
active (next run +15min).
T2: hardened worker-tick.sh — State Hub /state/health precheck → graceful skip (exit 0) when
unreachable; worker-run failure logged but never fails the unit (retry next tick). Verified
hub-down skip and a live tick.
Conservative tier only; nothing auto-sent. Kill switch is one command.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
1.8 KiB
Bash
Executable File
42 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Install (and optionally enable) the ops-warden conservative worker systemd --user timer.
|
|
# WARDEN-WP-0021 T1. Build-stage, conservative tier only (triage + draft, never auto-send).
|
|
#
|
|
# ./scripts/install-worker-timer.sh # install units + env, DISABLED
|
|
# ./scripts/install-worker-timer.sh --enable # install + start the 15-min timer
|
|
#
|
|
# Kill switch (one command):
|
|
# systemctl --user disable --now ops-warden-worker.timer
|
|
# (or set WORKER_ENABLED=0 in ~/.config/warden/worker.env)
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
UNIT_DIR="$HOME/.config/systemd/user"
|
|
ENV_FILE="$HOME/.config/warden/worker.env"
|
|
|
|
if ! command -v systemctl >/dev/null 2>&1; then
|
|
echo "systemctl not found — this host has no systemd. Use the cron fallback:" >&2
|
|
echo " */15 * * * * $ROOT/scripts/worker-tick.sh >> ~/.local/state/warden/worker-tick.log 2>&1" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$UNIT_DIR" "$(dirname "$ENV_FILE")"
|
|
if [[ ! -f "$ENV_FILE" ]]; then
|
|
install -m 600 "$ROOT/examples/worker.env.example" "$ENV_FILE"
|
|
echo "wrote $ENV_FILE (review it)"
|
|
fi
|
|
|
|
# Substitute the repo path into the service unit at install time.
|
|
sed "s#@ROOT@#$ROOT#g" "$ROOT/systemd/ops-warden-worker.service" > "$UNIT_DIR/ops-warden-worker.service"
|
|
cp "$ROOT/systemd/ops-warden-worker.timer" "$UNIT_DIR/ops-warden-worker.timer"
|
|
systemctl --user daemon-reload
|
|
echo "installed: ops-warden-worker.{service,timer} → $UNIT_DIR"
|
|
|
|
if [[ "${1:-}" == "--enable" ]]; then
|
|
systemctl --user enable --now ops-warden-worker.timer
|
|
echo "ENABLED — next runs: systemctl --user list-timers ops-warden-worker.timer"
|
|
else
|
|
echo "not enabled. start with: systemctl --user enable --now ops-warden-worker.timer"
|
|
fi
|
|
echo "kill switch: systemctl --user disable --now ops-warden-worker.timer (or WORKER_ENABLED=0 in $ENV_FILE)"
|