Ticket #1814: update.ps1

File update.ps1, 890 bytes (added by hamletmun, 8 months ago)
Line 
1# PowerShell < 4
2function Get-FileHash($filename) {
3 $HashAlgorithm = New-Object -TypeName System.Security.Cryptography.SHA256CryptoServiceProvider
4 $Path = Resolve-Path $filename
5 @{Hash = [System.BitConverter]::ToString($HashAlgorithm.ComputeHash([System.IO.File]::ReadAllBytes($Path))) -replace '-'}
6}
7
8$URL = "https://trac.wildfiregames.com/export/HEAD/ps/trunk/binaries/system"
9# Invoke-WebRequest "$URL/SHA256SUMS" -OutFile SHA256SUMS
10
11Get-Content SHA256SUMS | ForEach-Object {
12 $hash,$filename = $_ -split ' +\*?'
13
14 if((Test-Path -Path $filename) -And (Get-FileHash $filename).Hash.toLower() -eq $hash) {
15 Write-Host "$filename`: OK"
16 } else {
17 Write-Host "$filename`: FAILED" -ForegroundColor Red
18 # Invoke-WebRequest "$URL/$filename" -OutFile $filename
19 Write-Host "$filename`: Hash $((Get-FileHash $filename).Hash.toLower())" -ForegroundColor Green
20 }
21}