diff --git a/README.md b/README.md index 7988ee8..8a2c85f 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,18 @@ chmod +x shell_ntfy_remote_shutdown.sh Erstellen Sie eine `.env`-Datei mit den folgenden Variablen: ```bash +# NTFY Server NTFY_URL=https://ntfy.server.net/ AUTH_TOKEN=tk_elwqvm6niscdn30f45iksdfh6sope + +# Duplicati Server DUPLICATI_URL=http://192.168.178.100:8200 SERVER_NAME=unRAID + +# NTFY Icon (Optional / Leer lassen falls nicht benötigt) ICON=http://192.168.178.25:3030/icons/qnap-ts-412.png + +# SSH Zugangsdaten des entfernten System SSH_HOST=192.168.178.105 SSH_USER=sshuser SSH_PASSWORD=sshpass diff --git a/shell_ntfy_remote_shutdown.env b/shell_ntfy_remote_shutdown.env index 0468fbe..47b3baa 100644 --- a/shell_ntfy_remote_shutdown.env +++ b/shell_ntfy_remote_shutdown.env @@ -1,8 +1,15 @@ +# NTFY Server NTFY_URL=https://ntfy.server.net/ AUTH_TOKEN=tk_elwqvm6niscdn30f45iksdfh6sope + +# Duplicati Server DUPLICATI_URL=http://192.168.178.100:8200 SERVER_NAME=unRAID + +# NTFY Icon (Optional / Leer lassen falls nicht benötigt) ICON=http://192.168.178.25:3030/icons/qnap-ts-412.png + +# SSH Zugangsdaten des entfernten System SSH_HOST=192.168.178.105 SSH_USER=sshuser SSH_PASSWORD=sshpass diff --git a/shell_ntfy_remote_shutdown.sh b/shell_ntfy_remote_shutdown.sh old mode 100644 new mode 100755 index ff0f022..4583fc6 --- a/shell_ntfy_remote_shutdown.sh +++ b/shell_ntfy_remote_shutdown.sh @@ -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" \ No newline at end of file +#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" \ No newline at end of file