-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
136 lines (117 loc) · 4.44 KB
/
install.sh
File metadata and controls
136 lines (117 loc) · 4.44 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
#!/bin/bash
# OpenZax Installer
# Usage: curl -fsSL https://raw.githubusercontent.com/zAxCoder/OpenZax/main/install.sh | bash
set -euo pipefail
REPO="zAxCoder/OpenZax"
INSTALL_DIR="$HOME/.openzax/bin"
BINARY_NAME="openzax"
echo ""
echo " ╔══════════════════════════════════╗"
echo " ║ OPENZAX INSTALLER ║"
echo " ╚══════════════════════════════════╝"
echo ""
# Detect OS and architecture
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
case "$OS" in
linux) TARGET_OS="linux" ;;
darwin) TARGET_OS="macos" ;;
*) echo " [!] Unsupported OS: $OS"; exit 1 ;;
esac
case "$ARCH" in
x86_64|amd64) TARGET_ARCH="x86_64" ;;
aarch64|arm64) TARGET_ARCH="aarch64" ;;
*) echo " [!] Unsupported arch: $ARCH"; exit 1 ;;
esac
echo " [*] Detected: ${TARGET_OS} ${TARGET_ARCH}"
# Get latest release tag
echo " [*] Finding latest release..."
LATEST=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')
if [ -z "$LATEST" ]; then
echo " [!] Could not find latest release."
echo " [*] Building from source instead..."
# Check for Rust
if ! command -v cargo &> /dev/null; then
echo " [!] Rust not found. Install: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
exit 1
fi
TMPDIR=$(mktemp -d)
echo " [*] Cloning repository..."
git clone --depth 1 "https://github.com/${REPO}.git" "$TMPDIR/openzax"
cd "$TMPDIR/openzax"
echo " [*] Building (this may take a few minutes)..."
cargo build -p openzax-cli --release
mkdir -p "$INSTALL_DIR"
cp "target/release/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
rm -rf "$TMPDIR"
else
echo " [*] Latest: $LATEST"
# Download binary
ASSET_NAME="openzax-${TARGET_OS}-${TARGET_ARCH}.tar.gz"
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${LATEST}/${ASSET_NAME}"
echo " [*] Downloading ${ASSET_NAME}..."
TMPDIR=$(mktemp -d)
if curl -fsSL -o "$TMPDIR/$ASSET_NAME" "$DOWNLOAD_URL" 2>/dev/null; then
echo " [OK] Downloaded"
tar -xzf "$TMPDIR/$ASSET_NAME" -C "$TMPDIR"
mkdir -p "$INSTALL_DIR"
cp "$TMPDIR/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
rm -rf "$TMPDIR"
else
echo " [!] Pre-built binary not available for your platform."
echo " [*] Building from source..."
if ! command -v cargo &> /dev/null; then
echo " [!] Rust not found. Install: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
exit 1
fi
git clone --depth 1 "https://github.com/${REPO}.git" "$TMPDIR/openzax"
cd "$TMPDIR/openzax"
echo " [*] Building (this may take a few minutes)..."
cargo build -p openzax-cli --release
mkdir -p "$INSTALL_DIR"
cp "target/release/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
rm -rf "$TMPDIR"
fi
fi
echo " [OK] Installed to $INSTALL_DIR/$BINARY_NAME"
# Add to PATH
SHELL_NAME="$(basename "$SHELL")"
PROFILE=""
case "$SHELL_NAME" in
bash) PROFILE="$HOME/.bashrc" ;;
zsh) PROFILE="$HOME/.zshrc" ;;
fish) PROFILE="$HOME/.config/fish/config.fish" ;;
*) PROFILE="$HOME/.profile" ;;
esac
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
if [ "$SHELL_NAME" = "fish" ]; then
echo "set -gx PATH \$PATH $INSTALL_DIR" >> "$PROFILE"
else
echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$PROFILE"
fi
echo " [OK] Added to PATH in $PROFILE"
echo ""
echo " >>> Restart your terminal or run: source $PROFILE"
else
echo " [OK] Already in PATH"
fi
echo ""
echo " Installation complete!"
echo ""
echo " Usage:"
echo " openzax Open the TUI"
echo " openzax --help Show all commands"
echo " openzax doctor Check system health"
echo ""
echo " Free API keys (no credit card):"
echo " OpenRouter: https://openrouter.ai/keys"
echo " Groq: https://console.groq.com"
echo " Cerebras: https://cloud.cerebras.ai"
echo ""
echo " Set your key and run:"
echo " export OPENROUTER_API_KEY=sk-or-v1-..."
echo " openzax"
echo ""