53 lines
2.1 KiB
Batchfile
53 lines
2.1 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
:: ============================================================================
|
|
:: CONFIGURATION
|
|
:: ============================================================================
|
|
set "GITEA_URL=https://gitea.digitoolsolutions.synology.me"
|
|
set "REPO_OWNER=lamtruong28"
|
|
set "REPO_NAME=mini-pc-setup"
|
|
|
|
:: ============================================================================
|
|
:: AUTO-ELEVATE TO ADMINISTRATOR
|
|
:: ============================================================================
|
|
net session >nul 2>&1
|
|
if %errorLevel% neq 0 (
|
|
echo Requesting Administrator privileges...
|
|
powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
|
|
exit /b
|
|
)
|
|
|
|
echo ============================================================================
|
|
echo DTS TORQUE VAULT - ONE-CLICK LATEST RELEASE BOOTSTRAPPER
|
|
echo ============================================================================
|
|
echo Repository : %GITEA_URL%/%REPO_OWNER%/%REPO_NAME%
|
|
echo.
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
|
"$ErrorActionPreference = 'Stop';" ^
|
|
"$base = '%GITEA_URL%'.TrimEnd('/'); $owner = '\%REPO_OWNER\%';$repo = '%REPO_NAME%';" ^
|
|
"$apiUrl = \"$base/api/v1/repos/$owner/$repo/releases/latest\";" ^
|
|
"$cred =$null;" ^
|
|
"try {" ^
|
|
" $rel = Invoke-RestMethod -Uri$apiUrl -UseBasicParsing;" ^
|
|
"} catch {" ^
|
|
" Write-Host '[AUTH] Private repository detected. Please sign in to Gitea:' -ForegroundColor Yellow;" ^
|
|
" $cred = Get-Credential -Message 'Enter Gitea Credentials';" ^
|
|
" $rel = Invoke-RestMethod -Uri $apiUrl -Credential$cred -UseBasicParsing;" ^
|
|
"}" ^
|
|
"$tag =$rel.tag_name;" ^
|
|
"$rawUrl = \"$base/$owner/$repo/raw/tag/$tag/scripts/bootstrap.ps1\";" ^
|
|
"if ($null -ne$cred) {" ^
|
|
" $script = Invoke-RestMethod -Uri $rawUrl -Credential$cred -UseBasicParsing;" ^
|
|
"} else {" ^
|
|
" $script = Invoke-RestMethod -Uri$rawUrl -UseBasicParsing;" ^
|
|
"}" ^
|
|
"& ([scriptblock]::Create($script)) -GiteaUrl$base -Owner $owner -Repo$repo -ReleaseJson $rel -Credential$cred"
|
|
|
|
if %errorLevel% neq 0 (
|
|
echo.
|
|
echo [ERROR] Bootstrap failed. Verify that at least one Release exists on Gitea.
|
|
pause
|
|
exit /b 1
|
|
) |