$ICON is optional now

This commit is contained in:
2024-12-21 18:30:14 +01:00
parent 8214ecf60d
commit 5617e3a03c
3 changed files with 36 additions and 16 deletions

38
shell_ntfy_remote_shutdown.sh Normal file → Executable file
View File

@@ -12,21 +12,27 @@ fi
# .env-Datei laden
source "$ENV_FILE"
# NTFY-Benachrichtigung senden
curl -s -X POST "$NTFY_URL" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Priority: default" \
-H "Tags: checkered_flag" \
-H "Icon: $ICON" \
-H "Content-Type: application/json" \
-d "{
\"topic\": \"Duplicati\",
\"title\": \"Backups beendet\",
\"message\": \"QNas wird heruntergefahren.\n\nServer: $SERVER_NAME\",
\"click\": \"\",
\"actions\": [{ \"action\": \"view\", \"label\": \"Duplicati öffnen\", \"url\": \"$DUPLICATI_URL\" }]
}"
# Server herunterfahren
sshpass -p "$SSH_PASSWORD" ssh -o "StrictHostKeyChecking=no" "$SSH_USER@$SSH_HOST" "poweroff"
sshpass -p "$SSH_PASSWORD" ssh -o "StrictHostKeyChecking=no" "$SSH_USER@$SSH_HOST" "shutdown"
#sshpass -p "$SSH_PASSWORD" ssh -o "StrictHostKeyChecking=no" "$SSH_USER@$SSH_HOST" "poweroff"
#sshpass -p "$SSH_PASSWORD" ssh -o "StrictHostKeyChecking=no" "$SSH_USER@$SSH_HOST" "shutdown"
# NTFY-Benachrichtigung vorbereiten
CURL_CMD="curl -s -X POST \"$NTFY_URL\" \
-H \"Authorization: Bearer $AUTH_TOKEN\" \
-H \"Priority: default\" \
-H \"Tags: checkered_flag\""
[ -n "$ICON" ] && CURL_CMD="$CURL_CMD -H \"Icon: $ICON\""
CURL_CMD="$CURL_CMD -H \"Content-Type: application/json\" \
-d \"{
\\\"topic\\\": \\\"Duplicati\\\",
\\\"title\\\": \\\"Backups beendet\\\",
\\\"message\\\": \\\"QNas wird heruntergefahren.\\n\\nServer: $SERVER_NAME\\\",
\\\"click\\\": \\\"\\\",
\\\"actions\\\": [{ \\\"action\\\": \\\"view\\\", \\\"label\\\": \\\"Duplicati öffnen\\\", \\\"url\\\": \\\"$DUPLICATI_URL\\\" }]
}\""
# Benachrichtigung senden
/bin/bash -c "$CURL_CMD"