From 48d1240836caa9f98d133984dfc622d76e7a4b04 Mon Sep 17 00:00:00 2001 From: kalugin66 Date: Thu, 16 Apr 2026 13:45:18 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20Install=5Fact=5Frunnerx64.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Install_act_runnerx64.ps1 | 183 +++++++++++++++++++------------------- 1 file changed, 93 insertions(+), 90 deletions(-) diff --git a/Install_act_runnerx64.ps1 b/Install_act_runnerx64.ps1 index b096767..f793442 100644 --- a/Install_act_runnerx64.ps1 +++ b/Install_act_runnerx64.ps1 @@ -1,91 +1,94 @@ -# ================================================================= # -# 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 +# ================================================================= # +# 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. Сбор системной информации (С вашей меткой School25) +$defaultLabel = "School25" # Ваша основная метка +$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" + +# Формируем полный список для регистрации в Gitea +$fullLabels = "$defaultLabel:host,windows-amd64:host,self-hosted:host,$pcName:host,$arch:host,$memLabel:host" + +Write-Host "--- Данные системы: ПК=$pcName, ОЗУ=$memLabel, Метка=$defaultLabel ---" -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 (Используем {0} для School25) +Write-Host "--- Шаг 3: Формирование конфига ---" -ForegroundColor Cyan +$template = @" +log: + level: info +runner: + file: .runner + capacity: 1 + labels: + - "{0}:host" + - "windows-amd64:host" + - "self-hosted:host" + - "{1}:host" + - "{2}:host" + - "{3}:host" +container: + force_pull: false +host: + workdir: "" +"@ + +# Принудительная подстановка: 0-Школа, 1-Имя ПК, 2-Архитектура, 3-Память +$configText = $template -f $defaultLabel, $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 "ГОТОВО! Раннер активен с меткой $defaultLabel" -ForegroundColor Green + Write-Host "===============================================" -ForegroundColor Green } \ No newline at end of file