diff --git a/deployment/proxmox/provision.sh b/deployment/proxmox/provision.sh index 9ad2cd4..0b38bfb 100755 --- a/deployment/proxmox/provision.sh +++ b/deployment/proxmox/provision.sh @@ -24,6 +24,8 @@ cores=1 memory=2048 vm_ids= +debug=false + help () { cat <&2 '\033[37m'; printf >&2 "$@"; printf >&2 '\033[0m\n'; fi } + while [ $# -gt 0 ]; do argument=$1 shift @@ -62,6 +68,8 @@ while [ $# -gt 0 ]; do --cores) cores=$1; shift ;; --memory) memory=$1; shift ;; + --debug) debug=true ;; + -h|-\?|--help) help; exit 0 ;; -*) die_with_help "Unknown argument: '%s'." "$argument" ;; @@ -91,6 +99,8 @@ readonly memory # fi # readonly node +readonly debug + ################################################################################ ## Getting started @@ -117,14 +127,19 @@ release_lock () { proxmox () { acquire_lock proxmox - http \ - --form \ - --verify no \ - --ignore-stdin \ - "$@" \ - "Cookie:PVEAuthCookie=$ticket" \ - "CSRFPreventionToken:$csrf_token" + debug 'request %s' "$*" + response=$( + http \ + --form \ + --verify no \ + --ignore-stdin \ + "$@" \ + "Cookie:PVEAuthCookie=$ticket" \ + "CSRFPreventionToken:$csrf_token" + ) + debug 'response to request %s:\n %s' "$*" "$response" release_lock proxmox + echo "$response" } ## Synchronous variant for when the `proxmox` function would just respond an