-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·85 lines (71 loc) · 2.05 KB
/
install.sh
File metadata and controls
executable file
·85 lines (71 loc) · 2.05 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
#!/bin/bash
set -e
REPO="DennySORA/Ops-Tools"
BINARY_NAME="ops-tools"
INSTALL_DIR="$HOME/.local/bin"
# Detect OS and Arch
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS" in
Linux)
OS_TYPE="linux"
;;
Darwin)
OS_TYPE="macos"
;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac
case "$ARCH" in
x86_64)
ARCH_TYPE="x86_64"
;;
arm64|aarch64)
if [ "$OS" = "Darwin" ]; then
ARCH_TYPE="arm64"
else
echo "Unsupported Architecture: $ARCH on Linux (only x86_64 supported for now)"
exit 1
fi
;;
*)
echo "Unsupported Architecture: $ARCH"
exit 1
;;
esac
ASSET_NAME="${BINARY_NAME}-${OS_TYPE}-${ARCH_TYPE}.tar.gz"
echo "Detected platform: $OS_TYPE $ARCH_TYPE"
echo "Looking for asset: $ASSET_NAME"
# Get latest release URL
LATEST_RELEASE_URL="https://api.github.com/repos/$REPO/releases/latest"
echo "Fetching latest release info..."
RELEASE_DATA=$(curl -s $LATEST_RELEASE_URL)
DOWNLOAD_URL=$(echo "$RELEASE_DATA" | grep "browser_download_url" | grep "$ASSET_NAME" | cut -d '"' -f 4)
if [ -z "$DOWNLOAD_URL" ]; then
echo "Error: Could not find download URL for $ASSET_NAME in latest release."
echo "Please check if a release exists at https://github.com/$REPO/releases"
exit 1
fi
echo "Downloading from: $DOWNLOAD_URL"
curl -L -o "/tmp/$ASSET_NAME" "$DOWNLOAD_URL"
echo "Extracting..."
tar -xzf "/tmp/$ASSET_NAME" -C /tmp/
echo "Installing to $INSTALL_DIR..."
mkdir -p "$INSTALL_DIR"
mv "/tmp/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
rm "/tmp/$ASSET_NAME"
echo "Installation complete!"
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo ""
echo "WARNING: $INSTALL_DIR is not in your PATH."
echo "Add the following line to your shell config (~/.bashrc, ~/.zshrc, etc.):"
echo ""
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
echo "Then restart your shell or run: source ~/.bashrc"
else
echo "Try running '$BINARY_NAME --help'"
fi