🎁 Sync 2026-04-03 23:44:19

This commit is contained in:
github-actions[bot] committed 2026-04-03 23:44:19 +08:00
1 parent c3c67665a1
commit 3b13fc3626
4 files changed
+42 -71

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-openclaw
PKG_VERSION:=$(strip $(shell cat $(CURDIR)/VERSION 2>/dev/null || echo "1.0.0"))
PKG_RELEASE:=7
PKG_RELEASE:=8
PKG_MAINTAINER:=10000ge10000 <10000ge10000@users.noreply.github.com>
PKG_LICENSE:=GPL-3.0
@@ -481,7 +481,8 @@ function action_uninstall()
sys.exec("rm -f /tmp/openclaw-setup.* /tmp/openclaw-update.log /tmp/openclaw-plugin-upgrade.* /var/run/openclaw*.pid")
-- 清理 LuCI 缓存
sys.exec("rm -f /tmp/luci-indexcache /tmp/luci-modulecache/* 2>/dev/null")
-- 注意:不再删除 openclaw 系统用户,因为环境卸载后重新安装时需要该用户,且避免产生孤儿文件导致权限问题
-- 删除 openclaw 系统用户
sys.exec("sed -i '/^openclaw:/d' /etc/passwd /etc/shadow /etc/group 2>/dev/null")
http.prepare_content("application/json")
http.write_json({
@@ -1149,17 +1150,15 @@ function action_wechat_install()
"echo '开始安装微信插件...' > /tmp/openclaw-wechat-install.log; " ..
"echo '安装路径: %s' >> /tmp/openclaw-wechat-install.log; " ..
"cd %s && " ..
"su -s /bin/sh -c 'HOME=%s OPENCLAW_HOME=%s OPENCLAW_STATE_DIR=%s/.openclaw " ..
"PATH=%s/node/bin:%s/global/bin:$PATH; cd %s && " ..
"npm config set cache %s/.npm && " ..
"npx -y @tencent-weixin/openclaw-weixin-cli install' openclaw >> /tmp/openclaw-wechat-install.log 2>&1; " ..
"su -s /bin/sh openclaw -c 'HOME=%s OPENCLAW_HOME=%s OPENCLAW_STATE_DIR=%s/.openclaw " ..
"PATH=%s/node/bin:%s/global/bin:$PATH " ..
"%s -y @tencent-weixin/openclaw-weixin-cli install' >> /tmp/openclaw-wechat-install.log 2>&1; " ..
"RC=$?; echo $RC > /tmp/openclaw-wechat-install.exit; " ..
"if [ $RC -eq 0 ]; then echo '✅ 微信插件安装成功!' >> /tmp/openclaw-wechat-install.log; " ..
"else echo '❌ 安装失败 (exit: '$RC')' >> /tmp/openclaw-wechat-install.log; fi " ..
") & echo $! > /tmp/openclaw-wechat-install.pid",
install_path, oc_data, oc_data, oc_data, oc_data, install_path, install_path, oc_data, oc_data
)
sys.exec(install_cmd)
install_path, oc_data, oc_data, oc_data, oc_data, install_path, install_path, npx_bin
) sys.exec(install_cmd)
http.prepare_content("application/json")
http.write_json({ status = "ok", message = "微信插件安装已在后台启动..." })
@@ -1256,21 +1255,21 @@ function action_wechat_login()
-- 清理旧状态和可能的残留进程
sys.exec("kill -9 $(cat /tmp/openclaw-wechat-login.pid 2>/dev/null) 2>/dev/null")
sys.exec("pkill -f 'channels login --channel openclaw-weixin' 2>/dev/null")
sys.exec("rm -f /tmp/openclaw-wechat-qrcode.txt /tmp/openclaw-wechat-login.pid /tmp/openclaw-wechat-login.exit /tmp/openclaw-wechat-restarted")
-- 后台启动登录流程,将二维码输出到文件
sys.exec("rm -f /tmp/openclaw-wechat-qrcode.txt /tmp/openclaw-wechat-login.pid /tmp/openclaw-wechat-login.exit /tmp/openclaw-wechat-restarted") -- 后台启动登录流程,将二维码输出到文件
local login_cmd = string.format(
"( " ..
"echo '正在启动微信登录...' > /tmp/openclaw-wechat-qrcode.txt; " ..
"echo '安装路径: %s' >> /tmp/openclaw-wechat-qrcode.txt; " ..
"cd %s && " ..
"su -s /bin/sh -c 'HOME=%s OPENCLAW_HOME=%s OPENCLAW_STATE_DIR=%s/.openclaw OPENCLAW_CONFIG_PATH=%s/.openclaw/openclaw.json " ..
"PATH=%s/node/bin:%s/global/bin:$PATH " ..
"cd %s && %s %s channels login --channel openclaw-weixin' openclaw >> /tmp/openclaw-wechat-qrcode.txt 2>&1; " ..
"echo $? > /tmp/openclaw-wechat-login.exit; " ..
") >/dev/null 2>&1 & echo $! > /tmp/openclaw-wechat-login.pid",
install_path, oc_data, oc_data, oc_data, oc_data, oc_data, install_path, install_path, oc_data, node_bin, oc_entry
) sys.exec(login_cmd) http.prepare_content("application/json")
"su -s /bin/sh openclaw -c 'HOME=%s OPENCLAW_HOME=%s OPENCLAW_STATE_DIR=%s/.openclaw OPENCLAW_CONFIG_PATH=%s/.openclaw/openclaw.json " ..
"PATH=%s/node/bin:%s/global/bin:$PATH " ..
"%s %s channels login --channel openclaw-weixin' >> /tmp/openclaw-wechat-qrcode.txt 2>&1; " ..
"echo $? > /tmp/openclaw-wechat-login.exit; " ..
") >/dev/null 2>&1 & echo $! > /tmp/openclaw-wechat-login.pid",
install_path, oc_data, oc_data, oc_data, oc_data, oc_data, install_path, install_path, node_bin, oc_entry
) sys.exec(login_cmd)
http.prepare_content("application/json")
http.write_json({ status = "ok", message = "微信登录流程已启动" })
end
@@ -1315,9 +1314,7 @@ function action_wechat_login_status()
local qrcode_url = ""
for url in qrcode:gmatch("https?://[^\n\r]+") do
qrcode_url = url
end
-- 检查是否登录成功
end -- 检查是否登录成功
local logged_in = qrcode:find("登录成功") ~= nil or qrcode:find("成功登录") ~= nil or qrcode:find("Login success") ~= nil or qrcode:find("Logged in") ~= nil
local state = "idle"
@@ -1336,7 +1333,7 @@ function action_wechat_login_status()
-- 如果刚登录成功,触发一次重启,确保主进程加载微信
if state == "success" and not nixio.fs.stat("/tmp/openclaw-wechat-restarted", "type") then
sys.exec("touch /tmp/openclaw-wechat-restarted")
sys.exec("/etc/init.d/openclaw restart_gateway >/dev/null 2>&1 &")
sys.exec("/etc/init.d/openclaw restart &")
end http.prepare_content("application/json")
http.write_json({
status = "ok",
@@ -1462,16 +1459,17 @@ function action_wechat_upgrade_plugin()
"echo '正在升级微信插件...' > /tmp/openclaw-wechat-install.log; " ..
"echo '安装路径: %s' >> /tmp/openclaw-wechat-install.log; " ..
"cd %s && " ..
"su -s /bin/sh -c 'HOME=%s OPENCLAW_HOME=%s OPENCLAW_STATE_DIR=%s/.openclaw " ..
"PATH=%s/node/bin:%s/global/bin:$PATH; cd %s && " ..
"npm config set cache %s/.npm && " ..
"npx -y @tencent-weixin/openclaw-weixin-cli install' openclaw >> /tmp/openclaw-wechat-install.log 2>&1; " ..
"RC=$?; echo $RC > /tmp/openclaw-wechat-install.exit; " ..
"if [ $RC -eq 0 ]; then echo '✅ 微信插件升级成功!' >> /tmp/openclaw-wechat-install.log; " ..
"else echo '❌ 升级失败 (exit: '$RC')' >> /tmp/openclaw-wechat-install.log; fi " ..
") & echo $! > /tmp/openclaw-wechat-install.pid",
install_path, oc_data, oc_data, oc_data, oc_data, install_path, install_path, oc_data, oc_data
) sys.exec(upgrade_cmd) http.prepare_content("application/json")
"su -s /bin/sh openclaw -c 'HOME=%s OPENCLAW_HOME=%s OPENCLAW_STATE_DIR=%s/.openclaw " ..
"PATH=%s/node/bin:%s/global/bin:$PATH " ..
"%s -y @tencent-weixin/openclaw-weixin-cli install' >> /tmp/openclaw-wechat-install.log 2>&1; " ..
"RC=$?; echo $RC > /tmp/openclaw-wechat-install.exit; " ..
"if [ $RC -eq 0 ]; then echo '✅ 微信插件升级成功!' >> /tmp/openclaw-wechat-install.log; " ..
"else echo '❌ 升级失败 (exit: '$RC')' >> /tmp/openclaw-wechat-install.log; fi " ..
") & echo $! > /tmp/openclaw-wechat-install.pid",
install_path, oc_data, oc_data, oc_data, oc_data, install_path, install_path, npx_bin
) sys.exec(upgrade_cmd)
http.prepare_content("application/json")
http.write_json({ status = "ok", message = "微信插件升级已在后台启动..." })
end
@@ -1516,15 +1514,17 @@ function action_wechat_logout()
end
-- 在后台执行 logout
local logout_cmd = string.format(
"su -s /bin/sh -c 'HOME=%s OPENCLAW_HOME=%s OPENCLAW_STATE_DIR=%s/.openclaw OPENCLAW_CONFIG_PATH=%s/.openclaw/openclaw.json " ..
"PATH=%s/node/bin:%s/global/bin:$PATH " ..
"cd %s && %s %s channels logout --channel openclaw-weixin --account \"%s\"' openclaw",
oc_data, oc_data, oc_data, oc_data, install_path, install_path, oc_data, node_bin, oc_entry, account_id
) sys.exec(logout_cmd .. " >/dev/null 2>&1")
local logout_cmd = string.format(
"cd %s && su -s /bin/sh openclaw -c 'HOME=%s OPENCLAW_HOME=%s OPENCLAW_STATE_DIR=%s/.openclaw OPENCLAW_CONFIG_PATH=%s/.openclaw/openclaw.json " ..
"PATH=%s/node/bin:%s/global/bin:$PATH " ..
"%s %s channels logout --channel openclaw-weixin --account \"%s\"'",
oc_data, oc_data, oc_data, oc_data, oc_data, install_path, install_path, node_bin, oc_entry, account_id
)
sys.exec(logout_cmd .. " >/dev/null 2>&1")
-- 重启服务
sys.exec("/etc/init.d/openclaw restart_gateway >/dev/null 2>&1 &")
sys.exec("/etc/init.d/openclaw restart &")
http.prepare_content("application/json")
http.write_json({ status = "ok", message = "已下线账号: " .. account_id })
+2 -6
View File
@@ -205,19 +205,15 @@ fi
# 问题: 旧版本写入的是 "openclaw-qqbot",但实际插件名是 "@tencent-connect/openclaw-qqbot"
fix_plugin_config() {
local qqbot_ext_dir="${OC_DATA}/.openclaw/extensions/openclaw-qqbot"
local weixin_ext_dir="${OC_DATA}/.openclaw/extensions/openclaw-weixin"
[ ! -d "$qqbot_ext_dir" ] && [ ! -d "$weixin_ext_dir" ] && return
[ ! -d "$qqbot_ext_dir" ] && return
[ ! -f "$CONFIG_FILE" ] && return
"$NODE_BIN" -e "
const fs=require('fs');
try{
const d=JSON.parse(fs.readFileSync('${CONFIG_FILE}','utf8'));
if(!d.plugins)d.plugins={};
let modified=false;
if(!d.plugins)d.plugins={};
if(!Array.isArray(d.plugins.allow))d.plugins.allow=[];
const hasWechat=fs.existsSync('${weixin_ext_dir}'); if(hasWechat && !d.plugins.allow.includes("@tencent-weixin/openclaw-weixin")) { d.plugins.allow.push("@tencent-weixin/openclaw-weixin"); modified=true; }
// 修复 plugins.allow 数组中的插件名称
if(Array.isArray(d.plugins.allow)){
@@ -389,34 +389,9 @@ install_openclaw() {
fi
}
ensure_openclaw_user() {
if ! id openclaw >/dev/null 2>&1; then
echo " 正在创建 openclaw 系统用户..."
local OC_UID=1000
while grep -q "^[^:]*:x:${OC_UID}:" /etc/passwd 2>/dev/null; do
OC_UID=$((OC_UID + 1))
done
local OC_GID=$OC_UID
while grep -q "^[^:]*:x:${OC_GID}:" /etc/group 2>/dev/null; do
OC_GID=$((OC_GID + 1))
done
if ! grep -q "^openclaw:" /etc/passwd 2>/dev/null; then
echo "openclaw:x:${OC_UID}:${OC_GID}:openclaw:/opt/openclaw/data:/bin/false" >> /etc/passwd
fi
if ! grep -q "^openclaw:" /etc/shadow 2>/dev/null; then
echo "openclaw:x:0:0:99999:7:::" >> /etc/shadow
fi
if ! grep -q "^openclaw:" /etc/group 2>/dev/null; then
echo "openclaw:x:${OC_GID}:" >> /etc/group
fi
log_info "用户 openclaw 创建成功"
fi
}
init_openclaw() {
echo ""
echo "=== 初始化 OpenClaw ==="
ensure_openclaw_user
# 创建数据目录
ensure_mkdir "$OC_DATA/.openclaw"