summaryrefslogtreecommitdiffstats
path: root/web/install.ps1
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--web/install.ps1 (renamed from scripts/installers/windows.ps1.in)45
1 files changed, 33 insertions, 12 deletions
diff --git a/scripts/installers/windows.ps1.in b/web/install.ps1
index 4b8e61d..92eef83 100644
--- a/scripts/installers/windows.ps1.in
+++ b/web/install.ps1
@@ -1,21 +1,18 @@
1# Zagan-Bet desktop installer for Windows. 1# Zagan-Bet installer for Windows.
2# 2#
3# Verifies the app against its published SHA-256, installs it for the current 3# Asks the site which build is newest, verifies its SHA-256, installs it for
4# user and adds a Start-menu shortcut. Put the downloaded app next to this 4# the current user and adds a Start-menu shortcut. Point it at a staging site
5# script, or run the script on its own and it will fetch the matching binary. 5# with -Site http://127.0.0.1:8899; add -NoPause for automation.
6# 6#
7# Run it with: 7# Run it with:
8# powershell -ExecutionPolicy Bypass -File .\zagan-bet-gui-*-install.ps1 8# powershell -ExecutionPolicy Bypass -File .\install.ps1
9# Add -NoPause to run it unattended. 9param(
10param([switch]$NoPause) 10 [string]$Site = "https://zagan.2137697.xyz",
11 [switch]$NoPause
12)
11 13
12$ErrorActionPreference = "Stop" 14$ErrorActionPreference = "Stop"
13 15
14$Version = "__VERSION__"
15$Binary = "__BINARY__"
16$Sha256 = "__SHA256__"
17$Url = "__URL__"
18
19function Finish([int]$Code) { 16function Finish([int]$Code) {
20 if (-not $NoPause) { 17 if (-not $NoPause) {
21 Read-Host "Press Enter to close" | Out-Null 18 Read-Host "Press Enter to close" | Out-Null
@@ -28,6 +25,30 @@ function Stop-Install([string]$Message) {
28 Finish 1 25 Finish 1
29} 26}
30 27
28try {
29 $latest = (Invoke-WebRequest -Uri "$Site/latest.php" -UseBasicParsing).Content
30} catch {
31 Stop-Install "could not read $Site/latest.php: $_"
32}
33
34$line = ($latest -split "`r?`n") |
35 Where-Object { $_ -match '^gui windows x86_64 ' } |
36 Select-Object -First 1
37if (-not $line) {
38 Stop-Install "no Windows build is published yet"
39}
40
41$parts = $line.Trim() -split '\s+'
42if ($parts.Count -lt 6) {
43 Stop-Install "the latest-build file is malformed"
44}
45$Version = $parts[3]
46$Binary = $parts[4]
47$Sha256 = $parts[5]
48$Url = "$Site/bin/gui/$Binary"
49
50Write-Host "Newest Zagan-Bet is $Version."
51
31$here = Split-Path -Parent $MyInvocation.MyCommand.Path 52$here = Split-Path -Parent $MyInvocation.MyCommand.Path
32$candidates = @( 53$candidates = @(
33 (Join-Path $here $Binary), 54 (Join-Path $here $Binary),