Files
u-claw/bootable/linux-setup/test-installation.sh
zheng 45026b9d35
Some checks failed
Tests / test (push) Has been cancelled
docs: 翻掉我上轮漏掉的三处,并修正发布说明里一条错误建议
上一轮我说"剩余中文都合理",说得太满。这三处不合理:

1. bootable/linux-setup/test-installation.sh —— 在用户的 Linux 机器上跑的
   自检脚本,输出中英混杂(check "安装目录存在" ... "Directory $INSTALL_DIR")

2. issue / PR 模板 —— 贡献者第一眼看到的东西,而 CONTRIBUTING.md 已经是
   英文了。顺带修掉模板里指向上游官网和上游微信的链接(那些我们控制不了),
   改为指向本仓库。PR 模板加了一条"说明你在哪个平台跑过" —— 只在 Mac 上
   验证过的 .bat 改动一直是本项目最主要的故障来源。

3. release.yml 的发布说明正文 —— 那是用户在 release 页面读到的文字,内容
   还停留在旧产品(DeepSeek/通义、预装微信 QQ 钉钉飞书企微)。

第 3 项里还有一条**和事实相反**的建议:它让用户把 U 盘格式化成 NTFS。
macOS 对 NTFS 只读,照做正好会让"配置跟着盘走"这个核心卖点在 Mac 上
彻底失效。改为 exFAT,并说明为什么慢、以及我们如何用本机缓存补偿。

track-upstream.yml 的输入描述和输出也翻了 —— 它们会显示给手动触发
workflow 的人。
2026-08-17 19:24:55 +08:00

