### Separation of Concerns in Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-install.func This example shows how to structure an installation script by separating concerns into distinct phases: network setup, system updates, configuration, and application-specific installation. ```bash # Network setup verb_ip6 setting_up_container network_check # System updates update_os # Configuration motd_ssh # Application-specific # ... app installation ... ``` -------------------------------- ### Basic DHCP Setup Example Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-cloud‐init.func Example of configuring a VM with basic DHCP networking using `setup_cloud_init`. This results in a VM with a random password and root user. ```bash # Example 1: Basic DHCP setup VMID=100 STORAGE="local-lvm" setup_cloud_init "$VMID" "$STORAGE" "myvm" "yes" # Result: VM configured with DHCP, random password, root user ``` -------------------------------- ### Example: Ensure Tools are Installed Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-alpine‐tools.func Demonstrates using 'need_tool' to install common utilities, check for an optional tool, and handle installation failures. ```bash # Example 1: Ensure common tools available need_tool curl jq unzip git # Installs any missing packages # Example 2: Optional tool check if need_tool myapp-cli; then myapp-cli --version else echo "myapp-cli not available in apk" fi # Example 3: With error handling need_tool docker || { echo "Failed to install docker" exit 1 } ``` -------------------------------- ### Best Practice: Test First Boot After Cloud-Init Setup Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-cloud‐init.func Steps to start a VM after cloud-init setup, wait for it to boot, and then verify its network configuration and cloud-init status. ```bash # After cloud-init setup: qm start "$VMID" # Wait for boot sleep 10 # Check cloud-init status qm exec "$VMID" cloud-init status # Verify network configuration qm exec "$VMID" hostname -I ``` -------------------------------- ### Setup Node.js Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs Node.js and optionally global npm modules. Configure `NODE_VERSION` for the Node.js version and `NODE_MODULE` for global modules. ```bash NODE_VERSION="22" NODE_MODULE="yarn,@vue/cli@5.0.0" setup_nodejs ``` -------------------------------- ### Quick Start: Save App Defaults Source: https://github.com/community-scripts/proxmoxve/wiki/[Settings]:-Configuration-&-Defaults-System-‐-User-Guide Follow these steps to quickly install an application and save its configuration as App Defaults for future use. This involves running an installation script, selecting advanced settings, answering configuration questions, and confirming to save the defaults. ```bash # 1. Run any container installation script bash pihole-install.sh # 2. When prompted, select: "Advanced Settings" # (This allows you to customize everything) # 3. Answer all configuration questions # 4. At the end, when asked "Save as App Defaults?" # Select: YES # 5. Done! Your settings are now saved ``` -------------------------------- ### Prepare and Manage Repository Setup Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Prepares the system for repository setup and manages tool repositories. Returns an error if setup fails. ```bash prepare_repository_setup "mariadb" || return 1 manage_tool_repository "mariadb" "11.4" "$REPO_URL" "$GPG_URL" || return 1 ``` -------------------------------- ### Example: Interactive Cloud-Init Configuration Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-cloud‐init.func Demonstrates how to call the interactive cloud-init configuration function with a custom default user. This setup is useful within script workflows before VM creation. ```bash # Example 1: Interactive configuration configure_cloud_init_interactive "root" # Prompts user for all settings interactively # Exports variables for use in setup_cloud_init() # Example 2: With custom default user configure_cloud_init_interactive "debian" # Suggests "debian" as default username # Example 3: In script workflow configure_cloud_init_interactive "$DEFAULT_USER" setup_cloud_init "$VMID" "$STORAGE" "$HOSTNAME" "$CLOUDINIT_ENABLE" "$CLOUDINIT_USER" # User configures interactively, then script sets up VM ``` -------------------------------- ### Typical Installation Sequence Script Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-install.func This bash script outlines a typical installation workflow for a container, including loading functions, network setup, system updates, SSH/MOTD configuration, and application-specific installation. ```bash #!/bin/bash # Inside container during installation source <(curl -fsSL .../core.func) source <(curl -fsSL .../error_handler.func) load_functions catch_errors # Step 1: Network setup verb_ip6 setting_up_container network_check # Step 2: System update update_os # Step 3: SSH and MOTD motd_ssh # Step 4: Install application (app-specific) # ... application installation steps ... # Step 5: Create update script customize ``` -------------------------------- ### Setup PHP with Modules Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Installs PHP with specified modules. Ensure PHP_VERSION and PHP_MODULE variables are set before execution. ```bash PHP_VERSION="8.4" PHP_MODULE="redis,imagick" setup_php ``` -------------------------------- ### Update Installation Script Example Source: https://github.com/community-scripts/proxmoxve/wiki/CONTRIBUTING Steps to update an existing application's installation script. Remember to update version numbers, package dependencies, and configuration files as needed. Thorough testing is crucial before committing changes. ```bash # Edit: install/existingapp-install.sh # 1. Update version (if hardcoded) RELEASE="2.0.0" # 2. Update package dependencies (if any changed) $STD apt-get install -y newdependency # 3. Update configuration (if format changed) # Update sed replacements or config files # 4. Test thoroughly before committing ``` -------------------------------- ### Setup PHP Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs PHP with selected modules and configures Apache or FPM support. Numerous variables control the PHP version, modules, and server integration. ```bash PHP_VERSION="8.4" PHP_MODULE="redis,imagick" PHP_FPM="YES" setup_php ``` -------------------------------- ### Setup PostgreSQL Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs or upgrades PostgreSQL, with options to include specific extensions. Use `PG_VERSION` for the major version and `PG_MODULES` for extensions. ```bash PG_VERSION="16" PG_MODULES="postgis,contrib" setup_postgresql ``` -------------------------------- ### Run Pi-hole Installation Script Source: https://github.com/community-scripts/proxmoxve/wiki/[Settings]:-Configuration-&-Defaults-System-‐-User-Guide Execute the Pi-hole installation script to begin the setup process. This is the first step for saving defaults during installation. ```bash bash pihole-install.sh ``` -------------------------------- ### Container OS Setup with setting_up_container() Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Performs initial setup for a container, including OS configuration, locale, timezone, and network settings. ```bash setting_up_container ``` -------------------------------- ### Setup MySQL Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs or upgrades MySQL, including configuring the APT repository. It handles specific Debian transitions and can fall back to MariaDB if MySQL is unavailable. ```bash MYSQL_VERSION="8.0" setup_mysql ``` -------------------------------- ### setup_ruby() Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Installs rbenv and ruby-build, then installs Ruby and optionally Rails. Allows specifying Ruby version and whether to install Rails. ```APIDOC ## setup_ruby() ### Description Installs rbenv and ruby-build, then installs Ruby and optionally Rails. ### Method Shell command ### Endpoint N/A ### Parameters #### Query Parameters - **RUBY_VERSION** (string) - Optional - Ruby version (default: 3.4.4) - **RUBY_INSTALL_RAILS** (boolean) - Optional - true/false to install Rails (default: true) ### Request Example ```bash RUBY_VERSION="3.4.4" RUBY_INSTALL_RAILS="true" setup_ruby ``` ### Response #### Success Response (0) - Installation successful #### Response Example N/A ``` -------------------------------- ### Setup MariaDB Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs or updates MariaDB from its official repository. The `MARIADB_VERSION` variable can be set to specify a particular version. ```bash MARIADB_VERSION="11.4" setup_mariadb ``` -------------------------------- ### Install Core Functions Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-install.func Installs prerequisites like curl, sources core and error handling functions, and initializes them. Ensure these functions are loaded before proceeding with container setup. ```bash # Install.func requires two prerequisites if ! command -v curl >/dev/null 2>&1; then apt-get update >/dev/null 2>&1 apt-get install -y curl >/dev/null 2>&1 fi # Source core functions (colors, formatting, messages) source <(curl -fsSL https://git.community-scripts.org/.../core.func) # Source error handling (traps, signal handlers) source <(curl -fsSL https://git.community-scripts.org/.../error_handler.func) # Initialize both modules load_functions # Sets up colors, icons, defaults catch_errors # Configures ERR, EXIT, INT, TERM traps ``` -------------------------------- ### Monitor Installation with Defaults Source: https://github.com/community-scripts/proxmoxve/wiki/[Settings]:-Configuration-&-Defaults-System-‐-User-Guide Executes an installation script while simultaneously logging its output to a file using `tee`. This is useful for monitoring the installation process and troubleshooting issues. ```bash # Monitor installation with defaults bash pihole-install.sh 2>&1 | tee installation.log ``` -------------------------------- ### Basic Cloud-Init Setup Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-cloud‐init.func Perform a basic Cloud-Init setup for a VM using default DHCP networking. This configures the VM for first-boot automation. ```bash # Basic setup: setup_cloud_init "$VMID" "$STORAGE" "$HOSTNAME" "yes" ``` -------------------------------- ### Example: Check Command Availability Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-alpine‐tools.func Shows how to use the 'has' function to check if 'jq' is installed and how to use it in a conditional statement. ```bash # Example 1: Check availability if has jq; then echo "jq is installed" else echo "jq is not installed" fi # Example 2: In conditionals has docker && docker ps || echo "Docker not installed" ``` -------------------------------- ### Install PHP, Node.js, and Python with uv Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Installs specified versions of PHP, Node.js, and Python with the uv package manager. Handles repository setup and version management automatically. ```bash # Use functions from tools.func for standardized setup PHP_VERSION="8.4" setup_php # Installs from repository NODE_VERSION="22" setup_nodejs # Installs from NodeSource repo PYTHON_VERSION="3.12" setup_uv # Python + uv package manager ``` -------------------------------- ### Tool Installation Patterns Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-alpine‐tools.func Demonstrates common patterns for installing tools using community scripts, including simple package installation, GitHub release downloads, and version pinning. ```APIDOC ## Tool Installation Patterns ### Pattern 1: Simple Package Installation Ensures necessary tools like `curl` and `jq` are available before proceeding. ```bash #!/bin/sh need_tool curl jq # Ensure tools available # Continue with script ``` ### Pattern 2: GitHub Release Installation Downloads and installs an application from its GitHub releases using `check_for_gh_release` and `download_with_progress`. ```bash #!/bin/sh source <(curl -fsSL .../alpine-tools.func) load_functions # Check for updates check_for_gh_release "myapp" "owner/myapp" # Download from GitHub releases RELEASE="$CHECK_UPDATE_RELEASE" URL="https://github.com/owner/myapp/releases/download/v${RELEASE}/myapp-alpine.tar.gz" download_with_progress "$URL" "/tmp/myapp-${RELEASE}.tar.gz" tar -xzf "/tmp/myapp-${RELEASE}.tar.gz" -C /usr/local/bin/ ``` ### Pattern 3: Version Pinning Uses `check_for_gh_release` to ensure a specific, known-good version of a tool is used, even if newer versions are available. ```bash #!/bin/sh # For specific use case, pin to known good version check_for_gh_release "nodejs" "nodejs/node" "20.10.0" # Will use 20.10.0 even if 21.0.0 available ``` ``` -------------------------------- ### Select Installation Mode for Defaults Source: https://github.com/community-scripts/proxmoxve/wiki/[Settings]:-Configuration-&-Defaults-System-‐-User-Guide Choose the installation mode when prompted by the script. Selecting 'Advanced Settings' is necessary for saving defaults. ```bash # 2. Choose installation mode # ┌─────────────────────────┐ # │ Select installation mode:│ # │ 1) Default Settings │ # │ 2) Advanced Settings │ # │ 3) User Defaults │ # │ 4) App Defaults │ # │ 5) Settings Menu │ # └─────────────────────────┘ # # Enter: 2 (Advanced Settings) ``` -------------------------------- ### setup_rust() Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Installs the Rust toolchain and optional global crates. Allows specifying the Rust toolchain and a list of crates to install. ```APIDOC ## setup_rust() ### Description Installs Rust toolchain and optional global crates. ### Method Shell command ### Endpoint N/A ### Parameters #### Query Parameters - **RUST_TOOLCHAIN** (string) - Optional - Rust toolchain (default: stable) - **RUST_CRATES** (string) - Optional - Comma-separated list of crates ### Request Example ```bash RUST_TOOLCHAIN="stable" RUST_CRATES="cargo-edit,wasm-pack@0.12.1" setup_rust ``` ### Response #### Success Response (0) - Installation successful #### Response Example N/A ``` -------------------------------- ### Static IP Configuration Example Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-cloud‐init.func Example demonstrating static IP configuration for a VM, including specifying the IP address, gateway, and DNS servers. ```bash # Example 2: Static IP configuration setup_cloud_init "$VMID" "$STORAGE" "myvm" "yes" "root" \ "static" "192.168.1.100/24" "192.168.1.1" "1.1.1.1 8.8.8.8" # Result: VM configured with static IP, specific DNS ``` -------------------------------- ### Install Node.js and Application Dependencies Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh This script installs Node.js using a helper function, clones a Git repository for the application, and installs production dependencies using `npm install --production`. It also sets up systemd service. ```bash # Copyright (c) 2021-2025 community-scripts ORG # Author: YourUsername # License: MIT # Source: https://github.com/app/repo source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" color catch_errors setting_up_container network_check update_os msg_info "Installing Dependencies" $STD apt-get install -y git curl nano msg_ok "Installed Dependencies" msg_info "Setting up Node.js" NODE_VERSION="22" setup_nodejs msg_ok "Node.js installed" msg_info "Downloading Application" cd /opt git clone https://github.com/app/repo appname cd appname npm install --production msg_ok "Application installed" msg_info "Setting permissions" chown -R www-data:www-data /opt/appname msg_ok "Permissions set" msg_info "Configuring Service" cat > /etc/systemd/system/appname.service < /opt/${APP}_version.txt motd_ssh customize cleanup_lxc ``` -------------------------------- ### Best Practice: Setup Traps Early Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-error_handler.func This example emphasizes the importance of calling `catch_errors()` immediately after sourcing necessary functions and before any significant work is done in the script. This ensures all error and signal handling is active from the beginning. ```bash #!/bin/bash set -Eeuo pipefail source <(curl -fsSL .../core.func) source <(curl -fsSL .../error_handler.func) load_functions catch_errors # MUST be called before any real work # Now safe - all signals handled ``` -------------------------------- ### Install Go (Golang) Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs Go from the official tarball. Set GO_VERSION to specify the desired Go version; defaults to latest. ```bash GO_VERSION="1.22.2" setup_go ``` -------------------------------- ### Enable and Start Systemd Service Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Enables a systemd service to start on boot and starts it immediately. Use 'systemctl' for systemd-based systems. ```bash # Enable systemd service systemctl enable -q --now appname ``` -------------------------------- ### Create Custom Setup Menu with Whiptail Source: https://github.com/community-scripts/proxmoxve/wiki/CONTRIBUTING For applications with many configuration options, create a custom setup menu using `whiptail` to prompt the user for input. ```bash function custom_config() { OPTION=$(whiptail --inputbox "Enter database name:" 8 60) # ... use $OPTION in installation } ``` -------------------------------- ### Setup Cloud-Init Function Signature Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-cloud‐init.func The `setup_cloud_init` function configures Cloud-init for automatic VM first-boot setup. It accepts various parameters for network and user configuration. ```bash setup_cloud_init() ``` -------------------------------- ### setup_uv() Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Installs or upgrades uv (Python package manager) from GitHub releases. Supports installing the uvx wrapper and a specific Python version. ```APIDOC ## setup_uv() ### Description Installs or upgrades uv (Python package manager) from GitHub releases. ### Method Shell command ### Endpoint N/A ### Parameters #### Query Parameters - **USE_UVX** (string) - Optional - Set YES to install uvx wrapper (default: NO) - **PYTHON_VERSION** (string) - Optional - Python version to install via uv ### Request Example ```bash USE_UVX="YES" PYTHON_VERSION="3.12" setup_uv ``` ### Response #### Success Response (0) - uv installed or upgraded successfully. #### Response Example N/A ``` -------------------------------- ### Use User Defaults During Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[Settings]:-Configuration-&-Defaults-System-‐-User-Guide Select 'User Defaults' (Option 3) during installation to apply settings from `/usr/local/community-scripts/default.vars`. ```bash # 2. When asked for mode, select: # Option: 3 (User Defaults) ``` -------------------------------- ### Use App Defaults During Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[Settings]:-Configuration-&-Defaults-System-‐-User-Guide Select 'App Defaults' (Option 4) during installation to apply settings from the application-specific defaults file (e.g., `/usr/local/community-scripts/defaults/pihole.vars`). ```bash # 2. When asked for mode, select: # Option: 4 (App Defaults) ``` -------------------------------- ### Load Alpine-Tools.func and Install Tools Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-alpine‐tools.func Source the core and alpine-tools.func scripts, then use 'need_tool' to install any missing utilities like curl and jq. ```bash #!/bin/sh # Alpine uses ash, not bash source <(curl -fsSL .../core.func) source <(curl -fsSL .../alpine-tools.func) load_functions # Now Alpine-specific tool functions available need_tool curl jq # Install if missing ``` -------------------------------- ### Install FFmpeg Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs FFmpeg from source or a prebuilt binary. Specify FFMPEG_VERSION and FFMPEG_TYPE (minimal, medium, full, binary). ```bash FFMPEG_VERSION="n7.1.1" FFMPEG_TYPE="full" setup_ffmpeg ``` -------------------------------- ### Quick Start: First Contribution Workflow Source: https://github.com/community-scripts/proxmoxve/wiki/CONTRIBUTING Follow these steps to quickly set up your environment, create a new application script, test it locally, and prepare it for submission. ```bash # 1. Fork the repository on GitHub # Visit: https://github.com/community-scripts/ProxmoxVED # Click: Fork (top right) # 2. Clone your fork git clone https://github.com/YOUR_USERNAME/ProxmoxVED.git cd ProxmoxVED # 3. Create feature branch git checkout -b add/my-awesome-app # 4. Create application scripts cp ct/example.sh ct/myapp.sh cp install/example-install.sh install/myapp-install.sh # 5. Edit your scripts nano ct/myapp.sh nano install/myapp-install.sh # 6. Test locally bash ct/myapp.sh # Will prompt for container creation # 7. Commit and push git add ct/myapp.sh install/myapp-install.sh git commit -m "feat: add MyApp container" git push origin add/my-awesome-app # 8. Open Pull Request on GitHub # Visit: https://github.com/community-scripts/ProxmoxVED/pulls # Click: New Pull Request ``` -------------------------------- ### Setup MongoDB Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs or updates MongoDB to a specified major version. The `MONGO_VERSION` variable controls which major version is installed. ```bash MONGO_VERSION="7.0" setup_mongodb ``` -------------------------------- ### Install Docker Engine Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Installs Docker Engine and Docker Compose on the system. ```bash setup_docker # Result: /usr/bin/docker, /usr/bin/docker-compose ``` -------------------------------- ### Complete Script Template: Phase 2 - Dependency Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Installs necessary packages for the application using apt-get. It emphasizes using the `$STD` variable for silent installation and proper line continuation for readability. ```bash msg_info "Installing Dependencies" $STD apt-get install -y \ curl \ wget \ git \ nano \ build-essential \ libssl-dev \ python3-dev msg_ok "Installed Dependencies" ``` -------------------------------- ### Disabled Cloud-Init Example Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-cloud‐init.func Example showing how to disable Cloud-Init for a VM by setting the enable parameter to 'no'. No cloud-init configuration will be applied. ```bash # Example 3: Disabled (no cloud-init) setup_cloud_init "$VMID" "$STORAGE" "myvm" "no" ``` -------------------------------- ### Example: Standard OS Update Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-install.func This example shows a basic call to the `update_os` function to update all packages. Output is silent unless the `VERBOSE` variable is set. ```bash # Example 1: Standard update update_os ``` -------------------------------- ### setup_go() Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Installs Go (Golang) from the official tarball. Allows specifying the Go version. ```APIDOC ## setup_go() ### Description Installs Go (Golang) from official tarball. ### Method Shell command ### Endpoint N/A ### Parameters #### Query Parameters - **GO_VERSION** (string) - Optional - Go version (default: latest) ### Request Example ```bash GO_VERSION="1.22.2" setup_go ``` ### Response #### Success Response (0) - Installation successful #### Response Example N/A ``` -------------------------------- ### Update Application Installation Script Source: https://github.com/community-scripts/proxmoxve/wiki/CONTRIBUTING Configure the installation script for an application, including dependencies, downloads, and versioning. ```bash #!/usr/bin/env bash # Copyright (c) 2021-2025 community-scripts ORG # Author: YourUsername # License: MIT # Source: https://github.com/example/myapp source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" color verb_ip6 catch_errors setting_up_container network_check update_os msg_info "Installing Dependencies" $STD apt-get install -y \ curl \ wget \ git \ build-essential msg_ok "Installed Dependencies" msg_info "Setting up Node.js" NODE_VERSION="22" setup_nodejs msg_ok "Node.js installed" msg_info "Downloading Application" cd /opt wget -q "https://github.com/user/repo/releases/download/v1.0.0/myapp.tar.gz" tar -xzf myapp.tar.gz rm -f myapp.tar.gz msg_ok "Application installed" echo "1.0.0" > /opt/${APP}_version.txt motd_ssh customize cleanup_lxc ``` -------------------------------- ### Setup deb822 Repository Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Standardized setup for deb822 repositories, including optional architectures. Automatically runs apt update after creation. ```bash setup_deb822_repo "adoptium" \ "https://packages.adoptium.net/artifactory/api/gpg/key/public" \ "https://packages.adoptium.net/artifactory/deb" \ "bookworm" \ "main" ``` -------------------------------- ### Setup deb822 Repository Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Standardized setup for deb822 repositories, including optional architectures. Automatically runs apt update after creation. ```bash setup_deb822_repo "adoptium" "https://packages.adoptium.net/artifactory/api/gpg/key/public" "https://packages.adoptium.net/artifactory/deb" "bookworm" "main" ``` -------------------------------- ### Install Base Dependencies Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Installs essential development and utility packages including curl, wget, git, build-essential, and text editors. ```bash msg_info "Installing Base Dependencies" $STD apt-get install -y \ curl wget git wget \ build-essential \ libssl-dev libffi-dev \ nano mc htop msg_ok "Installed Base Dependencies" ``` -------------------------------- ### setup_ffmpeg() Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Installs FFmpeg from source or a prebuilt binary. Allows specifying the FFmpeg version and build type. ```APIDOC ## setup_ffmpeg() ### Description Installs FFmpeg from source or prebuilt binary. ### Method Shell command ### Endpoint N/A ### Parameters #### Query Parameters - **FFMPEG_VERSION** (string) - Optional - FFmpeg version (default: latest) - **FFMPEG_TYPE** (string) - Optional - Build profile: minimal, medium, full, binary (default: full) ### Request Example ```bash FFMPEG_VERSION="n7.1.1" FFMPEG_TYPE="full" setup_ffmpeg ``` ### Response #### Success Response (0) - FFmpeg installed successfully. #### Response Example N/A ``` -------------------------------- ### Execution Flow of Installation Scripts Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Illustrates the sequence of operations from the Proxmox host to the installation script running inside the LXC container. ```bash ct/AppName.sh (Proxmox Host) ↓ build_container() ↓ pct exec CTID bash -c "$(cat install/AppName-install.sh)" ↓ install/AppName-install.sh (Inside Container) ↓ Container Ready with App Installed ``` -------------------------------- ### Complete Script Template: Phase 1 - Header & Initialization Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Initializes the installation script by setting up the environment, including loading functions, configuring colors, error handling, and performing system checks. ```bash #!/usr/bin/env bash # Copyright (c) 2021-2025 community-scripts ORG # Author: YourUsername # Co-Author: AnotherAuthor (for updates) # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE # Source: https://github.com/application/repo # Load all available functions (from core.func + tools.func) source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" # Initialize environment color # Setup ANSI colors and icons verb_ip6 # Configure IPv6 (if needed) catch_errors # Setup error traps setting_up_container # Verify OS is ready network_check # Verify internet connectivity update_os # Update packages (apk/apt) ``` -------------------------------- ### setup_hwaccel() Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Sets up Hardware Acceleration for Intel/AMD/NVIDIA GPUs. ```APIDOC ## setup_hwaccel() ### Description Sets up Hardware Acceleration for Intel/AMD/NVIDIA GPUs. ### Method Shell command ### Endpoint N/A ### Parameters N/A ### Request Example ```bash setup_hwaccel ``` ### Response #### Success Response (0) - Hardware acceleration setup completed. #### Response Example N/A ``` -------------------------------- ### Get Specific Package Information Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-alpine‐tools.func Retrieves detailed information about a specific installed or available package, such as postgresql-client. ```bash # Get specific package info apk info postgresql-client ``` -------------------------------- ### Prepare Repository Setup Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Perform unified repository preparation, including cleaning old repositories and keyrings, and ensuring APT is functional. Accepts repository names as arguments. ```bash prepare_repository_setup "mariadb" "mysql" ``` -------------------------------- ### Setup Local IP Updater Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs a script using networkd-dispatcher to automatically update the local IP address. ```bash setup_local_ip_helper ``` -------------------------------- ### setup_imagemagick() Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Installs ImageMagick 7 from source. ```APIDOC ## setup_imagemagick() ### Description Installs ImageMagick 7 from source. ### Method Shell command ### Endpoint N/A ### Parameters N/A ### Request Example ```bash setup_imagemagick ``` ### Response #### Success Response (0) - ImageMagick 7 installed successfully. #### Response Example N/A ``` -------------------------------- ### Check Available Variables Source: https://github.com/community-scripts/proxmoxve/wiki/[Settings]:-Configuration-&-Defaults-System-‐-User-Guide Uses `grep` to find and display available variables starting with 'var_' from an installation script. This command helps in understanding which variables can be configured. ```bash # Check what variables are available grep "var_" /path/to/app-install.sh | head -20 ``` -------------------------------- ### Proxmox VE Container Creation Flow Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName.sh Details the step-by-step process of creating an LXC container using a script, from initial setup to successful application installation and access. ```bash START: bash ct/pihole.sh ↓ [1] Set APP, var_*, defaults ↓ [2] header_info() → Display ASCII art ↓ [3] variables() → Parse arguments & load build.func ↓ [4] color() → Setup ANSI codes ↓ [5] catch_errors() → Setup trap handlers ↓ [6] install_script() → Show mode menu (5 options) ↓ ├─ INSTALL_MODE="0" (Default) ├─ INSTALL_MODE="1" (Advanced - 19-step wizard) ├─ INSTALL_MODE="2" (User Defaults) ├─ INSTALL_MODE="3" (App Defaults) └─ INSTALL_MODE="4" (Settings Menu) ↓ [7] advanced_settings() → Collect user configuration (if mode=1) ↓ [8] start() → Confirm or re-edit settings ↓ [9] build_container() → Create LXC + execute install script ↓ [10] description() → Set container description ↓ [11] SUCCESS → Display access URL ↓ END ``` -------------------------------- ### Complete Script Template: Phase 3 - Tool Setup Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Shows how to use functions from `tools.func` to set up specific tool versions, such as Node.js or MySQL, within the container. ```bash # Setup specific tool versions NODE_VERSION="22" setup_nodejs # Or for databases MYSQL_VERSION="8.0" setup_mysql ``` -------------------------------- ### Call post_to_api Early for Tracking Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-api.func Call the post_to_api function early in the script, right after container creation starts, to track the attempt even if subsequent installation steps fail. Ensure RANDOM_UUID is initialized before calling. ```bash # Call post_to_api right after container creation starts # This tracks attempt, even if installation fails variables() { RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" # ... other variables ... } # Later, in main script: post_to_api # Report container creation started # ... perform installation ... post_update_to_api # Report completion ``` -------------------------------- ### setup_yq() Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Installs or updates yq (mikefarah/yq - Go version). ```APIDOC ## setup_yq() ### Description Installs or updates yq (mikefarah/yq - Go version). ### Method Shell command ### Endpoint N/A ### Parameters N/A ### Request Example ```bash setup_yq ``` ### Response #### Success Response (0) - yq installed or updated successfully. #### Response Example N/A ``` -------------------------------- ### Network Check and Update Sequence Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-install.func This sequence demonstrates a best practice for checking network connectivity early in the installation process before proceeding with system updates. It includes steps for container setup, network validation, and OS updates. ```bash # Network setup setting_up_container # Verify network available network_check # Validate connectivity and DNS update_os # Proceed with updates # If network fails, exit immediately # Don't waste time on installation ``` -------------------------------- ### Defaults File Format Examples Source: https://github.com/community-scripts/proxmoxve/wiki/[Settings]:-Configuration-&-Defaults-System-‐-User-Guide Illustrates the correct syntax for defining variables in default configuration files. Comments start with '#', and spaces around the '=' sign are not permitted. String values do not require quotes unless they contain spaces. ```bash # Comments start with # var_name=value # No spaces around = ✓ var_cpu=4 ✗ var_cpu = 4 # String values don't need quotes ✓ var_hostname=mycontainer ✓ var_hostname='mycontainer' # Values with spaces need quotes ✓ var_tags="docker,production,testing" ✗ var_tags=docker,production,testing ``` -------------------------------- ### Setup Hardware Acceleration Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Sets up hardware acceleration for Intel, AMD, and NVIDIA GPUs. ```bash setup_hwaccel ``` -------------------------------- ### Update Update Function Example Source: https://github.com/community-scripts/proxmoxve/wiki/CONTRIBUTING Instructions for updating the update function within an application's script. This involves checking and potentially updating GitHub API URLs, backup/restore logic, and cleanup paths. Test the update process on an existing installation. ```bash # Edit: ct/existingapp.sh → update_script() # 1. Update GitHub API URL if repo changed RELEASE=$(curl -fsSL https://api.github.com/repos/user/repo/releases/latest | ...) # 2. Update backup/restore logic (if structure changed) # 3. Update cleanup paths # 4. Test update on existing installation ``` -------------------------------- ### Setup MySQL/MariaDB Database and User Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Creates a new database and user, granting privileges. Requires root access to the database. Credentials are saved to a file. ```bash # For MySQL/MariaDB mysql -u root <> ~/appname.creds Database Credentials Database: ${DB_NAME} Username: ${DB_USER} Password: ${DB_PASS} EOF ``` -------------------------------- ### Setup Error Traps and Signal Handlers Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-error_handler.func Call this function once at the start of your script to configure error traps for command failures, script exits, interrupts (Ctrl+C), termination signals, and function return errors. It ensures that `error_handler()` and `on_exit()` functions are invoked appropriately. ```bash catch_errors() { # Set strict mode set -Eeuo pipefail # Configure traps trap 'error_handler $? "$BASH_COMMAND" $LINENO' ERR trap on_exit EXIT trap on_interrupt INT trap on_terminate TERM trap 'error_handler $? "$BASH_COMMAND" $LINENO' RETURN } ``` -------------------------------- ### setup_java() Source: https://github.com/community-scripts/proxmoxve/wiki/tools.func Installs Temurin JDK via Adoptium APT repository. Allows specifying the JDK version. ```APIDOC ## setup_java() ### Description Installs Temurin JDK via Adoptium APT repository. ### Method Shell command ### Endpoint N/A ### Parameters #### Query Parameters - **JAVA_VERSION** (string) - Optional - Temurin JDK version (default: 21) ### Request Example ```bash JAVA_VERSION="21" setup_java ``` ### Response #### Success Response (0) - Installation successful #### Response Example N/A ``` -------------------------------- ### Cache Installed Version Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Caches the version of an installed tool. This is useful for tracking installed versions and preventing redundant installations. ```bash setup_nodejs cache_installed_version "nodejs" "$NODE_VERSION" ``` -------------------------------- ### Example: Verbose OS Update Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-install.func This example shows how to enable verbose output for the `update_os` function by setting the `VERBOSE` environment variable to 'yes'. This will display all `apt-get` operations. ```bash # Example 3: Verbose output VERBOSE="yes" update_os ``` -------------------------------- ### Install Missing Tools with apk Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-alpine‐tools.func Ensures specified tools are installed via 'apk add', installing any that are missing. Returns 1 if installation fails. ```bash # Checks each tool # If any missing: runs apk add for all # Displays message before and after ``` -------------------------------- ### Installation Mode: Default Settings Source: https://github.com/community-scripts/proxmoxve/wiki/[Settings]:-Configuration-&-Defaults-System-‐-User-Guide Describes the 'Default Settings' installation mode, suitable for first-time users or quick deployments. This mode uses built-in defaults and requires no user interaction. ```text Quick installation with standard settings ├─ Best for: First-time users, quick deployments ├─ What happens: │ 1. Script uses built-in defaults │ 2. Container created immediately │ 3. No questions asked └─ Time: ~2 minutes ``` -------------------------------- ### Install Ruby with rbenv Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs rbenv and ruby-build, then installs Ruby. Set RUBY_INSTALL_RAILS to 'true' to also install Rails. Specify RUBY_VERSION for a specific Ruby version. ```bash RUBY_VERSION="3.4.4" RUBY_INSTALL_RAILS="true" setup_ruby ``` -------------------------------- ### Install Node.js with Global Modules Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Installs Node.js from the NodeSource repository. Optionally installs specified global npm modules. ```bash NODE_VERSION="22" setup_nodejs # With modules NODE_VERSION="22" NODE_MODULE="yarn,@vue/cli@5.0.0" setup_nodejs # Result: /usr/bin/node, /usr/bin/npm, /usr/bin/yarn ``` -------------------------------- ### Script Launch Commands Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName.sh Initiate the container creation process, build the container with selected configurations, set its description in the Proxmox UI, and display a success message with access details. ```bash # Start the container creation workflow start # Build the container with selected configuration build_container # Set container description/notes in Proxmox UI description # Display success message msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}" ``` -------------------------------- ### Install Packages with Retry Logic Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs packages and includes retry logic for robustness. Check the return code to handle installation failures. ```bash if ! install_packages_with_retry "nginx"; then msg_error "Failed to install nginx" return 1 fi ``` -------------------------------- ### Troubleshooting: Cloud-Init Not Applying Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-cloud‐init.func Commands to run inside a VM to diagnose issues with cloud-init not applying configurations. Includes checking status, analyzing boot, querying data sources, and examining logs. ```bash # Inside VM: cloud-init status # Show cloud-init status cloud-init analyze # Analyze cloud-init boot cloud-init query # Query cloud-init datasource # Check logs: tail -100 /var/log/cloud-init-output.log tail -100 /var/log/cloud-init.log ``` -------------------------------- ### Install Ghostscript Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs or updates Ghostscript (gs) from source. ```bash setup_gs ``` -------------------------------- ### Best Practice: Use Static IPs for Production Cloud-Init Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-cloud‐init.func Compares the cloud-init setup for DHCP (suitable for dev/test) versus static IP configuration (suitable for production). ```bash # DHCP - suitable for dev/test setup_cloud_init "$VMID" "$STORAGE" "$HOSTNAME" "yes" "root" "dhcp" # Static - suitable for production setup_cloud_init "$VMID" "$STORAGE" "$HOSTNAME" "yes" "root" \ "static" "192.168.1.100/24" "192.168.1.1" ``` -------------------------------- ### Install ImageMagick 7 Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs ImageMagick 7 from source. ```bash setup_imagemagick ``` -------------------------------- ### Check if Package is Installed Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Efficiently checks if a given package is installed on the system. Returns 0 if installed and 1 otherwise, offering a faster alternative to `dpkg -l`. ```bash if is_package_installed "nginx"; then echo "Nginx is installed" fi ``` -------------------------------- ### Script Initialization Commands Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName.sh Execute essential setup tasks at the beginning of a script, including displaying headers, processing arguments, setting up colors, and initializing error handling. ```bash # Display header ASCII art header_info "$APP" # Process command-line arguments and load configuration variables # Setup ANSI color codes and formatting color # Initialize error handling (trap ERR, EXIT, INT, TERM) catch_errors ``` -------------------------------- ### Orchestrate Container Installation Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-build.func Orchestrates the container installation workflow inside the LXC container. It copies the install script, executes it, captures output, reports completion, and handles errors with cleanup. ```bash install_script() ``` ```bash # If installation fails: # - Captures exit code # - Posts failure to API (if telemetry enabled) # - Displays error with explanation # - Offers debug shell (if DEV_MODE_BREAKPOINT) # - Cleans up container (unless DEV_MODE_KEEP) ``` -------------------------------- ### Set Up Container OS, Locale, Timezone, and Network Source: https://github.com/community-scripts/proxmoxve/wiki/install.func-‐-script-function-explanations Initializes the container's operating system by configuring locale, timezone, and network settings. It ensures the correct locale is generated and network configuration is applied. ```bash setting_up_container # Configures OS, locale, timezone, and network ``` -------------------------------- ### Software Installation Scripts Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Scripts for installing various software and development tools. ```APIDOC ## setup_java() ### Description Installs Temurin JDK via Adoptium APT repository. ### Variables - `JAVA_VERSION` - Temurin JDK version (default: 21) ### Example ```bash JAVA_VERSION="21" setup_java ``` ``` ```APIDOC ## setup_ruby() ### Description Installs rbenv and ruby-build, installs Ruby and optionally Rails. ### Variables - `RUBY_VERSION` - Ruby version (default: 3.4.4) - `RUBY_INSTALL_RAILS` - true/false to install Rails (default: true) ### Example ```bash RUBY_VERSION="3.4.4" RUBY_INSTALL_RAILS="true" setup_ruby ``` ``` ```APIDOC ## setup_rust() ### Description Installs Rust toolchain and optional global crates. ### Variables - `RUST_TOOLCHAIN` - Rust toolchain (default: stable) - `RUST_CRATES` - Comma-separated list of crates ### Example ```bash RUST_TOOLCHAIN="stable" RUST_CRATES="cargo-edit,wasm-pack@0.12.1" setup_rust ``` ``` ```APIDOC ## setup_go() ### Description Installs Go (Golang) from official tarball. ### Variables - `GO_VERSION` - Go version (default: latest) ### Example ```bash GO_VERSION="1.22.2" setup_go ``` ``` ```APIDOC ## setup_composer() ### Description Installs or updates Composer globally (robust, idempotent). ### Features - Installs to /usr/local/bin/composer - Removes old binaries/symlinks - Ensures /usr/local/bin is in PATH - Auto-updates to latest version ### Example ```bash setup_composer ``` ``` ```APIDOC ## setup_uv() ### Description Installs or upgrades uv (Python package manager) from GitHub releases. ### Variables - `USE_UVX` - Set YES to install uvx wrapper (default: NO) - `PYTHON_VERSION` - Optional Python version to install via uv ### Example ```bash USE_UVX="YES" PYTHON_VERSION="3.12" setup_uv ``` ``` ```APIDOC ## setup_yq() ### Description Installs or updates yq (mikefarah/yq - Go version). ### Example ```bash setup_yq ``` ``` ```APIDOC ## setup_ffmpeg() ### Description Installs FFmpeg from source or prebuilt binary. ### Variables - `FFMPEG_VERSION` - FFmpeg version (default: latest) - `FFMPEG_TYPE` - Build profile: minimal, medium, full, binary (default: full) ### Example ```bash FFMPEG_VERSION="n7.1.1" FFMPEG_TYPE="full" setup_ffmpeg ``` ``` ```APIDOC ## setup_imagemagick() ### Description Installs ImageMagick 7 from source. ### Example ```bash setup_imagemagick ``` ``` ```APIDOC ## setup_gs() ### Description Installs or updates Ghostscript (gs) from source. ### Example ```bash setup_gs ``` ``` ```APIDOC ## setup_hwaccel() ### Description Sets up Hardware Acceleration for Intel/AMD/NVIDIA GPUs. ### Example ```bash setup_hwaccel ``` ``` ```APIDOC ## setup_clickhouse() ### Description Installs or upgrades ClickHouse database server. ### Variables - `CLICKHOUSE_VERSION` - ClickHouse version (default: latest) ### Example ```bash CLICKHOUSE_VERSION="latest" setup_clickhouse ``` ``` ```APIDOC ## setup_adminer() ### Description Installs Adminer (supports Debian/Ubuntu and Alpine). ### Example ```bash setup_adminer ``` ``` -------------------------------- ### Minimal install/AppName-install.sh Template Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh A basic template for an installation script, including shebang, metadata, function loading, and essential initialization steps. ```bash #!/usr/bin/env bash # [1] Shebang # [2] Copyright/Metadata # Copyright (c) 2021-2025 community-scripts ORG # Author: YourUsername # License: MIT # Source: https://example.com # [3] Load functions source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" color verb_ip6 catch_errors setting_up_container network_check update_os # [4] Installation steps msg_info "Installing Dependencies" $STD apt-get install -y package1 package2 msg_ok "Installed Dependencies" # [5] Final setup motd_ssh customize cleanup_lxc ``` -------------------------------- ### Install Adminer Source: https://github.com/community-scripts/proxmoxve/wiki/[core]:-tools.func Installs Adminer, supporting both Debian/Ubuntu and Alpine Linux distributions. ```bash setup_adminer ``` -------------------------------- ### Create and Configure Application Environment File Source: https://github.com/community-scripts/proxmoxve/wiki/[Script]:-AppName‐install.sh Creates a .env file for application configuration with specified database settings and sets ownership of the application directory. ```bash # Application-specific configuration cat > /opt/appname/.env <