diff --git a/Install_act_runnerx64.ps1 b/Install_act_runnerx64.ps1 new file mode 100644 index 0000000..b096767 --- /dev/null +++ b/Install_act_runnerx64.ps1 @@ -0,0 +1,91 @@ +# ================================================================= # +# SMART INSTALLER: ACT_RUNNER + NSSM + SYSTEM LABELS (STRICT MODE) +# ================================================================= # +$workDir = "C:\act_runner" +$exeUrl = "https://git.dadehard.ru/kalugin66/act_runner/raw/branch/main/act_runner-0.4.0-windows-amd64.exe" +$nssmUrl = "https://git.dadehard.ru/kalugin66/act_runner/raw/branch/main/nssm.exe" +$instanceUrl = "https://git.dadehard.ru/" +$token = "UzVNobPFBJe8ZoQXwu5ZamfgqCpTJZGR3LDVnX7N" +$serviceName = "act_runner" + +# 1. Сбор системной информации (Строгая инициализация) +$pcName = [System.Net.Dns]::GetHostName() +$arch = if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" } +$memRaw = (Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory +$memGB = [math]::Round($memRaw / 1GB) +$memLabel = "$($memGB)GB_RAM" +$fullLabels = "windows-latest:host,windows-amd64:host,self-hosted:host,$pcName:host,$arch:host,$memLabel:host" + +Write-Host "--- Данные системы: ПК=$pcName, Архитектура=$arch, ОЗУ=$memLabel ---" -ForegroundColor Magenta + +# 2. Подготовка окружения +if (-not (Test-Path $workDir)) { New-Item -ItemType Directory -Path $workDir | Out-Null } +Set-Location $workDir + +# 3. Очистка старых процессов +Write-Host "--- Шаг 1: Очистка ---" -ForegroundColor Cyan +Stop-Service $serviceName -Force -ErrorAction SilentlyContinue +Stop-Process -Name "act_runner" -Force -ErrorAction SilentlyContinue +sc.exe delete $serviceName | Out-Null +Start-Sleep -Seconds 2 + +# 4. Загрузка компонентов +Write-Host "--- Шаг 2: Загрузка EXE ---" -ForegroundColor Cyan +if (-not (Test-Path "act_runner.exe")) { Invoke-WebRequest -Uri $exeUrl -OutFile "act_runner.exe" } +if (-not (Test-Path "nssm.exe")) { Invoke-WebRequest -Uri $nssmUrl -OutFile "nssm.exe" } +Unblock-File -Path "$workDir\act_runner.exe" +Unblock-File -Path "$workDir\nssm.exe" + +# 5. Генерация config.yaml (Метод строгого форматирования) +Write-Host "--- Шаг 3: Формирование конфига ---" -ForegroundColor Cyan +$template = @" +log: + level: info +runner: + file: .runner + capacity: 1 + labels: + - "windows-latest:host" + - "windows-amd64:host" + - "self-hosted:host" + - "{0}:host" + - "{1}:host" + - "{2}:host" +container: + force_pull: false +host: + workdir: "" +"@ + +# Принудительная подстановка переменных в шаблон +$configText = $template -f $pcName, $arch, $memLabel + +# Запись в файл (UTF8 без BOM) +[System.IO.File]::WriteAllText("$workDir\config.yaml", $configText) + +# 6. Проверка и регистрация +Write-Host "--- Шаг 4: Авторизация ---" -ForegroundColor Cyan +if (-not (Test-Path ".runner")) { + Write-Host "Регистрация нового раннера..." -ForegroundColor Yellow + .\act_runner.exe register --instance $instanceUrl --token $token --no-interactive --name "$pcName" --labels "$fullLabels" +} + +# 7. Установка службы через NSSM +Write-Host "--- Шаг 5: Установка службы ---" -ForegroundColor Cyan +$exePath = "$workDir\act_runner.exe" +$args = "daemon --config `"$workDir\config.yaml`"" + +& ".\nssm.exe" install $serviceName $exePath $args +& ".\nssm.exe" set $serviceName AppDirectory $workDir +& ".\nssm.exe" set $serviceName Start SERVICE_AUTO_START +& ".\nssm.exe" set $serviceName ObjectName LocalSystem + +# 8. Запуск +Write-Host "--- Шаг 6: Запуск ---" -ForegroundColor Cyan +Start-Service $serviceName + +if ((Get-Service $serviceName).Status -eq "Running") { + Write-Host "===============================================" -ForegroundColor Green + Write-Host "ГОТОВО! Проверьте метки в интерфейсе Gitea." -ForegroundColor Green + Write-Host "===============================================" -ForegroundColor Green +} \ No newline at end of file