Files
homelab-configs/scripts/gitea-centralized-setup.sh
T
jgitta 290aedf82d Add complete homelab documentation and configurations
Documentation:
- OpenCode + LiteLLM integration guide
- LiteLLM complete setup with 16 models
- Gitea centralized configuration guide
- Testing procedures and verification
- API keys setup instructions

Configurations:
- OpenCode config pointing to LiteLLM
- Updated LiteLLM config with all models
- Nextcloud docker-compose template

Scripts:
- Gitea setup automation
- OpenCode testing script

Infrastructure:
- Gitea: 192.168.88.200:3000
- LiteLLM: 192.168.88.27:4000
- Nextcloud: 192.168.88.62
2026-04-25 10:56:21 -05:00

312 lines
9.4 KiB
Bash

#!/bin/bash
################################################################################
# Homelab Centralized Configuration via Gitea
#
# This script sets up a central homelab-configs repository and configures VMs
# to pull their configurations from Gitea instead of managing per-VM configs
################################################################################
set -e
# Configuration
GITEA_URL="http://192.168.88.200:3000"
GITEA_USER="jgitta"
REPO_NAME="homelab-configs"
LITELLM_API="http://192.168.88.27:4000"
MASTER_KEY="litellm-local-key-change-in-production"
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Homelab Centralized Configuration Setup via Gitea ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
# Step 1: Create local repository
echo -e "${BLUE}Step 1: Creating local homelab-configs repository...${NC}"
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
git init
git config user.name "$GITEA_USER"
git config user.email "$GITEA_USER@jgitta.com"
# Create directory structure
mkdir -p opencode litellm jellyfin
# Create OpenCode configuration
cat > opencode/config.json << 'EOF'
{
"apiProvider": "openai",
"apiBase": "http://192.168.88.27:4000",
"apiKey": "litellm-local-key-change-in-production",
"model": "gpt-4o",
"timeout": 600,
"maxTokens": 4096,
"verbose": true
}
EOF
echo -e "${GREEN}✅ Created opencode/config.json${NC}"
# Create LiteLLM reference
cat > litellm/README.md << 'EOF'
# LiteLLM API Gateway Reference
**Endpoint**: `http://192.168.88.27:4000`
**Master Authentication Key**: `litellm-local-key-change-in-production`
**Available Models** (16 total):
### OpenAI (5 models)
- gpt-4o (latest, multimodal)
- gpt-4o-mini (fast, cheap)
- gpt-4-turbo
- gpt-4
- gpt-3.5-turbo
### Claude (6 models)
- claude-3.5-sonnet (latest)
- claude-opus-4 (flagship)
- claude-3-opus
- claude-3-sonnet
- claude-3-haiku
- claude-2.1
### Gemini (5 models)
- gemini-2.0-flash (latest, ultra-fast)
- gemini-2.0-pro
- gemini-1.5-pro
- gemini-1.5-flash
- gemini-pro
**Configuration Location**: `/opt/litellm/config/litellm_config.yaml` (docker-server)
**Full Setup Guide**: See litellm-complete-setup.md in the main project folder
EOF
echo -e "${GREEN}✅ Created litellm/README.md${NC}"
# Create Jellyfin placeholder
cat > jellyfin/README.md << 'EOF'
# Jellyfin Configuration
Placeholder for Jellyfin service configuration.
This will be expanded as needed for centralized media server management.
EOF
echo -e "${GREEN}✅ Created jellyfin/README.md${NC}"
# Create main README
cat > README.md << 'EOF'
# 🏠 Homelab Centralized Configuration
Central Git repository for managing configurations across all homelab VMs and services.
## 📂 Repository Structure
```
homelab-configs/
├── opencode/ # OpenCode IDE configuration
│ └── config.json # Points to LiteLLM API gateway
├── litellm/ # LiteLLM API Gateway reference
│ └── README.md # Model list and endpoint details
├── jellyfin/ # Jellyfin media server configs
└── README.md # This file
```
## 🔄 How VMs Use These Configs
Each VM's docker-compose pulls configs from this repo at startup:
```yaml
services:
opencode:
image: opencode:latest
volumes:
- opencode-config:/root/.opencode
entrypoint: /bin/sh
command: |
-c "
git clone $GITEA_URL/$GITEA_USER/$REPO_NAME.git /tmp/configs
cp /tmp/configs/opencode/config.json /root/.opencode/config.json
exec opencode
"
volumes:
opencode-config:
```
## 📝 Central Configuration Management Pattern
### To Update a Config for All VMs:
1. **Edit the config here**:
```bash
nano opencode/config.json
```
2. **Commit and push**:
```bash
git add opencode/config.json
git commit -m "Update OpenCode to use gpt-4o-mini"
git push origin main
```
3. **Next time VMs restart**, they automatically pull the latest:
- Container starts
- Runs: `git clone ... && cp /tmp/configs/...`
- Gets latest config from this repo
- Starts service with new config
**No per-VM configuration needed!**
## 🌐 Infrastructure Reference
| Service | URL/IP | Purpose |
|---------|--------|---------|
| Gitea | http://192.168.88.200:3000 | Central config repository |
| LiteLLM API | http://192.168.88.27:4000 | Unified AI model gateway |
| Nextcloud (next) | 192.168.88.62 | Running OpenCode |
| Docker Server (siklos) | 192.168.88.27 | Hosting LiteLLM |
## 🚀 Key Features
- ✅ **Single Point of Configuration**: All VM configs in one repo
- ✅ **Version Control**: Track all changes via git
- ✅ **Zero Per-VM Setup**: Configs injected at container startup
- ✅ **Easy Rollbacks**: Just `git revert` and re-deploy
- ✅ **Centralized Secrets**: API keys managed in one place
## 📋 Adding New Services
To add a new service to centralized config:
1. Create directory: `mkdir -p servicename`
2. Add config file: `touch servicename/config.json`
3. Update the service's docker-compose to clone and use it
4. Commit and push
## 🔒 Security Notes
- API keys stored here should be masked/excluded from public repos
- Use `.env` files for sensitive data (not committed)
- Each service's docker-compose should fetch configs at runtime
- Rotate master keys periodically
## 📚 Documentation
- **LiteLLM Setup**: See `litellm-complete-setup.md`
- **Model Information**: See `litellm/README.md`
- **Testing Guide**: See `litellm-testing-verification.md`
---
**Last Updated**: April 25, 2026
**Maintained By**: jgitta
**Repository**: http://192.168.88.200:3000/jgitta/homelab-configs
EOF
echo -e "${GREEN}✅ Created README.md${NC}"
# Stage and commit
git add .
git commit -m "Initial homelab-configs setup - centralized configuration management
- OpenCode configuration pointing to LiteLLM gateway at 192.168.88.27:4000
- LiteLLM API reference with all 16 available models
- Jellyfin placeholder for future expansion
- Central management pattern documentation
- Infrastructure reference and usage guide"
echo ""
echo -e "${GREEN}✅ Local repository prepared${NC}"
echo -e "${BLUE}Repository location: $TEMP_DIR${NC}"
echo ""
# Step 2: Instructions for Gitea
echo -e "${YELLOW}Step 2: Create repository in Gitea${NC}"
echo ""
echo "📍 Manual steps (takes 30 seconds):"
echo " 1. Open: $GITEA_URL/user/repositories"
echo " 2. Click: '+' (New Repository)"
echo " 3. Fill in:"
echo " - Name: $REPO_NAME"
echo " - Description: Centralized configuration for all homelab VMs"
echo " - Private: (your choice)"
echo " 4. Click: 'Create Repository'"
echo ""
# Step 3: Push to Gitea
echo -e "${YELLOW}Step 3: Push repository to Gitea${NC}"
echo ""
echo "📋 After creating the repo in Gitea, run these commands:"
echo ""
echo " cd $TEMP_DIR"
echo " git remote add origin $GITEA_URL/$GITEA_USER/$REPO_NAME.git"
echo " git branch -M main"
echo " git push -u origin main"
echo ""
echo "Or via SSH (if configured):"
echo " git remote add origin ssh://git@192.168.88.200:22/$GITEA_USER/$REPO_NAME.git"
echo " git branch -M main"
echo " git push -u origin main"
echo ""
# Step 4: Update Nextcloud docker-compose
echo -e "${YELLOW}Step 4: Update Nextcloud (next) docker-compose${NC}"
echo ""
echo "📝 Update the OpenCode service in the Nextcloud VM's docker-compose.yml:"
echo ""
cat << 'DOCKER_COMPOSE_EXAMPLE'
services:
opencode:
image: opencode:latest
container_name: opencode
volumes:
- opencode-config:/root/.opencode
- ./workspace:/workspace
ports:
- "8000:8000" # Adjust port as needed
entrypoint: /bin/sh
command: |
-c "
mkdir -p /tmp/configs
git clone http://192.168.88.200:3000/jgitta/homelab-configs.git /tmp/configs || true
mkdir -p /root/.opencode
cp /tmp/configs/opencode/config.json /root/.opencode/config.json
exec opencode
"
restart: unless-stopped
volumes:
opencode-config:
DOCKER_COMPOSE_EXAMPLE
echo ""
echo "🔄 Restart OpenCode after updating:"
echo " ssh jgitta@192.168.88.62"
echo " cd /path/to/docker-compose"
echo " docker-compose down"
echo " docker-compose up -d"
echo ""
# Summary
echo ""
echo -e "${GREEN}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Setup Complete! ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo "✨ Next steps:"
echo " 1. Create repository in Gitea web UI"
echo " 2. Push local repo from: $TEMP_DIR"
echo " 3. Update Nextcloud docker-compose"
echo " 4. Restart OpenCode service"
echo ""
echo "📚 After setup:"
echo " - All configs managed in: $GITEA_URL/$GITEA_USER/$REPO_NAME"
echo " - VMs automatically pull latest on startup"
echo " - No per-VM configuration needed"
echo ""