forked from tailcallhq/tailcall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·69 lines (56 loc) · 1.98 KB
/
install.sh
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
#!/bin/bash
set -e
# Get version argument from command line
VERSION=${1:-"latest"}
BASE_URL="https://github.com/tailcallhq/tailcall/releases/download"
if [ "$VERSION" = "latest" ]; then
VERSION=$(curl --silent "https://api.github.com/repos/tailcallhq/tailcall/releases/latest" | jq -r '.tag_name')
fi
# Determine OS and architecture to get the correct URL
if [[ "$OSTYPE" == "darwin"* ]]; then
OS="apple-darwin"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="unknown-linux-gnu"
elif [[ "$OSTYPE" == "linux-musl"* ]]; then
OS="unknown-linux-musl"
else
OS="unknown"
fi
if [[ "$(uname -m)" == "x86_64" ]]; then
ARCH="x86_64"
elif [[ "$(uname -m)" == "i686" ]]; then
ARCH="i686"
elif [[ "$(uname -m)" == "aarch64" ]] || [[ "$(uname -m)" == "arm64" ]]; then
ARCH="aarch64"
else
ARCH="unknown"
fi
# Ensure we recognize the OS and architecture
if [[ "$OS" == "unknown" ]] || [[ "$ARCH" == "unknown" ]]; then
echo "Unsupported OS or architecture."
exit 1
fi
# Derive download URL based on detected OS and architecture
URL="$BASE_URL/$VERSION/tailcall-${ARCH}-${OS}"
# Prepare versioned directory for download
INSTALL_DIR="$HOME/.tailcall/lib/$VERSION"
mkdir -p "$INSTALL_DIR"
# Download the executable directly into the versioned directory
curl -#Lo "$INSTALL_DIR/tailcall-${OS}-${ARCH}" "$URL"
chmod +x "$INSTALL_DIR/tailcall-${OS}-${ARCH}"
# Create symlinks in ~/.tailcall/bin
mkdir -p "$HOME/.tailcall/bin"
ln -sf "$INSTALL_DIR/tailcall-${OS}-${ARCH}" "$HOME/.tailcall/bin/tailcall"
# Determine which shell the user is running and which profile file to update
if [[ "$SHELL" == *"zsh"* ]]; then
SHELL_PROFILE="$HOME/.zshrc"
elif [[ "$SHELL" == *"bash"* ]]; then
if [ -f "$HOME/.bash_profile" ]; then
SHELL_PROFILE="$HOME/.bash_profile"
else
SHELL_PROFILE="$HOME/.bashrc"
fi
fi
# Provide instructions to add ~/.tailcall/bin to PATH in shell profile
echo "Installation complete. Please add the following line to your $SHELL_PROFILE:"
echo 'export PATH="$HOME/.tailcall/bin:$PATH"'