build.func Documentation
Overview
This directory contains comprehensive documentation for the build.func
script, which is the core orchestration script for Proxmox LXC container creation in the Community Scripts project.
Documentation Files
📊 BUILD_FUNC_FLOWCHART.md
Visual ASCII flowchart showing the main execution flow, decision trees, and key decision points in the build.func script.
Contents:
- Main execution flow diagram
- Installation mode selection flows
- Storage selection workflow
- GPU passthrough decision logic
- Variable precedence chain
- Error handling flow
- Integration points
🔧 BUILD_FUNC_ENVIRONMENT_VARIABLES.md
Complete reference of all environment variables used in build.func, organized by category and usage context.
Contents:
- Core container variables
- Operating system variables
- Resource configuration variables
- Network configuration variables
- Storage configuration variables
- Feature flags
- GPU passthrough variables
- API and diagnostics variables
- Settings persistence variables
- Variable precedence chain
- Critical variables for non-interactive use
- Common variable combinations
📚 BUILD_FUNC_FUNCTIONS_REFERENCE.md
Alphabetical function reference with detailed descriptions, parameters, dependencies, and usage information.
Contents:
- Initialization functions
- UI and menu functions
- Storage functions
- Container creation functions
- GPU and hardware functions
- Settings persistence functions
- Utility functions
- Function call flow
- Function dependencies
- Function usage examples
- Function error handling
🔄 BUILD_FUNC_EXECUTION_FLOWS.md
Detailed execution flows for different installation modes and scenarios, including variable precedence and decision trees.
Contents:
- Default install flow
- Advanced install flow
- My defaults flow
- App defaults flow
- Variable precedence chain
- Storage selection logic
- GPU passthrough flow
- Network configuration flow
- Container creation flow
- Error handling flows
- Integration flows
- Performance considerations
🏗️ BUILD_FUNC_ARCHITECTURE.md
High-level architectural overview including module dependencies, data flow, integration points, and system architecture.
Contents:
- High-level architecture diagram
- Module dependencies
- Data flow architecture
- Integration architecture
- System architecture components
- User interface components
- Security architecture
- Performance architecture
- Deployment architecture
- Maintenance architecture
- Future architecture considerations
💡 BUILD_FUNC_USAGE_EXAMPLES.md
Practical usage examples covering common scenarios, CLI examples, and environment variable combinations.
Contents:
- Basic usage examples
- Silent/non-interactive examples
- Network configuration examples
- Storage configuration examples
- Feature configuration examples
- Settings persistence examples
- Error handling examples
- Integration examples
- Best practices
Quick Start Guide
For New Users
- Start with BUILD_FUNC_FLOWCHART.md to understand the overall flow
- Review BUILD_FUNC_ENVIRONMENT_VARIABLES.md for configuration options
- Follow examples in BUILD_FUNC_USAGE_EXAMPLES.md
For Developers
- Read BUILD_FUNC_ARCHITECTURE.md for system overview
- Study BUILD_FUNC_FUNCTIONS_REFERENCE.md for function details
- Review BUILD_FUNC_EXECUTION_FLOWS.md for implementation details
For System Administrators
- Focus on BUILD_FUNC_USAGE_EXAMPLES.md for deployment scenarios
- Review BUILD_FUNC_ENVIRONMENT_VARIABLES.md for configuration management
- Check BUILD_FUNC_ARCHITECTURE.md for security and performance considerations
Key Concepts
Variable Precedence
Variables are resolved in this order (highest to lowest priority):
- Hard environment variables (set before script execution)
- App-specific .vars file (
/usr/local/community-scripts/defaults/<app>.vars
) - Global default.vars file (
/usr/local/community-scripts/default.vars
) - Built-in defaults (set in
base_settings()
function)
Installation Modes
- Default Install: Uses built-in defaults, minimal prompts
- Advanced Install: Full interactive configuration via whiptail
- My Defaults: Loads from global default.vars file
- App Defaults: Loads from app-specific .vars file
Storage Selection Logic
- If only 1 storage exists for content type → auto-select
- If preselected via environment variables → validate and use
- Otherwise → prompt user via whiptail
GPU Passthrough Flow
- Detect hardware (Intel/AMD/NVIDIA)
- Check if app is in GPU_APPS list OR container is privileged
- Auto-select if single GPU type, prompt if multiple
- Configure
/etc/pve/lxc/<ctid>.conf
with proper device entries - Fix GIDs post-creation to match container's video/render groups
Common Use Cases
Basic Container Creation
export APP="plex"
export CTID="100"
export var_hostname="plex-server"
export var_os="debian"
export var_version="12"
export var_cpu="4"
export var_ram="4096"
export var_disk="20"
export var_net="vmbr0"
export var_gateway="192.168.1.1"
export var_ip="192.168.1.100"
export var_template_storage="local"
export var_container_storage="local"
source build.func
GPU Passthrough
export APP="jellyfin"
export CTID="101"
export var_hostname="jellyfin-server"
export var_os="debian"
export var_version="12"
export var_cpu="8"
export var_ram="16384"
export var_disk="30"
export var_net="vmbr0"
export var_gateway="192.168.1.1"
export var_ip="192.168.1.101"
export var_template_storage="local"
export var_container_storage="local"
export GPU_APPS="jellyfin"
export var_gpu="nvidia"
export ENABLE_PRIVILEGED="true"
source build.func
Silent/Non-Interactive Deployment
#!/bin/bash
# Automated deployment
export APP="nginx"
export CTID="102"
export var_hostname="nginx-proxy"
export var_os="alpine"
export var_version="3.18"
export var_cpu="1"
export var_ram="512"
export var_disk="2"
export var_net="vmbr0"
export var_gateway="192.168.1.1"
export var_ip="192.168.1.102"
export var_template_storage="local"
export var_container_storage="local"
export ENABLE_UNPRIVILEGED="true"
source build.func
Troubleshooting
Common Issues
- Container creation fails: Check resource availability and configuration validity
- Storage errors: Verify storage exists and supports required content types
- Network errors: Validate network configuration and IP address availability
- GPU passthrough issues: Check hardware detection and container privileges
- Permission errors: Verify user permissions and container privileges
Debug Mode
Enable verbose output for debugging:
export VERBOSE="true"
export DIAGNOSTICS="true"
source build.func
Log Files
Check system logs for detailed error information:
/var/log/syslog
/var/log/pve/lxc/<ctid>.log
- Container-specific logs
Contributing
When contributing to build.func documentation:
- Update relevant documentation files
- Add examples for new features
- Update architecture diagrams if needed
- Test all examples before submitting
- Follow the existing documentation style
Related Documentation
- Main README - Project overview
- Installation Guide - Installation scripts
- Container Templates - Container templates
- Tools - Additional tools and utilities
Support
For issues and questions:
- Check this documentation first
- Review the troubleshooting section
- Check existing issues in the project repository
- Create a new issue with detailed information
Last updated: $(date) Documentation version: 1.0