play.wenpai.net/scripts/inbox-reactor-daemon.sh
elementary-qa bddd9840cb
All checks were successful
Deploy play.wenpai.net / deploy (push) Successful in 5s
feat: add missing plugin sha256 checksums and operational tooling
- add sha256 for wpavatar, wp-china-yes, wpdate, wpfonts, wpmind
- restore accidentally deleted wpfonts-1.2.0.zip from git HEAD
- add NATS messaging wrappers (vm-dm.sh, vm-say.sh, lib/nats-msg.sh)
- add inbox automation hooks (inbox-reactor.sh, daemon, codex hook)
- symlink generate-html-report.js from qa/scripts/
2026-04-11 04:22:53 +08:00

38 lines
1 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
# inbox-reactor-daemon.sh — 监听 ~/inbox/ 新消息并触发分类处理
INBOX_DIR="${HOME}/inbox"
REACTOR="${HOME}/scripts/inbox-reactor.sh"
CACHE_DIR="${HOME}/.cache/vm-watcher"
LOG="${CACHE_DIR}/reactor.log"
mkdir -p "$CACHE_DIR" "$INBOX_DIR"
log() { echo "[$(date -Iseconds)] $*" >> "$LOG"; }
if ! command -v inotifywait >/dev/null 2>&1; then
log "FATAL: inotifywait not found, install inotify-tools"
exit 1
fi
if [[ ! -x "$REACTOR" ]]; then
log "FATAL: inbox-reactor.sh not found at $REACTOR"
exit 1
fi
log "Inbox reactor daemon started, watching $INBOX_DIR"
# 不处理启动时已有的旧消息(留给 cron autonomous-session 处理)
# 只监听新到达的文件
# 持续监听新文件
inotifywait -m "$INBOX_DIR" -e create -e moved_to --format '%f' 2>/dev/null |
while read -r filename; do
[[ "$filename" == *.json ]] || continue
filepath="$INBOX_DIR/$filename"
[[ -f "$filepath" ]] || continue
sleep 0.5
log "New message detected: $filename"
bash "$REACTOR" "$filepath"
done