-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·78 lines (64 loc) · 2.19 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
70
71
72
73
74
75
76
#!/bin/sh
set -e
# Color definitions
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BOLD='\033[1m'
NC='\033[0m' # No Color
# Determine architecture
arch=$(uname -m)
case $arch in
x86_64)
arch="x86_64"
;;
aarch64|arm64)
arch="aarch64"
;;
*)
echo "${RED}Unsupported architecture: $arch${NC}"
exit 1
;;
esac
# Determine OS
os=$(uname -s | tr '[:upper:]' '[:lower:]')
case $os in
linux)
os="unknown-linux-gnu"
;;
darwin)
os="apple-darwin"
;;
*)
echo "${RED}Unsupported OS: $os${NC}"
exit 1
;;
esac
# Fetch latest release version
latest_version=$(curl -sL https://api.github.com/repos/BBai-Tips/bbai/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
# echo "Latest version: $latest_version"
# Download URL
download_url="https://github.com/BBai-Tips/bbai/releases/download/${latest_version}/bbai-${arch}-${os}-${latest_version}.tar.gz"
# echo "Download URL: $download_url"
# Create a temporary directory
temp_dir=$(mktemp -d)
# echo "Temporary directory: $temp_dir"
trap 'rm -rf "$temp_dir"' EXIT
# Download and extract the tarball
echo "${YELLOW}Downloading BBai ${latest_version} for ${arch}-${os}...${NC}"
curl -sL "$download_url" -o "$temp_dir/bbai.tar.gz"
# echo "Download complete. File size: $(wc -c < "$temp_dir/bbai.tar.gz") bytes"
# echo "File type: $(file "$temp_dir/bbai.tar.gz")"
echo "${YELLOW}Extracting archive...${NC}"
tar xzf "$temp_dir/bbai.tar.gz" -C "$temp_dir"
# List contents of temp directory
# echo "Contents of $temp_dir:"
# ls -la "$temp_dir"
# Make binaries executable
chmod +x "$temp_dir/bbai" "$temp_dir/bbai-api"
# Install binaries
echo "${YELLOW}Installing 'bbai' and 'bbai-api' to /usr/local/bin...${NC}"
echo "${RED}Note: This step requires sudo access. You may be prompted for your password.${NC}"
sudo mv "$temp_dir/bbai" "$temp_dir/bbai-api" /usr/local/bin/
echo "${YELLOW}'bbai' and 'bbai-api' have been successfully installed to /usr/local/bin/${NC}"
echo "${GREEN}You can now run '${BOLD}bbai init${NC}${GREEN}' from a project directory, and then run '${BOLD}bbai start${NC}${GREEN}' (or '${BOLD}bbai chat${NC}${GREEN}').${NC}"