mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 15:23:56 +08:00
🍉 Sync 2026-05-16 08:37:13
This commit is contained in:
1 parent
8c1c3dd8ec
commit
8ed4c2a2a5
32 files changed
+1145
-234
No files matched your search
@@ -11,13 +11,33 @@ EXTRA_HELP=" setup 下载 Node.js 并安装 OpenClaw
|
||||
restart_gateway 仅重启 Gateway 实例 (不影响 Web PTY)"
|
||||
|
||||
# ── 安装路径 (支持自定义) ──
|
||||
# 从 UCI 配置读取自定义路径,默认为 /opt
|
||||
# 程序会在此路径下自动创建 openclaw 目录
|
||||
OC_BASE_PATH="$(uci -q get openclaw.main.install_path || echo '/opt')"
|
||||
OC_INSTALL_PATH="${OC_BASE_PATH}/openclaw"
|
||||
NODE_BASE="${OC_INSTALL_PATH}/node"
|
||||
OC_GLOBAL="${OC_INSTALL_PATH}/global"
|
||||
OC_DATA="${OC_INSTALL_PATH}/data"
|
||||
# 从 UCI 配置读取自定义路径,公开字段仍为 install_path。
|
||||
# 统一路径解析可以兼容 /mnt/data/openclaw 输入,避免双拼路径。
|
||||
[ -r /usr/libexec/openclaw-paths.sh ] && . /usr/libexec/openclaw-paths.sh
|
||||
[ -r /usr/libexec/openclaw-node.sh ] && . /usr/libexec/openclaw-node.sh
|
||||
OC_NODE_MIN_VERSION="${OC_NODE_MIN_VERSION:-22.14.0}"
|
||||
OC_CONFIGURED_PATH="$(uci -q get openclaw.main.install_path 2>/dev/null || echo '/opt')"
|
||||
if command -v oc_load_paths >/dev/null 2>&1; then
|
||||
if ! oc_load_paths "$OC_CONFIGURED_PATH"; then
|
||||
logger -t openclaw "安装路径无效: $OC_CONFIGURED_PATH"
|
||||
OC_BASE_PATH="/opt"
|
||||
OC_INSTALL_PATH="/opt/openclaw"
|
||||
NODE_BASE="${OC_INSTALL_PATH}/node"
|
||||
OC_GLOBAL="${OC_INSTALL_PATH}/global"
|
||||
OC_DATA="${OC_INSTALL_PATH}/data"
|
||||
CONFIG_FILE="${OC_DATA}/.openclaw/openclaw.json"
|
||||
else
|
||||
OC_BASE_PATH="$OPENCLAW_INSTALL_PATH"
|
||||
OC_INSTALL_PATH="$OC_ROOT"
|
||||
fi
|
||||
else
|
||||
OC_BASE_PATH="${OC_CONFIGURED_PATH%/}"
|
||||
OC_INSTALL_PATH="${OC_BASE_PATH}/openclaw"
|
||||
NODE_BASE="${OC_INSTALL_PATH}/node"
|
||||
OC_GLOBAL="${OC_INSTALL_PATH}/global"
|
||||
OC_DATA="${OC_INSTALL_PATH}/data"
|
||||
CONFIG_FILE="${OC_DATA}/.openclaw/openclaw.json"
|
||||
fi
|
||||
|
||||
# ── OverlayFS 兼容性修复 ──
|
||||
# Docker bind mount (/overlay/upper/opt/docker) 会导致 /opt 不可写
|
||||
@@ -220,6 +240,27 @@ if(d.plugins.installs){
|
||||
}
|
||||
});
|
||||
}
|
||||
// v2026.5.x: 微信插件渠道名统一为 openclaw-weixin
|
||||
// 旧配置里可能残留 weixin,启动前迁移,避免渠道加载失败。
|
||||
if(Array.isArray(d.plugins.allow)){
|
||||
d.plugins.allow=d.plugins.allow.map(x=>x==='weixin'?'openclaw-weixin':x)
|
||||
.filter((x,i,a)=>x&&a.indexOf(x)===i);
|
||||
}
|
||||
['entries','installs'].forEach(ns=>{
|
||||
if(d.plugins&&d.plugins[ns]&&d.plugins[ns].weixin){
|
||||
if(!d.plugins[ns]['openclaw-weixin'])d.plugins[ns]['openclaw-weixin']=d.plugins[ns].weixin;
|
||||
delete d.plugins[ns].weixin;
|
||||
}
|
||||
});
|
||||
['channel','channels'].forEach(ns=>{
|
||||
if(d[ns]&&d[ns].weixin){
|
||||
if(!d[ns]['openclaw-weixin'])d[ns]['openclaw-weixin']=d[ns].weixin;
|
||||
delete d[ns].weixin;
|
||||
}
|
||||
});
|
||||
if(!d.plugins.allow.includes('openclaw-weixin') && d.plugins.installs && d.plugins.installs['openclaw-weixin']){
|
||||
d.plugins.allow.push('openclaw-weixin');
|
||||
}
|
||||
// 始终信任 copilot-proxy (内置插件)
|
||||
if(!d.plugins.allow.includes('copilot-proxy'))d.plugins.allow.push('copilot-proxy');
|
||||
fs.writeFileSync(f,JSON.stringify(d,null,2));
|
||||
@@ -248,6 +289,13 @@ echo "未找到 Node.js: $NODE_BIN"
|
||||
echo "请运行: openclaw-env setup"
|
||||
return 1
|
||||
fi
|
||||
if command -v oc_assert_node_min_version >/dev/null 2>&1; then
|
||||
oc_assert_node_min_version "$NODE_BIN" "$OC_NODE_MIN_VERSION" >/dev/null || {
|
||||
echo "Node.js 版本过低,OpenClaw 需要 >= v${OC_NODE_MIN_VERSION}"
|
||||
echo "请运行: openclaw-env node"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# 检查 openclaw 入口
|
||||
local oc_entry
|
||||
|
||||
@@ -6,13 +6,23 @@
|
||||
# 支持自定义安装路径
|
||||
# ============================================================================
|
||||
|
||||
# 从 UCI 配置读取自定义安装路径
|
||||
# 用户配置的是基础路径,程序会在此路径下创建 openclaw 目录
|
||||
OC_BASE_PATH="$(uci -q get openclaw.main.install_path 2>/dev/null || echo '/opt')"
|
||||
OC_INSTALL_PATH="${OC_BASE_PATH}/openclaw"
|
||||
NODE_BASE="${OC_INSTALL_PATH}/node"
|
||||
OC_GLOBAL="${OC_INSTALL_PATH}/global"
|
||||
OC_DATA="${OC_INSTALL_PATH}/data"
|
||||
# 从 UCI 配置读取自定义安装路径。
|
||||
# 注意:这里不能修改全局 HOME。profile 会被 SSH shell、zsh/oh-my-zsh 等加载,
|
||||
# 全局改 HOME 会让 cd ~、插件缓存、历史文件全部跑到 OpenClaw 数据目录。
|
||||
# OpenClaw CLI 需要的 HOME 只在 openclaw 命令包装器里单独注入。
|
||||
[ -r /usr/libexec/openclaw-paths.sh ] && . /usr/libexec/openclaw-paths.sh
|
||||
OC_CONFIGURED_PATH="$(uci -q get openclaw.main.install_path 2>/dev/null || echo '/opt')"
|
||||
if command -v oc_load_paths >/dev/null 2>&1; then
|
||||
oc_load_paths "$OC_CONFIGURED_PATH" || return 0
|
||||
OC_INSTALL_PATH="$OC_ROOT"
|
||||
else
|
||||
OC_BASE_PATH="${OC_CONFIGURED_PATH%/}"
|
||||
OC_INSTALL_PATH="${OC_BASE_PATH}/openclaw"
|
||||
NODE_BASE="${OC_INSTALL_PATH}/node"
|
||||
OC_GLOBAL="${OC_INSTALL_PATH}/global"
|
||||
OC_DATA="${OC_INSTALL_PATH}/data"
|
||||
CONFIG_FILE="${OC_DATA}/.openclaw/openclaw.json"
|
||||
fi
|
||||
|
||||
# 检查 Node.js 是否已安装
|
||||
[ -x "${NODE_BASE}/bin/node" ] || return 0
|
||||
@@ -30,26 +40,32 @@ export NODE_ICU_DATA="${NODE_BASE}/share/icu"
|
||||
# 这些变量确保 openclaw 命令使用正确的配置路径
|
||||
export OPENCLAW_HOME="$OC_DATA"
|
||||
export OPENCLAW_STATE_DIR="${OC_DATA}/.openclaw"
|
||||
export OPENCLAW_CONFIG_PATH="${OC_DATA}/.openclaw/openclaw.json"
|
||||
export OPENCLAW_CONFIG_PATH="$CONFIG_FILE"
|
||||
|
||||
# 设置 HOME 为 OpenClaw 数据目录
|
||||
# 这是解决 Issue #42 的关键:确保 OpenClaw CLI 使用正确的配置路径
|
||||
# 注意:这会影响 cd ~ 等行为,但为了配置一致性是必要的
|
||||
export HOME="$OC_DATA"
|
||||
|
||||
# 创建便捷别名:用户可直接运行 openclaw 命令
|
||||
if [ -x "${OC_GLOBAL}/bin/openclaw" ] || [ -x "${NODE_BASE}/bin/openclaw" ]; then
|
||||
# openclaw 已在 PATH 中,无需别名
|
||||
:
|
||||
# 创建便捷包装器:只给 openclaw 命令单独注入 HOME,避免污染用户 shell。
|
||||
_oc_cli=""
|
||||
if [ -x "${OC_GLOBAL}/bin/openclaw" ]; then
|
||||
_oc_cli="${OC_GLOBAL}/bin/openclaw"
|
||||
elif [ -x "${NODE_BASE}/bin/openclaw" ]; then
|
||||
_oc_cli="${NODE_BASE}/bin/openclaw"
|
||||
else
|
||||
# 尝试查找 openclaw 入口并创建别名
|
||||
for _oc_dir in "${OC_GLOBAL}/lib/node_modules/openclaw" "${OC_GLOBAL}/node_modules/openclaw" "${NODE_BASE}/lib/node_modules/openclaw"; do
|
||||
if [ -f "${_oc_dir}/openclaw.mjs" ]; then
|
||||
alias openclaw="${NODE_BASE}/bin/node ${_oc_dir}/openclaw.mjs"
|
||||
break
|
||||
elif [ -f "${_oc_dir}/dist/cli.js" ]; then
|
||||
alias openclaw="${NODE_BASE}/bin/node ${_oc_dir}/dist/cli.js"
|
||||
break
|
||||
fi
|
||||
done
|
||||
for _oc_dir in "${OC_GLOBAL}/lib/node_modules/openclaw" "${OC_GLOBAL}/node_modules/openclaw" "${NODE_BASE}/lib/node_modules/openclaw"; do
|
||||
if [ -f "${_oc_dir}/openclaw.mjs" ]; then
|
||||
_oc_cli="${NODE_BASE}/bin/node ${_oc_dir}/openclaw.mjs"
|
||||
break
|
||||
elif [ -f "${_oc_dir}/dist/cli.js" ]; then
|
||||
_oc_cli="${NODE_BASE}/bin/node ${_oc_dir}/dist/cli.js"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "$_oc_cli" ]; then
|
||||
openclaw() {
|
||||
HOME="$OC_DATA" \
|
||||
OPENCLAW_HOME="$OC_DATA" \
|
||||
OPENCLAW_STATE_DIR="${OC_DATA}/.openclaw" \
|
||||
OPENCLAW_CONFIG_PATH="$CONFIG_FILE" \
|
||||
sh -c 'exec "$@"' openclaw $_oc_cli "$@"
|
||||
}
|
||||
fi
|
||||
@@ -2,9 +2,17 @@
|
||||
# luci-app-openclaw — 首次安装/升级初始化脚本
|
||||
|
||||
# 获取安装路径 (支持自定义)
|
||||
# 用户配置的是基础路径,程序会在此路径下创建 openclaw 目录
|
||||
OC_BASE_PATH="$(uci -q get openclaw.main.install_path || echo '/opt')"
|
||||
OC_INSTALL_PATH="${OC_BASE_PATH}/openclaw"
|
||||
# 用户配置的是基础路径,程序会在此路径下创建 openclaw 目录。
|
||||
# 这里复用统一路径解析,兼容用户误填 /mnt/data/openclaw 的情况。
|
||||
[ -r /usr/libexec/openclaw-paths.sh ] && . /usr/libexec/openclaw-paths.sh
|
||||
OC_CONFIGURED_PATH="$(uci -q get openclaw.main.install_path 2>/dev/null || echo '/opt')"
|
||||
if command -v oc_load_paths >/dev/null 2>&1 && oc_load_paths "$OC_CONFIGURED_PATH"; then
|
||||
OC_BASE_PATH="$OPENCLAW_INSTALL_PATH"
|
||||
OC_INSTALL_PATH="$OC_ROOT"
|
||||
else
|
||||
OC_BASE_PATH="/opt"
|
||||
OC_INSTALL_PATH="/opt/openclaw"
|
||||
fi
|
||||
|
||||
# ── v1.0.16: 清理错误路径下的配置文件 (Issue #42) ──
|
||||
# 用户在 SSH 中直接运行 openclaw 命令时,可能创建了 /root/.openclaw/ 目录
|
||||
|
||||
Reference in new issue
Block a user