feat: add and align uninstall flow for newbie setup
This commit is contained in:
@@ -106,6 +106,8 @@ iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branc
|
|||||||
|
|
||||||
## 卸载
|
## 卸载
|
||||||
|
|
||||||
|
> 已对齐当前安装方式:Windows 卸载脚本会按“原生 Windows 安装”路径执行卸载。
|
||||||
|
|
||||||
### macOS
|
### macOS
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -102,6 +102,6 @@ echo -e "${GREEN}${BOLD}========================================${NC}"
|
|||||||
echo ""
|
echo ""
|
||||||
echo -e " ${BOLD}接下来:${NC}"
|
echo -e " ${BOLD}接下来:${NC}"
|
||||||
echo -e " 1. 开始使用 OpenClaw:${BLUE}openclaw${NC}"
|
echo -e " 1. 开始使用 OpenClaw:${BLUE}openclaw${NC}"
|
||||||
echo -e " 2. 添加技能(可选):${BLUE}openclaw configure --section skills${NC}"
|
echo -e " 2. 查看网关状态:${BLUE}openclaw gateway status${NC}"
|
||||||
echo -e " 3. 浏览可用技能:${BLUE}openclaw skills${NC}"
|
echo -e " 3. 如需卸载:${BLUE}curl -fsSL https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-macos.sh | bash${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -186,10 +186,9 @@ Write-Host " Setup complete!" -ForegroundColor Green
|
|||||||
Write-Host "========================================" -ForegroundColor Green
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Next steps:" -ForegroundColor White
|
Write-Host " Next steps:" -ForegroundColor White
|
||||||
Write-Host " 1. Navigate to your project: cd your-project-path" -ForegroundColor Gray
|
Write-Host " 1. Start OpenClaw: openclaw" -ForegroundColor Gray
|
||||||
Write-Host " 2. Start OpenClaw: openclaw" -ForegroundColor Gray
|
Write-Host " 2. Check gateway status: openclaw gateway status" -ForegroundColor Gray
|
||||||
Write-Host " 3. Add skills (optional): openclaw configure --section skills" -ForegroundColor Gray
|
Write-Host " 3. Uninstall (if needed): iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-windows.ps1 | iex" -ForegroundColor Gray
|
||||||
Write-Host " 4. Browse available skills: openclaw skills" -ForegroundColor Gray
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -187,10 +187,9 @@ Write-Host " 配置完成!" -ForegroundColor Green
|
|||||||
Write-Host "========================================" -ForegroundColor Green
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " 接下来:" -ForegroundColor White
|
Write-Host " 接下来:" -ForegroundColor White
|
||||||
Write-Host " 1. 进入项目目录:cd 你的项目路径" -ForegroundColor Gray
|
Write-Host " 1. 开始使用 OpenClaw:openclaw" -ForegroundColor Gray
|
||||||
Write-Host " 2. 开始使用 OpenClaw:openclaw" -ForegroundColor Gray
|
Write-Host " 2. 查看网关状态:openclaw gateway status" -ForegroundColor Gray
|
||||||
Write-Host " 3. 添加技能(可选):openclaw configure --section skills" -ForegroundColor Gray
|
Write-Host " 3. 如需卸载:iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-windows.ps1 | iex" -ForegroundColor Gray
|
||||||
Write-Host " 4. 浏览可用技能:openclaw skills" -ForegroundColor Gray
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# OpenClaw 卸载脚本 (Windows / WSL)
|
# OpenClaw 卸载脚本 (Windows)
|
||||||
|
# 与当前“原生 Windows 安装”流程对齐
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
@@ -7,6 +8,7 @@ $ErrorActionPreference = "Stop"
|
|||||||
function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan }
|
function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan }
|
||||||
function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green }
|
function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green }
|
||||||
function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow }
|
function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow }
|
||||||
|
function Write-Err($msg) { Write-Host "[错误] $msg" -ForegroundColor Red; throw $msg }
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "========================================" -ForegroundColor White
|
Write-Host "========================================" -ForegroundColor White
|
||||||
@@ -14,20 +16,51 @@ Write-Host " OpenClaw 卸载器 (Windows)" -ForegroundColor White
|
|||||||
Write-Host "========================================" -ForegroundColor White
|
Write-Host "========================================" -ForegroundColor White
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
$uninstallScript = @'
|
$uninstalled = $false
|
||||||
set -e
|
|
||||||
export PATH="$HOME/.openclaw/bin:$PATH"
|
|
||||||
if command -v openclaw &>/dev/null; then
|
|
||||||
echo "[信息] 已找到 openclaw,正在运行卸载..."
|
|
||||||
openclaw uninstall --all --yes --non-interactive
|
|
||||||
else
|
|
||||||
echo "[警告] 在 PATH 中未找到 openclaw,使用 npx..."
|
|
||||||
npx -y openclaw uninstall --all --yes --non-interactive
|
|
||||||
fi
|
|
||||||
'@
|
|
||||||
|
|
||||||
Write-Info "正在卸载 WSL 中的 OpenClaw..."
|
# 1) 优先使用已安装的 openclaw 命令
|
||||||
wsl -d Ubuntu-24.04 -- bash -c $uninstallScript
|
if (Get-Command openclaw -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
Write-Info "已找到 openclaw,正在卸载(--all)..."
|
||||||
|
openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
Write-Ok "OpenClaw 卸载命令执行完成。"
|
||||||
|
} catch {
|
||||||
|
Write-Warn "openclaw 卸载失败,尝试 npx 方式..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2) 回退:npx 直接调用
|
||||||
|
if (-not $uninstalled) {
|
||||||
|
if (Get-Command npx -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
Write-Info "使用 npx 执行卸载..."
|
||||||
|
npx -y openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
Write-Ok "OpenClaw 卸载命令执行完成(npx)。"
|
||||||
|
} catch {
|
||||||
|
Write-Warn "npx 卸载失败。"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Warn "未找到 npx,跳过 npx 卸载。"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 3) 清理全局 npm 包(幂等,失败不终止)
|
||||||
|
if (Get-Command npm -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
Write-Info "尝试移除全局 npm 包 openclaw(如存在)..."
|
||||||
|
npm uninstall -g openclaw 2>$null | Out-Null
|
||||||
|
Write-Ok "全局 npm 包清理完成。"
|
||||||
|
} catch {
|
||||||
|
Write-Warn "全局 npm 包清理跳过:$_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $uninstalled) {
|
||||||
|
Write-Err "未能完成 OpenClaw 卸载。请确认 Node.js/npm 可用后重试。"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
Write-Ok "OpenClaw 已卸载。"
|
Write-Ok "OpenClaw 已卸载。"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|||||||
Reference in New Issue
Block a user