💐 Sync 2026-07-09 02:25:04

This commit is contained in:
github-actions[bot] committed 2026-07-09 02:25:04 +08:00
1 parent f077ddaf47
commit 2af7926aeb
37 files changed
+597 -329

No files matched your search

@@ -229,6 +229,35 @@ assert_node_runtime() {
if command -v oc_assert_node_min_version >/dev/null 2>&1; then
oc_assert_node_min_version "$NODE_BIN" "$required" || exit 1
fi
# OpenClaw CLI 依赖 Unicode property escapes(例如 \p{Extended_Pictographic})。
# ARM64 musl 自托管 Node 包必须带上 NODE_ICU_DATA,否则用户直接执行
# `openclaw status` 等子命令会在 CLI 入口阶段抛 SyntaxError。
if ! NODE_ICU_DATA="${NODE_BASE}/share/icu" "$NODE_BIN" -e "new RegExp('\\\\p{Extended_Pictographic}','u')" >/dev/null 2>&1; then
log_error "Node.js ICU/Unicode 正则能力异常,请重新安装 Node.js 运行时"
exit 1
fi
}
install_openclaw_cli_wrapper() {
local oc_entry
oc_entry=$(find_oc_entry)
[ -n "$oc_entry" ] || return 1
ensure_mkdir "$OC_GLOBAL/bin"
# npm 默认生成的 openclaw 可能是指向 openclaw.mjs 的 symlink。
# 写 wrapper 前必须先 unlink,否则重定向会顺着 symlink 覆盖真实 CLI 入口。
rm -f "$OC_GLOBAL/bin/openclaw" 2>/dev/null || true
cat > "$OC_GLOBAL/bin/openclaw" << EOF
#!/bin/sh
export HOME="${OC_DATA}"
export OPENCLAW_HOME="${OC_DATA}"
export OPENCLAW_STATE_DIR="${OC_DATA}/.openclaw"
export OPENCLAW_CONFIG_PATH="${OC_DATA}/.openclaw/openclaw.json"
export NODE_ICU_DATA="${NODE_BASE}/share/icu"
export PATH="${NODE_BASE}/bin:${OC_GLOBAL}/bin:\$PATH"
exec "${NODE_BIN}" "${oc_entry}" "\$@"
EOF
chmod +x "$OC_GLOBAL/bin/openclaw" 2>/dev/null || true
}
detect_arch() {
@@ -471,6 +500,7 @@ install_openclaw() {
fi
if [ -n "$oc_ver" ]; then
install_openclaw_cli_wrapper || true
log_info "OpenClaw v${oc_ver} 安装成功"
assert_node_runtime
else
@@ -510,6 +540,7 @@ do_setup() {
# 检查是否已安装
if [ -x "$NODE_BIN" ] && [ -n "$(find_oc_entry)" ]; then
install_openclaw_cli_wrapper || true
local oc_ver=""
local oc_entry="$(find_oc_entry)"
local oc_pkg_dir="$(dirname "$oc_entry")"
@@ -665,6 +696,7 @@ do_upgrade() {
echo ""
if [ -n "$new_ver" ]; then
install_openclaw_cli_wrapper || true
assert_node_runtime
if [ "$current_ver" = "$new_ver" ]; then
log_info "当前已是最新版本 v${new_ver}"
@@ -827,6 +859,7 @@ do_setup_offline() {
local oc_entry=$(find_oc_entry)
if [ -n "$oc_entry" ]; then
local oc_ver=$("$NODE_BIN" "$oc_entry" --version 2>/dev/null | tr -d '[:space:]')
install_openclaw_cli_wrapper || true
log_info "OpenClaw v${oc_ver} 安装成功"
assert_node_runtime
else
@@ -338,7 +338,15 @@ async function restartGateway() {
console.log(`\n${C.yellow}正在重启 Gateway...${C.reset}`);
try {
await runCommand('/etc/init.d/openclaw', ['restart_gateway']);
await runCommand('/bin/sh', ['-c', [
"if [ \"$(uci -q get openclaw.main.enabled 2>/dev/null || echo 0)\" != \"1\" ]; then",
" uci -q set openclaw.main.enabled='1';",
" uci -q commit openclaw;",
" /etc/init.d/openclaw enable >/dev/null 2>&1 || true;",
'fi;',
'/etc/init.d/openclaw restart_gateway >/dev/null 2>&1 || true;',
'/etc/init.d/openclaw start >/dev/null 2>&1 || true'
].join(' ')]);
} catch {}
const spin = spinner({ text: 'Gateway 启动中,请稍候 (约 15-30 秒)...' });
@@ -558,12 +558,22 @@ restart_gateway() {
# 修复数据目录权限 (root 用户操作可能改变了文件属主)
fix_openclaw_state_permissions 2>/dev/null || true
# 首次安装后 UCI 默认保持 disabled。用户在配置向导中确认“立即重启”
# 即表示希望当前配置生效,这里同步启用服务,避免提示重启但实际仍为“已禁用”。
if [ "$(uci -q get openclaw.main.enabled 2>/dev/null || echo 0)" != "1" ]; then
echo -e " ${CYAN}检测到 Gateway 未启用,正在启用服务...${NC}"
uci -q set openclaw.main.enabled='1' 2>/dev/null || true
uci -q commit openclaw 2>/dev/null || true
/etc/init.d/openclaw enable >/dev/null 2>&1 || true
fi
local port
port=$(json_get gateway.port)
port=${port:-18789}
# ── kill gateway 进程,让 procd respawn ──
/etc/init.d/openclaw restart_gateway >/dev/null 2>&1
/etc/init.d/openclaw start >/dev/null 2>&1
# ── 等待端口恢复 (最多 30 秒,含端口释放 + Node.js 冷启动) ──
echo -e " ${YELLOW}⏳ Gateway 启动中,请稍候 (约 15-30 秒)...${NC}"