diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-01 22:23:00 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-01 22:23:00 +0100 |
| commit | 4887abc5773b33ab1e213ed5f528dfebd242e2cd (patch) | |
| tree | 8eb2316783a21817cce422c3fb58ec953206dd9a /web/install.sh | |
| parent | v4.3.1: render Windows through wgpu and keep the installer window open (diff) | |
| download | zagan-bet-4887abc5773b33ab1e213ed5f528dfebd242e2cd.tar.gz zagan-bet-4887abc5773b33ab1e213ed5f528dfebd242e2cd.zip | |
Adds web/latest.php: a plain-text feed of the newest version with each artifact's filename and SHA-256. The per-release generated installers are replaced by stable web/install.sh and web/install.ps1; both read the feed, pick the newest build, verify it, install per-user and add a launcher. Publishing a new app version no longer regenerates or versions the installers.
publish.sh drops the installer renderer and Python dependency. deploy.sh now also verifies latest.php against the local artifacts and that the served installer scripts match the repository.
Diffstat (limited to 'web/install.sh')
| -rw-r--r-- | web/install.sh | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/web/install.sh b/web/install.sh new file mode 100644 index 0000000..998b262 --- /dev/null +++ b/web/install.sh | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # Zagan-Bet installer for Linux. | ||
| 3 | # | ||
| 4 | # Asks the site which build is newest, verifies its SHA-256, installs it for | ||
| 5 | # the current user and adds a launcher. Point it at a staging site with | ||
| 6 | # ZAGAN_SITE=http://127.0.0.1:8899. | ||
| 7 | set -euo pipefail | ||
| 8 | |||
| 9 | SITE=${ZAGAN_SITE:-https://zagan.2137697.xyz} | ||
| 10 | PLATFORM=linux | ||
| 11 | ARCH=x86_64 | ||
| 12 | |||
| 13 | say() { printf '%s\n' "$*"; } | ||
| 14 | die() { printf 'install: %s\n' "$*" >&2; exit 1; } | ||
| 15 | |||
| 16 | command -v curl >/dev/null 2>&1 || die "curl is required" | ||
| 17 | command -v sha256sum >/dev/null 2>&1 || die "sha256sum is required" | ||
| 18 | |||
| 19 | latest=$(curl -fsSL --max-time 30 "$SITE/latest.php") \ | ||
| 20 | || die "could not read $SITE/latest.php" | ||
| 21 | line=$(printf '%s\n' "$latest" \ | ||
| 22 | | awk -v p="$PLATFORM" -v a="$ARCH" '$1 == "gui" && $2 == p && $3 == a { print; exit }') | ||
| 23 | [ -n "$line" ] || die "no Linux build is published yet" | ||
| 24 | |||
| 25 | version=$(printf '%s\n' "$line" | awk '{print $4}') | ||
| 26 | binary=$(printf '%s\n' "$line" | awk '{print $5}') | ||
| 27 | sha=$(printf '%s\n' "$line" | awk '{print $6}') | ||
| 28 | [ -n "$version" ] && [ -n "$binary" ] && [ -n "$sha" ] \ | ||
| 29 | || die "the latest-build file is malformed" | ||
| 30 | |||
| 31 | say "Newest Zagan-Bet is $version." | ||
| 32 | |||
| 33 | here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
| 34 | source_file="" | ||
| 35 | for candidate in "$here/$binary" "./$binary" "$HOME/Downloads/$binary"; do | ||
| 36 | if [ -f "$candidate" ]; then | ||
| 37 | source_file=$candidate | ||
| 38 | break | ||
| 39 | fi | ||
| 40 | done | ||
| 41 | |||
| 42 | cleanup="" | ||
| 43 | if [ -z "$source_file" ]; then | ||
| 44 | cleanup=$(mktemp) || die "cannot create a temporary file" | ||
| 45 | say "Downloading $binary..." | ||
| 46 | curl -fsSL --max-time 300 "$SITE/bin/gui/$binary" -o "$cleanup" \ | ||
| 47 | || die "download failed" | ||
| 48 | source_file=$cleanup | ||
| 49 | fi | ||
| 50 | trap 'if [ -n "$cleanup" ]; then rm -f "$cleanup"; fi' EXIT | ||
| 51 | |||
| 52 | actual=$(sha256sum "$source_file" | awk '{print $1}') | ||
| 53 | [ "$actual" = "$sha" ] \ | ||
| 54 | || die "checksum mismatch: expected $sha, got $actual" | ||
| 55 | |||
| 56 | bin_dir="${XDG_BIN_HOME:-$HOME/.local/bin}" | ||
| 57 | data_dir="${XDG_DATA_HOME:-$HOME/.local/share}" | ||
| 58 | app="$bin_dir/zagan-bet-gui" | ||
| 59 | desktop_dir="$data_dir/applications" | ||
| 60 | icon_dir="$data_dir/icons/hicolor/scalable/apps" | ||
| 61 | |||
| 62 | mkdir -p "$bin_dir" "$desktop_dir" "$icon_dir" | ||
| 63 | install -m 0755 "$source_file" "$app" | ||
| 64 | |||
| 65 | cat > "$icon_dir/zagan-bet.svg" <<'ICON' | ||
| 66 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64"> | ||
| 67 | <rect width="64" height="64" rx="14" fill="#0a0e12"/> | ||
| 68 | <rect x="9" y="9" width="46" height="46" rx="10" fill="#0f1a14" stroke="#1f7d52" stroke-width="2"/> | ||
| 69 | <path d="M22 20h20L22 44h20" fill="none" stroke="#4ec27b" stroke-width="6" | ||
| 70 | stroke-linecap="round" stroke-linejoin="round"/> | ||
| 71 | </svg> | ||
| 72 | ICON | ||
| 73 | |||
| 74 | cat > "$desktop_dir/zagan-bet.desktop" <<DESKTOP | ||
| 75 | [Desktop Entry] | ||
| 76 | Type=Application | ||
| 77 | Name=Zagan-Bet | ||
| 78 | Comment=Slots, roulette, blackjack and crash | ||
| 79 | Exec=$app | ||
| 80 | Icon=zagan-bet | ||
| 81 | Terminal=false | ||
| 82 | Categories=Game; | ||
| 83 | DESKTOP | ||
| 84 | chmod 0644 "$desktop_dir/zagan-bet.desktop" "$icon_dir/zagan-bet.svg" | ||
| 85 | |||
| 86 | if command -v update-desktop-database >/dev/null 2>&1; then | ||
| 87 | update-desktop-database "$desktop_dir" >/dev/null 2>&1 || true | ||
| 88 | fi | ||
| 89 | if command -v gtk-update-icon-cache >/dev/null 2>&1; then | ||
| 90 | gtk-update-icon-cache -q "$data_dir/icons/hicolor" >/dev/null 2>&1 || true | ||
| 91 | fi | ||
| 92 | |||
| 93 | say "Installed Zagan-Bet $version to $app" | ||
| 94 | say "A launcher was added to your applications menu." | ||
| 95 | case ":$PATH:" in | ||
| 96 | *":$bin_dir:"*) ;; | ||
| 97 | *) say "Add $bin_dir to PATH to start it as 'zagan-bet-gui'." ;; | ||
| 98 | esac | ||
