-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
73 lines (66 loc) · 2.55 KB
/
Copy pathinstall.sh
File metadata and controls
73 lines (66 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
# Universal DIG installer bootstrap (macOS / Linux) — the one-line install.
#
# curl -fsSL https://raw.githubusercontent.com/DIG-Network/dig-installer/main/install.sh | sh
#
# Downloads the dig-installer binary for this OS/arch from the latest
# DIG-Network/dig-installer release, then runs it. By default the installer is a
# THIN SHIM that resolves + installs the latest digstore CLI (the $DIG content
# tooling) for this OS/arch and adds it to PATH. Pass installer flags after
# `-s --` to also install other components:
#
# # ALSO install + start the dig-node local node as a service (+ dig.local):
# curl -fsSL .../install.sh | sh -s -- --with-dig-node
# # ALSO download the DIG Browser native installer:
# curl -fsSL .../install.sh | sh -s -- --with-browser
# # Everything, machine-readable result:
# curl -fsSL .../install.sh | sh -s -- --with-dig-node --with-browser --json
#
# Flags are forwarded verbatim to dig-installer (see `dig-installer --help` /
# `dig-installer --help-json`).
set -eu
REPO="DIG-Network/dig-installer"
STEM="dig-installer"
say() { printf '%s\n' "$*"; }
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
have() { command -v "$1" >/dev/null 2>&1; }
# --- resolve OS/arch slug (must match the release matrix out_names) ---------
os="$(uname -s)"
arch="$(uname -m)"
case "$os" in
Linux) os_slug="linux-x64" ;;
Darwin)
case "$arch" in
arm64|aarch64) os_slug="macos-arm64" ;;
*) os_slug="macos-x64" ;;
esac ;;
*) die "unsupported OS: $os (use install.ps1 on Windows)" ;;
esac
# --- discover the latest release tag ---------------------------------------
api="https://api.github.com/repos/${REPO}/releases/latest"
if have curl; then
body="$(curl -fsSL "$api")"
elif have wget; then
body="$(wget -qO- "$api")"
else
die "need curl or wget to download"
fi
tag="$(printf '%s' "$body" | sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' | head -n1)"
[ -n "$tag" ] || die "could not determine latest $REPO release tag"
ver="${tag#v}"
asset="${STEM}-${ver}-${os_slug}"
url="https://github.com/${REPO}/releases/download/${tag}/${asset}"
# --- download the installer binary -----------------------------------------
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
bin="${tmp}/${STEM}"
say "Downloading ${STEM} ${ver} (${os_slug})…"
if have curl; then
curl -fsSL "$url" -o "$bin" || die "download failed: $url"
else
wget -qO "$bin" "$url" || die "download failed: $url"
fi
chmod +x "$bin"
# --- run it, forwarding any extra flags ------------------------------------
say "Running ${STEM} $*"
exec "$bin" "$@"