-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.cmd
More file actions
97 lines (77 loc) · 2.29 KB
/
install.cmd
File metadata and controls
97 lines (77 loc) · 2.29 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
91
92
93
94
95
96
97
@echo off
setlocal enabledelayedexpansion
REM Install evershell-agent from GitHub Releases.
REM
REM Usage:
REM curl -fsSL https://raw.githubusercontent.com/oviano/evershell/main/install.cmd -o install.cmd && install.cmd && del install.cmd
REM install.cmd --version 0.9.0
REM --- Parse arguments ---
set "VERSION="
:parse_args
if "%~1"=="" goto :args_done
if /i "%~1"=="--version" (
set "VERSION=%~2"
shift
shift
goto :parse_args
)
echo Unknown option: %~1
exit /b 1
:args_done
REM --- Detect architecture ---
set "ARCH=x86_64"
if /i "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "ARCH=arm_64"
REM --- Get latest version if not specified ---
set "REPO=oviano/evershell"
set "TMPDIR=%TEMP%\evershell-install"
if exist "!TMPDIR!" rmdir /s /q "!TMPDIR!"
mkdir "!TMPDIR!"
if "!VERSION!"=="" (
echo Fetching latest release...
curl -fsSL "https://api.github.com/repos/%REPO%/releases/latest" -o "!TMPDIR!\release.json"
if !ERRORLEVEL! neq 0 (
echo ERROR: Could not fetch latest release
exit /b 1
)
for /f "tokens=2 delims=:," %%a in ('findstr /c:"\"tag_name\"" "!TMPDIR!\release.json"') do (
set "TAG=%%~a"
set "TAG=!TAG: =!"
set "TAG=!TAG:"=!"
set "VERSION=!TAG:v=!"
)
del "!TMPDIR!\release.json"
)
if "!VERSION!"=="" (
echo ERROR: Could not determine latest version
exit /b 1
)
echo Installing evershell-agent v!VERSION!...
REM --- Download tarball ---
set "ARCHIVE=evershell-agent-!VERSION!-windows-!ARCH!.tar.gz"
set "URL=https://github.com/%REPO%/releases/download/v!VERSION!/!ARCHIVE!"
echo Downloading !URL!...
curl -fsSL "!URL!" -o "!TMPDIR!\!ARCHIVE!"
if !ERRORLEVEL! neq 0 (
echo ERROR: Download failed. Check the version and platform.
echo Available releases: https://github.com/%REPO%/releases
rmdir /s /q "!TMPDIR!"
exit /b 1
)
REM --- Extract ---
tar xzf "!TMPDIR!\!ARCHIVE!" -C "!TMPDIR!"
if !ERRORLEVEL! neq 0 (
echo ERROR: Extraction failed
rmdir /s /q "!TMPDIR!"
exit /b 1
)
REM --- Run local installer ---
if not exist "!TMPDIR!\install-windows.cmd" (
echo ERROR: install-windows.cmd not found in tarball
rmdir /s /q "!TMPDIR!"
exit /b 1
)
call "!TMPDIR!\install-windows.cmd"
set "INSTALL_RESULT=!ERRORLEVEL!"
REM --- Clean up ---
rmdir /s /q "!TMPDIR!"
exit /b !INSTALL_RESULT!