mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-02-05 21:03:24 +01:00
* Enhance setup-fork.sh with --full mode and misc/ targeting Added a new --full flag to setup-fork.sh to allow updating all files, not just those in misc/. Updated documentation and usage examples to clarify the new behavior. Improved file search and replacement logic for broader compatibility and flexibility. * add AI.md * fix links in AI.md * Update contribution docs and templates for best practices Refreshed AI.md with new reference scripts, expanded checklist, and improved AI assistant tips. Updated container and install script templates for modern defaults (Debian 13, larger disk, two tags), clarified helper function usage, and improved update/backup patterns. Enhanced JSON template with realistic metadata, new fields, and example notes. * Update fetch_and_deploy_gh_release usage in docs and templates Standardize the usage of fetch_and_deploy_gh_release by specifying all arguments, including mode, version, and target directory, in AI.md and template scripts. This clarifies the function's usage and ensures consistency across documentation and install/update templates. * Revise contribution docs and update CT template Expanded and clarified contribution documentation for forking, local development, cherry-picking, and AI-assisted code generation. Improved explanations for setup-fork.sh, local testing, and PR submission. Enhanced the container script template with detailed comments, clearer update_script structure, and step-by-step guidance for maintainers and contributors. * Update fork and release instructions in contribution docs Replaced placeholder GitHub repo references with 'YourUsername/YourRepo' throughout documentation for clarity. Expanded explanations in FORK_SETUP.md and README.md to clarify the difference between development and production script execution, and emphasized the importance of cherry-picking only relevant files for PRs. Updated install script template examples to use the new repo placeholder. * Update GitHub repo placeholders in docs and templates Replaced 'YourUsername/YourRepo' with 'owner/repo' in documentation and template scripts for consistency and clarity. This change standardizes example usage and reduces confusion for contributors. * Move user submitted guides to guides directory Renamed USER_SUBMITTED_GUIDES.md from docs/contribution to docs/guides for improved documentation organization. * Update contribution docs for improved workflow and clarity Revised multiple documentation files to clarify the recommended development workflow: contributors must test scripts via curl from their GitHub fork (not local bash), use setup-fork.sh for URL rewriting, and submit only new files using cherry-pick. Expanded and modernized install and JSON metadata template guides, emphasizing use of helper functions, resource requirements, and the JSON generator tool. Added detailed step-by-step instructions, best practices, and updated examples throughout. * Update contribution docs for new file structure Updated documentation to reflect the migration of install scripts from install_scripts/ to install/, and JSON metadata from config/ to frontend/public/json/. Adjusted all relevant paths, instructions, and examples to match the new directory structure for improved clarity and consistency. * Update contribution docs for fork setup and metadata Revised documentation to standardize use of 'bash docs/contribution/setup-fork.sh --full' for fork configuration, clarified install script execution flow, and updated JSON metadata template and field references. Improved helper function docs, resource requirements, and category lists. Updated references and instructions throughout for consistency and accuracy. * Docs: add GPU/TUN, update endpoints & tool refs Documentation updates across guides and function references: - Added var_gpu and var_tun configuration entries to CONFIGURATION_REFERENCE (GPU passthrough and TUN/TAP support), including features and prerequisites. - Fixed repository URLs throughout UNATTENDED_DEPLOYMENTS and examples: replaced community-scripts/ProxmoxVED with community-scripts/ProxmoxVE and updated curl usage to the new paths. - Added an "Advanced Configuration Variables" table and examples (var_os, var_version, var_gpu, var_tun, var_nesting) to UNATTENDED_DEPLOYMENTS; adjusted sample apps, hostnames, and container mappings in batch examples. - Switched API endpoints in API_FUNCTIONS_REFERENCE and API_USAGE_EXAMPLES from http://api.community-scripts.org to https://api.community-scripts.org. - Expanded BUILD_FUNC_FUNCTIONS_REFERENCE with container resource/ID management helper descriptions (validate_container_id, get_valid_container_id, maxkeys_check, get_current_ip, update_motd_ip). - Large edits to TOOLS_FUNC_FUNCTIONS_REFERENCE: renamed/refactored helper signatures and docs (pkg_install -> install_packages_with_retry, pkg_update -> upgrade_packages_with_retry), added new tooling functions (fetch_and_deploy_gh_release, check_for_gh_release, prepare_repository_setup, verify_tool_version) and updated examples and feature notes. - Updated vm/README.md to list additional VM scripts (new and reorganized examples). These are documentation-only changes to clarify configuration options, correct links and endpoints, and expand the reference material for tooling and build helpers. * Docs: expand developer/debugging and tools references Add extensive documentation and examples across contribution, guides, templates and tools references. Key changes: - Introduce a Developer Mode & Debugging section (dev_mode flags: trace, keep, pause, breakpoint, logs, dryrun, motd) in CONTRIBUTING.md with usage example. - Provide a standard update_script() pattern and BookStack example in GUIDE.md to clarify update flow (stop services, backup, deploy, restore, migrate, restart). - Add new helper entries (BookLore, KaraKeep) and advanced repository helpers (setup_deb822_repo, prepare_repository_setup, cleanup_tool_keyrings) plus utilities (setup_meilisearch, verify_tool_version) in HELPER_FUNCTIONS.md. - Update install template to suggest PNPM, Java 21 and Meilisearch; update example DB setup notes in AppName-install.sh. - Add var_diagnostics option and switch var_fuse to boolean/toggle wording in CONFIGURATION_REFERENCE.md; clarify privacy and defaults. - Adjust example container definitions in UNATTENDED_DEPLOYMENTS.md (container entries and resource values). - Change storage and flag variables and examples in BUILD_FUNC_USAGE_EXAMPLES.md (ssd-storage, var_fuse/var_tun, etc.). - Expand TOOLS_FUNC_FUNCTIONS_REFERENCE.md with many setup_* function signatures, environment vars, clarified fetch_and_deploy_gh_release modes/parameters, and additional tool docs (nodejs, php, mariadb_db, postgresql_db, java, uv, yq, meilisearch, composer, build tools). These updates improve onboarding, debugging guidance, and operational clarity for contributors and maintainers.
api.func Documentation
Overview
The api.func file provides Proxmox API integration and diagnostic reporting functionality for the Community Scripts project. It handles API communication, error reporting, and status updates to the community-scripts.org API.
Purpose and Use Cases
- API Communication: Send installation and status data to community-scripts.org API
- Diagnostic Reporting: Report installation progress and errors for analytics
- Error Description: Provide detailed error code explanations
- Status Updates: Track installation success/failure status
- Analytics: Contribute anonymous usage data for project improvement
Quick Reference
Key Function Groups
- Error Handling:
get_error_description()- Convert exit codes to human-readable messages - API Communication:
post_to_api(),post_to_api_vm()- Send installation data - Status Updates:
post_update_to_api()- Report installation completion status
Dependencies
- External:
curlcommand for HTTP requests - Internal: Uses environment variables from other scripts
Integration Points
- Used by: All installation scripts for diagnostic reporting
- Uses: Environment variables from build.func and other scripts
- Provides: API communication and error reporting services
Documentation Files
📊 API_FLOWCHART.md
Visual execution flows showing API communication processes and error handling.
📚 API_FUNCTIONS_REFERENCE.md
Complete alphabetical reference of all functions with parameters, dependencies, and usage details.
💡 API_USAGE_EXAMPLES.md
Practical examples showing how to use API functions and common patterns.
🔗 API_INTEGRATION.md
How api.func integrates with other components and provides API services.
Key Features
Error Code Descriptions
- Comprehensive Coverage: 50+ error codes with detailed explanations
- LXC-Specific Errors: Container creation and management errors
- System Errors: General system and network errors
- Signal Errors: Process termination and signal errors
API Communication
- LXC Reporting: Send LXC container installation data
- VM Reporting: Send VM installation data
- Status Updates: Report installation success/failure
- Diagnostic Data: Anonymous usage analytics
Diagnostic Integration
- Optional Reporting: Only sends data when diagnostics enabled
- Privacy Respect: Respects user privacy settings
- Error Tracking: Tracks installation errors for improvement
- Usage Analytics: Contributes to project statistics
Common Usage Patterns
Basic API Setup
#!/usr/bin/env bash
# Basic API setup
source api.func
# Set up diagnostic reporting
export DIAGNOSTICS="yes"
export RANDOM_UUID="$(uuidgen)"
# Report installation start
post_to_api
Error Reporting
#!/usr/bin/env bash
source api.func
# Get error description
error_msg=$(get_error_description 127)
echo "Error 127: $error_msg"
# Output: Error 127: Command not found: Incorrect path or missing dependency.
Status Updates
#!/usr/bin/env bash
source api.func
# Report successful installation
post_update_to_api "success" 0
# Report failed installation
post_update_to_api "failed" 127
Environment Variables
Required Variables
DIAGNOSTICS: Enable/disable diagnostic reporting ("yes"/"no")RANDOM_UUID: Unique identifier for tracking
Optional Variables
CT_TYPE: Container type (1 for LXC, 2 for VM)DISK_SIZE: Disk size in GBCORE_COUNT: Number of CPU coresRAM_SIZE: RAM size in MBvar_os: Operating system typevar_version: OS versionDISABLEIP6: IPv6 disable settingNSAPP: Namespace application nameMETHOD: Installation method
Internal Variables
POST_UPDATE_DONE: Prevents duplicate status updatesAPI_URL: Community scripts API endpointJSON_PAYLOAD: API request payloadRESPONSE: API response
Error Code Categories
General System Errors
- 0-9: Basic system errors
- 18, 22, 28, 35: Network and I/O errors
- 56, 60: TLS/SSL errors
- 125-128: Command execution errors
- 129-143: Signal errors
- 152: Resource limit errors
- 255: Unknown critical errors
LXC-Specific Errors
- 100-101: LXC installation errors
- 200-209: LXC creation and management errors
Docker Errors
- 125: Docker container start errors
Best Practices
Diagnostic Reporting
- Always check if diagnostics are enabled
- Respect user privacy settings
- Use unique identifiers for tracking
- Report both success and failure cases
Error Handling
- Use appropriate error codes
- Provide meaningful error descriptions
- Handle API communication failures gracefully
- Don't block installation on API failures
API Usage
- Check for curl availability
- Handle network failures gracefully
- Use appropriate HTTP methods
- Include all required data
Troubleshooting
Common Issues
- API Communication Fails: Check network connectivity and curl availability
- Diagnostics Not Working: Verify DIAGNOSTICS setting and RANDOM_UUID
- Missing Error Descriptions: Check error code coverage
- Duplicate Updates: POST_UPDATE_DONE prevents duplicates
Debug Mode
Enable diagnostic reporting for debugging:
export DIAGNOSTICS="yes"
export RANDOM_UUID="$(uuidgen)"
API Testing
Test API communication:
source api.func
export DIAGNOSTICS="yes"
export RANDOM_UUID="test-$(date +%s)"
post_to_api
Related Documentation
- core.func - Core utilities and error handling
- error_handler.func - Error handling utilities
- build.func - Container creation with API integration
- tools.func - Extended utilities with API integration
This documentation covers the api.func file which provides API communication and diagnostic reporting for all Proxmox Community Scripts.