From ac10a96cc821f8fb7051fda25b1ea3abcf5a9406 Mon Sep 17 00:00:00 2001 From: mag37 Date: Mon, 7 Oct 2024 21:28:31 +0200 Subject: [PATCH] all template rewritten, some guesswork --- notify_templates/notify_DSM.sh | 4 ++-- notify_templates/notify_apprise.sh | 11 +++-------- notify_templates/notify_generic.sh | 8 +++++--- notify_templates/notify_gotify.sh | 6 +++--- notify_templates/notify_matrix.sh | 4 ++-- notify_templates/notify_ntfy-sh.sh | 11 +++-------- notify_templates/notify_pushbullet.sh | 6 +++--- notify_templates/notify_pushover.sh | 6 +++--- notify_templates/notify_smtp.sh | 4 ++-- notify_templates/notify_telegram.sh | 4 ++-- 10 files changed, 28 insertions(+), 36 deletions(-) diff --git a/notify_templates/notify_DSM.sh b/notify_templates/notify_DSM.sh index 1c74c11..84ba7e9 100644 --- a/notify_templates/notify_DSM.sh +++ b/notify_templates/notify_DSM.sh @@ -18,8 +18,8 @@ else fi send_notification() { -Updates=("$@") -[ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) +[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") +UpdToString=$( printf '%s\\n' "${Updates[@]}" ) FromHost=$(hostname) CfgFile="/usr/syno/etc/synosmtp.conf" diff --git a/notify_templates/notify_apprise.sh b/notify_templates/notify_apprise.sh index b3c0219..74a6cb5 100644 --- a/notify_templates/notify_apprise.sh +++ b/notify_templates/notify_apprise.sh @@ -5,20 +5,15 @@ # Modify to fit your setup - if API, set AppriseURL to your Apprise ip/domain. send_notification() { -Updates=("$@") -[ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) +[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") +UpdToString=$( printf '%s\\n' "${Updates[@]}" ) FromHost=$(hostname) printf "\nSending Apprise notification\n" MessageTitle="$FromHost - updates available." # Setting the MessageBody variable here. -read -d '\n' MessageBody << __EOF -Containers on $FromHost with updates available: - -$UpdToString - -__EOF +MessageBody=$(printf "🐋 Containers on $FromHost with updates available: \n$UpdToString") # Modify to fit your setup: apprise -vv -t "$MessageTitle" -b "$MessageBody" \ diff --git a/notify_templates/notify_generic.sh b/notify_templates/notify_generic.sh index 9ff6226..e74d806 100644 --- a/notify_templates/notify_generic.sh +++ b/notify_templates/notify_generic.sh @@ -4,11 +4,13 @@ # generic sample, the "Hello World" of notification addons send_notification() { - Updates=("$@") - [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) + [ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") + UpdToString=$( printf '%s\\n' "${Updates[@]}" ) + FromHost=$(hostname) # platform specific notification code would go here printf "\n%bGeneric notification addon:%b" "$c_green" "$c_reset" - printf "\nThe following docker containers on %s need to be updated:\n%s\n" "$FromHost" "$UpdToString" + printf "\nThe following docker containers on %s need to be updated:\n" "$FromHost" + printf "$UpdToString" } diff --git a/notify_templates/notify_gotify.sh b/notify_templates/notify_gotify.sh index 5590ea2..0b22cbc 100644 --- a/notify_templates/notify_gotify.sh +++ b/notify_templates/notify_gotify.sh @@ -5,8 +5,8 @@ # Modify to fit your setup - set GotifyUrl and GotifyToken. send_notification() { - Updates=("$@") - [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) + [ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") + UpdToString=$( printf '%s\\n' "${Updates[@]}" ) FromHost=$(hostname) # platform specific notification code would go here @@ -14,7 +14,7 @@ send_notification() { # Setting the MessageTitle and MessageBody variable here. MessageTitle="${FromHost} - updates available." - MessageBody="Containers on ${FromHost} with updates available: ${UpdToString}" + MessageBody=$(printf "🐋 Containers on $FromHost with updates available: \n$UpdToString") # Modify to fit your setup: GotifyToken="Your Gotify token here" diff --git a/notify_templates/notify_matrix.sh b/notify_templates/notify_matrix.sh index b9af93a..acbcb34 100644 --- a/notify_templates/notify_matrix.sh +++ b/notify_templates/notify_matrix.sh @@ -5,8 +5,8 @@ # Modify to fit your setup - set MatrixServer, Room_id and AccessToken send_notification() { - Updates=("$@") - [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) + [ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") + UpdToString=$( printf '%s\\n' "${Updates[@]}" ) FromHost=$(hostname) # platform specific notification code would go here diff --git a/notify_templates/notify_ntfy-sh.sh b/notify_templates/notify_ntfy-sh.sh index dc9ded7..7126c63 100644 --- a/notify_templates/notify_ntfy-sh.sh +++ b/notify_templates/notify_ntfy-sh.sh @@ -5,20 +5,15 @@ # Use your unique Topic Name in the URL below. send_notification() { -Updates=("$@") -[ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) +[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") +UpdToString=$( printf '%s\\n' "${Updates[@]}" ) FromHost=$(hostname) printf "\nSending ntfy.sh notification\n" MessageTitle="$FromHost - updates available." # Setting the MessageBody variable here. -read -d '\n' MessageBody << __EOF -Containers on $FromHost with updates available: - -$UpdToString - -__EOF +MessageBody=$(printf "🐋 Containers on $FromHost with updates available: \n$UpdToString") # Modify to fit your setup: NtfyUrl="ntfy.sh/YourUniqueTopicName" diff --git a/notify_templates/notify_pushbullet.sh b/notify_templates/notify_pushbullet.sh index c422ad8..3f181a2 100644 --- a/notify_templates/notify_pushbullet.sh +++ b/notify_templates/notify_pushbullet.sh @@ -6,8 +6,8 @@ # Modify to fit your setup - set Url and Token. send_notification() { -Updates=("$@") -[ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) +[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") +UpdToString=$( printf '%s\\n' "${Updates[@]}" ) FromHost=$(hostname) # platform specific notification code would go here @@ -15,7 +15,7 @@ printf "\nSending pushbullet notification\n" MessageTitle="$FromHost - updates available." # Setting the MessageBody variable here. -MessageBody="Containers on $FromHost with updates available: $UpdToString" +MessageBody=$(printf "🐋 Containers on $FromHost with updates available: \n$UpdToString") # Modify to fit your setup: PushUrl="https://api.pushbullet.com/v2/pushes" diff --git a/notify_templates/notify_pushover.sh b/notify_templates/notify_pushover.sh index 85182b8..15a491a 100644 --- a/notify_templates/notify_pushover.sh +++ b/notify_templates/notify_pushover.sh @@ -6,8 +6,8 @@ # Modify to fit your setup - set Url and Token. send_notification() { - Updates=("$@") - [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) + [ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") + UpdToString=$( printf '%s\\n' "${Updates[@]}" ) FromHost=$(hostname) # platform specific notification code would go here @@ -15,7 +15,7 @@ send_notification() { MessageTitle="$FromHost - updates available." # Setting the MessageBody variable here. - MessageBody="Containers on $FromHost with updates available: $UpdToString" + MessageBody=$(printf "🐋 Containers on $FromHost with updates available: \n$UpdToString") # Modify to fit your setup: PushoverUrl="https://api.pushover.net/1/messages.json" diff --git a/notify_templates/notify_smtp.sh b/notify_templates/notify_smtp.sh index 8ae8bec..5b110c7 100644 --- a/notify_templates/notify_smtp.sh +++ b/notify_templates/notify_smtp.sh @@ -17,8 +17,8 @@ else fi send_notification() { -Updates=("$@") -[ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) +[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") +UpdToString=$( printf '%s\\n' "${Updates[@]}" ) FromHost=$(hostname) # User variables: diff --git a/notify_templates/notify_telegram.sh b/notify_templates/notify_telegram.sh index 6183ccb..4772149 100644 --- a/notify_templates/notify_telegram.sh +++ b/notify_templates/notify_telegram.sh @@ -5,8 +5,8 @@ # Modify to fit your setup - set TelegramChatId and TelegramToken. send_notification() { - Updates=("$@") - [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) + [ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") + UpdToString=$( printf '%s\\n' "${Updates[@]}" ) FromHost=$(hostname) # platform specific notification code would go here