Anto
·
2026-01-04
stubdl
Bash
1#!/bin/sh
2
3ARCH="$(uname -m)"
4case "$ARCH" in
5 x86_64|amd64) ARCH="amd64" ;;
6 aarch64|arm64) ARCH="arm64" ;;
7 riscv64) ARCH="riscv64" ;;
8 loongarch64|loong64) ARCH="loong64" ;;
9 *) echo "dbin: unsupported architecture: $ARCH" >&2; exit 1 ;;
10esac
11
12DEST="${TMPDIR:-/tmp}/.dbin_$ARCH"
13URL="https://github.com/xplshn/dbin/releases/download/1.7/dbin_$ARCH"
14[ "$ARCH" = "amd64" ] || [ "$ARCH" = "arm64" ] && URL="$URL.upx"
15
16[ "$1" = "--install" ] && { DEST="$2"; shift 2; }
17
18if [ ! -x "$DEST" ]; then
19 if command -v curl >/dev/null 2>&1; then
20 curl -fsSL "$URL" -o "$DEST" || exit 1
21 elif command -v wget >/dev/null 2>&1; then
22 wget -q "$URL" -O "$DEST" || exit 1
23 else
24 echo "dbin: curl or wget required" >&2; exit 1
25 fi
26 chmod +x "$DEST"
27 [ "$1" = "--install" ] && { echo "dbin: installed to $DEST"; exit 0; }
28fi
29
30exec "$DEST" "$@"