This commit is contained in:
parent
ec3d4e2cbc
commit
67ddc3ce61
|
|
@ -1 +0,0 @@
|
|||
[basic] # Браузеры, архиватор, кодеки, видеоплеер, акробат
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
basic:
|
||||
off_antivirus: true
|
||||
reinstall: true
|
||||
|
||||
|
||||
programs_x86_64:
|
||||
office_mail:
|
||||
1: office_2010.exe
|
||||
2: office_2016.exe
|
||||
3: office_2019.exe
|
||||
4: Thunderbird_128.exe
|
||||
|
||||
pdf:
|
||||
1: acrobat_reader.exe
|
||||
2: acrobat_pro.exe
|
||||
|
||||
browsers:
|
||||
1: yandex.exe
|
||||
2: chrome.exe
|
||||
3: Firefox.Browser-x64.exe
|
||||
4: Firefox.Browser-x86.exe
|
||||
5: Firefox.ESR-x64.exe
|
||||
6: Firefox.ESR-x86.exe
|
||||
|
||||
archives:
|
||||
1: Win.RAR.7.01.exe
|
||||
2: 7zip.exe
|
||||
|
||||
remote:
|
||||
1: Rustdesk-1.4.4-x86_64.exe
|
||||
|
||||
other:
|
||||
1: openssh.exe
|
||||
2: CSPSetup-5.0.12417.exe
|
||||
3: K.Lite.Codec.Pack.exe
|
||||
|
|
@ -1 +0,0 @@
|
|||
[ecp] # Утилиты для ЭЦП
|
||||
|
|
@ -1 +0,0 @@
|
|||
[lite] # Браузеры, архиватор, кодеки, видеоплеер, акробат облегчённые версии
|
||||
|
|
@ -1 +0,0 @@
|
|||
[other] # Офис и другие специфичные программы
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
337
setup.ps1
337
setup.ps1
|
|
@ -1,216 +1,193 @@
|
|||
# ============================================================
|
||||
# Скрипт установки и настройки Windows ПК
|
||||
# Запуск: irm https://git.help-d.ru/go | iex
|
||||
# Требования: PowerShell от имени администратора
|
||||
# Скрипт установки программ
|
||||
# Запуск: irm https://git.help-d.ru/helmut/auto-turning/raw/branch/main/setup.ps1 | iex
|
||||
# ============================================================
|
||||
|
||||
Write-Host "`n==========================================" -ForegroundColor Cyan
|
||||
Write-Host " АВТОМАТИЧЕСКАЯ НАСТРОЙКА ПК" -ForegroundColor Cyan
|
||||
Write-Host "==========================================`n" -ForegroundColor Cyan
|
||||
$repo = "https://git.help-d.ru/helmut/auto-turning/raw/branch/main"
|
||||
$temp = "$env:TEMP\win_setup"
|
||||
|
||||
# ============================================================
|
||||
# 1. ОТКЛЮЧЕНИЕ АНТИВИРУСА
|
||||
# 1. ОТКЛЮЧЕНИЕ АНТИВИРУСА (ОБЯЗАТЕЛЬНО!)
|
||||
# ============================================================
|
||||
Write-Host "[1/8] Отключаю антивирус Windows Defender..." -ForegroundColor Yellow
|
||||
|
||||
Set-MpPreference -DisableRealtimeMonitoring $true
|
||||
Set-MpPreference -DisableBehaviorMonitoring $true
|
||||
Set-MpPreference -DisableBlockAtFirstSeen $true
|
||||
Set-MpPreference -DisableIOAVProtection $true
|
||||
Set-MpPreference -DisablePrivacyMode $true
|
||||
Set-MpPreference -DisableArchiveScanning $true
|
||||
Set-MpPreference -DisableIntrusionPreventionSystem $true
|
||||
Set-MpPreference -DisableScriptScanning $true
|
||||
Write-Host "`n[1/5] Отключение антивируса..." -ForegroundColor Yellow
|
||||
|
||||
Set-MpPreference -DisableRealtimeMonitoring $true -ErrorAction SilentlyContinue
|
||||
Set-MpPreference -DisableBehaviorMonitoring $true -ErrorAction SilentlyContinue
|
||||
Set-MpPreference -DisableBlockAtFirstSeen $true -ErrorAction SilentlyContinue
|
||||
Set-MpPreference -DisableIOAVProtection $true -ErrorAction SilentlyContinue
|
||||
Set-MpPreference -DisableArchiveScanning $true -ErrorAction SilentlyContinue
|
||||
Stop-Service -Name WinDefend -Force -ErrorAction SilentlyContinue
|
||||
Stop-Service -Name MsMpSvc -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host " Антивирус отключен" -ForegroundColor Green
|
||||
|
||||
# ============================================================
|
||||
# 2. ВЫБОР ПРОФИЛЯ УСТАНОВКИ
|
||||
# 2. ЗАГРУЗКА КОНФИГА
|
||||
# ============================================================
|
||||
Write-Host "[2/8] Выбор профиля установки..." -ForegroundColor Yellow
|
||||
Write-Host "[2/5] Загрузка конфигурации..." -ForegroundColor Yellow
|
||||
|
||||
Write-Host "`nВыберите профиль установки:" -ForegroundColor Cyan
|
||||
Write-Host " 1 - Обычная (базовые программы)" -ForegroundColor Yellow
|
||||
Write-Host " 2 - Для слабых ПК (облегчённая)" -ForegroundColor Yellow
|
||||
Write-Host " 3 - Для ЭЦП (криптография)" -ForegroundColor Yellow
|
||||
Write-Host " 4 - Рабочая станция (полная)" -ForegroundColor Yellow
|
||||
|
||||
$choice = Read-Host "Введите номер"
|
||||
|
||||
switch ($choice) {
|
||||
"1" { $profile = "base" }
|
||||
"2" { $profile = "weak" }
|
||||
"3" { $profile = "ecp" }
|
||||
"4" { $profile = "work" }
|
||||
default { $profile = "base" }
|
||||
}
|
||||
|
||||
Write-Host "Выбран профиль: $profile" -ForegroundColor Green
|
||||
|
||||
# ============================================================
|
||||
# 3. ПЕРЕМЕННЫЕ И ПОДГОТОВКА
|
||||
# ============================================================
|
||||
$repo = "https://git.help-d.ru/helmut/auto-turning/raw/branch/main"
|
||||
$temp = "$env:TEMP\win_setup"
|
||||
|
||||
Write-Host "[3/8] Подготовка временной папки..." -ForegroundColor Yellow
|
||||
Remove-Item $temp -Recurse -Force -ErrorAction SilentlyContinue
|
||||
New-Item -ItemType Directory -Path $temp -Force | Out-Null
|
||||
Write-Host " Готово" -ForegroundColor Green
|
||||
|
||||
# ============================================================
|
||||
# 4. СКАЧИВАНИЕ УСТАНОВЩИКОВ ИЗ ВЫБРАННОЙ ПАПКИ
|
||||
# ============================================================
|
||||
Write-Host "[4/8] Скачиваю установщики из папки: $profile ..." -ForegroundColor Yellow
|
||||
$configUrl = "$repo/configs/config.yaml"
|
||||
$configPath = "$temp\config.yaml"
|
||||
|
||||
# Список файлов для скачивания (добавляйте свои)
|
||||
$files = @(
|
||||
"7zip.msi",
|
||||
"adobe_reader.exe"
|
||||
)
|
||||
|
||||
# Дополнительные файлы для разных профилей
|
||||
switch ($profile) {
|
||||
"ecp" {
|
||||
$files += "crypto_pro.msi"
|
||||
$files += "root_cert.cer"
|
||||
}
|
||||
"work" {
|
||||
$files += "office.iso"
|
||||
$files += "visual_studio.exe"
|
||||
$files += "docker.msi"
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($file in $files) {
|
||||
$url = "$repo/installers/$profile/$file"
|
||||
$output = "$temp\$file"
|
||||
Write-Host " Скачиваю: $file" -ForegroundColor Gray
|
||||
try {
|
||||
Invoke-WebRequest -Uri $url -OutFile $output -ErrorAction Stop
|
||||
Write-Host " OK" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " Ошибка: $file не найден, пропускаю" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host " Скачивание завершено" -ForegroundColor Green
|
||||
|
||||
# ============================================================
|
||||
# 5. УСТАНОВКА ПРОГРАММ
|
||||
# ============================================================
|
||||
Write-Host "[5/8] Установка программ..." -ForegroundColor Yellow
|
||||
|
||||
# 7-Zip
|
||||
if (Test-Path "$temp\7zip.msi") {
|
||||
Write-Host " Устанавливаю 7-Zip..." -ForegroundColor Gray
|
||||
msiexec /i "$temp\7zip.msi" /quiet /norestart
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
|
||||
# Adobe Reader
|
||||
if (Test-Path "$temp\adobe_reader.exe") {
|
||||
Write-Host " Устанавливаю Adobe Reader..." -ForegroundColor Gray
|
||||
Start-Process -FilePath "$temp\adobe_reader.exe" -ArgumentList "/sAll /msi EULA_ACCEPT=YES" -Wait -NoNewWindow
|
||||
}
|
||||
|
||||
# КриптоПро (для профиля ЭЦП)
|
||||
if ($profile -eq "ecp" -and (Test-Path "$temp\crypto_pro.msi")) {
|
||||
Write-Host " Устанавливаю КриптоПро..." -ForegroundColor Gray
|
||||
msiexec /i "$temp\crypto_pro.msi" /quiet /norestart
|
||||
Start-Sleep -Seconds 3
|
||||
}
|
||||
|
||||
# Visual Studio (для профиля work)
|
||||
if ($profile -eq "work" -and (Test-Path "$temp\visual_studio.exe")) {
|
||||
Write-Host " Устанавливаю Visual Studio..." -ForegroundColor Gray
|
||||
Start-Process -FilePath "$temp\visual_studio.exe" -ArgumentList "--quiet" -Wait -NoNewWindow
|
||||
}
|
||||
|
||||
Write-Host " Установка завершена" -ForegroundColor Green
|
||||
|
||||
# ============================================================
|
||||
# 6. НАСТРОЙКА SSH (если нужна)
|
||||
# ============================================================
|
||||
Write-Host "[6/8] Настройка SSH..." -ForegroundColor Yellow
|
||||
|
||||
# Скачиваем SSH отдельно (если есть в репозитории)
|
||||
try {
|
||||
Invoke-WebRequest -Uri "$repo/installers/ssh.msi" -OutFile "$temp\ssh.msi" -ErrorAction Stop
|
||||
|
||||
# Установка SSH
|
||||
Write-Host " Устанавливаю SSH сервер..." -ForegroundColor Gray
|
||||
msiexec /i "$temp\ssh.msi" /quiet /norestart
|
||||
Start-Sleep -Seconds 3
|
||||
|
||||
# Создаём папку .ssh
|
||||
$sshPath = "$env:USERPROFILE\.ssh"
|
||||
New-Item -ItemType Directory -Path $sshPath -Force | Out-Null
|
||||
|
||||
# Добавляем публичный ключ
|
||||
$pubKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHceolzaC/nnN14/lVqeXzcXcIANtQgJcIaFczLIchVo efgufk\admin@ISERVER"
|
||||
$pubKey | Out-File "$sshPath\authorized_keys" -Encoding utf8 -Force
|
||||
|
||||
# Настройка sshd_config
|
||||
$config = "C:\ProgramData\ssh\sshd_config"
|
||||
if (Test-Path $config) {
|
||||
$content = Get-Content $config
|
||||
$content = $content -replace '^#Port 22', 'Port 2222'
|
||||
$content = $content -replace '^Match Group administrators', '#Match Group administrators'
|
||||
$content = $content -replace '^ AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys', '# AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys'
|
||||
$content | Set-Content $config
|
||||
}
|
||||
|
||||
# Перезапуск службы
|
||||
Restart-Service sshd -Force
|
||||
Write-Host " SSH настроен на порт 2222" -ForegroundColor Green
|
||||
Invoke-WebRequest -Uri $configUrl -OutFile $configPath -ErrorAction Stop
|
||||
Write-Host " Конфиг загружен" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " SSH не найден в репозитории, пропускаю" -ForegroundColor Gray
|
||||
Write-Host " Ошибка загрузки конфига" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Парсим конфиг
|
||||
$yaml = Get-Content $configPath -Raw
|
||||
$offAntivirus = $yaml -match "off_antivirus:\s*true"
|
||||
$reinstall = $yaml -match "reinstall:\s*true"
|
||||
|
||||
if ($offAntivirus) {
|
||||
Write-Host " off_antivirus: true (подтверждено)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Извлекаем категории и программы
|
||||
$categories = @{}
|
||||
$currentCat = $null
|
||||
|
||||
Get-Content $configPath | ForEach-Object {
|
||||
if ($_ -match "^\s*(\w+):\s*$" -and $_ -notmatch "basic:") {
|
||||
$currentCat = $matches[1]
|
||||
$categories[$currentCat] = @()
|
||||
}
|
||||
if ($currentCat -and $_ -match '\d+:\s*"(.+)"') {
|
||||
$categories[$currentCat] += $matches[1]
|
||||
}
|
||||
}
|
||||
|
||||
# ============================================================
|
||||
# 7. ЧИСТКА И ВКЛЮЧЕНИЕ АНТИВИРУСА
|
||||
# 3. ВЫБОР КАТЕГОРИЙ
|
||||
# ============================================================
|
||||
Write-Host "[7/8] Чистка и включение антивируса..." -ForegroundColor Yellow
|
||||
Write-Host "[3/5] Выбор категорий..." -ForegroundColor Yellow
|
||||
|
||||
Remove-Item $temp -Recurse -Force
|
||||
Write-Host "`nДоступные категории:`n" -ForegroundColor Cyan
|
||||
|
||||
$catList = $categories.Keys | Sort-Object
|
||||
$i = 1
|
||||
$catMap = @{}
|
||||
|
||||
foreach ($cat in $catList) {
|
||||
Write-Host " $i - $cat ($($categories[$cat].Count) программ)" -ForegroundColor Yellow
|
||||
$catMap[$i] = $cat
|
||||
$i++
|
||||
}
|
||||
|
||||
Write-Host "`n a - ВСЕ категории" -ForegroundColor Green
|
||||
Write-Host " 0 - Отмена`n" -ForegroundColor Gray
|
||||
|
||||
$choice = Read-Host "Выберите категории (1,2,3 или a)"
|
||||
|
||||
if ($choice -eq "0") {
|
||||
Write-Host "Отмена" -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
|
||||
$selectedCategories = @()
|
||||
if ($choice -eq "a") {
|
||||
$selectedCategories = $catList
|
||||
} else {
|
||||
foreach ($num in $choice.Split(',')) {
|
||||
$num = $num.Trim()
|
||||
if ($catMap[$num]) {
|
||||
$selectedCategories += $catMap[$num]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($selectedCategories.Count -eq 0) {
|
||||
Write-Host "Категории не выбраны" -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
|
||||
Write-Host "`nВыбрано: $($selectedCategories -join ', ')" -ForegroundColor Green
|
||||
|
||||
# ============================================================
|
||||
# 4. СКАЧИВАНИЕ И УСТАНОВКА
|
||||
# ============================================================
|
||||
Write-Host "[4/5] Установка программ..." -ForegroundColor Yellow
|
||||
|
||||
$installed = @()
|
||||
$failed = @()
|
||||
|
||||
foreach ($category in $selectedCategories) {
|
||||
Write-Host "`n >>> $category" -ForegroundColor Cyan
|
||||
|
||||
foreach ($program in $categories[$category]) {
|
||||
$programUrl = "$repo/installers/$program"
|
||||
$programPath = "$temp\$program"
|
||||
|
||||
Write-Host " Скачиваю: $program" -ForegroundColor Gray
|
||||
|
||||
try {
|
||||
Invoke-WebRequest -Uri $programUrl -OutFile $programPath -ErrorAction Stop
|
||||
|
||||
Write-Host " Устанавливаю: $program" -ForegroundColor Gray
|
||||
|
||||
# Установка в зависимости от типа файла
|
||||
if ($program -match "\.msi$") {
|
||||
$result = Start-Process msiexec -ArgumentList "/i `"$programPath`" /quiet /norestart" -Wait -PassThru -NoNewWindow
|
||||
} elseif ($program -match "chrome.*\.exe$") {
|
||||
$result = Start-Process $programPath -ArgumentList "/silent /install" -Wait -PassThru -NoNewWindow
|
||||
} elseif ($program -match "firefox.*\.exe$") {
|
||||
$result = Start-Process $programPath -ArgumentList "/S" -Wait -PassThru -NoNewWindow
|
||||
} elseif ($program -match "winrar.*\.exe$") {
|
||||
$result = Start-Process $programPath -ArgumentList "/S" -Wait -PassThru -NoNewWindow
|
||||
} elseif ($program -match "7zip.*\.exe$") {
|
||||
$result = Start-Process $programPath -ArgumentList "/S" -Wait -PassThru -NoNewWindow
|
||||
} else {
|
||||
$result = Start-Process $programPath -Wait -PassThru -NoNewWindow
|
||||
}
|
||||
|
||||
if ($result.ExitCode -eq 0 -or $result.ExitCode -eq 3010) {
|
||||
Write-Host " ✓ $program установлен" -ForegroundColor Green
|
||||
$installed += $program
|
||||
} else {
|
||||
Write-Host " ✗ $program ошибка (код: $($result.ExitCode))" -ForegroundColor Red
|
||||
$failed += $program
|
||||
}
|
||||
|
||||
} catch {
|
||||
Write-Host " ✗ $program - не найден в репозитории" -ForegroundColor Red
|
||||
$failed += $program
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ============================================================
|
||||
# 5. ЧИСТКА И ВКЛЮЧЕНИЕ АНТИВИРУСА
|
||||
# ============================================================
|
||||
Write-Host "[5/5] Завершение..." -ForegroundColor Yellow
|
||||
|
||||
Remove-Item $temp -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Write-Host " Временные файлы удалены" -ForegroundColor Green
|
||||
|
||||
Set-MpPreference -DisableRealtimeMonitoring $false
|
||||
Set-MpPreference -DisableBehaviorMonitoring $false
|
||||
Set-MpPreference -DisableBlockAtFirstSeen $false
|
||||
Set-MpPreference -DisableIOAVProtection $false
|
||||
Set-MpPreference -DisablePrivacyMode $false
|
||||
Set-MpPreference -DisableArchiveScanning $false
|
||||
Set-MpPreference -DisableIntrusionPreventionSystem $false
|
||||
Set-MpPreference -DisableScriptScanning $false
|
||||
|
||||
Write-Host "`nВключаю антивирус..." -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
|
||||
|
||||
# ============================================================
|
||||
# 8. ВЫВОД РЕЗУЛЬТАТА
|
||||
# РЕЗУЛЬТАТ
|
||||
# ============================================================
|
||||
Write-Host "[8/8] Завершение..." -ForegroundColor Yellow
|
||||
|
||||
$ip = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object {$_.InterfaceAlias -notlike "*Loopback*" -and $_.PrefixOrigin -ne "WellKnown"}).IPAddress
|
||||
|
||||
Write-Host "`n==========================================" -ForegroundColor Green
|
||||
Write-Host " УСТАНОВКА ЗАВЕРШЕНА!" -ForegroundColor Green
|
||||
Write-Host " УСТАНОВКА ЗАВЕРШЕНА" -ForegroundColor Green
|
||||
Write-Host "==========================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host " Профиль: $profile" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Показываем SSH данные только если SSH был установлен
|
||||
if (Get-Service sshd -ErrorAction SilentlyContinue) {
|
||||
Write-Host " SSH подключение:" -ForegroundColor Cyan
|
||||
Write-Host " ssh -p 2222 $env:USERNAME@$ip" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
Write-Host "`nУстановлено: $($installed.Count)" -ForegroundColor Cyan
|
||||
if ($failed.Count -gt 0) {
|
||||
Write-Host "Ошибок: $($failed.Count)" -ForegroundColor Red
|
||||
Write-Host "`nНе установлены:" -ForegroundColor Yellow
|
||||
foreach ($f in $failed) { Write-Host " - $f" -ForegroundColor Gray }
|
||||
}
|
||||
|
||||
Write-Host " Проверка: Get-Service sshd" -ForegroundColor Gray
|
||||
Write-Host "==========================================`n" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Loading…
Reference in New Issue