FIX --HOST-DISABLE

This commit is contained in:
Erreur32 2024-07-28 16:09:01 +02:00
parent 94bb96bc48
commit ca8cc272dd

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# Nginx Proxy Manager CLI Script v2.1.0 # Nginx Proxy Manager CLI Script v1.1.2
# Erreur32 - July 2024 # Erreur32 - July 2024
# #
# This script allows you to manage Nginx Proxy Manager via the API. It provides # This script allows you to manage Nginx Proxy Manager via the API. It provides
@ -1171,18 +1171,9 @@ disable_proxy_host() {
fi fi
echo -e "\n ❌ Disabling 🌐 proxy host ID: $HOST_ID..." echo -e "\n ❌ Disabling 🌐 proxy host ID: $HOST_ID..."
# Check if the proxy host exists before disabling HTTP_RESPONSE=$(curl -s -w "HTTPSTATUS:%{http_code}" -X POST "$BASE_URL/nginx/proxy-hosts/$HOST_ID/disable" \
CHECK_RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)")
if echo "$CHECK_RESPONSE" | jq -e '.id' > /dev/null 2>&1; then
# Proxy host exists, proceed to disable
DATA=$(echo "$CHECK_RESPONSE" | jq '{enabled: 0}')
HTTP_RESPONSE=$(curl -s -w "HTTPSTATUS:%{http_code}" -X PUT "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)" \ -H "Authorization: Bearer $(cat $TOKEN_FILE)" \
-H "Content-Type: application/json; charset=UTF-8" \ -H "Content-Type: application/json")
--data-raw "$DATA")
# Extract the body and the status # Extract the body and the status
HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g') HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
@ -1193,11 +1184,9 @@ disable_proxy_host() {
else else
echo -e "${COLOR_RED}Failed to disable proxy host. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}\n" echo -e "${COLOR_RED}Failed to disable proxy host. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}\n"
fi fi
else
echo -e "${COLOR_RED}Proxy host with ID $HOST_ID does not exist.${COLOR_RESET}\n"
fi
} }
# Generate Let's Encrypt certificate if not exists # Generate Let's Encrypt certificate if not exists
generate_certificate() { generate_certificate() {
if [ -z "$DOMAIN" ] || [ -z "$EMAIL" ]; then if [ -z "$DOMAIN" ] || [ -z "$EMAIL" ]; then