feat: improve Linux bootable USB stability and user experience

- Enhanced Live USB environment detection and support
- Added troubleshooting guide (TROUBLESHOOTING.md)
- Added installation test script (test-installation.sh)
- Improved error handling in PowerShell scripts
- Better network retry logic for downloads
- Enhanced desktop integration for Live environments
- Added detailed improvements summary (IMPROVEMENTS_SUMMARY.md)
- Updated README with troubleshooting links

Key improvements:
1. Auto-detection of Live USB environment (boot=casper)
2. Additional dependency installation for Live environments
3. Network download retry mechanism (3 attempts)
4. Smart browser opening with fallback instructions
5. Comprehensive installation validation script
6. Detailed fault diagnosis and recovery guide
This commit is contained in:
dongsheng123132
2026-03-16 19:59:58 +08:00
parent a93e9161dd
commit 5813e384af
7 changed files with 736 additions and 8 deletions

View File

@@ -33,7 +33,14 @@ REAL_HOME=$(eval echo "~$REAL_USER")
# ── 2. Install system dependencies ──
echo "[1/9] Installing system dependencies..."
apt-get update -qq
apt-get install -y -qq curl xdg-utils > /dev/null 2>&1
# Live USB环境需要额外的包
if grep -q "boot=casper" /proc/cmdline 2>/dev/null; then
echo " Detected Live USB environment, installing additional packages..."
apt-get install -y -qq curl xdg-utils gvfs-bin libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 xdg-utils libatspi2.0-0 libuuid1 libgbm1 libasound2 > /dev/null 2>&1
else
apt-get install -y -qq curl xdg-utils > /dev/null 2>&1
fi
echo " Done."
# ── 3. Create install directory ──
@@ -132,6 +139,21 @@ DESKTOP_FILE="$REAL_HOME/Desktop/openclaw.desktop"
APPS_DIR="$REAL_HOME/.local/share/applications"
mkdir -p "$APPS_DIR"
# 检查是否是Live环境如果是则创建更简单的启动脚本
if grep -q "boot=casper" /proc/cmdline 2>/dev/null; then
echo " Live USB detected, creating simplified launcher..."
# 创建直接启动脚本
cat > "$REAL_HOME/Desktop/Start-U-Claw.sh" << 'LAUNCHEREOF'
#!/bin/bash
echo "Starting U-Claw AI Assistant..."
cd /opt/u-claw
bash start-openclaw.sh
LAUNCHEREOF
chmod +x "$REAL_HOME/Desktop/Start-U-Claw.sh"
chown "$REAL_USER:$REAL_USER" "$REAL_HOME/Desktop/Start-U-Claw.sh"
fi
# 仍然创建标准的.desktop文件
cat > "$DESKTOP_FILE" << 'DESKTOPEOF'
[Desktop Entry]
Name=U-Claw AI Assistant
@@ -140,6 +162,7 @@ Exec=/opt/u-claw/start-openclaw.sh
Terminal=true
Type=Application
Categories=Utility;
Icon=utilities-terminal
DESKTOPEOF
cp "$DESKTOP_FILE" "$APPS_DIR/openclaw.desktop"
@@ -177,5 +200,19 @@ echo ""
echo " To start: Double-click 'U-Claw AI Assistant' on desktop"
echo " or: bash $INSTALL_DIR/start-openclaw.sh"
echo ""
# 复制测试脚本
if [[ -f "$SCRIPT_DIR/test-installation.sh" ]]; then
cp "$SCRIPT_DIR/test-installation.sh" "$INSTALL_DIR/test-installation.sh"
chmod +x "$INSTALL_DIR/test-installation.sh"
echo " Test script: bash $INSTALL_DIR/test-installation.sh"
echo ""
fi
# 运行快速测试
echo "Running quick installation test..."
if [[ -f "$SCRIPT_DIR/test-installation.sh" ]]; then
bash "$SCRIPT_DIR/test-installation.sh" | tail -20
fi
echo " First time? Configure your AI model in the browser after startup."
echo "============================================"

View File

@@ -18,14 +18,22 @@ export OPENCLAW_CONFIG_PATH="$DATA_DIR/.openclaw/openclaw.json"
# --- Sanity checks ---
if [[ ! -x "$NODE_BIN" ]]; then
echo "[ERROR] Node.js not found at $NODE_BIN"
echo "Please run setup-openclaw.sh first."
echo ""
echo "Possible solutions:"
echo "1. Run setup script: sudo bash /opt/u-claw/setup-openclaw.sh"
echo "2. If on Live USB, the script might be at:"
echo " /media/ubuntu/u-claw-linux/setup-openclaw.sh"
echo ""
read -rp "Press Enter to exit..."
exit 1
fi
if [[ ! -d "$CORE_DIR/node_modules/openclaw" ]]; then
echo "[ERROR] OpenClaw not installed in $CORE_DIR"
echo "Please run setup-openclaw.sh first."
echo ""
echo "Please run the setup script first:"
echo "sudo bash /opt/u-claw/setup-openclaw.sh"
echo ""
read -rp "Press Enter to exit..."
exit 1
fi
@@ -73,8 +81,16 @@ fi
echo "Opening browser at http://localhost:$PORT ..."
# Open browser after a short delay
(sleep 3 && xdg-open "http://localhost:$PORT" 2>/dev/null) &
# Open browser after a short delay - 检查是否在图形环境中
if [[ -n "$DISPLAY" ]] && command -v xdg-open >/dev/null 2>&1; then
(sleep 3 && xdg-open "http://localhost:$PORT" 2>/dev/null) &
echo " Browser will open automatically."
else
echo ""
echo "[INFO] No graphical environment detected or xdg-open not available."
echo " Please open http://localhost:$PORT in your browser manually."
echo ""
fi
"$NODE_BIN" "$OPENCLAW_ENTRY" gateway run \
--allow-unconfigured \

