This commit is contained in:
parent
ef5eb0fcbb
commit
52c01be923
96
setup.ps1
96
setup.ps1
|
|
@ -1,6 +1,6 @@
|
|||
# ============================================================
|
||||
# Скрипт установки программ
|
||||
# Запуск: irm https://git.help-d.ru/helmut/auto-turning/raw/branch/main/setup.ps1 | iex
|
||||
# ============================================================
|
||||
# Skript ustanovki programm
|
||||
# Zapusk: irm https://git.help-d.ru/helmut/auto-turning/raw/branch/main/setup.ps1 | iex
|
||||
# ============================================================
|
||||
|
||||
$repo = "https://git.help-d.ru/helmut/auto-turning/raw/branch/main"
|
||||
|
|
@ -8,9 +8,9 @@ $repoApi = "https://git.help-d.ru/api/v1/repos/helmut/auto-turning/tree/main/ins
|
|||
$temp = "$env:TEMP\win_setup"
|
||||
|
||||
# ============================================================
|
||||
# 1. ОТКЛЮЧЕНИЕ АНТИВИРУСА (ОБЯЗАТЕЛЬНО!)
|
||||
# 1. OTKLYuChENIE ANTIVIRUSA (OBYAZATELNO!)
|
||||
# ============================================================
|
||||
Write-Host "`n[1/4] Отключение антивируса..." -ForegroundColor Yellow
|
||||
Write-Host "`n[1/4] Antivirus disable..." -ForegroundColor Yellow
|
||||
|
||||
Set-MpPreference -DisableRealtimeMonitoring $true -ErrorAction SilentlyContinue
|
||||
Set-MpPreference -DisableBehaviorMonitoring $true -ErrorAction SilentlyContinue
|
||||
|
|
@ -20,12 +20,12 @@ Set-MpPreference -DisableArchiveScanning $true -ErrorAction SilentlyContinue
|
|||
Stop-Service -Name WinDefend -Force -ErrorAction SilentlyContinue
|
||||
Stop-Service -Name MsMpSvc -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host " Антивирус отключен" -ForegroundColor Green
|
||||
Write-Host " Antivirus disabled" -ForegroundColor Green
|
||||
|
||||
# ============================================================
|
||||
# 2. ЗАГРУЗКА КОНФИГА И СПИСКА ПРОГРАММ
|
||||
# 2. ZAGRUZKA KONFIGA I SPISKA PROGRAMM
|
||||
# ============================================================
|
||||
Write-Host "[2/4] Загрузка конфигурации и списка программ..." -ForegroundColor Yellow
|
||||
Write-Host "[2/4] Loading config and program list..." -ForegroundColor Yellow
|
||||
|
||||
Remove-Item $temp -Recurse -Force -ErrorAction SilentlyContinue
|
||||
New-Item -ItemType Directory -Path $temp -Force | Out-Null
|
||||
|
|
@ -35,31 +35,31 @@ $configPath = "$temp\config.yaml"
|
|||
|
||||
try {
|
||||
Invoke-WebRequest -Uri $configUrl -OutFile $configPath -ErrorAction Stop
|
||||
Write-Host " Конфиг загружен" -ForegroundColor Green
|
||||
Write-Host " Config loaded" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " Ошибка загрузки конфига" -ForegroundColor Red
|
||||
Write-Host " Config load error" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Загружаем список файлов из репозитория через API
|
||||
Write-Host " Получаю список программ из репозитория..." -ForegroundColor Gray
|
||||
# Zagruzhayem spisok faylov iz repo cherez API
|
||||
Write-Host " Scanning installers repo..." -ForegroundColor Gray
|
||||
|
||||
try {
|
||||
$response = Invoke-WebRequest -Uri $repoApi -ErrorAction Stop
|
||||
$files = ($response.Content | ConvertFrom-Json) | Where-Object { $_.type -eq "file" }
|
||||
|
||||
if ($files.Count -eq 0) {
|
||||
Write-Host " Программы не найдены в репозитории" -ForegroundColor Red
|
||||
Write-Host " No programs found in repo" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host " Найдено программ: $($files.Count)" -ForegroundColor Green
|
||||
Write-Host " Found: $($files.Count) programs" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " Ошибка получения списка программ" -ForegroundColor Red
|
||||
Write-Host " Failed to get program list" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Группируем программы по категориям из конфига
|
||||
# Gruppiruem programmy po kategoriyam iz konfiga
|
||||
$categories = @{}
|
||||
$currentCat = $null
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ Get-Content $configPath | ForEach-Object {
|
|||
}
|
||||
}
|
||||
|
||||
# Создаём карту: имя файла -> программа
|
||||
# Sozdayom kartu: imya faila -> programma
|
||||
$programMap = @{}
|
||||
foreach ($file in $files) {
|
||||
$fileName = $file.name
|
||||
|
|
@ -84,7 +84,7 @@ foreach ($file in $files) {
|
|||
}
|
||||
}
|
||||
|
||||
# Автоматически распределяем программы по категориям
|
||||
# Avtomaticheski raspredelyaem programmy po kategoriyam
|
||||
$autoCategories = @{}
|
||||
$uncategorized = @()
|
||||
|
||||
|
|
@ -109,15 +109,15 @@ foreach ($prog in $programMap.Values) {
|
|||
}
|
||||
|
||||
if ($uncategorized.Count -gt 0) {
|
||||
$autoCategories["Другие"] = $uncategorized
|
||||
$autoCategories["Other"] = $uncategorized
|
||||
}
|
||||
|
||||
# ============================================================
|
||||
# 3. ВЫБОР ПРОГРАММ
|
||||
# 3. VYBOR PROGRAMM
|
||||
# ============================================================
|
||||
Write-Host "[3/4] Выбор программ..." -ForegroundColor Yellow
|
||||
Write-Host "[3/4] Program selection..." -ForegroundColor Yellow
|
||||
|
||||
Write-Host "`nДоступные программы в репозитории:`n" -ForegroundColor Cyan
|
||||
Write-Host "`nAvailable programs in repo:`n" -ForegroundColor Cyan
|
||||
|
||||
$i = 1
|
||||
$progMap = @{}
|
||||
|
|
@ -133,13 +133,13 @@ foreach ($cat in ($autoCategories.Keys | Sort-Object)) {
|
|||
}
|
||||
}
|
||||
|
||||
Write-Host "`n a - ВСЕ программы" -ForegroundColor Green
|
||||
Write-Host " 0 - Отмена`n" -ForegroundColor Gray
|
||||
Write-Host "`n a - ALL programs" -ForegroundColor Green
|
||||
Write-Host " 0 - Cancel`n" -ForegroundColor Gray
|
||||
|
||||
$choice = Read-Host "Выберите программы (1,2,3 или a)"
|
||||
$choice = Read-Host "Select programs (1,2,3 or a)"
|
||||
|
||||
if ($choice -eq "0") {
|
||||
Write-Host "Отмена" -ForegroundColor Red
|
||||
Write-Host "Canceled" -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
|
||||
|
|
@ -156,16 +156,16 @@ if ($choice -eq "a") {
|
|||
}
|
||||
|
||||
if ($selectedPrograms.Count -eq 0) {
|
||||
Write-Host "Программы не выбраны" -ForegroundColor Red
|
||||
Write-Host "No programs selected" -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
|
||||
Write-Host "`nВыбрано программ: $($selectedPrograms.Count)" -ForegroundColor Green
|
||||
Write-Host "`nSelected: $($selectedPrograms.Count) programs" -ForegroundColor Green
|
||||
|
||||
# ============================================================
|
||||
# 4. СКАЧИВАНИЕ И УСТАНОВКА
|
||||
# 4. SKACHIVANIE I USTANOVKA
|
||||
# ============================================================
|
||||
Write-Host "[4/4] Установка программ..." -ForegroundColor Yellow
|
||||
Write-Host "[4/4] Installing programs..." -ForegroundColor Yellow
|
||||
|
||||
$installed = @()
|
||||
$failed = @()
|
||||
|
|
@ -174,14 +174,14 @@ foreach ($prog in $selectedPrograms) {
|
|||
$programUrl = "$repo/installers/$($prog.File)"
|
||||
$programPath = "$temp\$($prog.File)"
|
||||
|
||||
Write-Host "`n Скачиваю: $($prog.Name)" -ForegroundColor Gray
|
||||
Write-Host "`n Downloading: $($prog.Name)" -ForegroundColor Gray
|
||||
|
||||
try {
|
||||
Invoke-WebRequest -Uri $programUrl -OutFile $programPath -ErrorAction Stop
|
||||
|
||||
Write-Host " Устанавливаю: $($prog.Name)" -ForegroundColor Gray
|
||||
Write-Host " Installing: $($prog.Name)" -ForegroundColor Gray
|
||||
|
||||
# Установка в зависимости от типа файла
|
||||
# Setup by file type
|
||||
if ($prog.Type -eq "msi") {
|
||||
$result = Start-Process msiexec -ArgumentList "/i `"$programPath`" /quiet /norestart" -Wait -PassThru -NoNewWindow
|
||||
} elseif ($prog.File -match "chrome.*\.exe$") {
|
||||
|
|
@ -200,51 +200,53 @@ foreach ($prog in $selectedPrograms) {
|
|||
$result = Start-Process $programPath -ArgumentList "/S" -Wait -PassThru -NoNewWindow
|
||||
} elseif ($prog.File -match "thunderbird.*\.exe$") {
|
||||
$result = Start-Process $programPath -ArgumentList "/S" -Wait -PassThru -NoNewWindow
|
||||
} elseif ($prog.File -match "openssh.*\.msi$") {
|
||||
$result = Start-Process msiexec -ArgumentList "/i `"$programPath`" /quiet /norestart" -Wait -PassThru -NoNewWindow
|
||||
} else {
|
||||
$result = Start-Process $programPath -ArgumentList "/S" -Wait -PassThru -NoNewWindow
|
||||
}
|
||||
|
||||
if ($result.ExitCode -eq 0 -or $result.ExitCode -eq 3010) {
|
||||
Write-Host " ✓ $($prog.Name) установлен" -ForegroundColor Green
|
||||
Write-Host " [OK] $($prog.Name) installed" -ForegroundColor Green
|
||||
$installed += $prog.Name
|
||||
} else {
|
||||
Write-Host " ✗ $($prog.Name) ошибка (код: $($result.ExitCode))" -ForegroundColor Red
|
||||
Write-Host " [FAIL] $($prog.Name) error (code: $($result.ExitCode))" -ForegroundColor Red
|
||||
$failed += $prog.Name
|
||||
}
|
||||
|
||||
} catch {
|
||||
Write-Host " ✗ $($prog.Name) - ошибка загрузки или установки" -ForegroundColor Red
|
||||
Write-Host " [FAIL] $($prog.Name) - download or install error" -ForegroundColor Red
|
||||
$failed += $prog.Name
|
||||
}
|
||||
}
|
||||
|
||||
# ============================================================
|
||||
# 5. ЧИСТКА И ВКЛЮЧЕНИЕ АНТИВИРУСА
|
||||
# 5. ChISTKA I VKLYuChENIE ANTIVIRUSA
|
||||
# ============================================================
|
||||
Write-Host "`n[5/4] Завершение..." -ForegroundColor Yellow
|
||||
Write-Host "`n[5/4] Cleanup..." -ForegroundColor Yellow
|
||||
|
||||
Remove-Item $temp -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Write-Host " Временные файлы удалены" -ForegroundColor Green
|
||||
Write-Host " Temp files deleted" -ForegroundColor Green
|
||||
|
||||
Write-Host "`nВключаю антивирус..." -ForegroundColor Yellow
|
||||
Write-Host "`nEnabling antivirus..." -ForegroundColor Yellow
|
||||
Set-MpPreference -DisableRealtimeMonitoring $false -ErrorAction SilentlyContinue
|
||||
Set-MpPreference -DisableBehaviorMonitoring $false -ErrorAction SilentlyContinue
|
||||
Set-MpPreference -DisableBlockAtFirstSeen $false -ErrorAction SilentlyContinue
|
||||
Set-MpPreference -DisableIOAVProtection $false -ErrorAction SilentlyContinue
|
||||
Set-MpPreference -DisableArchiveScanning $false -ErrorAction SilentlyContinue
|
||||
Start-Service -Name WinDefend -ErrorAction SilentlyContinue
|
||||
Write-Host " Антивирус включен" -ForegroundColor Green
|
||||
Write-Host " Antivirus enabled" -ForegroundColor Green
|
||||
|
||||
# ============================================================
|
||||
# РЕЗУЛЬТАТ
|
||||
# REZULTAT
|
||||
# ============================================================
|
||||
Write-Host "`n==========================================" -ForegroundColor Green
|
||||
Write-Host " УСТАНОВКА ЗАВЕРШЕНА" -ForegroundColor Green
|
||||
Write-Host " INSTALLATION COMPLETE" -ForegroundColor Green
|
||||
Write-Host "==========================================" -ForegroundColor Green
|
||||
Write-Host "`nУстановлено: $($installed.Count)" -ForegroundColor Cyan
|
||||
Write-Host "`nInstalled: $($installed.Count)" -ForegroundColor Cyan
|
||||
if ($failed.Count -gt 0) {
|
||||
Write-Host "Ошибок: $($failed.Count)" -ForegroundColor Red
|
||||
Write-Host "`nНе установлены:" -ForegroundColor Yellow
|
||||
Write-Host "Failed: $($failed.Count)" -ForegroundColor Red
|
||||
Write-Host "`nNot installed:" -ForegroundColor Yellow
|
||||
foreach ($f in $failed) { Write-Host " - $f" -ForegroundColor Gray }
|
||||
}
|
||||
Write-Host ""
|
||||
Write-Host ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue