finalizing new notification structure

This commit is contained in:
mag37 2025-02-10 19:46:23 +01:00
parent 71967277aa
commit 111cb955b1
10 changed files with 194 additions and 113 deletions

View file

@ -49,26 +49,26 @@ __EOF
} }
send_notification() { send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") [ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" ) UpdToString=$( printf '%s\\n' "${Updates[@]}" )
printf "\nSending email notification\n" printf "\nSending email notification.\n"
MessageTitle="Updates available on" MessageTitle="Updates available on"
# Setting the MessageBody variable here. # Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString" printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
trigger_notification trigger_notification
} }
### Remove or comment out the following function ### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates. ### to not send notifications when dockcheck itself has updates.
dockcheck_notification() { dockcheck_notification() {
printf "\nSending email dockcheck notification\n" printf "\nSending email dockcheck notification.\n"
MessageTitle="New version of dockcheck available on" MessageTitle="New version of dockcheck available on"
# Setting the MessageBody variable here. # Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification trigger_notification
} }

View file

@ -37,11 +37,11 @@ send_notification() {
### Remove or comment out the following function ### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates. ### to not send notifications when dockcheck itself has updates.
dockcheck_notification() { dockcheck_notification() {
printf "\nSending Apprise dockcheck notification\n" printf "\nSending Apprise dockcheck notification\n"
MessageTitle="$FromHost - New version of dockcheck available." MessageTitle="$FromHost - New version of dockcheck available."
# Setting the MessageBody variable here. # Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification trigger_notification
} }

View file

@ -6,33 +6,31 @@
FromHost=$(hostname) FromHost=$(hostname)
trigger_notification() { trigger_notification() {
# Modify to fit your setup:
printf "\n$MessageTitle\n" printf "\n$MessageTitle\n"
printf "\n$MessageBody\n" printf "\n$MessageBody\n"
} }
send_notification() { send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") [ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" ) UpdToString=$( printf '%s\\n' "${Updates[@]}" )
# platform specific notification code would go here
# platform specific notification code would go here printf "\n%bGeneric notification addon:%b" "$c_green" "$c_reset"
printf "\n%bGeneric notification addon:%b" "$c_green" "$c_reset" MessageTitle="$FromHost - updates available."
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
MessageTitle="$FromHost - updates available."
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString" trigger_notification
trigger_notification
} }
### Remove or comment out the following function ### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates. ### to not send notifications when dockcheck itself has updates.
dockcheck_notification() { dockcheck_notification() {
printf "\nGeneric dockcheck notification\n" printf "\nGeneric dockcheck notification\n"
MessageTitle="$FromHost - New version of dockcheck available." MessageTitle="$FromHost - New version of dockcheck available."
# Setting the MessageBody variable here. # Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification trigger_notification
} }

View file

@ -35,11 +35,11 @@ send_notification() {
### Remove or comment out the following function ### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates. ### to not send notifications when dockcheck itself has updates.
dockcheck_notification() { dockcheck_notification() {
printf "\nSending Apprise dockcheck notification\n" printf "\nSending Apprise dockcheck notification\n"
MessageTitle="$FromHost - New version of dockcheck available." MessageTitle="$FromHost - New version of dockcheck available."
# Setting the MessageBody variable here. # Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification trigger_notification
} }

View file

@ -33,11 +33,11 @@ send_notification() {
### Remove or comment out the following function ### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates. ### to not send notifications when dockcheck itself has updates.
dockcheck_notification() { dockcheck_notification() {
printf "\nSending Matrix dockcheck notification\n" printf "\nSending Matrix dockcheck notification\n"
MessageTitle="$FromHost - New version of dockcheck available." MessageTitle="$FromHost - New version of dockcheck available."
# Setting the MessageBody variable here. # Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification trigger_notification
} }

View file

@ -4,23 +4,39 @@
# Setup app and subscription at https://ntfy.sh # Setup app and subscription at https://ntfy.sh
# Use your unique Topic Name in the URL below. # Use your unique Topic Name in the URL below.
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
printf "\nSending ntfy.sh notification\n" trigger_notification() {
# Modify to fit your setup:
MessageTitle="$FromHost - updates available." NtfyUrl="ntfy.sh/YourUniqueTopicName"
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
# Modify to fit your setup:
NtfyUrl="ntfy.sh/YourUniqueTopicName"
curl -sS -o /dev/null --show-error --fail \
-H "Title: $MessageTitle" \
-d "$MessageBody" \
$NtfyUrl
curl -sS -o /dev/null --show-error --fail \
-H "Title: $MessageTitle" \
-d "$MessageBody" \
$NtfyUrl
}
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
printf "\nSending ntfy.sh notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending ntfy.sh dockcheck notification\n"
MessageTitle="$FromHost - New version of dockcheck available."
# Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification
} }

View file

