How alex3025/ilo-fans-controller works
Project type and purpose
• This is a lightweight, single-page full-stack web tool (“iLO Fans Controller”) written in PHP. It exposes a clean UI (Alpine.js + TailwindCSS) to retrieve and set HP iLO server fan speeds via iLO’s REST API (php-curl) and a patched SSH interface (php-ssh2). It can run as a standalone PHP script inside Docker, or be deployed manually on Apache+PHP.
File structure
Top-level entries:
• .github/… – CI/CD workflows (build & push Docker image)
• Dockerfile & docker-compose.yaml – container build & runtime orchestration
• config.inc.php(.env) – environment-specific credentials (ILO_HOST, ILO_USER, ILO_PASS)
• ilo-fans-controller.php (renamed to index.php) – the single monolithic script implementing both UI and API endpoints
• presets.json (created at runtime) – persistent fan-preset storage
• README.md, LICENSE.md, .gitignore – docs and metadata
README for additional insights
• Explains the dual use of php-curl for GET fan speeds and php-ssh2 for POST commands
• Describes the simple API (GET?api=fans, POST JSON) and filesystem-backed presets.json
• Provides Docker & manual install guides, emphasizing environment variables and web server setup
Main components
a. User Browser (Client)
• Alpine.js & TailwindCSS UI served over HTTP(S)
• AJAX calls to API endpoints (same index.php)
b. Web Application Container
• Apache2 + PHP 8.x runtime
• index.php core logic (UI rendering + API routing)
• config.inc.php (loaded from env or file)
• presets.json (persistent JSON store)
c. External iLO Server (Target Hardware)
• iLO REST API endpoint (HTTPS, consumed via php-curl)
• Patched iLO SSH interface (TCP port 22, consumed via php-ssh2)
d. DevOps/CI Pipeline (optional)
• GitHub Actions builds Docker image & pushes to GHCR
• docker-compose / Dockerfile orchestrates container deployment
Relationships and interactions
• Browser → HTTP GET to index.php → serves HTML + CSS + JS
• Browser → AJAX GET (?api=fans) → index.php invokes php-curl → iLO REST → returns JSON → index.php returns JSON → browser updates UI
• Browser → AJAX POST (action=fans) → index.php invokes php-ssh2 → iLO SSH → fan speed set → optionally writes presets.json → returns status JSON
• Deployment: GitHub Actions → Docker image → Container registry → docker-compose deploys container ← config.env mounted
Architectural patterns & design principles
• Single-file monolith: UI + API in one PHP script for simplicity of deployment
• Layered separation: Presentation (Alpine.js + Tailwind), Business logic (PHP handlers), Persistence (JSON file), Infrastructure (Docker/Apache)
• External integration: clearly delineated HTTP vs. SSH channels to iLO
Technologies & libraries
• Frontend: Alpine.js, TailwindCSS
• Server-side: PHP 8.x, php-curl, php-ssh2, Apache 2 (or built-in PHP server in Docker)
• Container: Dockerfile, docker-compose.yaml
• CI/CD: GitHub Actions, GHCR