View File

@@ -0,0 +1,200 @@
#!/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. 检查基本目录结构..."
check "安装目录存在" "[ -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 "✓ Node.js版本: ${GREEN}$NODE_VERSION${NC}"
if [ "$NODE_VERSION" != "v22.14.0" ]; then
warn "Node.js版本" "Expected v22.14.0, found $NODE_VERSION"
fi
else
echo -e "${RED}✗ Node.js未找到或不可执行${NC}"
((ERRORS++))
fi
echo ""
echo "3. 检查OpenClaw安装..."
if [ -d "$INSTALL_DIR/core/node_modules/openclaw" ]; then
echo -e "✓ OpenClaw已安装"
# 检查主要文件
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 "✓ OpenClaw入口文件: ${GREEN}$OPENCLAW_ENTRY${NC}"
else
echo -e "${RED}✗ 未找到openclaw.mjs${NC}"
((ERRORS++))
fi
else
echo -e "${RED}✗ OpenClaw未安装${NC}"
((ERRORS++))
fi
echo ""
echo "4. 检查配置文件..."
CONFIG_FILE="$INSTALL_DIR/data/.openclaw/openclaw.json"
if [ -f "$CONFIG_FILE" ]; then
echo -e "✓ 配置文件存在"
# 检查配置格式
if python3 -m json.tool "$CONFIG_FILE" >/dev/null 2>&1; then
echo -e "✓ 配置文件格式正确"
else
warn "配置文件" "JSON格式可能有问题"
fi
else
echo -e "${YELLOW}⚠ 配置文件不存在(首次运行正常)${NC}"
((WARNINGS++))
fi
echo ""
echo "5. 检查启动脚本..."
START_SCRIPT="$INSTALL_DIR/start-openclaw.sh"
if [ -x "$START_SCRIPT" ]; then
echo -e "✓ 启动脚本存在且可执行"
else
if [ -f "$START_SCRIPT" ]; then
echo -e "${YELLOW}⚠ 启动脚本存在但不可执行${NC}"
chmod +x "$START_SCRIPT" 2>/dev/null && echo " 已添加执行权限"
else
echo -e "${RED}✗ 启动脚本未找到${NC}"
((ERRORS++))
fi
fi
echo ""
echo "6. 检查端口可用性..."
PORT_FOUND=false
for port in $(seq 18789 18799); do
if ! ss -tlnp 2>/dev/null | grep -q ":$port "; then
echo -e "✓ 端口 $port 可用"
PORT_FOUND=true
break
fi
done
if [ "$PORT_FOUND" = false ]; then
warn "端口" "所有端口18789-18799都被占用"
fi
echo ""
echo "7. 检查桌面快捷方式..."
if [ -f "$HOME/Desktop/openclaw.desktop" ] || [ -f "$HOME/.local/share/applications/openclaw.desktop" ]; then
echo -e "✓ 桌面快捷方式已创建"
else
warn "桌面快捷方式" "未找到桌面快捷方式"
fi
echo ""
echo "============================================"
echo " 测试结果汇总"
echo "============================================"
echo ""
if [ $ERRORS -eq 0 ]; then
echo -e "${GREEN}✅ 所有关键检查通过!${NC}"
echo " 安装看起来是成功的。"
echo ""
echo " 启动命令:"
echo " bash /opt/u-claw/start-openclaw.sh"
echo ""
echo " 或双击桌面上的 'U-Claw AI Assistant' 图标"
else
echo -e "${RED}❌ 发现 $ERRORS 个错误${NC}"
echo " 请检查上述失败的项目。"
echo ""
echo " 常见解决方案:"
echo " 1. 重新运行安装脚本:"
echo " sudo bash /opt/u-claw/setup-openclaw.sh"
echo " 2. 检查网络连接"
echo " 3. 查看详细日志"
fi
if [ $WARNINGS -gt 0 ]; then
echo -e "${YELLOW}⚠ 有 $WARNINGS 个警告${NC}"
echo " 这些可能不会影响基本功能,但建议修复。"
fi
echo ""
echo "============================================"
# 提供快速修复选项
if [ $ERRORS -gt 0 ]; then
echo ""
read -rp "是否尝试自动修复问题? (y/N): " FIX
if [[ "$FIX" =~ ^[Yy]$ ]]; then
echo ""
echo "尝试修复..."
# 修复启动脚本权限
if [ -f "$START_SCRIPT" ] && [ ! -x "$START_SCRIPT" ]; then
echo " 修复启动脚本权限..."
sudo chmod +x "$START_SCRIPT"
fi
# 重新安装OpenClaw
if [ ! -d "$INSTALL_DIR/core/node_modules/openclaw" ]; then
echo " 重新安装OpenClaw..."
cd "$INSTALL_DIR/core"
sudo npm install --registry=https://registry.npmmirror.com openclaw@latest 2>/dev/null || true
fi
echo ""
echo "修复完成。请重新运行此测试脚本。"
fi
fi