summaryrefslogtreecommitdiffstats
path: root/scripts/installers
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/installers')
-rw-r--r--scripts/installers/linux.sh.in78
-rw-r--r--scripts/installers/windows.ps1.in87
2 files changed, 0 insertions, 165 deletions
diff --git a/scripts/installers/linux.sh.in b/scripts/installers/linux.sh.in
deleted file mode 100644
index 5b53c02..0000000
--- a/scripts/installers/linux.sh.in
+++ /dev/null
@@ -1,78 +0,0 @@
1#!/usr/bin/env bash
2# Zagan-Bet desktop installer for Linux.
3#
4# Verifies the app against its published SHA-256, installs it for the current
5# user and adds a launcher. Put the downloaded app next to this script, or run
6# the script on its own and it will fetch the matching binary.
7set -euo pipefail
8
9VERSION="__VERSION__"
10BINARY="__BINARY__"
11SHA256="__SHA256__"
12URL="__URL__"
13
14say() { printf '%s\n' "$*"; }
15die() { printf 'install: %s\n' "$*" >&2; exit 1; }
16
17command -v sha256sum >/dev/null 2>&1 || die "sha256sum is required"
18
19here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
20source_file=""
21for candidate in "$here/$BINARY" "./$BINARY" "$HOME/Downloads/$BINARY"; do
22 if [ -f "$candidate" ]; then
23 source_file=$candidate
24 break
25 fi
26done
27
28cleanup=""
29if [ -z "$source_file" ]; then
30 command -v curl >/dev/null 2>&1 || die "put $BINARY next to this installer, or install curl"
31 cleanup=$(mktemp) || die "cannot create a temporary file"
32 say "Downloading $BINARY..."
33 curl -fsSL --max-time 300 "$URL" -o "$cleanup" || die "download failed"
34 source_file=$cleanup
35fi
36trap 'if [ -n "$cleanup" ]; then rm -f "$cleanup"; fi' EXIT
37
38actual=$(sha256sum "$source_file" | awk '{print $1}')
39[ "$actual" = "$SHA256" ] || die "checksum mismatch: expected $SHA256, got $actual"
40
41bin_dir="${XDG_BIN_HOME:-$HOME/.local/bin}"
42data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"
43app="$bin_dir/zagan-bet-gui"
44desktop_dir="$data_dir/applications"
45icon_dir="$data_dir/icons/hicolor/scalable/apps"
46
47mkdir -p "$bin_dir" "$desktop_dir" "$icon_dir"
48install -m 0755 "$source_file" "$app"
49
50cat > "$icon_dir/zagan-bet.svg" <<'ICON'
51__ICON__
52ICON
53
54cat > "$desktop_dir/zagan-bet.desktop" <<DESKTOP
55[Desktop Entry]
56Type=Application
57Name=Zagan-Bet
58Comment=Slots, roulette, blackjack and crash
59Exec=$app
60Icon=zagan-bet
61Terminal=false
62Categories=Game;
63DESKTOP
64chmod 0644 "$desktop_dir/zagan-bet.desktop" "$icon_dir/zagan-bet.svg"
65
66if command -v update-desktop-database >/dev/null 2>&1; then
67 update-desktop-database "$desktop_dir" >/dev/null 2>&1 || true
68fi
69if command -v gtk-update-icon-cache >/dev/null 2>&1; then
70 gtk-update-icon-cache -q "$data_dir/icons/hicolor" >/dev/null 2>&1 || true
71fi
72
73say "Installed Zagan-Bet $VERSION to $app"
74say "A launcher was added to your applications menu."
75case ":$PATH:" in
76 *":$bin_dir:"*) ;;
77 *) say "Add $bin_dir to PATH to start it as 'zagan-bet-gui'." ;;
78esac
diff --git a/scripts/installers/windows.ps1.in b/scripts/installers/windows.ps1.in
deleted file mode 100644
index 4b8e61d..0000000
--- a/scripts/installers/windows.ps1.in
+++ /dev/null
@@ -1,87 +0,0 @@
1# Zagan-Bet desktop installer for Windows.
2#
3# Verifies the app against its published SHA-256, installs it for the current
4# user and adds a Start-menu shortcut. Put the downloaded app next to this
5# script, or run the script on its own and it will fetch the matching binary.
6#
7# Run it with:
8# powershell -ExecutionPolicy Bypass -File .\zagan-bet-gui-*-install.ps1
9# Add -NoPause to run it unattended.
10param([switch]$NoPause)
11
12$ErrorActionPreference = "Stop"
13
14$Version = "__VERSION__"
15$Binary = "__BINARY__"
16$Sha256 = "__SHA256__"
17$Url = "__URL__"
18
19function Finish([int]$Code) {
20 if (-not $NoPause) {
21 Read-Host "Press Enter to close" | Out-Null
22 }
23 exit $Code
24}
25
26function Stop-Install([string]$Message) {
27 Write-Host "install: $Message" -ForegroundColor Red
28 Finish 1
29}
30
31$here = Split-Path -Parent $MyInvocation.MyCommand.Path
32$candidates = @(
33 (Join-Path $here $Binary),
34 (Join-Path (Get-Location) $Binary),
35 (Join-Path $env:USERPROFILE "Downloads\$Binary")
36)
37$sourceFile = $null
38foreach ($candidate in $candidates) {
39 if (Test-Path -LiteralPath $candidate) {
40 $sourceFile = $candidate
41 break
42 }
43}
44
45$temporary = $null
46if (-not $sourceFile) {
47 $temporary = Join-Path ([System.IO.Path]::GetTempPath()) $Binary
48 Write-Host "Downloading $Binary..."
49 try {
50 Invoke-WebRequest -Uri $Url -OutFile $temporary -UseBasicParsing
51 } catch {
52 Stop-Install "download failed: $_"
53 }
54 $sourceFile = $temporary
55}
56
57try {
58 $actual = (Get-FileHash -LiteralPath $sourceFile -Algorithm SHA256).Hash.ToLowerInvariant()
59 if ($actual -ne $Sha256.ToLowerInvariant()) {
60 Stop-Install "checksum mismatch: expected $Sha256, got $actual"
61 }
62
63 $installDir = Join-Path $env:LOCALAPPDATA "Programs\Zagan-Bet"
64 New-Item -ItemType Directory -Force -Path $installDir | Out-Null
65 $target = Join-Path $installDir "zagan-bet-gui.exe"
66 Copy-Item -LiteralPath $sourceFile -Destination $target -Force
67
68 $startMenu = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs"
69 New-Item -ItemType Directory -Force -Path $startMenu | Out-Null
70 $shortcutPath = Join-Path $startMenu "Zagan-Bet.lnk"
71 $shell = New-Object -ComObject WScript.Shell
72 $shortcut = $shell.CreateShortcut($shortcutPath)
73 $shortcut.TargetPath = $target
74 $shortcut.WorkingDirectory = $installDir
75 $shortcut.IconLocation = "$target,0"
76 $shortcut.Description = "Slots, roulette, blackjack and crash"
77 $shortcut.Save()
78
79 Write-Host "Installed Zagan-Bet $Version to $target"
80 Write-Host "A Start-menu shortcut was created."
81} finally {
82 if ($temporary -and (Test-Path -LiteralPath $temporary)) {
83 Remove-Item -LiteralPath $temporary -Force
84 }
85}
86
87Finish 0