Refactor VM script to use shared vm-core helpers
Introduce a shared vm-core loader and refactor the Ubuntu 26.04 VM script to use reusable helper functions. misc/vm-core.func: add COMMUNITY_SCRIPTS_URL default and load_api_functions to dynamically source API helpers, then call load_api_functions from load_functions. vm/ubuntu2604-vm.sh: switch to sourcing the shared vm-core via COMMUNITY_SCRIPTS_URL, replace many inline UI and utility functions with generic vm_* helpers (vm_confirm_new_vm, vm_prompt_*, vm_select_storage, vm_define_disk_references, set_description, etc.), modernize quoting and pushd usage, simplify disk import/resizing logic, and set START_VM default to yes. Also update repository URLs to ProxmoxVED and adjust some behavior (machine type handling, storage/disk references). Overall this centralizes common functionality, reduces duplication, and prepares scripts to use the shared core utilities.
This commit is contained in:
@@ -14,9 +14,18 @@ declare -A MSG_INFO_SHOWN
|
||||
[[ -n "${_CORE_FUNC_LOADED:-}" ]] && return
|
||||
_CORE_FUNC_LOADED=1
|
||||
|
||||
COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main}"
|
||||
|
||||
load_api_functions() {
|
||||
if ! declare -f post_to_api_vm >/dev/null 2>&1; then
|
||||
source /dev/stdin <<<$(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/api.func")
|
||||
fi
|
||||
}
|
||||
|
||||
load_functions() {
|
||||
[[ -n "${__FUNCTIONS_LOADED:-}" ]] && return
|
||||
__FUNCTIONS_LOADED=1
|
||||
load_api_functions
|
||||
color
|
||||
formatting
|
||||
icons
|
||||
|
||||
Reference in New Issue
Block a user