f74cda9463
- Updated platform badge to include Windows support - Added Windows system requirements (WSL2, Docker Desktop) - Created detailed Windows installation section with: • Step-by-step WSL2 setup instructions • Docker Desktop installation and configuration • WSL2-specific HOPS installation commands • Important performance and file location notes - Added Windows support to CLAUDE.md development docs - Documented WSL2 compatibility analysis findings: • 95% native Linux performance when using WSL2 filesystem • Full bash script compatibility via Linux kernel • Seamless Docker Desktop integration • Cross-filesystem access for Windows media folders - Updated "What's New" to highlight tri-platform support - Verified current path functions work optimally in WSL2 HOPS now officially supports Linux, macOS, and Windows\! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
9.7 KiB
9.7 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
HOPS (Homelab Orchestration Provisioning Script) is a comprehensive automation tool for deploying homelab infrastructure using Docker Compose. It provides menu-driven installation, management, and monitoring of popular homelab services including media servers, download clients, monitoring tools, and more.
Cross-Platform Support: HOPS now supports Linux (Ubuntu/Debian/Mint), macOS, and Windows (via WSL2) systems with intelligent platform detection and abstraction.
Architecture
Core Components
- Main Script (
hops.sh): Primary entry point providing menu-driven interface for all operations - Installer (
install): Handles service installation and Docker Compose deployment - Uninstaller (
uninstall): Manages complete removal of services and configurations - Service Definitions (
services): Contains Docker Compose service templates and configurations - Library System (
lib/): Modular abstraction layer for cross-platform compatibilitylib/common.sh: Shared logging, UI, and utility functionslib/system.sh: OS detection, system requirements, and platform abstraction
Key Design Patterns
- Modular Architecture: Each major function is separated into dedicated scripts
- Cross-Platform Abstraction: OS-specific operations are abstracted through lib/system.sh
- Service-Driven: All services are defined as Docker Compose configurations with standardized patterns
- Error Handling: Comprehensive error handling with logging and rollback capabilities
- Security First: Built-in security hardening, platform-appropriate firewall configuration, and secure password generation
Development Commands
Running HOPS
# Main script (requires root on Linux, admin on macOS)
sudo ./hops.sh
# Direct installation (Linux)
sudo ./install
# Direct installation (macOS)
sudo ./install
# Direct installation (Windows WSL2)
sudo ./install
# Uninstallation
sudo ./uninstall
Platform-Specific Requirements
Linux (Ubuntu/Debian/Mint):
- Root/sudo access
- Internet connection
- 2GB+ RAM, 10GB+ disk space
macOS:
- Admin access
- Internet connection
- 2GB+ RAM, 10GB+ disk space
- Homebrew will be installed automatically if not present
- Docker Desktop will be installed automatically via Homebrew
Windows (WSL2):
- Windows 10/11 with WSL2 enabled
- Ubuntu 20.04+ distribution in WSL2
- Docker Desktop with WSL2 backend
- Admin access to install prerequisites
- 2GB+ RAM, 10GB+ disk space
Testing and Validation
# Check script syntax
bash -n hops.sh
bash -n install
bash -n services
bash -n uninstall
bash -n lib/system.sh
bash -n lib/common.sh
# Test OS detection and system requirements
source lib/common.sh && source lib/system.sh && detect_os && check_system_requirements 2 10
# Test service definitions
source services
generate_service_definition jellyfin
Log Management
# View installation logs (Linux)
sudo tail -f /var/log/hops/hops-main-*.log
# View installation logs (macOS)
sudo tail -f /usr/local/var/log/hops/hops-main-*.log
# View Docker Compose logs
cd ~/hops && docker compose logs -f [service-name]
Service Architecture
Service Definition Pattern
All services follow a standardized Docker Compose pattern:
- LinuxServer.io containers with PUID/PGID/TZ environment variables
- Platform-aware volume mounting:
- Linux:
/opt/appdatafor configs,/mnt/mediafor data - macOS:
/Users/[user]/hops/configfor configs,/Users/[user]/hops/mediafor data
- Linux:
- Health checks for web services
- Unified network configuration (
homelabnetwork) - Restart policy:
unless-stopped - Platform-specific features (timezone mounts, GPU access) handled automatically
Supported Service Categories
- Media Management: Sonarr, Radarr, Lidarr, Readarr, Bazarr, Prowlarr, Tdarr, Huntarr
- Download Clients: qBittorrent, Transmission, NZBGet, SABnzbd
- Media Servers: Jellyfin, Plex, Emby, Jellystat
- Request Management: Overseerr, Jellyseerr, Ombi
- Reverse Proxy: Traefik, Nginx Proxy Manager, Authelia
- Monitoring: Portainer, Uptime Kuma, Watchtower
File Structure
Linux File Structure
~/hops/ # Main deployment directory
├── docker-compose.yml # Generated service definitions
├── .env # Environment variables
└── logs/ # Application logs
/opt/appdata/ # Application configurations
└── [service-name]/ # Individual service configs
/mnt/media/ # Media storage
├── movies/
├── tv/
├── music/
└── downloads/
macOS File Structure
~/hops/ # Main deployment directory
├── docker-compose.yml # Generated service definitions
├── .env # Environment variables
├── logs/ # Application logs
├── config/ # Application configurations
│ └── [service-name]/ # Individual service configs
└── media/ # Media storage
├── movies/
├── tv/
├── music/
└── downloads/
Environment Configuration
Key environment variables in ~/hops/.env:
PUID/PGID: User/group IDs for file permissionsTZ: Timezone configurationDATA_ROOT: Media storage locationCONFIG_ROOT: Application configuration location- Security passwords (auto-generated)
Security Features
- Firewall Integration:
- Linux: Automatic UFW rule management
- macOS: Manual firewall configuration (automatic setup skipped)
- Secure Password Generation: Cryptographically secure passwords
- File Permission Hardening: Restrictive permissions on sensitive files
- Network Isolation: Docker network segregation
- SSL/TLS Support: Automatic certificate management with reverse proxies
Error Handling
- Comprehensive Logging: All operations logged to platform-specific directories
- Linux:
/var/log/hops/ - macOS:
/usr/local/var/log/hops/
- Linux:
- Rollback Capability: Automatic rollback on deployment failure
- Dependency Validation: Pre-deployment system requirement checks
- Service Health Monitoring: Built-in health checks for all services
Key Functions
In hops.sh
show_main_menu(): Primary interfacemanage_services(): Service start/stop/restartshow_service_status(): Real-time monitoringshow_access_info(): Service URL and credential display
In services
generate_service_definition(): Creates Docker Compose service blocksget_linuxserver_env(): Standard environment variablesget_web_healthcheck(): Health check configurationsget_timezone_mount(): Platform-specific timezone handlingget_gpu_devices(): Platform-specific GPU access
In install
- Service selection and dependency resolution
- Docker Compose file generation
- Cross-platform dependency installation
- Security hardening implementation
- Post-deployment verification
In lib/system.sh
detect_os(): Cross-platform OS detectioncheck_system_requirements(): Platform-aware system validationinstall_package(): Package manager abstractioninstall_docker(): Platform-specific Docker installationget_primary_ip(): Network interface detectionget_default_*_path(): Platform-specific path resolution
Development Guidelines
- Bash Best Practices: Use
set -efor error handling, quote variables, use readonly for constants - Cross-Platform Compatibility: Always use lib/system.sh abstraction functions instead of direct OS commands
- Logging: Use the logging functions (
log,error_exit,warning,success,info) - Color Output: Use predefined color constants for consistent formatting
- Service Patterns: Follow the established Docker Compose patterns when adding new services
- Security: Never commit secrets, use secure password generation, implement proper file permissions
- Path Handling: Use
get_default_*_path()functions for platform-specific paths
Common Operations
Adding New Services
- Add service definition function in
services - Add service to installer menu in
install - Configure any required dependencies or special handling
- Test deployment and health checks
Debugging Issues
- Check logs in platform-specific directories:
- Linux:
/var/log/hops/ - macOS:
/usr/local/var/log/hops/
- Linux:
- Verify Docker Compose syntax with
docker compose config - Check service health with
docker compose ps - Review firewall rules:
- Linux:
sudo ufw status - macOS: Check System Preferences > Security & Privacy > Firewall
- Linux:
Platform-Specific Notes
macOS Considerations
- Architecture Support: Both Intel (x86_64) and Apple Silicon (ARM64) are supported
- Docker Desktop: Automatically installed via Homebrew if not present
- Homebrew: Automatically installed if not present
- GPU Acceleration: Not available (Docker containers cannot access macOS GPU)
- Firewall: Manual configuration required (automatic UFW setup skipped)
- File Permissions: Uses user's home directory structure for better compatibility
- Service Management: Uses launchctl instead of systemctl where applicable
Linux Considerations
- Architecture Support: x86_64 only
- Docker Engine: Installed via official Docker script
- Package Management: Uses apt-get for Ubuntu/Debian/Mint
- GPU Acceleration: Available for Intel GPUs via /dev/dri passthrough
- Firewall: Automatic UFW configuration
- File Permissions: Uses system-wide directories (/opt, /mnt)
- Service Management: Uses systemctl for service management