mirror of
https://github.com/dockur/windows.git
synced 2025-10-27 19:35:49 +00:00
add deps and ready check
This commit is contained in:
parent
e51980dc0c
commit
941ebd6adf
6 changed files with 712 additions and 0 deletions
130
scripts/dependencies_windows.ps1
Normal file
130
scripts/dependencies_windows.ps1
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# https://stackoverflow.com/questions/9948517/how-to-stop-a-powershell-script-on-the-first-error
|
||||
function CheckStatus {
|
||||
if (-not $?)
|
||||
{
|
||||
throw "Native Failure"
|
||||
}
|
||||
}
|
||||
|
||||
function Validate-FileHash($filePath, $expectedHash, [Parameter(Mandatory=$false)] $algorithm) {
|
||||
if ($algorithm -ne $null) {
|
||||
$computedHash = Get-FileHash $filePath -Algorithm $algorithm
|
||||
} else {
|
||||
$computedHash = Get-FileHash $filePath
|
||||
}
|
||||
if ($computedHash.Hash -ne $expectedHash) {
|
||||
Write-Error "incorrect hash for file: $filePath, actual: $($computedHash.Hash), expected: $expectedHash"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Install-STUN() {
|
||||
$ZipPath = "stunserver_win64_1_2_16.zip"
|
||||
$URL = "http://www.stunprotocol.org/$ZipPath"
|
||||
$Destination = "C:\workspace\stunserver"
|
||||
$Hash = "CDC8C68400E3B9ECE95F900699CEF1535CFCF4E59C34AF9A33F4679638ACA3A1"
|
||||
|
||||
echo "Downloading $URL"
|
||||
curl.exe -L $URL -o $ZipPath
|
||||
CheckStatus
|
||||
|
||||
Validate-FileHash $ZipPath $Hash
|
||||
|
||||
echo "Extracting $ZipPath to $Destination"
|
||||
Expand-Archive $ZipPath -DestinationPath $Destination
|
||||
CheckStatus
|
||||
}
|
||||
|
||||
function Install-iperf() {
|
||||
$ZipPath = "iperf3.17_64.zip"
|
||||
$URL = "https://files.budman.pw/$ZipPath"
|
||||
$Hash = "C1AB63DE610D73779D1003753F8DCD3FAAE0B6AC5BE1EAF31BBF4A1D3D2E3356"
|
||||
$Destination = "C:\workspace\iperf3"
|
||||
$DestinationTmp = "$Destination.tmp"
|
||||
|
||||
echo "Downloading $URL"
|
||||
curl.exe -L $URL -o $ZipPath
|
||||
CheckStatus
|
||||
|
||||
Validate-FileHash $ZipPath $Hash
|
||||
|
||||
echo "Extracting $ZipPath to $DestinationTmp"
|
||||
Expand-Archive $ZipPath -DestinationPath $DestinationTmp
|
||||
CheckStatus
|
||||
|
||||
$firstSubDir = Get-ChildItem -Path $DestinationTmp -Directory | Select-Object -First 1
|
||||
echo "Moving $DestinationTmp\$firstSubDir to $Destination"
|
||||
mv $DestinationTmp\$firstSubDir $Destination
|
||||
Remove-Item $DestinationTmp
|
||||
}
|
||||
|
||||
function Install-Python() {
|
||||
$InstallerPath = "python-3.13.0-amd64.exe"
|
||||
$URL = "https://www.python.org/ftp/python/3.13.0/$InstallerPath"
|
||||
$Hash = "78156AD0CF0EC4123BFB5333B40F078596EBF15F2D062A10144863680AFBDEFC"
|
||||
|
||||
echo "Downloading $URL"
|
||||
curl.exe -L $URL -o $InstallerPath
|
||||
CheckStatus
|
||||
|
||||
Validate-FileHash $InstallerPath $Hash
|
||||
|
||||
echo "Installing python.."
|
||||
Start-Process -NoNewWindow -Wait -FilePath $PWD\$InstallerPath -ArgumentList "/quiet InstallAllUsers=1 PrependPath=1 Include_test=0 Include_doc=0 Include_dev=1 Include_launcher=0 Include_tcltk=0"
|
||||
CheckStatus
|
||||
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
|
||||
|
||||
python.exe -m pip install --upgrade pip
|
||||
}
|
||||
|
||||
function Install-WinDump() {
|
||||
$InstallerPath = "nmap-7.12-setup.exe"
|
||||
$URL = "https://nmap.org/dist/$InstallerPath"
|
||||
$Hash = "56580F1EEBDCCFBC5CE6D75690600225738DDBE8D991A417E56032869B0F43C7"
|
||||
|
||||
echo "Downloading $URL"
|
||||
curl.exe -L $URL -o $InstallerPath
|
||||
CheckStatus
|
||||
|
||||
Validate-FileHash $InstallerPath $Hash
|
||||
|
||||
echo "Installing winpcap.."
|
||||
Start-Process -NoNewWindow -Wait -FilePath $PWD\$InstallerPath -ArgumentList "/S"
|
||||
CheckStatus
|
||||
|
||||
sc.exe config npf start= auto
|
||||
CheckStatus
|
||||
|
||||
$BinaryPath = "WinDump.exe"
|
||||
$URL = "https://www.winpcap.org/windump/install/bin/windump_3_9_5/$BinaryPath"
|
||||
$Hash = "d59bc54721951dec855cbb4bbc000f9a71ea4d95"
|
||||
|
||||
echo "Downloading $URL"
|
||||
curl.exe -L $URL -o $BinaryPath
|
||||
CheckStatus
|
||||
|
||||
Validate-FileHash $BinaryPath $Hash SHA1
|
||||
}
|
||||
|
||||
[System.IO.Directory]::CreateDirectory("C:\workspace")
|
||||
CheckStatus
|
||||
|
||||
cd C:\workspace
|
||||
setx PATH "%PATH%;C:\workspace\uniffi"
|
||||
|
||||
Install-STUN
|
||||
CheckStatus
|
||||
|
||||
Install-iperf
|
||||
CheckStatus
|
||||
|
||||
Install-Python
|
||||
CheckStatus
|
||||
|
||||
Install-WinDump
|
||||
CheckStatus
|
||||
|
||||
pip install Pyro5==5.15
|
||||
52
scripts/disable_updates.ps1
Normal file
52
scripts/disable_updates.ps1
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Set-RegistryProperty {
|
||||
param (
|
||||
[string]$path,
|
||||
[string]$name,
|
||||
[int]$value
|
||||
)
|
||||
|
||||
if (-not (Test-Path $path)) {
|
||||
New-Item -Path $path -Force
|
||||
}
|
||||
|
||||
if (-not (Test-Path "$path\$name")) {
|
||||
New-ItemProperty -Path $path -Name $name -Value $value -Force
|
||||
} else {
|
||||
Set-ItemProperty -Path $path -Name $name -Value $value -Force
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "Windows Update settings have been configured to disable automatic updates and notifications."
|
||||
|
||||
$settings = @(
|
||||
@{ Type = "registry"; Name = "NoAutoUpdate"; Value = 1; Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" },
|
||||
@{ Type = "registry"; Name = "AUOptions"; Value = 0; Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" },
|
||||
@{ Type = "registry"; Name = "ExcludeWUDriversInQualityUpdate"; Value = 1; Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" },
|
||||
@{ Type = "registry"; Name = "DisableWindowsUpdateAccess"; Value = 1; Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" },
|
||||
@{ Type = "registry"; Name = "NoAutoRebootWithLoggedOnUsers"; Value = 1; Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" },
|
||||
@{ Type = "registry"; Name = "DisableAutoReboot"; Value = 1; Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" },
|
||||
@{ Type = "registry"; Name = "UseWUServer"; Value = 0; Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" },
|
||||
@{ Type = "registry"; Name = "ExternalManaged"; Value = 1; Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" },
|
||||
@{ Type = "registry"; Name = "DODownloadMode"; Value = 0; Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" },
|
||||
|
||||
@{ Type = "service"; Name = "wuauserv"; Value = 4; Path = "HKLM:\SYSTEM\CurrentControlSet\Services\wuauserv" },
|
||||
@{ Type = "service"; Name = "BITS"; Value = 4; Path = "HKLM:\SYSTEM\CurrentControlSet\Services\BITS" },
|
||||
@{ Type = "service"; Name = "cryptsvc"; Value = 4; Path = "HKLM:\SYSTEM\CurrentControlSet\Services\cryptsvc" },
|
||||
@{ Type = "service"; Name = "dosvc"; Value = 4; Path = "HKLM:\SYSTEM\CurrentControlSet\Services\dosvc" },
|
||||
@{ Type = "service"; Name = "usosvc"; Value = 4; Path = "HKLM:\SYSTEM\CurrentControlSet\Services\usosvc" },
|
||||
@{ Type = "service"; Name = "msiserver"; Value = 4; Path = "HKLM:\SYSTEM\CurrentControlSet\Services\msiserver" }
|
||||
)
|
||||
|
||||
foreach ($setting in $settings) {
|
||||
if ($setting.Type -eq "registry") {
|
||||
Set-RegistryProperty -path $setting.Path -name $setting.Name -value $setting.Value
|
||||
Write-Output "Set $($setting.Name) to $($setting.Value) in $($setting.Path)."
|
||||
} elseif ($setting.Type -eq "service") {
|
||||
Set-RegistryProperty -path $setting.Path -name "Start" -value $setting.Value
|
||||
Write-Output "Disabled $($setting.Name) service."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "All specified Windows Update services and group policies have been disabled."
|
||||
9
scripts/install.bat
Normal file
9
scripts/install.bat
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
pushd "C:/OEM"
|
||||
|
||||
powershell -ExecutionPolicy Bypass -File "dependencies_windows.ps1"
|
||||
powershell -ExecutionPolicy Bypass -File "optimize.ps1"
|
||||
powershell -ExecutionPolicy Bypass -File "disable_updates.ps1"
|
||||
|
||||
popd
|
||||
|
||||
shutdown /f /r /t 0
|
||||
36
scripts/optimize.ps1
Normal file
36
scripts/optimize.ps1
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Set Power Plan to High Performance and disable sleep
|
||||
Write-Output "Configuring Power Plan to High Performance and disabling sleep..."
|
||||
slmgr /rearm
|
||||
powercfg -setactive SCHEME_MIN
|
||||
powercfg /x -hibernate-timeout-ac 0
|
||||
powercfg /x -hibernate-timeout-dc 0
|
||||
powercfg /x -disk-timeout-ac 0
|
||||
powercfg /x -disk-timeout-dc 0
|
||||
powercfg /x -monitor-timeout-ac 0
|
||||
powercfg /x -monitor-timeout-dc 0
|
||||
powercfg /x -standby-timeout-ac 0
|
||||
powercfg /x -standby-timeout-dc 0
|
||||
|
||||
# Disable Windows Search Indexing (optional, for minimal interruption)
|
||||
Write-Output "Disabling Windows Search indexing service..."
|
||||
Stop-Service -Name "WSearch" -Force -ErrorAction SilentlyContinue
|
||||
Set-Service -Name "WSearch" -StartupType Disabled
|
||||
|
||||
# Set Network Adapters to not enter Power Saving mode
|
||||
Write-Output "Disabling Power Saving for Network Adapters..."
|
||||
Get-WmiObject -Namespace root\wmi -Class MSPower_DeviceEnable -Filter "InstanceName LIKE 'PCI\\\\VEN%'" | ForEach-Object {
|
||||
$_.Enable = $false
|
||||
$_.Put()
|
||||
}
|
||||
|
||||
# Set Firewall to allow all connections (optional; adjust based on your requirements)
|
||||
Write-Output "Configuring Windows Firewall to allow all connections (if necessary)..."
|
||||
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
|
||||
netsh advfirewall set allprofiles state off
|
||||
|
||||
# This can't be done inside provision script, because a restart is needed for changes to take effect.
|
||||
Write-Host "Enable IPv6"
|
||||
reg add hklm\system\currentcontrolset\services\tcpip6\parameters /f /v DisabledComponents /t REG_DWORD /d 0
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue