-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·123 lines (109 loc) · 4.27 KB
/
install.sh
File metadata and controls
executable file
·123 lines (109 loc) · 4.27 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
#!/usr/bin/env bash
set -euo pipefail
# ============================================================
# ragcli — One-Command Installer
# ragcli: a friendly interface to Oracle Autonomous 26ai
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/jasperan/ragcli/main/install.sh | bash
#
# Override install location:
# PROJECT_DIR=/opt/myapp curl -fsSL ... | bash
# ============================================================
REPO_URL="https://github.com/jasperan/ragcli.git"
PROJECT="ragcli"
BRANCH="main"
INSTALL_DIR="${PROJECT_DIR:-$(pwd)/$PROJECT}"
# ── Colors ──────────────────────────────────────────────────
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
info() { echo -e "${BLUE}→${NC} $1"; }
success() { echo -e "${GREEN}✓${NC} $1"; }
warn() { echo -e "${YELLOW}!${NC} $1"; }
fail() { echo -e "${RED}✗ $1${NC}"; exit 1; }
command_exists() { command -v "$1" &>/dev/null; }
print_banner() {
echo ""
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BOLD} ragcli${NC}"
echo -e " ragcli: a friendly interface to Oracle Autonomous 26ai"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
}
clone_repo() {
if [ -d "$INSTALL_DIR" ]; then
warn "Directory $INSTALL_DIR already exists"
info "Pulling latest changes..."
(cd "$INSTALL_DIR" && git pull origin "$BRANCH" 2>/dev/null) || true
else
info "Cloning repository..."
git clone --depth 1 -b "$BRANCH" "$REPO_URL" "$INSTALL_DIR" || fail "Clone failed. Check your internet connection."
fi
success "Repository ready at $INSTALL_DIR"
}
check_prereqs() {
info "Checking prerequisites..."
command_exists git || fail "Git is required — https://git-scm.com/"
success "Git $(git --version | cut -d' ' -f3)"
PYTHON=""
for cmd in python3 python; do
if command_exists "$cmd"; then
ver=$("$cmd" -c 'import sys; v=sys.version_info; print(f"{v.major}.{v.minor}")' 2>/dev/null) || continue
major=${ver%%.*}
minor=${ver##*.}
if [ "$major" -gt 3 ] || { [ "$major" -eq 3 ] && [ "$minor" -ge 9 ]; }; then
PYTHON="$cmd"
break
fi
fi
done
[ -n "$PYTHON" ] || fail "Python 3.9+ is required — https://www.python.org/downloads/"
success "Python $($PYTHON --version | cut -d' ' -f2)"
if command_exists docker; then
success "Docker $(docker --version | cut -d' ' -f3 | tr -d ',')"
else
warn "Docker not found — install from https://docs.docker.com/get-docker/"
fi
}
install_deps() {
cd "$INSTALL_DIR"
if [ ! -d ".venv" ]; then
info "Creating virtual environment..."
$PYTHON -m venv .venv
else
info "Using existing virtual environment..."
fi
# shellcheck disable=SC1091
source .venv/bin/activate
info "Installing dependencies..."
python -m pip install --upgrade pip -q
python -m pip install -e . -q
success "Dependencies installed"
}
main() {
print_banner
check_prereqs
clone_repo
install_deps
print_done
}
print_done() {
echo ""
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e " ${BOLD}Installation complete!${NC}"
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e " ${BOLD}Location:${NC} $INSTALL_DIR"
echo -e " ${BOLD}Activate:${NC} source $INSTALL_DIR/.venv/bin/activate"
echo -e " ${BOLD}Check:${NC} ragcli doctor"
echo -e " ${BOLD}Run API:${NC} ragcli api --port 8000"
echo ""
echo -e " ${BOLD}Note:${NC} Oracle Database connection required — see README for setup"
echo ""
}
main "$@"