From 2735d7ecc916b3544ec8d390fb8c3e067f3633ed Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Mon, 10 Nov 2025 13:32:10 +0100 Subject: [PATCH] Add missing api.func --- scripts/core/api.func | 132 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 scripts/core/api.func diff --git a/scripts/core/api.func b/scripts/core/api.func new file mode 100644 index 0000000..445ad06 --- /dev/null +++ b/scripts/core/api.func @@ -0,0 +1,132 @@ +# Copyright (c) 2021-2025 community-scripts ORG +# Author: michelroegl-brunner +# License: MIT | https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/LICENSE + +post_to_api() { + + if ! command -v curl &>/dev/null; then + return + fi + + if [ "$DIAGNOSTICS" = "no" ]; then + return + fi + + if [ -z "$RANDOM_UUID" ]; then + return + fi + + local API_URL="http://api.community-scripts.org/upload" + local pve_version="not found" + pve_version=$(pveversion | awk -F'[/ ]' '{print $2}') + + JSON_PAYLOAD=$( + cat </dev/null; then + return + fi + + if [ "$POST_UPDATE_DONE" = true ]; then + return 0 + fi + local API_URL="http://api.community-scripts.org/upload/updatestatus" + local status="${1:-failed}" + local error="${2:-No error message}" + + JSON_PAYLOAD=$( + cat <