-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
91 lines (77 loc) · 3.16 KB
/
install.sh
File metadata and controls
91 lines (77 loc) · 3.16 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
#!/bin/bash
# ╔═══════════════════════════════════════════════════════════╗
# ║ Ractor Installer ║
# ║ https://github.com/elezaio-linux/Ractor ║
# ╚═══════════════════════════════════════════════════════════╝
set -euo pipefail
RACTOR_URL="https://raw.githubusercontent.com/elezaio-linux/Ractor/refs/heads/main/ractor.sh"
if [[ -t 1 ]]; then
LGREEN='\033[1;32m'; CYAN='\033[0;36m'
LRED='\033[1;31m'; YELLOW='\033[1;33m'
BOLD='\033[1m'; NC='\033[0m'
else
LGREEN=''; CYAN=''; LRED=''; YELLOW=''; BOLD=''; NC=''
fi
msg() { echo -e "${LGREEN}==>${NC}${BOLD} $*${NC}"; }
info() { echo -e "${CYAN} ->${NC} $*"; }
success() { echo -e "${CYAN} ✓${NC} $*"; }
error() { echo -e "${LRED}[✗] Error:${NC} $*" >&2; exit 1; }
warn() { echo -e "${YELLOW}[!]${NC} $*"; }
# ───────── CHECK DEPS ─────────
for dep in curl tar jq; do
command -v "$dep" &>/dev/null || {
warn "Missing dependency: $dep"
if command -v apt-get &>/dev/null; then
info "Installing $dep..."
sudo apt-get install -y "$dep" || error "Could not install $dep"
else
error "$dep is required. Please install it manually."
fi
}
done
# ───────── INSTALL DIR ─────────
if [[ $EUID -eq 0 ]]; then
INSTALL_DIR="/usr/local/bin"
else
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
fi
INSTALL_PATH="$INSTALL_DIR/ractor"
# ───────── DOWNLOAD ─────────
msg "Installing Ractor..."
info "Downloading latest version..."
tmp_file=$(mktemp /tmp/ractor.XXXXXX)
curl -fsSL "$RACTOR_URL" -o "$tmp_file" || {
rm -f "$tmp_file"
error "Failed to download Ractor"
}
VERSION=$(grep '^RACTOR_VERSION=' "$tmp_file" | cut -d'"' -f2 || echo "unknown")
chmod +x "$tmp_file"
mv "$tmp_file" "$INSTALL_PATH"
success "Ractor v$VERSION installed to $INSTALL_PATH"
# ───────── PATH CHECK ─────────
# Detect shell config
SHELL_RC=""
if [[ -f "$HOME/.zshrc" ]]; then
SHELL_RC="$HOME/.zshrc"
elif [[ -f "$HOME/.bashrc" ]]; then
SHELL_RC="$HOME/.bashrc"
fi
# Only add PATH if not already present in rc file
if [[ -n "$SHELL_RC" ]] && ! grep -q "$INSTALL_DIR" "$SHELL_RC" 2>/dev/null; then
echo "" >> "$SHELL_RC"
echo "# Ractor" >> "$SHELL_RC"
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$SHELL_RC"
success "Added $INSTALL_DIR to PATH in $SHELL_RC"
warn "Run: source $SHELL_RC"
elif [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
warn "Run: source $SHELL_RC (to load PATH)"
fi
# ───────── DONE ─────────
echo
echo -e "${BOLD}${CYAN}Ractor v$VERSION is ready!${NC}"
echo
echo -e " ${BOLD}Usage:${NC} ractor help"
echo -e " ${BOLD}Install:${NC} ractor install <package>"
echo -e " ${BOLD}Update:${NC} ractor self-update"
echo