#!/bin/sh set -eu repo="gigirassy/riptide" base="https://codeberg.org/$repo" green="$(printf '\033[1;32m')" red="$(printf '\033[1;31m')" blue="$(printf '\033[1;34m')" reset="$(printf '\033[0m')" info() { printf "%s[+]%s %s\n" "$green" "$reset" "$*" } step() { printf "%s[*]%s %s\n" "$blue" "$reset" "$*" } error() { printf "%s[-]%s %s\n" "$red" "$reset" "$*" >&2 } tmpdir="$(mktemp -d)" trap 'rm -rf "$tmpdir"' EXIT if command -v run0 >/dev/null 2>&1; then asroot="run0" elif command -v doas >/dev/null 2>&1; then asroot="doas" elif command -v sudo >/dev/null 2>&1; then asroot="sudo" else error "run0, doas, or sudo is required" exit 1 fi step "fetching latest release information..." release_page="$(curl -fsSL "$base/releases/latest")" version="$( printf '%s' "$release_page" | grep -oE '/releases/tag/[0-9]+\.[0-9]+\.[0-9]+' | head -n1 | sed 's|.*/||' )" [ -n "$version" ] || { error "failed to determine latest version!" exit 1 } checksum="$( printf '%s' "$release_page" | grep -E '^[a-f0-9]{64}[[:space:]]+riptide$' | awk '{print $1}' )" [ -n "$checksum" ] || { error "failed to locate checksum!" exit 1 } url="$base/releases/download/$version/riptide" info "latest version is $version!" step "downloading riptide..." curl -fsSL "$url" -o "$tmpdir/riptide" step "verifying checksum..." printf '%s %s\n' "$checksum" "$tmpdir/riptide" | sha256sum -c - >/dev/null info "checksum verified!" chmod 755 "$tmpdir/riptide" step "installing to /usr/local/bin/riptide" step "authentication may be required ($asroot)" "$asroot" install -m 755 "$tmpdir/riptide" /usr/local/bin/riptide info "riptide $version installed successfully <3 have a nice day"