#!/bin/sh set -eu umask 077 base='https://t.0q.lv' case "$(uname -s)" in Linux) os=linux;; Darwin) os=darwin;; *) echo 'Unsupported OS' >&2; exit 1;; esac case "$(uname -m)" in x86_64|amd64) arch=amd64;; aarch64|arm64) arch=arm64;; *) echo 'Unsupported CPU' >&2; exit 1;; esac tmp=$(mktemp -d "${TMPDIR:-/tmp}/0qlv.XXXXXXXX") pid='' cleanup() { if [ -n "$pid" ]; then kill -TERM "$pid" 2>/dev/null || true; wait "$pid" 2>/dev/null || true; fi rm -rf -- "$tmp" } trap cleanup EXIT trap 'exit 130' INT trap 'exit 143' TERM file="0qlv-$os-$arch" curl -fsSL "$base/bin/$file" -o "$tmp/$file" curl -fsSL "$base/bin/$file.sha256" -o "$tmp/checksum" expected=$(cut -d ' ' -f 1 "$tmp/checksum") if command -v sha256sum >/dev/null 2>&1; then actual=$(sha256sum "$tmp/$file" | cut -d ' ' -f 1) else actual=$(shasum -a 256 "$tmp/$file" | cut -d ' ' -f 1); fi [ "$expected" = "$actual" ] || { echo 'Download checksum mismatch' >&2; exit 1; } chmod 700 "$tmp/$file" "$tmp/$file" --server 'https://t.0q.lv' --mode terminal