-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.bat
More file actions
90 lines (76 loc) · 2.3 KB
/
install.bat
File metadata and controls
90 lines (76 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@echo off
setlocal enabledelayedexpansion
:: Check for Administrator privileges
:: This will fail if the user is not running as Administrator
whoami /groups | find "S-1-5-32-544" >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] This script must be run as Administrator.
echo Please right-click this file and select "Run as Administrator."
pause
exit /b 1
)
:: Configuration
set REPO=DigitalTolk/exec-ecs
:: Check if curl exists
where curl >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] curl is not installed. Please install curl first.
pause
exit /b 1
)
:: Get the latest or specified version
set "VERSION="
if "%~1"=="" (
echo Fetching latest release version...
for /f "tokens=2 delims=:, " %%A in ('curl -s https://api.github.com/repos/%REPO%/releases/latest ^| findstr /i "tag_name"') do set "VERSION=%%A"
set "VERSION=!VERSION:~1,-1!"
) else (
set "VERSION=v%~1"
)
if not defined VERSION (
echo [ERROR] Failed to fetch the latest version.
pause
exit /b 1
)
echo Version: %VERSION%
:: Construct the filename and download URL
set "FILENAME=exec-ecs_Windows_x86_64.zip"
set "URL=https://github.com/%REPO%/releases/download/%VERSION%/%FILENAME%"
:: Create a temporary directory
set "TEMP_DIR=%TEMP%\exec-ecs"
if exist "%TEMP_DIR%" rd /s /q "%TEMP_DIR%"
mkdir "%TEMP_DIR%"
:: Download the file
echo Downloading %FILENAME% from %URL%...
curl -Lo "%TEMP_DIR%\%FILENAME%" %URL%
if not exist "%TEMP_DIR%\%FILENAME%" (
echo [ERROR] Download failed.
pause
exit /b 1
)
:: Extract the archive
echo Extracting %FILENAME%...
powershell -command "Expand-Archive -Path '%TEMP_DIR%\%FILENAME%' -DestinationPath '%TEMP_DIR%'"
if not exist "%TEMP_DIR%\exec-ecs.exe" (
echo [ERROR] Extraction failed.
pause
exit /b 1
)
:: Move the binary to a directory in PATH
echo Moving exec-ecs.exe to %ProgramFiles%\exec-ecs...
if not exist "%ProgramFiles%\exec-ecs" mkdir "%ProgramFiles%\exec-ecs"
move /y "%TEMP_DIR%\exec-ecs.exe" "%ProgramFiles%\exec-ecs\"
:: Add to PATH
echo Adding exec-ecs to PATH...
setx PATH "%PATH%;%ProgramFiles%\exec-ecs"
:: Verify installation
"%ProgramFiles%\exec-ecs\exec-ecs.exe" --version
if %errorlevel% equ 0 (
echo Installation completed successfully!
) else (
echo [ERROR] Installation verification failed.
pause
exit /b 1
)
pause
exit /b 0