13 小时以前 4ba8f509c44a58d1ea1324b817518fe90ae2c1b4
更新部署脚本
已修改1个文件
86 ■■■■■ 文件已修改
deploy.bat 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
deploy.bat
@@ -17,43 +17,57 @@
echo ==========================================
echo.
:: Check if sshpass is available, download if not
where sshpass >nul 2>&1
if %errorlevel% neq 0 (
    echo [WARN] sshpass not found, trying to install...
    echo.
:: Get script directory
set "SSHPASS_DIR=%~dp0bin"
set "SSHPASS_EXE=%SSHPASS_DIR%\sshpass.exe"
    :: Check if running in Git Bash environment
    where bash >nul 2>&1
    if %errorlevel% equ 0 (
        echo [INFO] Git Bash detected, trying pacman install...
        bash -c "pacman -S --noconfirm sshpass" 2>nul
        if !errorlevel! equ 0 (
            echo [OK] sshpass installed via pacman!
            goto :check_jar
        )
    )
    :: Download standalone sshpass
    echo [INFO] Downloading sshpass...
    :: Get script directory
    set "SSHPASS_DIR=%~dp0bin"
    if not exist "!SSHPASS_DIR!" mkdir "!SSHPASS_DIR!"
    :: Download using PowerShell with escaped variables
    powershell -NoProfile -Command "$url='https://github.com/xhcoding/sshpass-win32/releases/download/v1.0.3/sshpass.exe'; $out='!SSHPASS_DIR!\sshpass.exe'; Write-Host \"Downloading to: $out\"; try { Invoke-WebRequest -Uri $url -OutFile $out -UseBasicParsing; exit 0 } catch { Write-Host $_.Exception.Message; exit 1 }"
    if !errorlevel! neq 0 (
        echo [ERROR] Failed to download sshpass!
        echo [HINT] Please install sshpass manually or use Git Bash: pacman -S sshpass
        goto :error_exit
    )
    :: Add bin dir to PATH temporarily
    set "PATH=!SSHPASS_DIR!;%PATH%"
    echo [OK] sshpass downloaded to: !SSHPASS_DIR!
    echo.
:: Check if local sshpass.exe already exists
if exist "%SSHPASS_EXE%" (
    set "PATH=%SSHPASS_DIR%;%PATH%"
    echo [OK] Found local sshpass: %SSHPASS_EXE%
    goto :check_jar
)
:: Check if sshpass is available in system PATH
where sshpass >nul 2>&1
if %errorlevel% equ 0 (
    echo [OK] Found sshpass in system PATH
    goto :check_jar
)
:: sshpass not found, try to install
echo [WARN] sshpass not found, trying to install...
echo.
:: Check if running in Git Bash environment
where bash >nul 2>&1
if %errorlevel% equ 0 (
    echo [INFO] Git Bash detected, trying pacman install...
    bash -c "pacman -S --noconfirm sshpass" 2>nul
    if !errorlevel! equ 0 (
        echo [OK] sshpass installed via pacman!
        goto :check_jar
    )
)
:: Download standalone sshpass
echo [INFO] Downloading sshpass...
if not exist "%SSHPASS_DIR%" mkdir "%SSHPASS_DIR%"
:: Download using PowerShell
powershell -NoProfile -Command "$url='https://github.com/xhcoding/sshpass-win32/releases/download/v1.0.3/sshpass.exe'; $out='%SSHPASS_EXE%'; Write-Host \"Downloading to: $out\"; try { Invoke-WebRequest -Uri $url -OutFile $out -UseBasicParsing; exit 0 } catch { Write-Host $_.Exception.Message; exit 1 }"
if !errorlevel! neq 0 (
    echo [ERROR] Failed to download sshpass!
    echo [HINT] Please install sshpass manually or use Git Bash: pacman -S sshpass
    goto :error_exit
)
:: Add bin dir to PATH temporarily
set "PATH=%SSHPASS_DIR%;%PATH%"
echo [OK] sshpass downloaded to: %SSHPASS_DIR%
echo [HINT] Consider adding %SSHPASS_DIR% to system PATH for permanent use
echo.
:check_jar
:: Check if JAR file exists
@@ -101,4 +115,4 @@
echo ==========================================
:end
pause
pause