bookworm-boot/Bookworm-AutoSetup.bat

79 lines
2.1 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
chcp 65001 > nul
title Bookworm Portable - 全自动安装
echo.
echo ====================================================
echo Bookworm Portable - 全自动安装器
echo 双击即可完成全部配置,无需手动操作
echo ====================================================
echo.
:: 检查 auto-setup.ps1 是否在当前目录
if exist "%~dp0auto-setup.ps1" (
cd /d "%~dp0"
goto :RUN_SETUP
)
:: 检查 bookworm-boot 是否已克隆
if exist "%USERPROFILE%\bookworm-boot\auto-setup.ps1" (
echo [OK] 检测到 bookworm-boot 仓库
cd /d "%USERPROFILE%\bookworm-boot"
goto :RUN_SETUP
)
:: 检查 git
where git >nul 2>nul
if %errorlevel% neq 0 (
echo [!!] Git 未安装,请先安装 Git:
echo https://git-scm.com/download/win
echo.
echo 安装 Git 后重新双击本文件即可。
pause
exit /b 1
)
:: bookworm-boot 目录已存在但不完整 — 先删除再克隆
if exist "%USERPROFILE%\bookworm-boot" (
echo [..] 检测到不完整的 bookworm-boot重新下载...
rmdir /s /q "%USERPROFILE%\bookworm-boot" 2>nul
)
echo [..] 首次运行,下载配置文件 (需输入 Gitea 账号密码)...
echo.
git clone https://code.letcareme.com/bookworm/bookworm-boot.git "%USERPROFILE%\bookworm-boot"
if %errorlevel% neq 0 (
echo.
echo [!!] 克隆失败,请检查:
echo 1. 网络是否正常
echo 2. Gitea 账号密码是否正确
echo 3. 能否访问 https://code.letcareme.com
pause
exit /b 1
)
cd /d "%USERPROFILE%\bookworm-boot"
echo [OK] 引导仓库下载完成
echo.
:RUN_SETUP
:: 更新到最新版本
git pull >nul 2>nul
:: 检测 PowerShell 7 (pwsh) 或退回 5.1 (powershell)
where pwsh >nul 2>nul
if %errorlevel% equ 0 (
echo [OK] 使用 PowerShell 7
pwsh -ExecutionPolicy Bypass -File auto-setup.ps1
) else (
echo [..] 使用 PowerShell 5.1
powershell -ExecutionPolicy Bypass -File auto-setup.ps1
)
if %errorlevel% neq 0 (
echo.
echo [!!] 安装过程中出现错误
echo 请截图上方信息联系管理员
echo.
)
pause