@ -5,23 +5,39 @@
# Requires jq installed and in PATH. # Requires jq installed and in PATH.
# Modify to fit your setup - set Url and Token. # Modify to fit your setup - set Url and Token.
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
# platform specific notification code would go here trigger_notification() {
printf "\nSending pushbullet notification\n" # Modify to fit your setup:
PushUrl="https://api.pushbullet.com/v2/pushes"
MessageTitle="$FromHost - updates available." PushToken="Your Pushbullet token here"
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
# Modify to fit your setup:
PushUrl="https://api.pushbullet.com/v2/pushes"
PushToken="Your Pushbullet token here"
# Requires jq to process json data
jq -n --arg title "$MessageTitle" --arg body "$MessageBody" '{body: $body, title: $title, type: "note"}' | curl -sS -o /dev/null --show-error --fail -X POST -H "Access-Token: $PushToken" -H "Content-type: application/json" $PushUrl -d @-
# Requires jq to process json data
jq -n --arg title "$MessageTitle" --arg body "$MessageBody" '{body: $body, title: $title, type: "note"}' | curl -sS -o /dev/null --show-error --fail -X POST -H "Access-Token: $PushToken" -H "Content-type: application/json" $PushUrl -d @-
}
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
# platform specific notification code would go here
printf "\nSending pushbullet notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending pushbullet dockcheck notification\n"
MessageTitle="$FromHost - New version of dockcheck available."
# Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification
} }

View file

@ -5,18 +5,9 @@
# Requires jq installed and in PATH. # Requires jq installed and in PATH.
# Modify to fit your setup - set Url and Token. # Modify to fit your setup - set Url and Token.
send_notification() { FromHost=$(hostname)
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
FromHost=$(hostname)
# platform specific notification code would go here
printf "\nSending pushover notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification() {
# Modify to fit your setup: # Modify to fit your setup:
PushoverUrl="https://api.pushover.net/1/messages.json" PushoverUrl="https://api.pushover.net/1/messages.json"
PushoverUserKey="Your Pushover User Key Here" PushoverUserKey="Your Pushover User Key Here"
@ -30,3 +21,29 @@ send_notification() {
-F "message=$MessageBody" \ -F "message=$MessageBody" \
$PushoverUrl $PushoverUrl
} }
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
# platform specific notification code would go here
printf "\nSending pushover notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending Apprise dockcheck notification\n"
MessageTitle="$FromHost - New version of dockcheck available."
# Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification
}

View file

@ -16,25 +16,19 @@ else
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1 echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
fi fi
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
trigger_notification() {
# User variables: # User variables:
SendMailFrom="me@mydomain.tld" SendMailFrom="me@mydomain.tld"
SendMailTo="me@mydomain.tld" SendMailTo="me@mydomain.tld"
SubjectTag="dockcheck" SubjectTag="dockcheck"
printf "\nSending email notification.\n"
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
$MailPkg $SendMailTo << __EOF $MailPkg $SendMailTo << __EOF
From: "$FromHost" <$SendMailFrom> From: "$FromHost" <$SendMailFrom>
date:$(date -R) date:$(date -R)
To: <$SendMailTo> To: <$SendMailTo>
Subject: [$SubjectTag] Updates available on $FromHost Subject: [$SubjectTag] $MessageTitle $FromHost
Content-Type: text/plain; charset=UTF-8; format=flowed Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit
@ -42,3 +36,28 @@ $MessageBody
__EOF __EOF
} }
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
printf "\nSending email notification.\n"
MessageTitle="Updates available on"
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
trigger_notification
}
### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending email dockcheck notification.\n"
MessageTitle="New version of dockcheck available on"
# Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification
}

View file

@ -4,17 +4,9 @@
# Required receiving services must already be set up. # Required receiving services must already be set up.
# Modify to fit your setup - set TelegramChatId and TelegramToken. # Modify to fit your setup - set TelegramChatId and TelegramToken.
send_notification() { FromHost=$(hostname)
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
FromHost=$(hostname)
# platform specific notification code would go here
printf "\nSending Telegram notification\n"
# Setting the MessageBody variable here.
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
trigger_notification() {
# Modify to fit your setup: # Modify to fit your setup:
TelegramToken="Your Telegram token here" TelegramToken="Your Telegram token here"
TelegramChatId="Your Telegram ChatId here" TelegramChatId="Your Telegram ChatId here"
@ -24,4 +16,27 @@ send_notification() {
curl -sS -o /dev/null --fail -X POST "$TelegramUrl/sendMessage" -H 'Content-Type: application/json' -d "$TelegramData" curl -sS -o /dev/null --fail -X POST "$TelegramUrl/sendMessage" -H 'Content-Type: application/json' -d "$TelegramData"
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
# platform specific notification code would go here
printf "\nSending Telegram notification\n"
# Setting the MessageBody variable here.
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
trigger_notification
}
### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending Matrix dockcheck notification\n"
MessageTitle="$FromHost - New version of dockcheck available."
# Setting the MessageBody variable here.
printf -v MessageBody "$FromHost - New version of dockcheck available.\n\nInstalled version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification
} }