#!/usr/bin/env bash set -euo pipefail ACTION="status" add_runtime_paths() { local base="$HOME/.openclaw/runtime/node" if [[ -d "$base" ]]; then while IFS= read -r dir; do PATH="$dir/bin:$PATH" done < <(find "$base" -mindepth 1 -maxdepth 1 -type d | sort) fi export PATH } get_openclaw_cmd() { add_runtime_paths command -v openclaw >/dev/null 2>&1 || { echo 'openclaw not found in PATH' >&2 exit 1 } command -v openclaw } usage() { cat <&2 exit 1 ;; esac done OPENCLAW="$(get_openclaw_cmd)" case "$ACTION" in start) "$OPENCLAW" gateway start "$OPENCLAW" gateway status --json ;; stop) "$OPENCLAW" gateway stop "$OPENCLAW" gateway status --json ;; restart) "$OPENCLAW" gateway restart "$OPENCLAW" gateway status --json ;; status) "$OPENCLAW" gateway status --json ;; dashboard) "$OPENCLAW" dashboard ;; *) echo "Unsupported action: $ACTION" >&2 exit 1 ;; esac