mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	[API] update build.func (#1894)
* [API] update build.func * [API] update build.func
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							d416ff9cfa
						
					
				
				
					commit
					2fa3116c9c
				
			@@ -2,8 +2,7 @@
 | 
				
			|||||||
# Author: tteck (tteckster)
 | 
					# Author: tteck (tteckster)
 | 
				
			||||||
# Co-Author: MickLesk
 | 
					# Co-Author: MickLesk
 | 
				
			||||||
# Co-Author: michelroegl-brunner
 | 
					# Co-Author: michelroegl-brunner
 | 
				
			||||||
# License: MIT
 | 
					# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
variables() {
 | 
					variables() {
 | 
				
			||||||
  NSAPP=$(echo ${APP,,} | tr -d ' ') # This function sets the NSAPP variable by converting the value of the APP variable to lowercase and removing any spaces.
 | 
					  NSAPP=$(echo ${APP,,} | tr -d ' ') # This function sets the NSAPP variable by converting the value of the APP variable to lowercase and removing any spaces.
 | 
				
			||||||
@@ -73,7 +72,6 @@ error_handler() {
 | 
				
			|||||||
  local exit_code="$?"
 | 
					  local exit_code="$?"
 | 
				
			||||||
  local line_number="$1"
 | 
					  local line_number="$1"
 | 
				
			||||||
  local command="$2"
 | 
					  local command="$2"
 | 
				
			||||||
  post_update_to_api "failed"
 | 
					 | 
				
			||||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
					  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
				
			||||||
  echo -e "\n$error_message\n"
 | 
					  echo -e "\n$error_message\n"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -794,6 +792,9 @@ advanced_settings() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
post_to_api() {
 | 
					post_to_api() {
 | 
				
			||||||
 | 
					  if [ "$DIAGNOSTICS" = "no" ]; then
 | 
				
			||||||
 | 
					    return 0
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
  local API_URL="http://api.community-scripts.org/upload"
 | 
					  local API_URL="http://api.community-scripts.org/upload"
 | 
				
			||||||
  local pve_version="not found"
 | 
					  local pve_version="not found"
 | 
				
			||||||
  pve_version=$(pveversion | awk -F'[/ ]' '{print $2}')
 | 
					  pve_version=$(pveversion | awk -F'[/ ]' '{print $2}')
 | 
				
			||||||
@@ -831,13 +832,17 @@ EOF
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
POST_UPDATE_DONE=false
 | 
					POST_UPDATE_DONE=false
 | 
				
			||||||
 | 
					 | 
				
			||||||
post_update_to_api() {
 | 
					post_update_to_api() {
 | 
				
			||||||
 | 
					    if [ "$DIAGNOSTICS" = "no" ]; then
 | 
				
			||||||
 | 
					        return 0
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
    if [ "$POST_UPDATE_DONE" = true ]; then
 | 
					    if [ "$POST_UPDATE_DONE" = true ]; then
 | 
				
			||||||
        return 0
 | 
					        return 0
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
						
 | 
				
			||||||
    local API_URL="http://api.community-scripts.org/upload/updatestatus"    
 | 
					    local API_URL="http://api.community-scripts.org/upload/updatestatus"    
 | 
				
			||||||
    local status="${1:-}"
 | 
					    local status="${1:-failed}"
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    JSON_PAYLOAD=$(cat <<EOF
 | 
					    JSON_PAYLOAD=$(cat <<EOF
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    "status": "$status",
 | 
					    "status": "$status",
 | 
				
			||||||
@@ -846,17 +851,18 @@ 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 UPDATE request failed with HTTP code $RESPONSE"
 | 
					    msg_error "API UPDATE request failed with HTTP code $RESPONSE"
 | 
				
			||||||
    fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   POST_UPDATE_DONE=true
 | 
					  POST_UPDATE_DONE=true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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
 | 
				
			||||||
@@ -1233,12 +1239,10 @@ EOF
 | 
				
			|||||||
    systemctl start ping-instances.service
 | 
					    systemctl start ping-instances.service
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  if [[ $DIAGNOSTICS == "yes" ]]; then
 | 
					  post_update_to_api "done"
 | 
				
			||||||
    post_update_to_api
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
trap 'post_update_to_api "done"' EXIT
 | 
					trap 'post_update_to_api "failed"' EXIT
 | 
				
			||||||
trap 'post_update_to_api "failed"' SIGINT 
 | 
					trap 'post_update_to_api "failed"' SIGINT 
 | 
				
			||||||
trap 'post_update_to_api "failed"' SIGTERM
 | 
					trap 'post_update_to_api "failed"' SIGTERM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user