support:image_settings:start
Различия
Показаны различия между двумя версиями страницы.
| Следующая версия | Предыдущая версия | ||
| support:image_settings:start [2025/12/05 12:00] – создано aservice | support:image_settings:start [2025/12/05 13:03] (текущий) – aservice | ||
|---|---|---|---|
| Строка 1: | Строка 1: | ||
| ====== Первоначальная настройка системы ====== | ====== Первоначальная настройка системы ====== | ||
| + | Ниже приведен packages.json файл с содержимым где указано все что требуется для скачивания на новые компьютеры. | ||
| - | <code json> | + | < |
| { | { | ||
| " | " | ||
| Строка 29: | Строка 30: | ||
| - | {{ : | + | {{ support:image_settings: |
| + | |||
| + | |||
| + | |||
| + | <code bash universal_installer.bat> | ||
| + | @echo off | ||
| + | rem File: universal_ps1_launcher.bat | ||
| + | rem Purpose: launcher for get_remote_id_check.ps1 (finds pwsh or falls back to Windows PowerShell) | ||
| + | rem Author: takraztak | ||
| + | rem ================================================== | ||
| + | |||
| + | setlocal | ||
| + | |||
| + | :: try PowerShell 7 (pwsh) in Program Files | ||
| + | set " | ||
| + | if exist " | ||
| + | if not exist " | ||
| + | ) | ||
| + | |||
| + | :: fallback to Windows PowerShell if pwsh not found | ||
| + | if not exist " | ||
| + | |||
| + | :: final fallback: rely on PATH (just the name) | ||
| + | if not exist " | ||
| + | set " | ||
| + | ) | ||
| + | |||
| + | :: path to the PowerShell script with the same base name as this .bat | ||
| + | set " | ||
| + | |||
| + | :: Quote paths and forward all args | ||
| + | " | ||
| + | |||
| + | endlocal | ||
| + | pause | ||
| + | exit /b | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | <code powershell universal_installer.ps1> | ||
| + | # file: universal_installer.ps1 | ||
| + | # Universal package installer: | ||
| + | # - Downloads packages.zip | ||
| + | # - Extracts packages.json next to the script | ||
| + | # - Displays colored menu | ||
| + | # - Downloads selected ZIP archive | ||
| + | # - Extracts or saves according to JSON rules | ||
| + | |||
| + | $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition | ||
| + | |||
| + | # URL of the packages.zip archive | ||
| + | $PackagesZipUrl = " | ||
| + | $PackagesZip | ||
| + | |||
| + | Write-Host " | ||
| + | Invoke-WebRequest -Uri $PackagesZipUrl -OutFile $PackagesZip -UseBasicParsing | ||
| + | |||
| + | |||
| + | # ========== UNPACK packages.zip (RELIABLE METHOD) ========== | ||
| + | Write-Host " | ||
| + | |||
| + | Add-Type -AssemblyName System.IO.Compression.FileSystem | ||
| + | |||
| + | try { | ||
| + | # Remove old JSON if exists | ||
| + | $ExistingJson = Join-Path $ScriptDir " | ||
| + | if (Test-Path $ExistingJson) { Remove-Item $ExistingJson -Force } | ||
| + | |||
| + | # Extract all files directly into script directory | ||
| + | [System.IO.Compression.ZipFile]:: | ||
| + | } | ||
| + | catch { | ||
| + | Write-Host " | ||
| + | Write-Host $_.Exception.Message -ForegroundColor Yellow | ||
| + | pause | ||
| + | exit | ||
| + | } | ||
| + | |||
| + | |||
| + | # ========== LOAD JSON ========== | ||
| + | $JsonPath = Join-Path $ScriptDir " | ||
| + | |||
| + | if (-not (Test-Path $JsonPath)) { | ||
| + | Write-Host " | ||
| + | pause | ||
| + | exit | ||
| + | } | ||
| + | |||
| + | $JsonData = Get-Content $JsonPath -Raw | ConvertFrom-Json | ||
| + | $Packages = $JsonData.packages | ||
| + | |||
| + | |||
| + | # ========== MENU DISPLAY ========== | ||
| + | function Show-Menu { | ||
| + | Clear-Host | ||
| + | Write-Host "=== Package Installer ===`n" | ||
| + | |||
| + | $i = 1 | ||
| + | foreach ($pkg in $Packages) { | ||
| + | |||
| + | $line = "{0} - {1} : {2}" -f $i, $pkg.name, $pkg.desc | ||
| + | |||
| + | if ($i % 2 -eq 0) { | ||
| + | Write-Host $line -ForegroundColor Gray | ||
| + | } else { | ||
| + | Write-Host $line -ForegroundColor White | ||
| + | } | ||
| + | |||
| + | $i++ | ||
| + | } | ||
| + | |||
| + | Write-Host "`n0, 00 - Exit" | ||
| + | } | ||
| + | |||
| + | |||
| + | # ========== MAIN LOOP ========== | ||
| + | while ($true) { | ||
| + | Show-Menu | ||
| + | $choice = Read-Host " | ||
| + | |||
| + | if ($choice -eq " | ||
| + | |||
| + | if (($choice -as [int]) -lt 1 -or ($choice -as [int]) -gt $Packages.Count) { | ||
| + | Write-Host " | ||
| + | Start-Sleep 1.5 | ||
| + | continue | ||
| + | } | ||
| + | |||
| + | $Index = [int]$choice - 1 | ||
| + | $Item = $Packages[$Index] | ||
| + | |||
| + | Write-Host " | ||
| + | |||
| + | |||
| + | # ========== DOWNLOAD ARCHIVE ========== | ||
| + | $FileName = Split-Path $Item.url -Leaf | ||
| + | $ArchivePath = Join-Path $ScriptDir $FileName | ||
| + | |||
| + | Write-Host " | ||
| + | Invoke-WebRequest -Uri $Item.url -OutFile $ArchivePath | ||
| + | |||
| + | |||
| + | |||
| + | # ========== DETERMINE EXTRACTION TARGET ========== | ||
| + | if ($Item.target) { | ||
| + | $Target = Join-Path $ScriptDir $Item.target | ||
| + | } else { | ||
| + | $Base = [IO.Path]:: | ||
| + | $Target = Join-Path $ScriptDir $Base | ||
| + | } | ||
| + | |||
| + | if (-not (Test-Path $Target)) { | ||
| + | New-Item -ItemType Directory -Path $Target | Out-Null | ||
| + | } | ||
| + | |||
| + | |||
| + | # ========== EXTRACT OR JUST SAVE ========== | ||
| + | if ($Item.extract -eq $true) { | ||
| + | Write-Host " | ||
| + | |||
| + | try { | ||
| + | Add-Type -AssemblyName System.IO.Compression.FileSystem | ||
| + | [System.IO.Compression.ZipFile]:: | ||
| + | } | ||
| + | catch { | ||
| + | Write-Host "ERROR extracting archive" | ||
| + | Write-Host $_.Exception.Message -ForegroundColor Yellow | ||
| + | } | ||
| + | } | ||
| + | else { | ||
| + | Write-Host " | ||
| + | } | ||
| + | |||
| + | Write-Host " | ||
| + | pause | ||
| + | } | ||
| + | </ | ||
support/image_settings/start.1764925212.txt.gz · Последнее изменение: 2025/12/05 12:00 — aservice
