-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·104 lines (90 loc) · 3.53 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·104 lines (90 loc) · 3.53 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env sh
# runctl installer.
#
# Two modes, picked automatically:
# 1. If `cargo` is available, build and install from source (no env vars to
# set — it lands in ~/.cargo/bin, which is on PATH).
# 2. Otherwise download a prebuilt binary from the latest GitHub Release,
# verify its checksum, and place it on PATH.
#
# Usage:
# ./install.sh # from a clone, or piped: curl -fsSL .../install.sh | sh
# RUNCTL_VERSION=v0.1.0 ./install.sh # pin a release tag
# RUNCTL_INSTALL_DIR=~/.local/bin ./install.sh # override target dir (download mode)
# RUNCTL_FORCE_DOWNLOAD=1 ./install.sh # skip cargo, always download
set -eu
REPO="runify-dev/runctl"
BIN="runctl"
say() { printf '%s\n' "$*"; }
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
# --- Mode 1: build from source with cargo ------------------------------------
if [ "${RUNCTL_FORCE_DOWNLOAD:-0}" != "1" ] && command -v cargo >/dev/null 2>&1; then
if [ -f Cargo.toml ]; then
say "cargo found, source tree detected — installing from source..."
cargo install --path .
else
say "cargo found — installing from git ($REPO)..."
cargo install --git "https://github.com/$REPO"
fi
say "done. 'runctl' is in ~/.cargo/bin (ensure it is on your PATH)."
exit 0
fi
# --- Mode 2: download a prebuilt release -------------------------------------
OS=$(uname -s)
ARCH=$(uname -m)
case "$OS" in
Darwin)
case "$ARCH" in
arm64) ASSET="runctl-macos-arm64" ;;
x86_64) ASSET="runctl-macos-x64" ;;
*) die "unsupported macOS arch '$ARCH'" ;;
esac
;;
Linux)
die "no prebuilt Linux binary is published. Install Rust, then run: cargo install --git https://github.com/$REPO" ;;
*)
die "unsupported OS '$OS'. On Windows, download the .zip from https://github.com/$REPO/releases" ;;
esac
command -v curl >/dev/null 2>&1 || die "curl is required for download mode"
TAG="${RUNCTL_VERSION:-latest}"
if [ "$TAG" = "latest" ]; then
BASE="https://github.com/$REPO/releases/latest/download"
else
BASE="https://github.com/$REPO/releases/download/$TAG"
fi
FILE="$ASSET.tar.gz"
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
say "downloading $FILE ($TAG)..."
curl -fsSL "$BASE/$FILE" -o "$TMP/$FILE" || die "download failed (is the release published?)"
curl -fsSL "$BASE/$FILE.sha256" -o "$TMP/$FILE.sha256" 2>/dev/null || true
if [ -f "$TMP/$FILE.sha256" ]; then
say "verifying checksum..."
( cd "$TMP" && \
if command -v shasum >/dev/null 2>&1; then shasum -a 256 -c "$FILE.sha256";
else sha256sum -c "$FILE.sha256"; fi ) || die "checksum verification failed"
else
say "warning: no checksum file found, skipping verification"
fi
tar -xzf "$TMP/$FILE" -C "$TMP"
[ -f "$TMP/$BIN" ] || die "archive did not contain '$BIN'"
DIR="${RUNCTL_INSTALL_DIR:-/usr/local/bin}"
mkdir -p "$DIR" 2>/dev/null || true
if [ -w "$DIR" ]; then
install -m 755 "$TMP/$BIN" "$DIR/$BIN"
else
say "need elevated permission to write $DIR (using sudo)..."
sudo install -m 755 "$TMP/$BIN" "$DIR/$BIN"
fi
# macOS: clear the Gatekeeper quarantine flag set on downloaded files.
if [ "$OS" = "Darwin" ]; then
xattr -d com.apple.quarantine "$DIR/$BIN" 2>/dev/null || true
fi
say "installed $BIN to $DIR/$BIN"
case ":$PATH:" in
*":$DIR:"*) ;;
*) say "note: $DIR is not on your PATH — add it, e.g.: export PATH=\"$DIR:\$PATH\"" ;;
esac
if [ "$OS" = "Darwin" ]; then
say "macOS: grant Screen Recording + Accessibility before use — run 'runctl check'"
fi