Three-layer protection for the OpenClaw gateway: real-time config monitoring with auto-rollback, systemd crash recovery, and tiered notifications via Feishu/Telegram/Discord. Use when: (1) user shares a GitHub link and says "install this" / "帮我安装", (2) user asks for status: "gateway-guardian status" / "guardian 运行正常吗", (3) user asks to uninstall: "uninstall gateway-guardian" / "卸载 gateway-guardian".
SKILL_DIR="$HOME/.openclaw/workspace/skills/gateway-guardian"
mkdir -p "$SKILL_DIR"
BASE_URL="https://raw.githubusercontent.com/Dios-Man/gateway-guardian/main"
for f in config-lib.sh config-watcher.sh gateway-recovery.sh pre-stop.sh; do
# Skip if file already present (e.g. installed via clawhub install)
[ -f "$SKILL_DIR/$f" ] && continue
curl -fsSL "$BASE_URL/$f" -o "$SKILL_DIR/$f"
done
Step 3 — Ask bot name (optional)
Ask the user: "What name should I use for myself in team notifications? (e.g. Claw, MyBot, OpenClaw — press Enter to skip and use the default 'OpenClaw')"
Record as BOT_NAME. If the user skips, use OpenClaw.
Step 4 — Write guardian.conf
Substitute resolved values before running. Replace:
{FALLBACK_CHANNEL} → resolved channel name (e.g. feishu)
{FALLBACK_TARGET} → resolved target (e.g. user:ou_xxx for Feishu)
{LOCALE} → zh or en
{BOT_NAME} → bot display name from Step 3
bash
SKILL_DIR="$HOME/.openclaw/workspace/skills/gateway-guardian"
cat > "$SKILL_DIR/guardian.conf" << GUARDIANCONF
# Auto-generated by gateway-guardian installer. Do not upload to GitHub.
# Fallback notification target (used when dynamic session detection fails)
FALLBACK_CHANNEL={FALLBACK_CHANNEL}
FALLBACK_TARGET={FALLBACK_TARGET}
# Notification language: zh (Chinese) | en (English)
LOCALE={LOCALE}
# Bot display name used in staff/team notifications
BOT_NAME={BOT_NAME}
# Team group/channel notification (optional)
# Leave empty to disable. Supported formats:
# Feishu: oc_xxx
# Telegram: -100xxxxxxxxxx (supergroup/channel numeric id)
# Discord: 123456789012345678 (channel id, digits only)
# Only effective if the channel is configured and running in OpenClaw.
STAFF_GROUP_CHAT_ID=
GUARDIANCONF
If your team uses OpenClaw together, you can set up a group notification.
When the gateway recovers, your team will be notified automatically.
Send me this to configure (Feishu / Telegram / Discord supported):
set guardian group: oc_xxx
When you receive the config command:
Parse the group ID from the message
Write it to STAFF_GROUP_CHAT_ID in guardian.conf
Confirm back to the user
Status Check (AI-executed)
When the user asks for status:
bash
systemctl --user status openclaw-config-watcher.service
tail -10 /tmp/config-watcher.log
ls -lt ~/.openclaw/config-backups/ | head -5
Report: service active/inactive, recent log lines, number of config backups on hand.
Set Team Group (AI-executed)
When the user sends a message matching 设置通知群: <id> or set guardian group: <id>:
Extract the group ID from the message
Determine the channel based on ID format:
Starts with oc_ → feishu
Starts with -100 → telegram
Pure digits → discord
Update guardian.conf:
bash
SKILL_DIR="$HOME/.openclaw/workspace/skills/gateway-guardian"
sed -i "s|^STAFF_GROUP_CHAT_ID=.*|STAFF_GROUP_CHAT_ID={extracted_id}|" "$SKILL_DIR/guardian.conf"
Confirm to the user (zh/en based on LOCALE):
zh: ✅ 已配置团队通知群,网关恢复后会自动通知群里的成员。
en: ✅ Team group configured. Members will be notified automatically when the gateway recovers.