From 75926c6128f8b1a55e557a764415455ae5686aeb Mon Sep 17 00:00:00 2001
From: Sebastian Schmidt <2270806+jammsen@users.noreply.github.com>
Date: Wed, 14 Feb 2024 15:41:24 +0100
Subject: [PATCH] Added the option to enable webhook curl debugging for weird
error edge-cases
---
CHANGELOG.md | 4 ++++
Dockerfile | 1 +
default.env | 1 +
docs/ENV_VARS.md | 1 +
includes/webhook.sh | 13 ++++++++-----
5 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7f9fb86..cf426ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
[Back to main](README.md#changelog)
+## 2024-02-13
+
+* Added the option to enable webhook curl debugging for weird error edge-cases
+
## 2024-02-13
* **Breaking changes:**
* Changed the default BACKUP_RETENTION_POLICY to true and changed BACKUP_RETENTION_AMOUNT_TO_KEEP to 72, meaning 3 days worth of backup are kept in the default configuration
diff --git a/Dockerfile b/Dockerfile
index b42cba5..1434606 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -34,6 +34,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
RESTART_CRON_EXPRESSION="0 3,15 * * *" \
# Webhook-settings
WEBHOOK_ENABLED=false \
+ WEBHOOK_DEBUG_ENABLED=false \
WEBHOOK_URL= \
WEBHOOK_INFO_TITLE="Info" \
WEBHOOK_INFO_DESCRIPTION="This is an info from the server" \
diff --git a/default.env b/default.env
index 4d92349..4f96cf9 100644
--- a/default.env
+++ b/default.env
@@ -15,6 +15,7 @@ RESTART_ENABLED=false
RESTART_CRON_EXPRESSION="0 3,15 * * *"
# Webhook-settings
WEBHOOK_ENABLED=false
+WEBHOOK_DEBUG_ENABLED=false
WEBHOOK_URL="YOUR-URL-IN-HERE"
WEBHOOK_INFO_TITLE="Info"
WEBHOOK_INFO_DESCRIPTION="This is an info from the server"
diff --git a/docs/ENV_VARS.md b/docs/ENV_VARS.md
index 89678db..215689d 100644
--- a/docs/ENV_VARS.md
+++ b/docs/ENV_VARS.md
@@ -24,6 +24,7 @@ These settings control the behavior of the Docker container:
| RESTART_ENABLED | Automatic restarts the server | false | Boolean |
| RESTART_CRON_EXPRESSION | Needs a Cron-Expression - See [Cron expression](#cron-expression) | 0 3,15 * * * | Cron-Expression |
| WEBHOOK_ENABLED | Set to enabled will send webhook notifications, NEEDS `WEBHOOK_URL` | false | Boolean |
+| WEBHOOK_DEBUG_ENABLED | Set to enabled will enable feedback of curl and not use --silent | false | Boolean |
| WEBHOOK_URL | Defines the url the webhook to send data to | | Url |
| WEBHOOK_* | See below the table "Webhook environment variables" | | String |
| SERVER_SETTINGS_MODE | Determines whether settings can be modified via environment variables or via file, except `COMMUNITY_SERVER` and `MULTITHREAD_ENABLED`! | `auto` | Enum
`auto`: Settings are modified only by environment variables, manual edits will be ignored
`manual`: Settings are modified only by editing the file directly, environment variables are ignored |
diff --git a/includes/webhook.sh b/includes/webhook.sh
index 52224fb..d319abf 100644
--- a/includes/webhook.sh
+++ b/includes/webhook.sh
@@ -20,11 +20,14 @@ send_webhook_notification() {
local title="$1"
local description="$2"
local color="$3"
-
- # Debug Curl
- #curl --ssl-no-revoke -H "Content-Type: application/json" -X POST -d "$(generate_post_data "$title" "$description" "$color")" "$WEBHOOK_URL"
- # Prod Curl
- curl --silent --ssl-no-revoke -H "Content-Type: application/json" -X POST -d "$(generate_post_data "$title" "$description" "$color")" "$WEBHOOK_URL"
+
+ if [[ -n $WEBHOOK_DEBUG_ENABLED ]] && [[ $WEBHOOK_DEBUG_ENABLED == "true" ]]; then
+ # Debug Curl
+ curl --ssl-no-revoke -H "Content-Type: application/json" -X POST -d "$(generate_post_data "$title" "$description" "$color")" "$WEBHOOK_URL"
+ else
+ # Prod Curl
+ curl --silent --ssl-no-revoke -H "Content-Type: application/json" -X POST -d "$(generate_post_data "$title" "$description" "$color")" "$WEBHOOK_URL"
+ fi
}
#Aliases to use in scripts