llm-hub/setup.sh

85 lines
2.6 KiB
Bash

#!/bin/bash
set -e
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
INSTALL_DIR="$(pwd)"
echo -e "${GREEN}🧠 Agentic AI Hub Setup${NC}"
echo "======================="
# Detect Proxmox LXC
if [ -f /proc/1/environ ] && grep -q "container=lxc" /proc/1/environ 2>/dev/null; then
echo -e "${YELLOW}✓ LXC container detected${NC}"
if ! grep -q "lxc.cgroup.relative" /etc/pve/lxc/*.conf 2>/dev/null; then
echo -e "${YELLOW}⚠️ Tip: For LXC with Docker, add to /etc/pve/lxc/XXX.conf:${NC}"
echo " lxc.cgroup.relative = 0"
echo " lxc.apparmor.profile = unconfined"
echo " lxc.cgroup.devices.allow = a"
fi
fi
# Check/install Docker
if ! command -v docker &> /dev/null; then
echo -e "${YELLOW}Installing Docker...${NC}"
curl -fsSL https://get.docker.com | sh
usermod -aG docker $USER || true
systemctl enable docker
systemctl start docker
fi
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo -e "${YELLOW}Installing Docker Compose...${NC}"
apt-get update && apt-get install -y docker-compose-plugin
fi
# Install Node.js for MCP
if ! command -v node &> /dev/null || [ "$(node -v | cut -d'v' -f2 | cut -d'.' -f1)" != "20" ]; then
echo -e "${YELLOW}Installing Node.js 20...${NC}"
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs
fi
# Install uv for Python tools
if ! command -v uv &> /dev/null; then
pip install uv || pip3 install uv
fi
# Create directories
echo -e "${BLUE}Creating directories...${NC}"
mkdir -p {data/{redis,chroma,agent/{sessions,code-server,open-webui},neo4j},workspace,logs}
mkdir -p services/{agent-core,mcpo}
# Set permissions
chown -R 1000:1000 workspace data || true
chmod +x *.sh scripts/*.sh 2>/dev/null || true
# Create .env if not exists
if [ ! -f .env ]; then
echo -e "${YELLOW}Creating .env file...${NC}"
cp .env.example .env
# Generate random keys
sed -i "s/MASTER_KEY=.*/MASTER_KEY=sk-agent-$(openssl rand -hex 8)/" .env
sed -i "s/WEBUI_SECRET_KEY=.*/WEBUI_SECRET_KEY=$(openssl rand -hex 32)/" .env
echo -e "${GREEN}✓ .env created. Edit it to add your API keys.${NC}"
fi
# Create workspace gitkeep
touch workspace/.gitkeep
echo ""
echo -e "${GREEN}✅ Setup complete!${NC}"
echo ""
echo "Next steps:"
echo "1. Edit .env file: nano .env"
echo "2. Add your API keys (Groq, Mistral, etc.)"
echo "3. Start services: ./start.sh"
echo ""
echo "Documentation:"
echo " - Setup: docs/SETUP.md"
echo " - API: docs/API.md"
echo " - Providers: docs/PROVIDERS.md"