Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·83 lines (70 loc) · 3.21 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·83 lines (70 loc) · 3.21 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
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
# burn installer — one paste, zero dependencies beyond Node >= 22.5.
#
# curl -fsSL https://raw.githubusercontent.com/aashish254/burn/main/install.sh | bash
#
# What it does: downloads the pinned release tarball, verifies its SHA-256,
# installs the CLI under ~/.burn-cli, and links `burn` into ~/.local/bin.
# It touches nothing else. Uninstall: delete both directories.
set -euo pipefail
REPO="aashish254/burn"
VERSION="${BURN_VERSION:-v1.0.0}"
PREFIX="${BURN_HOME:-$HOME/.burn-cli}"
BIN_DIR="${BURN_BIN_DIR:-$HOME/.local/bin}"
BASE_URL="${BURN_BASE_URL:-https://github.com/$REPO/releases/download}"
die() { printf 'burn install: %s\n' "$1" >&2; exit 1; }
# --- prerequisites -----------------------------------------------------------
command -v curl >/dev/null 2>&1 || die "curl is required (or set BURN_BASE_URL to a local file:// mirror)"
TARBALL_TOOL=""
if command -v tar >/dev/null 2>&1; then TARBALL_TOOL="tar"; fi
[ -n "$TARBALL_TOOL" ] || die "tar is required"
if ! command -v node >/dev/null 2>&1; then
die "Node >= 22.5 not found. Install Node first (https://nodejs.org), then re-run this."
fi
NODE_OK=$(node -e 'const [M,m]=process.versions.node.split(".").map(Number);console.log(M>22||(M===22&&m>=5)?1:0)')
[ "$NODE_OK" = "1" ] || die "Node $(node --version) is too old — burn needs Node >= 22.5 (built-in node:sqlite)."
# --- download + checksum -----------------------------------------------------
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
NAME="burn-$VERSION.tar.gz"
printf 'downloading %s ...\n' "$NAME"
curl -fsSL --retry 3 -o "$TMP/$NAME" "$BASE_URL/$VERSION/$NAME" || die "download failed: $BASE_URL/$VERSION/$NAME"
curl -fsSL --retry 3 -o "$TMP/$NAME.sha256" "$BASE_URL/$VERSION/$NAME.sha256" || die "checksum download failed"
EXPECTED=$(awk '{print $1}' "$TMP/$NAME.sha256")
ACTUAL=""
if command -v shasum >/dev/null 2>&1; then
ACTUAL=$(shasum -a 256 "$TMP/$NAME" | awk '{print $1}')
elif command -v sha256sum >/dev/null 2>&1; then
ACTUAL=$(sha256sum "$TMP/$NAME" | awk '{print $1}')
else
die "need shasum or sha256sum to verify the download"
fi
[ "$ACTUAL" = "$EXPECTED" ] || die "checksum mismatch — refusing to install (got $ACTUAL, expected $EXPECTED)"
# --- install -----------------------------------------------------------------
mkdir -p "$TMP/src"
tar -xzf "$TMP/$NAME" -C "$TMP/src" --strip-components=1
[ -f "$TMP/src/src/cli.js" ] || die "tarball is missing src/cli.js"
rm -rf "$PREFIX.tmp"
mkdir -p "$(dirname "$PREFIX")"
mv "$TMP/src" "$PREFIX.tmp"
rm -rf "$PREFIX.old"
[ -d "$PREFIX" ] && mv "$PREFIX" "$PREFIX.old"
mv "$PREFIX.tmp" "$PREFIX"
rm -rf "$PREFIX.old"
mkdir -p "$BIN_DIR"
chmod +x "$PREFIX/src/cli.js"
ln -sf "$PREFIX/src/cli.js" "$BIN_DIR/burn"
# --- verify ------------------------------------------------------------------
VER="$("$BIN_DIR/burn" --version 2>/dev/null || true)"
[ -n "$VER" ] || die "installed binary failed to run"
PATH_NOTE=""
case ":$PATH:" in
*":$BIN_DIR:"*) ;;
*) PATH_NOTE="
note: $BIN_DIR is not on your PATH. Add this to your shell profile:
export PATH=\"$BIN_DIR:\$PATH\""
esac
printf '\n%s\n' "installed $VER to $PREFIX"
printf 'command linked at %s/burn\n' "$BIN_DIR"
printf '%s\n' "$PATH_NOTE"
printf '\npaste your first ledger:\n\n burn\n\n'