1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-02-01 16:51:52 +00:00

[API] Update build.func: add function to see if a script failed or not

This commit is contained in:
Michel Roegl-Brunner 2025-01-30 14:28:50 +01:00
parent 720c4ce1d2
commit 875f18dad1

View File

@ -797,7 +797,7 @@ post_to_api() {
local pve_version="not found" local pve_version="not found"
pve_version=$(pveversion | awk -F'[/ ]' '{print $2}') pve_version=$(pveversion | awk -F'[/ ]' '{print $2}')
JSON_PAYLOAD=$(cat <<EOF JSON_PAYLOAD=$(cat <<EOF
{ {
"ct_type": $CT_TYPE, "ct_type": $CT_TYPE,
"disk_size": $DISK_SIZE, "disk_size": $DISK_SIZE,
@ -830,9 +830,9 @@ EOF
} }
post_update_to_api() { post_update_to_api() {
local API_URL="http://api.community-scripts.org/upload/updatestatus" local API_URL="http://api.community-scripts.org/upload/updatestatus"
JSON_PAYLOAD=$(cat <<EOF JSON_PAYLOAD=$(cat <<EOF
{ {
"status": "done", "status": "done",
"random_id": "$RANDOM_UUID" "random_id": "$RANDOM_UUID"
@ -840,13 +840,13 @@ post_update_to_api() {
EOF EOF
) )
RESPONSE=$(curl -s -o response.txt -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \ RESPONSE=$(curl -s -o response.txt -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "$JSON_PAYLOAD") -d "$JSON_PAYLOAD")
if [ "$RESPONSE" -ne 201 ] && [ "$RESPONSE" -ne 302 ]; then if [ "$RESPONSE" -ne 201 ] && [ "$RESPONSE" -ne 302 ]; then
msg_error "API request failed with HTTP code $RESPONSE" msg_error "API request failed with HTTP code $RESPONSE"
fi fi
} }