-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Three-tier defaults system | security improvements | error_handler | improved logging | improved container creation | improved architecture #9540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+5,229
−2,287
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Refactored misc/alpine-install.func to improve error handling, network checks, and MOTD setup. Added misc/alpine-tools.func and misc/error_handler.func for modular tool installation and error management. Enhanced misc/api.func with detailed exit code explanations and telemetry functions. Updated misc/core.func for better initialization, validation, and execution helpers. Removed misc/create_lxc.sh as part of cleanup.
Refactor service stopping logic and improve variable handling
Updated copyright information and adjusted package installation commands. Enhanced IPv6 disabling logic and improved container customization process.
Refactor IPv6 handling and update OS function. Enhance MOTD with additional details and configure SSH settings.
Updated IPv6 Address Management menu options for clarity and added a new option for fully disabling IPv6.
This was
linked to
issues
Dec 2, 2025
tremor021
previously approved these changes
Dec 2, 2025
michelroegl-brunner
requested changes
Dec 2, 2025
Co-authored-by: Michel Roegl-Brunner <[email protected]>
michelroegl-brunner
approved these changes
Dec 2, 2025
CrazyWolf13
requested changes
Dec 2, 2025
michelroegl-brunner
requested changes
Dec 2, 2025
michelroegl-brunner
requested changes
Dec 2, 2025
Member
michelroegl-brunner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to recheck error_handler, ther are multiple dupicated error codes in there
CrazyWolf13
requested changes
Dec 2, 2025
13 tasks
Removed '[dev]' from whiptail --backtitle strings for consistency. Refactored custom exit codes in build.func and error_handler.func: updated Proxmox error codes, shifted MySQL/MariaDB codes to 260-263, and removed unused MongoDB code. Updated error descriptions to match new codes.
Standardized bash variable checks, removed unnecessary debug and commented code, and clarified error handling logic in container build and setup scripts. These changes improve code readability and maintainability without altering functional behavior.
Enhanced LXC container network setup to check for both IPv4 and IPv6 addresses, added connectivity (ping) tests, and provided troubleshooting tips on failure. Updated storage validation to support LINSTOR, including cluster connectivity checks and special handling for LINSTOR template storage.
michelroegl-brunner
approved these changes
Dec 3, 2025
CrazyWolf13
approved these changes
Dec 3, 2025
probers1
pushed a commit
to probers1/ProxmoxVE
that referenced
this pull request
Dec 5, 2025
…improved logging | improved container creation | improved architecture (community-scripts#9540) * Refactor Core Refactored misc/alpine-install.func to improve error handling, network checks, and MOTD setup. Added misc/alpine-tools.func and misc/error_handler.func for modular tool installation and error management. Enhanced misc/api.func with detailed exit code explanations and telemetry functions. Updated misc/core.func for better initialization, validation, and execution helpers. Removed misc/create_lxc.sh as part of cleanup. * Delete config-file.func * Update install.func * Refactor stop_all_services function and variable names Refactor service stopping logic and improve variable handling * Refactor installation script and update copyright Updated copyright information and adjusted package installation commands. Enhanced IPv6 disabling logic and improved container customization process. * Update install.func * Update license comment format in install.func * Refactor IPv6 handling and enhance MOTD and SSH Refactor IPv6 handling and update OS function. Enhance MOTD with additional details and configure SSH settings. * big core refactor * Enhance IPv6 configuration menu options Updated IPv6 Address Management menu options for clarity and added a new option for fully disabling IPv6. * Update default Node.js version to 24 LTS * Update misc/alpine-tools.func Co-authored-by: Michel Roegl-Brunner <[email protected]> * indention * remove debugf and duplicate codes * Update whiptail backtitles and error codes Removed '[dev]' from whiptail --backtitle strings for consistency. Refactored custom exit codes in build.func and error_handler.func: updated Proxmox error codes, shifted MySQL/MariaDB codes to 260-263, and removed unused MongoDB code. Updated error descriptions to match new codes. * comments * Refactor error handling and clean up debug comments Standardized bash variable checks, removed unnecessary debug and commented code, and clarified error handling logic in container build and setup scripts. These changes improve code readability and maintainability without altering functional behavior. * Update build.func * feat: Improve LXC network checks and LINSTOR storage handling Enhanced LXC container network setup to check for both IPv4 and IPv6 addresses, added connectivity (ping) tests, and provided troubleshooting tips on failure. Updated storage validation to support LINSTOR, including cluster connectivity checks and special handling for LINSTOR template storage. --------- Co-authored-by: Michel Roegl-Brunner <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
api
Changes to the API
core
delete script
A change that deletes a script
new script
A change that adds a new script
update script
A change that updates a script
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✍️ Description
The
/miscdirectory has undergone significant refactoring to improve maintainability, security, and functionality. This document tracks all changes, removed files, and new patterns.You can find several guides here:
Short Summary of Features
error_handler.funcwith stack traces & exit code explanationerror_handler.funcbuild.funcVAR_WHITELISTvalidationbuild.funcload_vars_file()withoutsource/eval- manual parsingbuild.func.varsfilesbuild.funcbuild.funccloud-init.funcwith IP validation & securitycloud-init.funcfind_host_ssh_keys()scans for available keysbuild.func/etc/sysctl.d/instead of/etc/sysctl.confinstall.funcbuild.func,install.funccore.funcbuild.funcbuild.funcFile Status Summary
api.funcbuild.funccloud-init.funccore.funcerror_handler.funcinstall.functools.funcconfig-file.funccreate_lxc.shMajor Changes in build.func
1. Configuration System Overhaul
❌ Removed
config-file.funcdependency: Old configuration file format no longer used✅ New System: Three-Tier Defaults Architecture
2. Variable Whitelisting System
A new security layer has been introduced to control which variables can be persisted:
# Allowed configurable variables VAR_WHITELIST=( var_apt_cacher var_apt_cacher_ip var_brg var_cpu var_disk var_fuse var_gateway var_hostname var_ipv6_method var_mac var_mknod var_mount_fs var_mtu var_net var_nesting var_ns var_protection var_pw var_ram var_tags var_timezone var_tun var_unprivileged var_verbose var_vlan var_ssh var_ssh_authorized_key var_container_storage var_template_storage )Changes from Previous:
var_ctid(unique per container, cannot be shared)var_ipv6_static(static IPs are container-specific)3. Default Settings Management Functions
default_var_settings()/usr/local/community-scripts/default.varsget_app_defaults_path()/usr/local/community-scripts/defaults/<appname>.vars/usr/local/community-scripts/defaults/pihole.varsmaybe_offer_save_app_defaults()4. Load Variables File Function
load_vars_file().varsfilessourceorevalExample Usage:
load_vars_file "/usr/local/community-scripts/defaults/pihole.vars"5. Removed Functions
create_lxc()- Replaced by build.func workflowread_config()- Replaced by load_vars_file()write_config()- Replaced by direct file generation with sanitizationInstallation Modes & Workflows
Mode 1: Default Settings
Use Case: First-time users, basic deployments
Mode 2: Advanced Settings
Use Case: Custom configurations, experienced users
Mode 3: User Defaults
Use Case: Consistent deployments across multiple containers
Mode 4: App Defaults
Use Case: Repeat installations with saved configurations
Mode 5: Settings Menu
Use Case: Configuration management
Configurable Variables Reference
Resource Allocation
var_cpu4var_ram2048var_disk20var_unprivileged11Network Configuration
var_netvethvar_brgvmbr0vmbr100var_gateway192.168.1.1var_mtu15009000var_vlan100Identity & Access
var_hostnamemypiholevar_pwMySecurePass123!var_sshnoyesvar_ssh_authorized_keyssh-rsa AAAA...Container Features
var_fuse01var_tun01var_nesting01var_keyctl01var_mknod01var_mount_fsext4var_protection01System Configuration
var_timezoneEurope/Berlinvar_searchdomainexample.comvar_apt_cacherapt-cacher-ngvar_apt_cacher_ip192.168.1.100var_tagsdocker,productionvar_verbosenoyesStorage Configuration
var_container_storagelocalvar_template_storagelocalFile Formats
User Defaults:
/usr/local/community-scripts/default.vars# User Global Defaults var_cpu=4 var_ram=2048 var_disk=20 var_unprivileged=1 var_brg=vmbr0 var_gateway=192.168.1.1 var_vlan=100 var_mtu=1500 var_hostname=mydefaults var_timezone=Europe/Berlin var_ssh=yes var_ssh_authorized_key=ssh-rsa AAAAB3NzaC1... var_container_storage=local var_template_storage=localApp Defaults:
/usr/local/community-scripts/defaults/<app>.vars# App-specific defaults for PiHole (pihole) - Example: var_unprivileged=1 var_cpu=2 var_ram=1024 var_disk=10 var_brg=vmbr0 var_net=veth var_gateway=192.168.1.1 var_mtu=1500 var_vlan=100 var_hostname=pihole var_timezone=Europe/Berlin var_container_storage=local var_template_storage=local var_tags=dns,pihole var_verbose=noUsage Examples
Example 1: Set Global User Defaults
/usr/local/community-scripts/default.varsFuture Installations: Select User Defaults mode to reuse settings
Example 2: Create & Use App Defaults
pihole-install.sh)/usr/local/community-scripts/defaults/pihole.varsNext Time:
pihole-install.shagain (bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/pihole.sh)")Example 3: Override via Environment Variables
Priority: Environment variables override all defaults
Example 4: Manual File Editing
Security Improvements
1. No
sourceorevalUsedsource config_file(Dangerous - executes arbitrary code)load_vars_file()(Safe - manual parsing with validation)2. Variable Whitelisting
3. Value Sanitization
4. File Permissions
# Default vars accessible only to root -rw-r--r-- root root /usr/local/community-scripts/default.vars -rw-r--r-- root root /usr/local/community-scripts/defaults/pihole.varsMigration Guide
For Users
OLD Workflow: Manual config file editing
NEW Workflow:
For Script Developers
OLD Pattern:
source /path/to/config-file.confNEW Pattern:
Removed Components
config-file.func(Deprecated)Reason: Replaced by three-tier defaults system
Migration Path: Use app/user defaults system
create_lxc.sh(Deprecated)Reason: Workflow integrated into build.func
Migration Path: Use build.func directly
Future Enhancements
Planned Features
Troubleshooting
Issue: Defaults not loading
Solution:
Issue: Variable not being applied
Solution:
VAR_WHITELISTvar_=)catnotsourceto read filesIssue: "Invalid option" in defaults menu
Solution:
/usr/local/community-scripts/defaults/sudo mkdir -p /usr/local/community-scripts/defaults/Technical Reference
Variable Loading Precedence
State Machine: Installation Modes
🔗 Related PR / Issue
Link: #7438 #7000 #6270 #6234 #9516
✅ Prerequisites (X in brackets)
🛠️ Type of Change (X in brackets)
README,AppName.md,CONTRIBUTING.md, or other docs.