-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
74 lines (61 loc) · 1.82 KB
/
install.sh
File metadata and controls
74 lines (61 loc) · 1.82 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
#!/bin/sh
set -e
REPO="sunilmallya/agentdiff"
# Detect OS and architecture
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS" in
Darwin) OS_TAG="darwin" ;;
Linux) OS_TAG="linux" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
case "$ARCH" in
arm64|aarch64) ARCH_TAG="arm64" ;;
x86_64) ARCH_TAG="x86_64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
BINARY="agentdiff-${OS_TAG}-${ARCH_TAG}"
# Get latest release tag
LATEST=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
if [ -z "$LATEST" ]; then
echo "Error: could not determine latest release"
exit 1
fi
URL="https://github.com/${REPO}/releases/download/${LATEST}/${BINARY}"
echo "agentdiff ${LATEST} (${OS_TAG}/${ARCH_TAG})"
echo ""
echo "Where do you want to install?"
echo " 1) /usr/local/bin (recommended, may need sudo)"
echo " 2) ~/.local/bin"
echo " 3) Custom path"
printf "Choice [1]: "
read -r choice </dev/tty
case "$choice" in
2) INSTALL_DIR="${HOME}/.local/bin" ;;
3) printf "Path: "; read -r INSTALL_DIR </dev/tty ;;
*) INSTALL_DIR="/usr/local/bin" ;;
esac
echo "Installing to ${INSTALL_DIR}..."
mkdir -p "$INSTALL_DIR"
if [ -w "$INSTALL_DIR" ]; then
curl -fsSL "$URL" -o "$INSTALL_DIR/agentdiff"
else
sudo curl -fsSL "$URL" -o "$INSTALL_DIR/agentdiff"
fi
chmod +x "$INSTALL_DIR/agentdiff"
# Check if install dir is in PATH
case ":$PATH:" in
*":$INSTALL_DIR:"*)
echo "Installed: $INSTALL_DIR/agentdiff"
;;
*)
echo ""
echo "Installed: $INSTALL_DIR/agentdiff"
echo ""
echo ">>> $INSTALL_DIR is not in your PATH. Run this to fix:"
echo ""
echo " echo 'export PATH=\"$INSTALL_DIR:\$PATH\"' >> ~/.zshrc && source ~/.zshrc"
echo ""
echo " (Use ~/.bashrc instead if you use bash)"
;;
esac