-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·97 lines (77 loc) · 2.44 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·97 lines (77 loc) · 2.44 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
#!/bin/sh
set -e
# Orc installer script
# Usage: curl -fsSL https://raw.githubusercontent.com/randalmurphal/orc/main/install.sh | sh
REPO="randalmurphal/orc"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
# Detect OS and architecture
detect_platform() {
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64|amd64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
case "$OS" in
linux) OS="linux" ;;
darwin) OS="darwin" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
PLATFORM="${OS}-${ARCH}"
}
# Get latest version from GitHub
get_latest_version() {
if command -v curl >/dev/null 2>&1; then
VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
elif command -v wget >/dev/null 2>&1; then
VERSION=$(wget -qO- "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
else
echo "Error: curl or wget required"
exit 1
fi
if [ -z "$VERSION" ]; then
echo "Error: Could not determine latest version"
exit 1
fi
}
# Download and install
install() {
FILENAME="orc-${VERSION}-${PLATFORM}.tar.gz"
URL="https://github.com/${REPO}/releases/download/${VERSION}/${FILENAME}"
echo "Installing orc ${VERSION} for ${PLATFORM}..."
# Create install directory
mkdir -p "$INSTALL_DIR"
# Download and extract
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
echo "Downloading ${URL}..."
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$URL" -o "$TMP_DIR/$FILENAME"
else
wget -q "$URL" -O "$TMP_DIR/$FILENAME"
fi
echo "Extracting..."
tar -xzf "$TMP_DIR/$FILENAME" -C "$TMP_DIR"
# Install binary
mv "$TMP_DIR/orc-${VERSION}-${PLATFORM}" "$INSTALL_DIR/orc"
chmod +x "$INSTALL_DIR/orc"
echo ""
echo "orc ${VERSION} installed to ${INSTALL_DIR}/orc"
# Check if in PATH
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
echo ""
echo "Add to your PATH:"
echo " export PATH=\"\$PATH:${INSTALL_DIR}\""
echo ""
echo "Add this to your ~/.bashrc, ~/.zshrc, or shell config."
fi
echo ""
echo "Run 'orc --help' to get started."
}
main() {
detect_platform
get_latest_version
install
}
main