forked from janhq/cortex.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.bat
65 lines (54 loc) · 1.71 KB
/
install.bat
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
@echo off
setlocal
:: Remove existing nitro directory if it exists
if exist "%APPDATA%\nitro" (
echo Removing existing Nitro installation...
rmdir /S /Q "%APPDATA%\nitro"
)
:: Parse arguments
set "VERSION=latest"
set "GPU=false"
:arg_loop
if "%~1"=="" goto arg_loop_end
if "%~1"=="--gpu" (
set "GPU=true"
shift
goto arg_loop
)
if "%~1"=="--version" (
set "VERSION=%~2"
shift
shift
goto arg_loop
)
shift
goto arg_loop
:arg_loop_end
echo %VERSION%
:: Get the release
if "%VERSION%"=="latest" (
:: If the version is set to "latest", get the latest version number from the Nitro GitHub repository
for /f "delims=" %%i in ('powershell -Command "& {$version = Invoke-RestMethod -Uri 'https://api.github.com/repos/janhq/nitro/releases/latest'; return $version.tag_name.TrimStart('v')}"') do set "VERSION=%%i"
)
:: Construct the download URL
set "URL=https://github.com/janhq/nitro/releases/download/v%VERSION%/nitro-%VERSION%-win-amd64"
if "%GPU%"=="true" (
:: If --gpu option is provided, append -cuda to the URL
set "URL=%URL%-cuda"
)
set "URL=%URL%.tar.gz"
:: Download and extract nitro
echo Downloading Nitro from: %URL%
powershell -Command "Invoke-WebRequest -OutFile '%TEMP%\nitro.tar.gz' '%URL%'"
echo Extracting Nitro...
powershell -Command "mkdir '%APPDATA%\nitro'"
powershell -Command "tar -zxvf '%TEMP%\nitro.tar.gz' -C '%APPDATA%\nitro'"
:: Add nitro to the PATH
setx PATH "%APPDATA%\nitro;%PATH%"
:: Create uninstallnitro.bat
echo @echo off > "%APPDATA%\nitro\uninstallnitro.bat"
echo setx PATH "%PATH:;%APPDATA%\nitro=;%"" >> "%APPDATA%\nitro\uninstallnitro.bat"
echo rmdir /S /Q "%APPDATA%\nitro" >> "%APPDATA%\nitro\uninstallnitro.bat"
:: Clean up
del %TEMP%\nitro.tar.gz
endlocal