-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·89 lines (80 loc) · 2.82 KB
/
install.sh
File metadata and controls
executable file
·89 lines (80 loc) · 2.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# This script installs the latest cli release from the GitHub repository
# Let's start by fetching the latest release information
REPO_BASE="Jelly-RDF/cli"
REPO="https://api.github.com/repos/$REPO_BASE/releases/latest"
RELEASE_INFO=$(curl -s $REPO)
# And let's get the tag name of the latest release
TAG_NAME=$(echo $RELEASE_INFO | grep -o '"tag_name": "[^"]*' | sed 's/"tag_name": "//')
if [ -z "$TAG_NAME" ]; then
echo "Error: Could not fetch the latest release tag name."
return 1
exit 1
fi
# Check the operating system and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
# Map the architecture to the appropriate binary name
case $OS in
linux) BINARY_NAME="jelly-cli-linux" ;;
darwin) BINARY_NAME="jelly-cli-mac" ;;
*) echo "Unsupported operating system: $OS"; exit 1 ;;
esac
# Append the architecture to the binary name but yell for cases we don't support
case $ARCH in
x86_64) ARCH_NAME="-x86_64"
# check that os not darwin here
if [ "$OS" = "darwin" ]; then
echo "Unsupported architecture: $ARCH on macOS"
return 1
exit 1
fi;;
aarch64)
ARCH_NAME="-arm64" ;;
arm64)
ARCH_NAME="-arm64" ;;
*) echo "Unsupported architecture: $ARCH"
return 1
exit 1
;;
esac
# Check the installation directory
INSTALL_DIR="$HOME/.local/bin"
if [ ! -d "$INSTALL_DIR" ]; then
echo "Creating installation directory: $INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
fi
# Download the binary
DOWNLOAD_URL="https://github.com/$REPO_BASE/releases/download/$TAG_NAME/$BINARY_NAME$ARCH_NAME.gz"
echo "Downloading $BINARY_NAME from $DOWNLOAD_URL"
curl -L "$DOWNLOAD_URL" -o "$INSTALL_DIR/jelly-cli.gz"
gzip -d "$INSTALL_DIR/jelly-cli.gz"
CONTENT=$(wc -c "$INSTALL_DIR/jelly-cli" | awk '{print $1}')
if [ $CONTENT -lt 500 ]; then
echo "Error: Failed to download the binary from $DOWNLOAD_URL"
return 1
exit 1
fi
chmod +x "$INSTALL_DIR/jelly-cli"
# Ensure that the installation directory is in the PATH
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
echo "Adding $INSTALL_DIR to PATH"
# Add the binary to the PATH for the current session
export PATH="$PATH:$INSTALL_DIR"
# Check shell config file from bash and zsh
if expr "$SHELL" : '.*zsh' >/dev/null; then
echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$HOME/.zshrc"
elif expr "$SHELL" : '.*bash' >/dev/null; then
echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$HOME/.bashrc"
fi
fi
# Silently install completions
nohup jelly-cli completions install > /dev/null 2>&1
eval "$(jelly-cli completions install --env)"
# Link the binary to the installation directory
if [ -f "$INSTALL_DIR/jelly-cli" ]; then
echo "Installation successful! You can now use Jelly CLI by running 'jelly-cli'."
else
echo "Error: Installation failed. The binary was not found in the installation directory."
exit 1
fi