From 0a833fc2df22efc8c7465541fe2d5994e22efba6 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt <2270806+jammsen@users.noreply.github.com> Date: Sat, 3 Feb 2024 12:07:36 +0100 Subject: [PATCH] #120 - Added new mechanic for sending notify on different ways of stop/exit/hard-kills --- includes/webhook.sh | 6 ++++++ servermanager.sh | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/webhook.sh b/includes/webhook.sh index a51038c..aa87927 100644 --- a/includes/webhook.sh +++ b/includes/webhook.sh @@ -26,3 +26,9 @@ send_webhook_notification() { # Prod Curl curl --silent --ssl-no-revoke -H "Content-Type: application/json" -X POST -d "$(generate_post_data "$title" "$description" "$color")" "$WEBHOOK_URL" } + +send_stop_notification() { + if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then + send_webhook_notification "$WEBHOOK_STOP_TITLE" "$WEBHOOK_STOP_DESCRIPTION" "$WEBHOOK_STOP_COLOR" + fi +} \ No newline at end of file diff --git a/servermanager.sh b/servermanager.sh index 8ad6433..1d03a60 100755 --- a/servermanager.sh +++ b/servermanager.sh @@ -59,9 +59,7 @@ term_handler() { fi kill -SIGTERM $(pidof PalServer-Linux-Test) tail --pid=$(pidof PalServer-Linux-Test) -f 2>/dev/null - if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then - send_webhook_notification "$WEBHOOK_STOP_TITLE" "$WEBHOOK_STOP_DESCRIPTION" "$WEBHOOK_STOP_COLOR" - fi + send_stop_notification exit 143; } @@ -72,5 +70,6 @@ killpid="$!" while true do wait $killpid + send_stop_notification exit 0; done