-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
49 lines (41 loc) · 1.2 KB
/
Copy pathinstall.sh
File metadata and controls
49 lines (41 loc) · 1.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
#!/bin/sh
set -e
# Detect OS and Architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$OS" in
linux)
ASSET="RouteCode-cli-linux-x86_64"
;;
darwin)
if [ "$ARCH" = "arm64" ]; then
ASSET="RouteCode-cli-macos-arm64"
else
ASSET="RouteCode-cli-macos-x86_64"
fi
;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac
echo "Downloading RouteCode for $OS ($ARCH)..."
# Get latest version tag
LATEST_TAG=$(curl -s https://api.github.com/repos/anasx07/routecode/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST_TAG" ]; then
echo "Failed to fetch latest release tag. Defaulting to main branch (not recommended)."
exit 1
fi
URL="https://github.com/anasx07/routecode/releases/download/$LATEST_TAG/$ASSET"
INSTALL_DIR="/usr/local/bin"
if [ ! -w "$INSTALL_DIR" ]; then
echo "Install directory $INSTALL_DIR is not writable. Trying with sudo..."
curl -L "$URL" -o routecode
chmod +x routecode
sudo mv routecode "$INSTALL_DIR/routecode"
else
curl -L "$URL" -o "$INSTALL_DIR/routecode"
chmod +x "$INSTALL_DIR/routecode"
fi
echo "RouteCode installed successfully to $INSTALL_DIR/routecode"
routecode --version