VM-Core: Update some Functions#15113
Conversation
|
@copilot im to lazy, summarize the changes as text |
Here’s a plain-text summary of what changed in the last commit:
|
| [[ -n "${_CORE_FUNC_LOADED:-}" ]] && return | ||
| _CORE_FUNC_LOADED=1 | ||
|
|
||
| COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-https://git.community-scripts.org/community-scripts/ProxmoxVE/raw/branch/main}" |
There was a problem hiding this comment.
why headers from one source and general from our git?
Or is this just a fallback?
There was a problem hiding this comment.
Pull request overview
Updates the shared VM helper library (misc/vm-core.func) to support newer VM creation flows (interactive prompts, storage selection, cloud-init helpers) and to adjust supporting utilities (loading shared functions, curl/error handling, cleanup, and VM description markup). This file is a core dependency for VM scripts (e.g., vm/docker-vm.sh) and affects script startup/validation and error semantics.
Changes:
- Added lazy-loading helpers for API and cloud-init functions, plus many new VM interactive prompt/helpers (VMID, machine type, disk, CPU/RAM, networking, storage selection, disk references).
- Modified error/curl utilities (
silent,curl_handler,__curl_err_handler) and cleanup behavior (spinner stop, temp dir removal). - Updated various URLs and the VM description HTML block.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 | ||
| } |
| # Source explain_exit_code if needed | ||
| if ! declare -f explain_exit_code >/dev/null 2>&1; then | ||
| source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/error_handler.func") 2>/dev/null || true | ||
| fi |
| set -Eeuo pipefail | ||
| trap 'error_handler' ERR | ||
|
|
| [[ -n "$curl_msg" ]] && printf "%s\n" "$curl_msg" >&2 | ||
| exit "$exit_code" | ||
| exit 1 | ||
| } |
| if [[ "$(ps -p $$ -o comm=)" != "bash" ]]; then | ||
| clear | ||
| msg_error "Your default shell is currently not set to Bash. To use these scripts, please switch to the Bash shell." | ||
| echo -e "\nExiting..." | ||
| sleep 2 | ||
| exit 103 | ||
| exit | ||
| fi |
| if [ -z "$valid_storage" ]; then | ||
| msg_error "Unable to detect a valid storage location." | ||
| exit | ||
| elif [ $((${#storage_menu[@]} / 3)) -eq 1 ]; then |
| if [[ -z "$url" ]]; then | ||
| msg_error "no valid url or option entered for curl_handler" | ||
| exit 64 | ||
| exit 1 | ||
| fi |
| curl_stderr=$(</tmp/curl_error.log) | ||
| rm -f /tmp/curl_error.log | ||
| fi | ||
| __curl_err_handler "$exit_code" "$url" "$curl_stderr" | ||
| exit "$exit_code" | ||
| exit 1 # hard exit if exit_code is not 0 | ||
| fi |
| <p style='margin: 16px 0;'> | ||
| <a href='${donate_url}' target='_blank' rel='noopener noreferrer'> | ||
| <img src='https://img.shields.io/badge/❤️-Sponsoring%20%26%20Donations-FF5E5B' alt='Sponsoring and donations' /> | ||
| </a> | ||
| </p> | ||
|
|
||
| <p style='margin: 12px 0;'> | ||
| <a href='${script_url}' target='_blank' rel='noopener noreferrer'> | ||
| <img src='https://img.shields.io/badge/📦-Open%20Script%20Page-00617f' alt='Open script page' /> | ||
| <a href='https://ko-fi.com/community_scripts' target='_blank' rel='noopener noreferrer'> | ||
| <img src='https://img.shields.io/badge/☕-Buy us a coffee-blue' alt='spend Coffee' /> | ||
| </a> | ||
| </p> |
| else | ||
| echo -e "${DISKSIZE}${BOLD}${RD}Invalid Disk Size. Please use a number (e.g., 10 or 10G).${CL}" | ||
| exit_script | ||
| fi |
✍️ Description
see summarize here; #15113 (comment)
🔗 Related Issue
Fixes #
✅ Prerequisites (X in brackets)
🛠️ Type of Change (X in brackets)
README,AppName.md,CONTRIBUTING.md, or other docs.