Initial import of watchdog-discord-route skill
This commit is contained in:
136
scripts/install_watchdog_bundle.sh
Executable file
136
scripts/install_watchdog_bundle.sh
Executable file
@@ -0,0 +1,136 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SKILL_DIR="$(cd -- "$SCRIPT_DIR/.." && pwd)"
|
||||
HOME_DIR="${HOME:?HOME is required}"
|
||||
WORKSPACE_DEFAULT="$HOME_DIR/.openclaw/workspace"
|
||||
WORKSPACE="${WATCHDOG_B_WORKSPACE:-$WORKSPACE_DEFAULT}"
|
||||
SYSTEMD_USER_DIR="${WATCHDOG_B_SYSTEMD_USER_DIR:-$HOME_DIR/.config/systemd/user}"
|
||||
CONFIG_DIR="${WATCHDOG_B_CONFIG_DIR:-$HOME_DIR/.config/openclaw}"
|
||||
LIVE_SCRIPT_DIR="${WATCHDOG_B_LIVE_SCRIPT_DIR:-$WORKSPACE/scripts/watchdog-b}"
|
||||
INSTALL_ENV_EXAMPLE=0
|
||||
FORCE=0
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [options]
|
||||
|
||||
Install bundled watchdog-discord-route assets into live paths.
|
||||
|
||||
Options:
|
||||
--workspace PATH Target workspace (default: $WORKSPACE_DEFAULT)
|
||||
--systemd-user-dir PATH Target systemd --user unit dir (default: ~/.config/systemd/user)
|
||||
--config-dir PATH Target config dir (default: ~/.config/openclaw)
|
||||
--live-script-dir PATH Target live watchdog script dir (default: <workspace>/scripts/watchdog-b)
|
||||
--install-env-example Also install watchdog-b.env.example to <config-dir>/watchdog-b.env.example
|
||||
--force Overwrite existing files in live paths
|
||||
-h, --help Show this help
|
||||
EOF
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--workspace)
|
||||
WORKSPACE="$2"; shift 2 ;;
|
||||
--systemd-user-dir)
|
||||
SYSTEMD_USER_DIR="$2"; shift 2 ;;
|
||||
--config-dir)
|
||||
CONFIG_DIR="$2"; shift 2 ;;
|
||||
--live-script-dir)
|
||||
LIVE_SCRIPT_DIR="$2"; shift 2 ;;
|
||||
--install-env-example)
|
||||
INSTALL_ENV_EXAMPLE=1; shift ;;
|
||||
--force)
|
||||
FORCE=1; shift ;;
|
||||
-h|--help)
|
||||
usage; exit 0 ;;
|
||||
*)
|
||||
echo "unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p "$LIVE_SCRIPT_DIR" "$SYSTEMD_USER_DIR" "$CONFIG_DIR"
|
||||
|
||||
copy_file() {
|
||||
local src="$1"
|
||||
local dest="$2"
|
||||
if [[ -e "$dest" && "$FORCE" != "1" ]]; then
|
||||
echo "skip existing: $dest"
|
||||
return 0
|
||||
fi
|
||||
install -m 0644 "$src" "$dest"
|
||||
echo "installed: $dest"
|
||||
}
|
||||
|
||||
copy_exec() {
|
||||
local src="$1"
|
||||
local dest="$2"
|
||||
if [[ -e "$dest" && "$FORCE" != "1" ]]; then
|
||||
echo "skip existing: $dest"
|
||||
return 0
|
||||
fi
|
||||
install -m 0755 "$src" "$dest"
|
||||
echo "installed: $dest"
|
||||
}
|
||||
|
||||
render_service() {
|
||||
local src="$SCRIPT_DIR/openclaw-watchdog-b.service"
|
||||
local dest="$SYSTEMD_USER_DIR/openclaw-watchdog-b.service"
|
||||
if [[ -e "$dest" && "$FORCE" != "1" ]]; then
|
||||
echo "skip existing: $dest"
|
||||
return 0
|
||||
fi
|
||||
sed \
|
||||
-e "s#%h/.openclaw/workspace#${WORKSPACE//\#/\\#}#g" \
|
||||
-e "s#%h/.config/openclaw#${CONFIG_DIR//\#/\\#}#g" \
|
||||
-e "s#%h/.openclaw/workspace/scripts/watchdog-b#${LIVE_SCRIPT_DIR//\#/\\#}#g" \
|
||||
"$src" > "$dest"
|
||||
chmod 0644 "$dest"
|
||||
echo "installed: $dest"
|
||||
}
|
||||
|
||||
copy_exec "$SCRIPT_DIR/check_openclaw_state.sh" "$LIVE_SCRIPT_DIR/check_openclaw_state.sh"
|
||||
copy_exec "$SCRIPT_DIR/run_watchdog_b.sh" "$LIVE_SCRIPT_DIR/run_watchdog_b.sh"
|
||||
copy_exec "$SCRIPT_DIR/verify_watchdog_b_e2e.sh" "$LIVE_SCRIPT_DIR/verify_watchdog_b_e2e.sh"
|
||||
copy_exec "$SCRIPT_DIR/notify_watchdog_b.py" "$LIVE_SCRIPT_DIR/notify_watchdog_b.py"
|
||||
copy_exec "$SCRIPT_DIR/openclaw_runtime_probe.py" "$LIVE_SCRIPT_DIR/openclaw_runtime_probe.py"
|
||||
copy_file "$SCRIPT_DIR/owner_report_consumer.py" "$LIVE_SCRIPT_DIR/owner_report_consumer.py"
|
||||
copy_file "$SCRIPT_DIR/owner_report_driver.py" "$LIVE_SCRIPT_DIR/owner_report_driver.py"
|
||||
copy_file "$SCRIPT_DIR/owner_report_producer.py" "$LIVE_SCRIPT_DIR/owner_report_producer.py"
|
||||
copy_file "$SCRIPT_DIR/openclaw-watchdog-b.timer" "$SYSTEMD_USER_DIR/openclaw-watchdog-b.timer"
|
||||
render_service
|
||||
|
||||
if [[ "$INSTALL_ENV_EXAMPLE" == "1" ]]; then
|
||||
copy_file "$SCRIPT_DIR/watchdog-b.env.example" "$CONFIG_DIR/watchdog-b.env.example"
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Install summary
|
||||
- skill_dir: $SKILL_DIR
|
||||
- workspace: $WORKSPACE
|
||||
- live_script_dir: $LIVE_SCRIPT_DIR
|
||||
- systemd_user_dir: $SYSTEMD_USER_DIR
|
||||
- config_dir: $CONFIG_DIR
|
||||
|
||||
Operator install order
|
||||
1. Install bundle files:
|
||||
./scripts/install_watchdog_bundle.sh --install-env-example
|
||||
2. Create live env if missing:
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
cp "$CONFIG_DIR/watchdog-b.env.example" "$CONFIG_DIR/watchdog-b.env"
|
||||
3. Edit live env and set at least:
|
||||
WATCHDOG_B_OWNER_REPORT_TARGET=channel:YOUR_DISCORD_CHANNEL_ID
|
||||
4. Run bootstrap:
|
||||
./scripts/bootstrap_watchdog_bundle.sh
|
||||
5. Only after bootstrap passes:
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable --now openclaw-watchdog-b.timer
|
||||
|
||||
Notes
|
||||
- If $CONFIG_DIR/watchdog-b.env does not exist, bootstrap will warn/fail until you create it.
|
||||
- The env example is intentionally installed as watchdog-b.env.example first; copy it to watchdog-b.env after editing.
|
||||
EOF
|
||||
Reference in New Issue
Block a user