summaryrefslogtreecommitdiffstats
path: root/scripts/installers/linux.sh.in
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-01 22:23:00 +0100
committersalmonik <salmonik@tuta.io>2026-11-01 22:23:00 +0100
commit4887abc5773b33ab1e213ed5f528dfebd242e2cd (patch)
tree8eb2316783a21817cce422c3fb58ec953206dd9a /scripts/installers/linux.sh.in
parentv4.3.1: render Windows through wgpu and keep the installer window open (diff)
downloadzagan-bet-master.tar.gz
zagan-bet-master.zip
v4.4.0: stable installers that follow the newest published buildHEADmaster
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 '')
-rw-r--r--web/install.sh (renamed from scripts/installers/linux.sh.in)50
1 files changed, 35 insertions, 15 deletions
diff --git a/scripts/installers/linux.sh.in b/web/install.sh
index 5b53c02..998b262 100644
--- a/scripts/installers/linux.sh.in
+++ b/web/install.sh
@@ -1,24 +1,38 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2# Zagan-Bet desktop installer for Linux. 2# Zagan-Bet installer for Linux.
3# 3#
4# Verifies the app against its published SHA-256, installs it for the current 4# Asks the site which build is newest, verifies its SHA-256, installs it for
5# user and adds a launcher. Put the downloaded app next to this script, or run 5# the current user and adds a launcher. Point it at a staging site with
6# the script on its own and it will fetch the matching binary. 6# ZAGAN_SITE=http://127.0.0.1:8899.
7set -euo pipefail 7set -euo pipefail
8 8
9VERSION="__VERSION__" 9SITE=${ZAGAN_SITE:-https://zagan.2137697.xyz}
10BINARY="__BINARY__" 10PLATFORM=linux
11SHA256="__SHA256__" 11ARCH=x86_64
12URL="__URL__"
13 12
14say() { printf '%s\n' "$*"; } 13say() { printf '%s\n' "$*"; }
15die() { printf 'install: %s\n' "$*" >&2; exit 1; } 14die() { printf 'install: %s\n' "$*" >&2; exit 1; }
16 15
16command -v curl >/dev/null 2>&1 || die "curl is required"
17command -v sha256sum >/dev/null 2>&1 || die "sha256sum is required" 17command -v sha256sum >/dev/null 2>&1 || die "sha256sum is required"
18 18
19latest=$(curl -fsSL --max-time 30 "$SITE/latest.php") \
20 || die "could not read $SITE/latest.php"
21line=$(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
25version=$(printf '%s\n' "$line" | awk '{print $4}')
26binary=$(printf '%s\n' "$line" | awk '{print $5}')
27sha=$(printf '%s\n' "$line" | awk '{print $6}')
28[ -n "$version" ] && [ -n "$binary" ] && [ -n "$sha" ] \
29 || die "the latest-build file is malformed"
30
31say "Newest Zagan-Bet is $version."
32
19here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 33here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
20source_file="" 34source_file=""
21for candidate in "$here/$BINARY" "./$BINARY" "$HOME/Downloads/$BINARY"; do 35for candidate in "$here/$binary" "./$binary" "$HOME/Downloads/$binary"; do
22 if [ -f "$candidate" ]; then 36 if [ -f "$candidate" ]; then
23 source_file=$candidate 37 source_file=$candidate
24 break 38 break
@@ -27,16 +41,17 @@ done
27 41
28cleanup="" 42cleanup=""
29if [ -z "$source_file" ]; then 43if [ -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" 44 cleanup=$(mktemp) || die "cannot create a temporary file"
32 say "Downloading $BINARY..." 45 say "Downloading $binary..."
33 curl -fsSL --max-time 300 "$URL" -o "$cleanup" || die "download failed" 46 curl -fsSL --max-time 300 "$SITE/bin/gui/$binary" -o "$cleanup" \
47 || die "download failed"
34 source_file=$cleanup 48 source_file=$cleanup
35fi 49fi
36trap 'if [ -n "$cleanup" ]; then rm -f "$cleanup"; fi' EXIT 50trap 'if [ -n "$cleanup" ]; then rm -f "$cleanup"; fi' EXIT
37 51
38actual=$(sha256sum "$source_file" | awk '{print $1}') 52actual=$(sha256sum "$source_file" | awk '{print $1}')
39[ "$actual" = "$SHA256" ] || die "checksum mismatch: expected $SHA256, got $actual" 53[ "$actual" = "$sha" ] \
54 || die "checksum mismatch: expected $sha, got $actual"
40 55
41bin_dir="${XDG_BIN_HOME:-$HOME/.local/bin}" 56bin_dir="${XDG_BIN_HOME:-$HOME/.local/bin}"
42data_dir="${XDG_DATA_HOME:-$HOME/.local/share}" 57data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"
@@ -48,7 +63,12 @@ mkdir -p "$bin_dir" "$desktop_dir" "$icon_dir"
48install -m 0755 "$source_file" "$app" 63install -m 0755 "$source_file" "$app"
49 64
50cat > "$icon_dir/zagan-bet.svg" <<'ICON' 65cat > "$icon_dir/zagan-bet.svg" <<'ICON'
51__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>
52ICON 72ICON
53 73
54cat > "$desktop_dir/zagan-bet.desktop" <<DESKTOP 74cat > "$desktop_dir/zagan-bet.desktop" <<DESKTOP
@@ -70,7 +90,7 @@ if 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 90 gtk-update-icon-cache -q "$data_dir/icons/hicolor" >/dev/null 2>&1 || true
71fi 91fi
72 92
73say "Installed Zagan-Bet $VERSION to $app" 93say "Installed Zagan-Bet $version to $app"
74say "A launcher was added to your applications menu." 94say "A launcher was added to your applications menu."
75case ":$PATH:" in 95case ":$PATH:" in
76 *":$bin_dir:"*) ;; 96 *":$bin_dir:"*) ;;