blob: fd2b8b3d28a90f87da9cea3f1ff9e005aa95bf4d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# Zagan-Bet desktop installer for Windows.
#
# Verifies the app against its published SHA-256, installs it for the current
# user and adds a Start-menu shortcut. Put the downloaded app next to this
# script, or run the script on its own and it will fetch the matching binary.
#
# Run it with:
# powershell -ExecutionPolicy Bypass -File .\zagan-bet-gui-*-install.ps1
$ErrorActionPreference = "Stop"
$Version = "__VERSION__"
$Binary = "__BINARY__"
$Sha256 = "__SHA256__"
$Url = "__URL__"
function Stop-Install([string]$Message) {
Write-Host "install: $Message" -ForegroundColor Red
exit 1
}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$candidates = @(
(Join-Path $here $Binary),
(Join-Path (Get-Location) $Binary),
(Join-Path $env:USERPROFILE "Downloads\$Binary")
)
$sourceFile = $null
foreach ($candidate in $candidates) {
if (Test-Path -LiteralPath $candidate) {
$sourceFile = $candidate
break
}
}
$temporary = $null
if (-not $sourceFile) {
$temporary = Join-Path ([System.IO.Path]::GetTempPath()) $Binary
Write-Host "Downloading $Binary..."
try {
Invoke-WebRequest -Uri $Url -OutFile $temporary -UseBasicParsing
} catch {
Stop-Install "download failed: $_"
}
$sourceFile = $temporary
}
try {
$actual = (Get-FileHash -LiteralPath $sourceFile -Algorithm SHA256).Hash.ToLowerInvariant()
if ($actual -ne $Sha256.ToLowerInvariant()) {
Stop-Install "checksum mismatch: expected $Sha256, got $actual"
}
$installDir = Join-Path $env:LOCALAPPDATA "Programs\Zagan-Bet"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
$target = Join-Path $installDir "zagan-bet-gui.exe"
Copy-Item -LiteralPath $sourceFile -Destination $target -Force
$startMenu = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs"
New-Item -ItemType Directory -Force -Path $startMenu | Out-Null
$shortcutPath = Join-Path $startMenu "Zagan-Bet.lnk"
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $target
$shortcut.WorkingDirectory = $installDir
$shortcut.IconLocation = "$target,0"
$shortcut.Description = "Slots, roulette, blackjack and crash"
$shortcut.Save()
Write-Host "Installed Zagan-Bet $Version to $target"
Write-Host "A Start-menu shortcut was created."
} finally {
if ($temporary -and (Test-Path -LiteralPath $temporary)) {
Remove-Item -LiteralPath $temporary -Force
}
}
|