From 2574e41ee89e6d20eceb9a8e9a1c65bc97cd36de Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com> Date: Tue, 10 Jun 2025 09:24:20 +0200 Subject: [PATCH] Prevent api from posing if disabled (#5080) --- misc/api.func | 12 +++++++++--- misc/build.func | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/misc/api.func b/misc/api.func index 4e77247c0..67f0b6510 100644 --- a/misc/api.func +++ b/misc/api.func @@ -39,9 +39,11 @@ post_to_api() { EOF ) - RESPONSE=$(curl -fsSL -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \ + if [[ "$DIAGNOSTICS" == "yes" ]]; then + RESPONSE=$(curl -s -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \ -H "Content-Type: application/json" \ -d "$JSON_PAYLOAD") || true + fi } post_to_api_vm() { @@ -87,9 +89,11 @@ post_to_api_vm() { EOF ) - RESPONSE=$(curl -fsSL -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \ + if [[ "$DIAGNOSTICS" == "yes" ]]; then + RESPONSE=$(curl -s -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \ -H "Content-Type: application/json" \ -d "$JSON_PAYLOAD") || true + fi } POST_UPDATE_DONE=false @@ -115,9 +119,11 @@ post_update_to_api() { EOF ) - RESPONSE=$(curl -fsSL -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \ + if [[ "$DIAGNOSTICS" == "yes" ]]; then + RESPONSE=$(curl -s -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \ -H "Content-Type: application/json" \ -d "$JSON_PAYLOAD") || true + fi POST_UPDATE_DONE=true } diff --git a/misc/build.func b/misc/build.func index 7ec76bc37..265c32a56 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1090,6 +1090,8 @@ build_container() { else export FUNCTIONS_FILE_PATH="$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/install.func)" fi + + export DIAGNOSTICS="$DIAGNOSTICS" export RANDOM_UUID="$RANDOM_UUID" export CACHER="$APT_CACHER" export CACHER_IP="$APT_CACHER_IP"