master
Ray Publish 0.1.0 b9c70d0 3mo ago
#!/usr/bin/env bash
# Install adom-agent-watch: put the poller on PATH + a cron that runs it every
# 30 min. No secrets. Idempotent.
set -uo pipefail
DIR="$(cd "$(dirname "$0")" && pwd)"
mkdir -p "$HOME/.local/bin" "$HOME/.config/adom-agent-watch"
install -m0755 "$DIR/bin/adom-agent-watch" "$HOME/.local/bin/adom-agent-watch"
[ -f "$HOME/.config/adom-agent-watch/config.json" ] || cat > "$HOME/.config/adom-agent-watch/config.json" <<JSON
{
  "_comment": "wake_cmd runs your agent with the digest appended; pages is the interim-poll watchlist (used only until the #58 feed is live).",
  "wake_cmd": null,
  "pages": ["adom/wiki"]
}
JSON
BIN="$HOME/.local/bin/adom-agent-watch"
CRON="*/30 * * * * $BIN run >> /tmp/adom-agent-watch.log 2>&1"
EXISTING="$(crontab -l 2>/dev/null || true)"
FILTERED="$(echo "$EXISTING" | grep -v 'adom-agent-watch' || true)"
printf '%s\n%s\n' "$FILTERED" "$CRON" | sed '/^$/d' | crontab -
echo "adom-agent-watch installed (cron every 30 min)."
echo "  wake command: $("$BIN" status 2>/dev/null | grep -m1 wake || echo 'set wake_cmd in ~/.config/adom-agent-watch/config.json')"
echo "  try:  adom-agent-watch status   |   adom-agent-watch run"