Refactor VM script settings and fix load_functions errors - #13
Merged
Conversation
Every migrated VM script still carried two blocks that were not its own. The default-or-advanced fork was byte for byte identical in all of them, and the fifteen-line settings summary agreed on thirteen lines -- the two that differed, the CPU model label and the app name, are both derivable from variables the script has already set. vm_echo_default_settings computes the labels rather than taking them, so a script can no longer print "Host" while CPU_TYPE says otherwise. That was not hypothetical: the summary text and the variable were separate edits. vm_start_script resolves default_settings and advanced_settings when it runs, so each script still supplies its own. Nothing existing is changed -- the ten scripts that define start_script themselves keep overriding it. Caught while testing: vm_machine_type_label takes the type as an argument rather than reading MACHINE_TYPE, so calling it bare reported i440fx for every machine, q35 included. Verified both ways round now, along with the cache and CPU labels.
Three faults, all visible in one run of the CachyOS VM: 101 curl: (22) The requested URL returned error: 404 vm-core.func: line 124: _cs_clear: command not found load_functions ended with six bare names -- get_valid_nextid, cleanup_vmid, cleanup, check_root, pve_check, arch_check -- left behind when their bodies moved out of it. Loading the engine therefore ran them: the stray 101 is a VM ID printed by get_valid_nextid, and cleanup tore down a temp dir before there was one. Every script calls those itself afterwards, in its own order. The same residue is in debian-vm.sh and k3s-vm.sh in ProxmoxVED. _cs_clear had five callers here and no definition. core/core.func owns it, but a VM script never loads that file -- it carries its own colours and icons -- so header_info died on the first line it drew. get_header let curl print its 404. A script whose banner the generator has not produced yet is the normal case, and header_info already handles it by drawing nothing; it just did so loudly. The empty file curl leaves behind is removed too, since it would satisfy the cache check forever after.
Contributor
Try this branchThe engine and the scripts resolve independently, so a production script can COMMUNITY_SCRIPTS_CORE_URL=https://raw.githubusercontent.com/community-scripts/core/feat/vm-core-settings-helpers \
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/ct/debian.sh)"Swap This PR touches Run a script from a fork as wellcurl -fsSL https://raw.githubusercontent.com/community-scripts/core/feat/vm-core-settings-helpers/tools/run.sh |
bash -s -- https://raw.githubusercontent.com/YOU/ProxmoxVED/your-branch ct/debian.sh \
https://raw.githubusercontent.com/community-scripts/core/feat/vm-core-settings-helpersNote that Useful flags while testing
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Refactor VM script settings and fix load_functions errors
🔗 Related Issue
Fixes #
✅ Prerequisites (X in brackets)
API.txtwas updated to match.🤖 AI Assistance (X in brackets)
🛠️ Type of Change (X in brackets)
README,docs/,CONTRIBUTING.md, or other docs.