mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-31 01:15:13 +08:00
🎈 Sync 2026-06-08 16:57:14
This commit is contained in:
1 parent
a75bbbe729
commit
e41d0593c1
37 files changed
+275
-10683
No files matched your search
@@ -15,7 +15,7 @@ EXTRA_HELP=" setup 下载 Node.js 并安装 OpenClaw
|
||||
# 统一路径解析可以兼容 /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_NODE_MIN_VERSION="${OC_NODE_MIN_VERSION:-22.19.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
|
||||
@@ -252,6 +252,9 @@ if(Array.isArray(d.plugins.allow)){
|
||||
delete d.plugins[ns].weixin;
|
||||
}
|
||||
});
|
||||
if(d.plugins.entries&&d.plugins.entries['openclaw-weixin']){
|
||||
delete d.plugins.entries['openclaw-weixin'];
|
||||
}
|
||||
['channel','channels'].forEach(ns=>{
|
||||
if(d[ns]&&d[ns].weixin){
|
||||
if(!d[ns]['openclaw-weixin'])d[ns]['openclaw-weixin']=d[ns].weixin;
|
||||
@@ -365,10 +368,35 @@ fi
|
||||
# v2026.4.10 补充: 同时修复权限模式为 755,确保 Gateway 可读取插件
|
||||
# 原因: npm/npx 以 root 创建目录时默认权限 700,其他用户无法读取
|
||||
local ext_dir="${OC_DATA}/.openclaw/extensions"
|
||||
local npm_projects_dir="${OC_DATA}/.openclaw/npm/projects"
|
||||
local wechat_legacy_dir="${ext_dir}/openclaw-weixin"
|
||||
local wechat_npm_plugin=""
|
||||
if [ -d "$npm_projects_dir" ]; then
|
||||
wechat_npm_plugin=$(find "$npm_projects_dir" -path "*/node_modules/@tencent-weixin/openclaw-weixin/openclaw.plugin.json" -type f 2>/dev/null | head -n 1)
|
||||
fi
|
||||
if [ -n "$wechat_npm_plugin" ] && [ -d "$wechat_legacy_dir" ]; then
|
||||
local archive_root="${OC_DATA}/.openclaw/archived-extensions"
|
||||
mkdir -p "$archive_root" 2>/dev/null || true
|
||||
local archived_dir="${archive_root}/openclaw-weixin.legacy.$(date +%Y%m%d%H%M%S)"
|
||||
mv "$wechat_legacy_dir" "$archived_dir" 2>/dev/null && logger -t openclaw "已归档旧微信扩展目录: $archived_dir"
|
||||
fi
|
||||
if [ -n "$wechat_npm_plugin" ] && [ -d "$ext_dir" ]; then
|
||||
local archive_root="${OC_DATA}/.openclaw/archived-extensions"
|
||||
mkdir -p "$archive_root" 2>/dev/null || true
|
||||
for stale_dir in "$ext_dir"/openclaw-weixin.legacy.*; do
|
||||
[ -d "$stale_dir" ] || continue
|
||||
local stale_name="${stale_dir##*/}"
|
||||
mv "$stale_dir" "${archive_root}/${stale_name}" 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
if [ -d "$ext_dir" ]; then
|
||||
chown -R root:root "$ext_dir" 2>/dev/null || true
|
||||
chmod -R 755 "$ext_dir" 2>/dev/null || true
|
||||
fi
|
||||
if [ -d "$npm_projects_dir" ]; then
|
||||
chown -R root:root "$npm_projects_dir" 2>/dev/null || true
|
||||
chmod -R 755 "$npm_projects_dir" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# v2026.4.x: 清理 jiti 缓存目录 (修复微信插件加载权限问题)
|
||||
# jiti 编译 TypeScript 时会在 /tmp/jiti 创建缓存,如果由 root 创建则 openclaw 用户无法写入
|
||||
@@ -486,8 +514,16 @@ if(d.gateway&&d.gateway.auth&&d.gateway.auth.token)process.stdout.write(d.gatewa
|
||||
# v2026.4.10: 最终权限修复 - 确保 Gateway 启动前所有数据目录权限正确
|
||||
# doctor --fix 或 _ensure_critical_config 可能创建新的目录/文件
|
||||
# 关键: agents 目录下的 agent 子目录必须可被 openclaw 用户写入
|
||||
find "${OC_DATA}/.openclaw" -user root -type d -exec chown openclaw:openclaw {} \; 2>/dev/null || true
|
||||
find "${OC_DATA}/.openclaw" -user root -type f -exec chown openclaw:openclaw {} \; 2>/dev/null || true
|
||||
find "${OC_DATA}/.openclaw" -user root \
|
||||
! -path "${OC_DATA}/.openclaw/extensions*" \
|
||||
! -path "${OC_DATA}/.openclaw/archived-extensions*" \
|
||||
! -path "${OC_DATA}/.openclaw/npm/projects*" \
|
||||
-type d -exec chown openclaw:openclaw {} \; 2>/dev/null || true
|
||||
find "${OC_DATA}/.openclaw" -user root \
|
||||
! -path "${OC_DATA}/.openclaw/extensions*" \
|
||||
! -path "${OC_DATA}/.openclaw/archived-extensions*" \
|
||||
! -path "${OC_DATA}/.openclaw/npm/projects*" \
|
||||
-type f -exec chown openclaw:openclaw {} \; 2>/dev/null || true
|
||||
# 特别确保 agents/main/agent 目录权限 (模型配置写入目录)
|
||||
local agent_dir="${OC_DATA}/.openclaw/agents/main/agent"
|
||||
if [ -d "$agent_dir" ]; then
|
||||
@@ -500,6 +536,14 @@ if(d.gateway&&d.gateway.auth&&d.gateway.auth.token)process.stdout.write(d.gatewa
|
||||
chown -R root:root "${OC_DATA}/.openclaw/extensions" 2>/dev/null || true
|
||||
chmod -R 755 "${OC_DATA}/.openclaw/extensions" 2>/dev/null || true
|
||||
fi
|
||||
if [ -d "${OC_DATA}/.openclaw/archived-extensions" ]; then
|
||||
chown -R root:root "${OC_DATA}/.openclaw/archived-extensions" 2>/dev/null || true
|
||||
chmod -R 700 "${OC_DATA}/.openclaw/archived-extensions" 2>/dev/null || true
|
||||
fi
|
||||
if [ -d "${OC_DATA}/.openclaw/npm/projects" ]; then
|
||||
chown -R root:root "${OC_DATA}/.openclaw/npm/projects" 2>/dev/null || true
|
||||
chmod -R 755 "${OC_DATA}/.openclaw/npm/projects" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Patch iframe 安全头,允许 LuCI 嵌入
|
||||
patch_iframe_headers
|
||||
|
||||
@@ -7,22 +7,22 @@
|
||||
# openclaw-env upgrade — 升级 OpenClaw 到最新版
|
||||
# openclaw-env node — 仅下载/更新 Node.js
|
||||
# 环境变量:
|
||||
# OC_VERSION — 指定 OpenClaw 版本 (如 2026.3.1),不设置则安装最新版
|
||||
# OC_VERSION — 指定 OpenClaw 版本 (如 2026.6.1),不设置则安装已测试稳定版
|
||||
# ============================================================================
|
||||
set -e
|
||||
|
||||
# ── Node.js 版本策略 (双版本兼容) ──
|
||||
# V2: 当前推荐版本,用于 OpenClaw v2026.3.22+ (要求 >= 22.14.0,使用 22.16.0 确保兼容)
|
||||
# V2: 当前推荐版本,用于 OpenClaw v2026.6.1+ (要求 >= 22.19.0,使用 24.15.0 确保兼容)
|
||||
# V1: 旧版兼容,用于 OpenClaw v2026.3.8 及更早版本
|
||||
NODE_VERSION_V2="22.16.0"
|
||||
NODE_VERSION_V2="24.15.0"
|
||||
NODE_VERSION_V1="22.15.1"
|
||||
# 默认使用 V2 版本 (可通过 NODE_VERSION 环境变量覆盖)
|
||||
NODE_VERSION="${NODE_VERSION:-${NODE_VERSION_V2}}"
|
||||
# 经过验证的 OpenClaw 稳定版本 (更新此值需同步测试)
|
||||
OC_TESTED_VERSION="2026.5.12"
|
||||
# OpenClaw 2026.5.x package.json engines.node 的最低要求。
|
||||
OC_TESTED_VERSION="2026.6.1"
|
||||
# OpenClaw 2026.6.x package.json engines.node 的最低要求。
|
||||
# 如果未来上游提高要求,安装成功后还会从 package.json 再做一次强校验。
|
||||
OC_NODE_MIN_VERSION="${OC_NODE_MIN_VERSION:-22.14.0}"
|
||||
OC_NODE_MIN_VERSION="${OC_NODE_MIN_VERSION:-22.19.0}"
|
||||
# 用户可通过 OC_VERSION 环境变量覆盖安装版本
|
||||
OC_VERSION="${OC_VERSION:-}"
|
||||
|
||||
@@ -216,7 +216,11 @@ assert_node_runtime() {
|
||||
local required="$OC_NODE_MIN_VERSION"
|
||||
local from_pkg
|
||||
from_pkg=$(detect_oc_node_requirement 2>/dev/null || true)
|
||||
[ -n "$from_pkg" ] && required="$from_pkg"
|
||||
if [ -n "$from_pkg" ] && command -v oc_node_version_ge >/dev/null 2>&1; then
|
||||
if oc_node_version_ge "$from_pkg" "$required"; then
|
||||
required="$from_pkg"
|
||||
fi
|
||||
fi
|
||||
|
||||
if command -v oc_assert_node_min_version >/dev/null 2>&1; then
|
||||
oc_assert_node_min_version "$NODE_BIN" "$required" || exit 1
|
||||
@@ -258,12 +262,8 @@ download_node() {
|
||||
assert_node_runtime
|
||||
return 0
|
||||
fi
|
||||
# ARM64 musl 使用 Alpine 打包,版本号可能不完全匹配
|
||||
# 只要主版本号相同即认为兼容 (如 22.15.1 vs 22.15.0)
|
||||
local cur_major=$(echo "$current_ver" | cut -d. -f1)
|
||||
local want_major=$(echo "$node_ver" | cut -d. -f1)
|
||||
if [ "$cur_major" = "$want_major" ]; then
|
||||
log_info "Node.js v${current_ver} 已安装 (兼容 v${node_ver}), 跳过下载"
|
||||
if command -v oc_node_version_ge >/dev/null 2>&1 && oc_node_version_ge "$current_ver" "$node_ver"; then
|
||||
log_info "Node.js v${current_ver} 已安装 (>= v${node_ver}), 跳过下载"
|
||||
assert_node_runtime
|
||||
return 0
|
||||
fi
|
||||
@@ -285,11 +285,6 @@ download_node() {
|
||||
mirror_list="${NODE_SELF_HOST}/${musl_tarball}"
|
||||
# 2) unofficial-builds (留作将来可能支持)
|
||||
mirror_list="$mirror_list ${NODE_MUSL_MIRROR}/v${node_ver}/${musl_tarball}"
|
||||
# 3) 回退到 V1 版本 (兼容旧环境,仅当请求 V2 时)
|
||||
if [ "$node_ver" = "$NODE_VERSION_V2" ]; then
|
||||
local v1_tarball="node-v${NODE_VERSION_V1}-${node_arch}-musl.tar.xz"
|
||||
mirror_list="$mirror_list ${NODE_SELF_HOST}/${v1_tarball}"
|
||||
fi
|
||||
else
|
||||
# x64 musl: unofficial-builds 提供
|
||||
# 1) unofficial-builds
|
||||
|
||||
@@ -606,7 +606,11 @@ show_current_config() {
|
||||
|
||||
# 检测微信渠道
|
||||
local wechat_ext_dir="${OC_STATE_DIR}/extensions/openclaw-weixin"
|
||||
if [ -d "$wechat_ext_dir" ] && [ -f "${wechat_ext_dir}/openclaw.plugin.json" ]; then
|
||||
local wechat_npm_plugin=""
|
||||
if [ -d "${OC_STATE_DIR}/npm/projects" ]; then
|
||||
wechat_npm_plugin=$(find "${OC_STATE_DIR}/npm/projects" -path "*/node_modules/@tencent-weixin/openclaw-weixin/openclaw.plugin.json" -type f 2>/dev/null | head -n 1)
|
||||
fi
|
||||
if { [ -d "$wechat_ext_dir" ] && [ -f "${wechat_ext_dir}/openclaw.plugin.json" ]; } || [ -n "$wechat_npm_plugin" ]; then
|
||||
echo -e "${GREEN}│${NC} 微信 .............. ${GREEN}✅ 已配置${NC}"
|
||||
else
|
||||
echo -e "${GREEN}│${NC} 微信 .............. ${YELLOW}❌ 未配置${NC}"
|
||||
|
||||
Reference in new issue
Block a user