refactor: rename to openclaw
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
# Reset Moltbot like Trimmy: kill running instances, rebuild, repackage, relaunch, verify.
|
||||
# Reset OpenClaw like Trimmy: kill running instances, rebuild, repackage, relaunch, verify.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
APP_BUNDLE="${CLAWDBOT_APP_BUNDLE:-}"
|
||||
APP_PROCESS_PATTERN="Moltbot.app/Contents/MacOS/Moltbot"
|
||||
DEBUG_PROCESS_PATTERN="${ROOT_DIR}/apps/macos/.build/debug/Moltbot"
|
||||
LOCAL_PROCESS_PATTERN="${ROOT_DIR}/apps/macos/.build-local/debug/Moltbot"
|
||||
RELEASE_PROCESS_PATTERN="${ROOT_DIR}/apps/macos/.build/release/Moltbot"
|
||||
LAUNCH_AGENT="${HOME}/Library/LaunchAgents/bot.molt.mac.plist"
|
||||
APP_BUNDLE="${OPENCLAW_APP_BUNDLE:-}"
|
||||
APP_PROCESS_PATTERN="OpenClaw.app/Contents/MacOS/OpenClaw"
|
||||
DEBUG_PROCESS_PATTERN="${ROOT_DIR}/apps/macos/.build/debug/OpenClaw"
|
||||
LOCAL_PROCESS_PATTERN="${ROOT_DIR}/apps/macos/.build-local/debug/OpenClaw"
|
||||
RELEASE_PROCESS_PATTERN="${ROOT_DIR}/apps/macos/.build/release/OpenClaw"
|
||||
LAUNCH_AGENT="${HOME}/Library/LaunchAgents/ai.openclaw.mac.plist"
|
||||
LOCK_KEY="$(printf '%s' "${ROOT_DIR}" | shasum -a 256 | cut -c1-8)"
|
||||
LOCK_DIR="${TMPDIR:-/tmp}/moltbot-restart-${LOCK_KEY}"
|
||||
LOCK_DIR="${TMPDIR:-/tmp}/openclaw-restart-${LOCK_KEY}"
|
||||
LOCK_PID_FILE="${LOCK_DIR}/pid"
|
||||
WAIT_FOR_LOCK=0
|
||||
LOG_PATH="${CLAWDBOT_RESTART_LOG:-/tmp/moltbot-restart.log}"
|
||||
LOG_PATH="${OPENCLAW_RESTART_LOG:-/tmp/openclaw-restart.log}"
|
||||
NO_SIGN=0
|
||||
SIGN=0
|
||||
AUTO_DETECT_SIGNING=1
|
||||
GATEWAY_WAIT_SECONDS="${CLAWDBOT_GATEWAY_WAIT_SECONDS:-0}"
|
||||
LAUNCHAGENT_DISABLE_MARKER="${HOME}/.clawdbot/disable-launchagent"
|
||||
GATEWAY_WAIT_SECONDS="${OPENCLAW_GATEWAY_WAIT_SECONDS:-0}"
|
||||
LAUNCHAGENT_DISABLE_MARKER="${HOME}/.openclaw/disable-launchagent"
|
||||
ATTACH_ONLY=1
|
||||
|
||||
log() { printf '%s\n' "$*"; }
|
||||
@@ -93,14 +93,14 @@ for arg in "$@"; do
|
||||
log " --no-attach-only Launch app without attach-only override"
|
||||
log ""
|
||||
log "Env:"
|
||||
log " CLAWDBOT_GATEWAY_WAIT_SECONDS=0 Wait time before gateway port check (unsigned only)"
|
||||
log " OPENCLAW_GATEWAY_WAIT_SECONDS=0 Wait time before gateway port check (unsigned only)"
|
||||
log ""
|
||||
log "Unsigned recovery:"
|
||||
log " node moltbot.mjs daemon install --force --runtime node"
|
||||
log " node moltbot.mjs daemon restart"
|
||||
log " node openclaw.mjs daemon install --force --runtime node"
|
||||
log " node openclaw.mjs daemon restart"
|
||||
log ""
|
||||
log "Reset unsigned overrides:"
|
||||
log " rm ~/.clawdbot/disable-launchagent"
|
||||
log " rm ~/.openclaw/disable-launchagent"
|
||||
log ""
|
||||
log "Default behavior: Auto-detect signing keys, fallback to --no-sign if none found"
|
||||
exit 0
|
||||
@@ -126,18 +126,18 @@ fi
|
||||
|
||||
acquire_lock
|
||||
|
||||
kill_all_moltbot() {
|
||||
kill_all_openclaw() {
|
||||
for _ in {1..10}; do
|
||||
pkill -f "${APP_PROCESS_PATTERN}" 2>/dev/null || true
|
||||
pkill -f "${DEBUG_PROCESS_PATTERN}" 2>/dev/null || true
|
||||
pkill -f "${LOCAL_PROCESS_PATTERN}" 2>/dev/null || true
|
||||
pkill -f "${RELEASE_PROCESS_PATTERN}" 2>/dev/null || true
|
||||
pkill -x "Moltbot" 2>/dev/null || true
|
||||
pkill -x "OpenClaw" 2>/dev/null || true
|
||||
if ! pgrep -f "${APP_PROCESS_PATTERN}" >/dev/null 2>&1 \
|
||||
&& ! pgrep -f "${DEBUG_PROCESS_PATTERN}" >/dev/null 2>&1 \
|
||||
&& ! pgrep -f "${LOCAL_PROCESS_PATTERN}" >/dev/null 2>&1 \
|
||||
&& ! pgrep -f "${RELEASE_PROCESS_PATTERN}" >/dev/null 2>&1 \
|
||||
&& ! pgrep -x "Moltbot" >/dev/null 2>&1; then
|
||||
&& ! pgrep -x "OpenClaw" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
sleep 0.3
|
||||
@@ -145,12 +145,12 @@ kill_all_moltbot() {
|
||||
}
|
||||
|
||||
stop_launch_agent() {
|
||||
launchctl bootout gui/"$UID"/bot.molt.mac 2>/dev/null || true
|
||||
launchctl bootout gui/"$UID"/ai.openclaw.mac 2>/dev/null || true
|
||||
}
|
||||
|
||||
# 1) Kill all running instances first.
|
||||
log "==> Killing existing Moltbot instances"
|
||||
kill_all_moltbot
|
||||
log "==> Killing existing OpenClaw instances"
|
||||
kill_all_openclaw
|
||||
stop_launch_agent
|
||||
|
||||
# Bundle Gateway-hosted Canvas A2UI assets.
|
||||
@@ -158,7 +158,7 @@ run_step "bundle canvas a2ui" bash -lc "cd '${ROOT_DIR}' && pnpm canvas:a2ui:bun
|
||||
|
||||
# 2) Rebuild into the same path the packager consumes (.build).
|
||||
run_step "clean build cache" bash -lc "cd '${ROOT_DIR}/apps/macos' && rm -rf .build .build-swift .swiftpm 2>/dev/null || true"
|
||||
run_step "swift build" bash -lc "cd '${ROOT_DIR}/apps/macos' && swift build -q --product Moltbot"
|
||||
run_step "swift build" bash -lc "cd '${ROOT_DIR}/apps/macos' && swift build -q --product OpenClaw"
|
||||
|
||||
if [ "$AUTO_DETECT_SIGNING" -eq 1 ]; then
|
||||
if check_signing_keys; then
|
||||
@@ -173,7 +173,7 @@ fi
|
||||
if [ "$NO_SIGN" -eq 1 ]; then
|
||||
export ALLOW_ADHOC_SIGNING=1
|
||||
export SIGN_IDENTITY="-"
|
||||
mkdir -p "${HOME}/.clawdbot"
|
||||
mkdir -p "${HOME}/.openclaw"
|
||||
run_step "disable launchagent writes" /usr/bin/touch "${LAUNCHAGENT_DISABLE_MARKER}"
|
||||
elif [ "$SIGN" -eq 1 ]; then
|
||||
if ! check_signing_keys; then
|
||||
@@ -191,20 +191,20 @@ choose_app_bundle() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -d "/Applications/Moltbot.app" ]]; then
|
||||
APP_BUNDLE="/Applications/Moltbot.app"
|
||||
if [[ -d "/Applications/OpenClaw.app" ]]; then
|
||||
APP_BUNDLE="/Applications/OpenClaw.app"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -d "${ROOT_DIR}/dist/Moltbot.app" ]]; then
|
||||
APP_BUNDLE="${ROOT_DIR}/dist/Moltbot.app"
|
||||
if [[ -d "${ROOT_DIR}/dist/OpenClaw.app" ]]; then
|
||||
APP_BUNDLE="${ROOT_DIR}/dist/OpenClaw.app"
|
||||
if [[ ! -d "${APP_BUNDLE}/Contents/Frameworks/Sparkle.framework" ]]; then
|
||||
fail "dist/Moltbot.app missing Sparkle after packaging"
|
||||
fail "dist/OpenClaw.app missing Sparkle after packaging"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
fail "App bundle not found. Set CLAWDBOT_APP_BUNDLE to your installed Moltbot.app"
|
||||
fail "App bundle not found. Set OPENCLAW_APP_BUNDLE to your installed OpenClaw.app"
|
||||
}
|
||||
|
||||
choose_app_bundle
|
||||
@@ -217,8 +217,8 @@ fi
|
||||
# When unsigned, ensure the gateway LaunchAgent targets the repo CLI (before the app launches).
|
||||
# This reduces noisy "could not connect" errors during app startup.
|
||||
if [ "$NO_SIGN" -eq 1 ] && [ "$ATTACH_ONLY" -ne 1 ]; then
|
||||
run_step "install gateway launch agent (unsigned)" bash -lc "cd '${ROOT_DIR}' && node moltbot.mjs daemon install --force --runtime node"
|
||||
run_step "restart gateway daemon (unsigned)" bash -lc "cd '${ROOT_DIR}' && node moltbot.mjs daemon restart"
|
||||
run_step "install gateway launch agent (unsigned)" bash -lc "cd '${ROOT_DIR}' && node openclaw.mjs daemon install --force --runtime node"
|
||||
run_step "restart gateway daemon (unsigned)" bash -lc "cd '${ROOT_DIR}' && node openclaw.mjs daemon restart"
|
||||
if [[ "${GATEWAY_WAIT_SECONDS}" -gt 0 ]]; then
|
||||
run_step "wait for gateway (unsigned)" sleep "${GATEWAY_WAIT_SECONDS}"
|
||||
fi
|
||||
@@ -227,7 +227,7 @@ if [ "$NO_SIGN" -eq 1 ] && [ "$ATTACH_ONLY" -ne 1 ]; then
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
try {
|
||||
const raw = fs.readFileSync(path.join(process.env.HOME, ".clawdbot", "moltbot.json"), "utf8");
|
||||
const raw = fs.readFileSync(path.join(process.env.HOME, ".openclaw", "openclaw.json"), "utf8");
|
||||
const cfg = JSON.parse(raw);
|
||||
const port = cfg && cfg.gateway && typeof cfg.gateway.port === "number" ? cfg.gateway.port : 18789;
|
||||
process.stdout.write(String(port));
|
||||
@@ -259,7 +259,7 @@ run_step "launch app" env -i \
|
||||
# 5) Verify the app is alive.
|
||||
sleep 1.5
|
||||
if pgrep -f "${APP_PROCESS_PATTERN}" >/dev/null 2>&1; then
|
||||
log "OK: Moltbot is running."
|
||||
log "OK: OpenClaw is running."
|
||||
else
|
||||
fail "App exited immediately. Check ${LOG_PATH} or Console.app (User Reports)."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user