-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-official.sh
More file actions
executable file
·194 lines (165 loc) · 6.41 KB
/
install-official.sh
File metadata and controls
executable file
·194 lines (165 loc) · 6.41 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/bin/bash
# Official Rax CLI Installer
# This script installs Rax CLI using apt or from source
set -e
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ 🚀 Rax CLI Installer ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
# Check if running as root
if [ "$EUID" -eq 0 ]; then
echo "❌ Please don't run this script as root"
echo " The script will use sudo when needed"
exit 1
fi
# Detect OS
if [ -f /etc/debian_version ]; then
OS="debian"
echo "✅ Detected Debian/Ubuntu system"
elif [ -f /etc/redhat-release ]; then
OS="rhel"
echo "⚠️ Detected RHEL/CentOS system (limited support)"
else
OS="unknown"
echo "⚠️ Unknown OS, will install from source"
fi
# Function to install from apt
install_from_apt() {
echo ""
echo "📦 Installing Rax CLI via apt..."
echo ""
# Add repository key
echo "🔑 Adding repository key..."
curl -fsSL https://raxcore-dev.github.io/rax-offline-cli/repo.key | \
sudo gpg --dearmor -o /usr/share/keyrings/rax-archive-keyring.gpg
# Add repository
echo "📂 Adding apt repository..."
echo "deb [signed-by=/usr/share/keyrings/rax-archive-keyring.gpg] https://raxcore-dev.github.io/rax-offline-cli/ /" | \
sudo tee /etc/apt/sources.list.d/rax.list
# Update and install
echo "🔄 Updating package list..."
sudo apt update
echo "📦 Installing Rax CLI..."
sudo apt install -y rax
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ ✅ Installation Complete! ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
echo "🎉 Rax CLI has been installed!"
echo ""
echo "Run 'rax' to start the setup and begin chatting!"
echo ""
}
# Function to install from source
install_from_source() {
echo ""
echo "🔨 Installing Rax CLI from source..."
echo ""
# Check for Rust
if ! command -v cargo &> /dev/null; then
echo "⚠️ Rust not found. Installing rustup..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
fi
# Build
echo "🔨 Building Rax CLI..."
cargo build --release
# Install
echo "📦 Installing binary..."
mkdir -p $HOME/.local/bin
cp target/release/rax $HOME/.local/bin/
chmod +x $HOME/.local/bin/rax
# Add to PATH if needed
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
echo ""
echo "⚠️ $HOME/.local/bin is not in your PATH"
echo ""
echo "Add this to your ~/.bashrc or ~/.zshrc:"
echo ""
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
# Offer to add automatically
read -p "Add it automatically? [Y/n] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] || [[ -z "$response" ]]; then
echo "" >> ~/.bashrc
echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" >> ~/.bashrc
echo "✅ Added to ~/.bashrc"
if [ -f ~/.zshrc ]; then
echo "" >> ~/.zshrc
echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" >> ~/.zshrc
echo "✅ Added to ~/.zshrc"
fi
echo ""
echo "Run 'source ~/.bashrc' or restart your terminal"
fi
fi
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ ✅ Installation Complete! ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
echo "🎉 Rax CLI has been installed!"
echo ""
echo "Run 'rax' to start the setup and begin chatting!"
echo ""
}
# Function to install from .deb file
install_from_deb() {
DEB_FILE="$1"
if [ ! -f "$DEB_FILE" ]; then
echo "❌ File not found: $DEB_FILE"
exit 1
fi
echo ""
echo "📦 Installing from local package..."
echo ""
sudo apt install -y ./ "$DEB_FILE"
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ ✅ Installation Complete! ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
echo "🎉 Rax CLI has been installed!"
echo ""
echo "Run 'rax' to start the setup and begin chatting!"
echo ""
}
# Main installation logic
if [ "$1" = "--local" ] && [ -n "$2" ]; then
install_from_deb "$2"
exit 0
fi
if [ "$OS" = "debian" ]; then
echo ""
echo "Installation methods:"
echo " 1) apt repository (recommended)"
echo " 2) local .deb file"
echo " 3) build from source"
echo ""
read -p "Choose installation method [1-3]: " method
case $method in
1)
install_from_apt
;;
2)
read -p "Enter path to .deb file: " deb_path
install_from_deb "$deb_path"
;;
3|*)
install_from_source
;;
esac
else
echo ""
echo "ℹ️ apt installation not available for your OS"
echo " Will install from source"
echo ""
read -p "Continue with source installation? [Y/n] " response
if [[ "$response" =~ ^([nN][oO]|[nN])$ ]]; then
echo "Installation cancelled."
exit 0
fi
install_from_source
fi