From 4ba8f509c44a58d1ea1324b817518fe90ae2c1b4 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 23 六月 2026 14:49:15 +0800
Subject: [PATCH] 更新部署脚本
---
deploy.bat | 86 +++++++++++++++++++++++++------------------
1 files changed, 50 insertions(+), 36 deletions(-)
diff --git a/deploy.bat b/deploy.bat
index a6b2f8f..d40bf33 100644
--- a/deploy.bat
+++ b/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
\ No newline at end of file
--
Gitblit v1.9.3