200 lines
5.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# ============================================================
# U-Claw Installation Test Script
# 测试OpenClaw安装是否成功
# ============================================================
set -euo pipefail
echo "============================================"
echo " U-Claw Installation Test"
echo "============================================"
echo ""
INSTALL_DIR="/opt/u-claw"
ERRORS=0
WARNINGS=0
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
check() {
local name="$1"
local command="$2"
local expected="$3"
echo -n "$name: "
if eval "$command" 2>/dev/null; then
echo -e "${GREEN}PASS${NC}"
return 0
else
echo -e "${RED}FAIL${NC}"
echo " Expected: $expected"
((ERRORS++))
return 1
fi
}
warn() {
local name="$1"
local message="$2"
echo -e "$name: ${YELLOW}$message${NC}"
((WARNINGS++))
}
echo "1. Folder layout"
check "install directory" "[ -d '$INSTALL_DIR' ]" "Directory $INSTALL_DIR"
check "runtime/" "[ -d '$INSTALL_DIR/runtime' ]" "Runtime directory"
check "core/" "[ -d '$INSTALL_DIR/core' ]" "Core directory"
check "data/" "[ -d '$INSTALL_DIR/data' ]" "Data directory"
echo ""
echo "2. Node.js"
NODE_BIN="$INSTALL_DIR/runtime/node-linux-x64/bin/node"
if [ -x "$NODE_BIN" ]; then
NODE_VERSION=$("$NODE_BIN" --version 2>/dev/null || echo "")
echo -e "[OK] Node.js ${GREEN}$NODE_VERSION${NC}"
if [ "$NODE_VERSION" != "v22.22.1" ]; then
warn "Node.js version" "Expected v22.22.1, found $NODE_VERSION"
fi
else
echo -e "${RED}[!!] Node.js is missing or will not run${NC}"
((ERRORS++))
fi
echo ""
echo "3. OpenClaw"
if [ -d "$INSTALL_DIR/core/node_modules/openclaw" ]; then
echo -e "[OK] OpenClaw is installed"
# 检查主要文件
OPENCLAW_ENTRY=$(find "$INSTALL_DIR/core/node_modules/openclaw" -name "openclaw.mjs" -maxdepth 2 2>/dev/null | head -1)
if [ -n "$OPENCLAW_ENTRY" ]; then
echo -e "[OK] entry point: ${GREEN}$OPENCLAW_ENTRY${NC}"
else
echo -e "${RED}[!!] openclaw.mjs not found${NC}"
((ERRORS++))
fi
else
echo -e "${RED}[!!] OpenClaw is not installed${NC}"
((ERRORS++))
fi
echo ""
echo "4. Configuration"
CONFIG_FILE="$INSTALL_DIR/data/.openclaw/openclaw.json"
if [ -f "$CONFIG_FILE" ]; then
echo -e "[OK] config file present"
# 检查配置格式
if python3 -m json.tool "$CONFIG_FILE" >/dev/null 2>&1; then
echo -e "[OK] config parses"
else
warn "config file" "may not be valid JSON"
fi
else
echo -e "${YELLOW}[ ?] no config file yet — normal before the first run${NC}"
((WARNINGS++))
fi
echo ""
echo "5. Launcher"
START_SCRIPT="$INSTALL_DIR/start-openclaw.sh"
if [ -x "$START_SCRIPT" ]; then
echo -e "[OK] start script present and executable"
else
if [ -f "$START_SCRIPT" ]; then
echo -e "${YELLOW}[ ?] start script is present but not executable${NC}"
chmod +x "$START_SCRIPT" 2>/dev/null && echo " added the executable bit"
else
echo -e "${RED}[!!] start script not found${NC}"
((ERRORS++))
fi
fi
echo ""
echo "6. Ports"
PORT_FOUND=false
for port in $(seq 18789 18799); do
if ! ss -tlnp 2>/dev/null | grep -q ":$port "; then
echo -e "[OK] port $port is free"
PORT_FOUND=true
break
fi
done
if [ "$PORT_FOUND" = false ]; then
warn "ports" "18789-18799 are all in use — U-Claw may already be running"
fi
echo ""
echo "7. Desktop shortcut"
if [ -f "$HOME/Desktop/openclaw.desktop" ] || [ -f "$HOME/.local/share/applications/openclaw.desktop" ]; then
echo -e "[OK] shortcut created"
else
warn "desktop shortcut" "not found"
fi
echo ""
echo "============================================"
echo " Results"
echo "============================================"
echo ""
if [ $ERRORS -eq 0 ]; then
echo -e "${GREEN}[OK] Everything essential checks out.${NC}"
echo " The install looks good."
echo ""
echo " Start it with:"
echo " bash /opt/u-claw/start-openclaw.sh"
echo ""
echo " Or double-click the U-Claw AI Assistant icon on the desktop."
else
echo -e "${RED}[!!] $ERRORS problem(s) found${NC}"
echo " Look at the failed checks above."
echo ""
echo " Usually one of these:"
echo " 1. Run the install script again:"
echo " sudo bash /opt/u-claw/setup-openclaw.sh"
echo " 2. Check the network"
echo " 3. Read the log"
fi
if [ $WARNINGS -gt 0 ]; then
echo -e "${YELLOW}[ ?] $WARNINGS warning(s)${NC}"
echo " These probably will not stop it working, but are worth fixing."
fi
echo ""
echo "============================================"
# 提供快速修复选项
if [ $ERRORS -gt 0 ]; then
echo ""
read -rp "Try to fix these automatically? (y/N): " FIX
if [[ "$FIX" =~ ^[Yy]$ ]]; then
echo ""
echo "Fixing…"
# 修复启动脚本权限
if [ -f "$START_SCRIPT" ] && [ ! -x "$START_SCRIPT" ]; then
echo " Restoring the start script permissions"
sudo chmod +x "$START_SCRIPT"
fi
# 重新安装OpenClaw
if [ ! -d "$INSTALL_DIR/core/node_modules/openclaw" ]; then
echo " Reinstalling OpenClaw"
cd "$INSTALL_DIR/core"
sudo npm install --registry=https://registry.npmjs.org openclaw@latest 2>/dev/null || true
fi
echo ""
echo "Done. Run this check again to confirm."
fi
fi