All checks were successful
Tests / test (push) Successful in 1m8s
Sync install scripts and CI container image with NODE_VERSION, regenerate Electron Config.html, and skip gitignored portable/app in origin scan. Co-authored-by: Cursor <cursoragent@cursor.com>
200 lines
5.4 KiB
Bash
Executable File
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.3" ]; then
|
|
warn "Node.js version" "Expected v22.22.3, 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 |