mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-02-01 17:51:49 +00:00
[API] Update build.func: add function to see if a script failed or not (#1874)
* [API] Update build.func: add function to see if a script failed or not * [API] Update build.func: add function to see if a script failed or not
This commit is contained in:
parent
af04e933e3
commit
0642c7e2c8
@ -12,6 +12,7 @@ variables() {
|
|||||||
PVEHOST_NAME=$(hostname) # gets the Proxmox Hostname and sets it to Uppercase
|
PVEHOST_NAME=$(hostname) # gets the Proxmox Hostname and sets it to Uppercase
|
||||||
DIAGNOSTICS="yes" # sets the DIAGNOSTICS variable to "yes", used for the API call.
|
DIAGNOSTICS="yes" # sets the DIAGNOSTICS variable to "yes", used for the API call.
|
||||||
METHOD="default" # sets the METHOD variable to "default", used for the API call.
|
METHOD="default" # sets the METHOD variable to "default", used for the API call.
|
||||||
|
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" # generates a random UUID and sets it to the RANDOM_UUDI variable.
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
# This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
||||||
@ -796,8 +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=$(
|
JSON_PAYLOAD=$(cat <<EOF
|
||||||
cat <<EOF
|
|
||||||
{
|
{
|
||||||
"ct_type": $CT_TYPE,
|
"ct_type": $CT_TYPE,
|
||||||
"disk_size": $DISK_SIZE,
|
"disk_size": $DISK_SIZE,
|
||||||
@ -812,10 +812,12 @@ post_to_api() {
|
|||||||
"tags": "$TAGS",
|
"tags": "$TAGS",
|
||||||
"nsapp": "$NSAPP",
|
"nsapp": "$NSAPP",
|
||||||
"method": "$METHOD",
|
"method": "$METHOD",
|
||||||
"pve_version": "$pve_version"
|
"pve_version": "$pve_version",
|
||||||
|
"status": "failed",
|
||||||
|
"random_id": "$RANDOM_UUID"
|
||||||
}
|
}
|
||||||
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" \
|
||||||
@ -827,6 +829,28 @@ EOF
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post_update_to_api() {
|
||||||
|
local API_URL="http://api.community-scripts.org/upload/updatestatus"
|
||||||
|
|
||||||
|
JSON_PAYLOAD=$(cat <<EOF
|
||||||
|
{
|
||||||
|
"status": "done",
|
||||||
|
"random_id": "$RANDOM_UUID"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
RESPONSE=$(curl -s -o response.txt -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$JSON_PAYLOAD")
|
||||||
|
|
||||||
|
if [ "$RESPONSE" -ne 201 ] && [ "$RESPONSE" -ne 302 ]; then
|
||||||
|
msg_error "API request failed with HTTP code $RESPONSE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
diagnostics_check(){
|
diagnostics_check(){
|
||||||
if ! [ -d "/usr/local/community-scripts" ]; then
|
if ! [ -d "/usr/local/community-scripts" ]; then
|
||||||
mkdir -p /usr/local/community-scripts
|
mkdir -p /usr/local/community-scripts
|
||||||
@ -1202,4 +1226,8 @@ EOF
|
|||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $DIAGNOSTICS == "yes" ]]; then
|
||||||
|
post_update_to_api
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user