mirror of
https://github.com/Erreur32/nginx-proxy-manager-Bash-API.git
synced 2024-12-22 05:22:11 +01:00
FIX --HOST-DISABLE
This commit is contained in:
parent
94bb96bc48
commit
ca8cc272dd
1 changed files with 11 additions and 22 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Nginx Proxy Manager CLI Script v2.1.0
|
||||
# Nginx Proxy Manager CLI Script v1.1.2
|
||||
# Erreur32 - July 2024
|
||||
#
|
||||
# This script allows you to manage Nginx Proxy Manager via the API. It provides
|
||||
|
@ -1171,18 +1171,9 @@ disable_proxy_host() {
|
|||
fi
|
||||
echo -e "\n ❌ Disabling 🌐 proxy host ID: $HOST_ID..."
|
||||
|
||||
# Check if the proxy host exists before disabling
|
||||
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" \
|
||||
HTTP_RESPONSE=$(curl -s -w "HTTPSTATUS:%{http_code}" -X POST "$BASE_URL/nginx/proxy-hosts/$HOST_ID/disable" \
|
||||
-H "Authorization: Bearer $(cat $TOKEN_FILE)" \
|
||||
-H "Content-Type: application/json; charset=UTF-8" \
|
||||
--data-raw "$DATA")
|
||||
-H "Content-Type: application/json")
|
||||
|
||||
# Extract the body and the status
|
||||
HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
|
||||
|
@ -1193,11 +1184,9 @@ disable_proxy_host() {
|
|||
else
|
||||
echo -e " ⛔ ${COLOR_RED}Failed to disable proxy host. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}\n"
|
||||
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_certificate() {
|
||||
if [ -z "$DOMAIN" ] || [ -z "$EMAIL" ]; then
|
||||
|
|
Loading…
Reference in a new issue