🍉 Sync 2026-05-16 08:37:13

This commit is contained in:
github-actions[bot] committed 2026-05-16 08:37:13 +08:00
1 parent 8c1c3dd8ec
commit 8ed4c2a2a5
32 files changed
+1145 -234

No files matched your search

@@ -33,10 +33,20 @@ get_pid_by_port() {
}
# ── 路径 (OpenWrt 适配,支持自定义安装路径) ──
# 从 UCI 配置读取自定义路径,环境变量可覆盖
# 用户配置的是基础路径,程序会在此路径下创建 openclaw 目录
OC_BASE_PATH="${OC_INSTALL_PATH:-$(uci -q get openclaw.main.install_path 2>/dev/null || echo '/opt')}"
OC_INSTALL_PATH="${OC_BASE_PATH}/openclaw"
# 从 UCI 配置读取自定义路径,环境变量可覆盖。
# 注意 OC_INSTALL_PATH 历史上被当作“基础路径”传入,统一解析后再展开到 openclaw 根目录。
[ -r /usr/libexec/openclaw-paths.sh ] && . /usr/libexec/openclaw-paths.sh
OC_CONFIGURED_PATH="${OC_INSTALL_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_INSTALL_PATH="$OC_ROOT"
else
OC_BASE_PATH="${OC_CONFIGURED_PATH%/}"
OC_INSTALL_PATH="${OC_BASE_PATH}/openclaw"
NODE_BASE="${NODE_BASE:-${OC_INSTALL_PATH}/node}"
OC_GLOBAL="${OC_GLOBAL:-${OC_INSTALL_PATH}/global}"
OC_DATA="${OC_DATA:-${OC_INSTALL_PATH}/data}"
CONFIG_FILE="${OC_DATA}/.openclaw/openclaw.json"
fi
NODE_BASE="${NODE_BASE:-${OC_INSTALL_PATH}/node}"
OC_GLOBAL="${OC_GLOBAL:-${OC_INSTALL_PATH}/global}"
OC_DATA="${OC_DATA:-${OC_INSTALL_PATH}/data}"
@@ -19,10 +19,19 @@ const PORT = parseInt(process.env.OC_CONFIG_PORT || '18793', 10);
const HOST = process.env.OC_CONFIG_HOST || '0.0.0.0'; // token 认证保护,可安全绑定所有接口
// 从 UCI 读取安装路径,默认为 /opt/openclaw
const { execSync } = require('child_process');
function normalizeInstallPath(raw) {
let value = String(raw || '').trim().replace(/\/+$/, '');
if (!value) value = '/opt';
if (!value.startsWith('/')) return '/opt';
if (/[\s'"`$;&|<>()]/.test(value)) return '/opt';
if (/^\/(proc|sys|dev|tmp|var|etc|usr|bin|sbin|lib|rom|overlay)(\/|$)/.test(value) || value === '/') return '/opt';
if (value.endsWith('/openclaw')) value = value.slice(0, -'/openclaw'.length) || '/opt';
return value;
}
let installPath = '/opt/openclaw';
try {
const uciPath = execSync('uci -q get openclaw.main.install_path 2>/dev/null', { encoding: 'utf8', timeout: 3000 }).trim();
if (uciPath) installPath = uciPath + '/openclaw';
if (uciPath) installPath = normalizeInstallPath(uciPath) + '/openclaw';
} catch {}
const NODE_BASE = process.env.NODE_BASE || installPath + '/node';
const OC_GLOBAL = process.env.OC_GLOBAL || installPath + '/global';
@@ -1,11 +1,17 @@
{
"luci-app-openclaw": {
"description": "Grant UCI access for luci-app-openclaw",
"description": "Grant access to the OpenClaw LuCI application",
"read": {
"uci": [ "openclaw" ]
"uci": [ "openclaw" ],
"ubus": {
"service": [ "list" ]
}
},
"write": {
"uci": [ "openclaw" ]
"uci": [ "openclaw" ],
"ubus": {
"service": [ "list", "set", "delete" ]
}
}
}
}