-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·40 lines (36 loc) · 1.42 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·40 lines (36 loc) · 1.42 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
#!/bin/sh
# null-e CLI installer: curl -fsSL https://raw.githubusercontent.com/us/null-e/main/install.sh | sh
# Downloads the right prebuilt binary for your OS/arch from the latest GitHub release.
# ponytail: covers the platforms the release workflow ships; add a case if you add a target.
set -eu
REPO="us/null-e"
BIN="null-e"
# Install dir: first writable of these, else ~/.local/bin.
for d in /usr/local/bin "$HOME/.local/bin"; do
if [ -d "$d" ] && [ -w "$d" ]; then DEST="$d"; break; fi
done
DEST="${DEST:-$HOME/.local/bin}"
mkdir -p "$DEST"
os=$(uname -s); arch=$(uname -m)
case "$os" in
Darwin) o=darwin ;;
Linux) o=linux ;;
*) echo "unsupported OS: $os (Windows: download the .exe from the releases page)" >&2; exit 1 ;;
esac
case "$arch" in
arm64|aarch64) a=aarch64 ;;
x86_64|amd64) a=x86_64 ;;
*) echo "unsupported arch: $arch" >&2; exit 1 ;;
esac
asset="${BIN}-${o}-${a}.tar.gz"
url="https://github.com/${REPO}/releases/latest/download/${asset}"
echo "Downloading $asset ..."
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
curl -fsSL "$url" -o "$tmp/a.tgz" || { echo "download failed: $url" >&2; exit 1; }
tar -xzf "$tmp/a.tgz" -C "$tmp"
binpath=$(find "$tmp" -name "$BIN" -type f | head -1)
[ -n "$binpath" ] || { echo "binary '$BIN' not found in archive" >&2; exit 1; }
install -m 755 "$binpath" "$DEST/$BIN"
echo "Installed $BIN -> $DEST/$BIN"
case ":$PATH:" in *":$DEST:"*) : ;; *) echo "Note: add $DEST to your PATH." ;; esac