Обновить Install_act_runnerx64.ps1
This commit is contained in:
@@ -8,15 +8,18 @@ $instanceUrl = "https://git.dadehard.ru/"
|
|||||||
$token = "UzVNobPFBJe8ZoQXwu5ZamfgqCpTJZGR3LDVnX7N"
|
$token = "UzVNobPFBJe8ZoQXwu5ZamfgqCpTJZGR3LDVnX7N"
|
||||||
$serviceName = "act_runner"
|
$serviceName = "act_runner"
|
||||||
|
|
||||||
# 1. Сбор системной информации (Строгая инициализация)
|
# 1. Сбор системной информации (С вашей меткой School25)
|
||||||
|
$defaultLabel = "School25" # Ваша основная метка
|
||||||
$pcName = [System.Net.Dns]::GetHostName()
|
$pcName = [System.Net.Dns]::GetHostName()
|
||||||
$arch = if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" }
|
$arch = if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" }
|
||||||
$memRaw = (Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory
|
$memRaw = (Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory
|
||||||
$memGB = [math]::Round($memRaw / 1GB)
|
$memGB = [math]::Round($memRaw / 1GB)
|
||||||
$memLabel = "$($memGB)GB_RAM"
|
$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
|
# Формируем полный список для регистрации в Gitea
|
||||||
|
$fullLabels = "$defaultLabel:host,windows-amd64:host,self-hosted:host,$pcName:host,$arch:host,$memLabel:host"
|
||||||
|
|
||||||
|
Write-Host "--- Данные системы: ПК=$pcName, ОЗУ=$memLabel, Метка=$defaultLabel ---" -ForegroundColor Magenta
|
||||||
|
|
||||||
# 2. Подготовка окружения
|
# 2. Подготовка окружения
|
||||||
if (-not (Test-Path $workDir)) { New-Item -ItemType Directory -Path $workDir | Out-Null }
|
if (-not (Test-Path $workDir)) { New-Item -ItemType Directory -Path $workDir | Out-Null }
|
||||||
@@ -36,7 +39,7 @@ if (-not (Test-Path "nssm.exe")) { Invoke-WebRequest -Uri $nssmUrl -OutFile "nss
|
|||||||
Unblock-File -Path "$workDir\act_runner.exe"
|
Unblock-File -Path "$workDir\act_runner.exe"
|
||||||
Unblock-File -Path "$workDir\nssm.exe"
|
Unblock-File -Path "$workDir\nssm.exe"
|
||||||
|
|
||||||
# 5. Генерация config.yaml (Метод строгого форматирования)
|
# 5. Генерация config.yaml (Используем {0} для School25)
|
||||||
Write-Host "--- Шаг 3: Формирование конфига ---" -ForegroundColor Cyan
|
Write-Host "--- Шаг 3: Формирование конфига ---" -ForegroundColor Cyan
|
||||||
$template = @"
|
$template = @"
|
||||||
log:
|
log:
|
||||||
@@ -45,20 +48,20 @@ runner:
|
|||||||
file: .runner
|
file: .runner
|
||||||
capacity: 1
|
capacity: 1
|
||||||
labels:
|
labels:
|
||||||
- "windows-latest:host"
|
- "{0}:host"
|
||||||
- "windows-amd64:host"
|
- "windows-amd64:host"
|
||||||
- "self-hosted:host"
|
- "self-hosted:host"
|
||||||
- "{0}:host"
|
|
||||||
- "{1}:host"
|
- "{1}:host"
|
||||||
- "{2}:host"
|
- "{2}:host"
|
||||||
|
- "{3}:host"
|
||||||
container:
|
container:
|
||||||
force_pull: false
|
force_pull: false
|
||||||
host:
|
host:
|
||||||
workdir: ""
|
workdir: ""
|
||||||
"@
|
"@
|
||||||
|
|
||||||
# Принудительная подстановка переменных в шаблон
|
# Принудительная подстановка: 0-Школа, 1-Имя ПК, 2-Архитектура, 3-Память
|
||||||
$configText = $template -f $pcName, $arch, $memLabel
|
$configText = $template -f $defaultLabel, $pcName, $arch, $memLabel
|
||||||
|
|
||||||
# Запись в файл (UTF8 без BOM)
|
# Запись в файл (UTF8 без BOM)
|
||||||
[System.IO.File]::WriteAllText("$workDir\config.yaml", $configText)
|
[System.IO.File]::WriteAllText("$workDir\config.yaml", $configText)
|
||||||
@@ -86,6 +89,6 @@ Start-Service $serviceName
|
|||||||
|
|
||||||
if ((Get-Service $serviceName).Status -eq "Running") {
|
if ((Get-Service $serviceName).Status -eq "Running") {
|
||||||
Write-Host "===============================================" -ForegroundColor Green
|
Write-Host "===============================================" -ForegroundColor Green
|
||||||
Write-Host "ГОТОВО! Проверьте метки в интерфейсе Gitea." -ForegroundColor Green
|
Write-Host "ГОТОВО! Раннер активен с меткой $defaultLabel" -ForegroundColor Green
|
||||||
Write-Host "===============================================" -ForegroundColor Green
|
Write-Host "===============================================" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user