-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·81 lines (70 loc) · 2 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·81 lines (70 loc) · 2 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
#!/bin/sh
set -eu
# Socket Patch installer
# Usage: curl -fsSL https://raw.githubusercontent.com/SocketDev/socket-patch/main/scripts/install.sh | sh
REPO="SocketDev/socket-patch"
BINARY="socket-patch"
# Detect platform
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS" in
Darwin)
case "$ARCH" in
arm64) TARGET="aarch64-apple-darwin" ;;
x86_64) TARGET="x86_64-apple-darwin" ;;
*) echo "Error: unsupported architecture: $ARCH" >&2; exit 1 ;;
esac
;;
Linux)
case "$ARCH" in
x86_64) TARGET="x86_64-unknown-linux-musl" ;;
aarch64) TARGET="aarch64-unknown-linux-gnu" ;;
armv7l) TARGET="arm-unknown-linux-gnueabihf" ;;
i686) TARGET="i686-unknown-linux-gnu" ;;
*) echo "Error: unsupported architecture: $ARCH" >&2; exit 1 ;;
esac
;;
*)
echo "Error: unsupported OS: $OS" >&2
exit 1
;;
esac
# Detect downloader
if command -v curl >/dev/null 2>&1; then
download() { curl -fsSL -o "$1" "$2"; }
elif command -v wget >/dev/null 2>&1; then
download() { wget -qO "$1" "$2"; }
else
echo "Error: curl or wget is required" >&2
exit 1
fi
# Pick install directory
if [ -w /usr/local/bin ]; then
INSTALL_DIR="/usr/local/bin"
else
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "$INSTALL_DIR"
fi
# Create temp dir with cleanup
TMPDIR="$(mktemp -d)"
trap 'rm -rf "$TMPDIR"' EXIT
# Download and extract
URL="https://github.com/${REPO}/releases/latest/download/${BINARY}-${TARGET}.tar.gz"
echo "Downloading ${BINARY} for ${TARGET}..."
download "$TMPDIR/${BINARY}.tar.gz" "$URL"
tar xzf "$TMPDIR/${BINARY}.tar.gz" -C "$TMPDIR"
# Install
install -m 755 "$TMPDIR/${BINARY}" "${INSTALL_DIR}/${BINARY}"
echo "Installed ${BINARY} to ${INSTALL_DIR}/${BINARY}"
# Print version
"${INSTALL_DIR}/${BINARY}" --version 2>/dev/null || true
# Warn if not on PATH
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) ;;
*)
echo ""
echo "Warning: ${INSTALL_DIR} is not on your PATH."
echo "Add it with:"
echo " export PATH=\"${INSTALL_DIR}:\$PATH\""
;;
esac