2024-01-03 11:06:37 +01:00
|
|
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
2025-09-15 05:25:23 -04:00
|
|
|
NOTIFY_DSM_VERSION="v0.5"
|
2025-03-14 20:36:07 +01:00
|
|
|
# INFO: ssmtp is deprecated - consider to use msmtp instead.
|
2024-01-06 17:29:35 +01:00
|
|
|
#
|
2024-07-24 12:18:23 +02:00
|
|
|
# mSMTP/sSMTP has to be installed and configured manually.
|
2024-07-02 11:56:51 -04:00
|
|
|
# The existing DSM Notification Email configuration will be used automatically.
|
2025-05-29 16:43:34 -04:00
|
|
|
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
|
|
|
|
|
# If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script.
|
|
|
|
|
# Do not modify this file directly within the "notify_templates" subdirectory. Set DSM_SENDMAILTO and DSM_SUBJECTTAG in your dockcheck.config file.
|
2024-01-01 13:46:09 -05:00
|
|
|
|
2024-07-24 12:18:23 +02:00
|
|
|
MSMTP=$(which msmtp)
|
|
|
|
|
SSMTP=$(which ssmtp)
|
2025-08-02 08:04:43 +02:00
|
|
|
SENDMAIL=$(which sendmail)
|
2024-07-24 12:18:23 +02:00
|
|
|
|
2024-10-10 09:48:41 +02:00
|
|
|
if [ -n "$MSMTP" ] ; then
|
2024-10-05 08:03:33 +02:00
|
|
|
MailPkg=$MSMTP
|
|
|
|
|
elif [ -n "$SSMTP" ] ; then
|
|
|
|
|
MailPkg=$SSMTP
|
2025-08-02 08:04:43 +02:00
|
|
|
elif [ -n "$SENDMAIL" ] ; then
|
|
|
|
|
MailPkg=$SENDMAIL
|
2024-07-24 12:18:23 +02:00
|
|
|
else
|
2025-08-02 08:04:43 +02:00
|
|
|
echo "No msmtp, ssmtp or sendmail binary found in PATH: $PATH" ; exit 1
|
2024-07-24 12:18:23 +02:00
|
|
|
fi
|
|
|
|
|
|
2025-05-25 12:26:13 -04:00
|
|
|
trigger_DSM_notification() {
|
2025-09-15 05:25:23 -04:00
|
|
|
if [[ -n "$1" ]]; then
|
|
|
|
|
DSM_channel="$1"
|
|
|
|
|
else
|
|
|
|
|
DSM_channel="DSM"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
UpperChannel="${DSM_channel^^}"
|
|
|
|
|
|
|
|
|
|
DSMSendmailToVar="${UpperChannel}_SENDMAILTO"
|
|
|
|
|
DSMSubjectTagVar="${UpperChannel}_SUBJECTTAG"
|
|
|
|
|
|
2024-07-02 11:56:51 -04:00
|
|
|
CfgFile="/usr/syno/etc/synosmtp.conf"
|
2024-01-06 17:29:35 +01:00
|
|
|
|
|
|
|
|
# User variables:
|
2024-07-02 11:56:51 -04:00
|
|
|
# Automatically sends to your usual destination for synology DSM notification emails.
|
2025-05-25 12:26:13 -04:00
|
|
|
# You can also manually override by assigning something else to DSM_SENDMAILTO in dockcheck.config.
|
2025-09-15 05:25:23 -04:00
|
|
|
SendMailTo=${!DSMSendmailToVar:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')}
|
2025-05-25 12:26:13 -04:00
|
|
|
# e.g. DSM_SENDMAILTO="me@mydomain.com"
|
2024-07-02 11:56:51 -04:00
|
|
|
|
2025-09-15 05:25:23 -04:00
|
|
|
SubjectTag=${!DSMSubjectTagVar:-$(grep 'eventsubjectprefix' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')}
|
2025-05-25 12:26:13 -04:00
|
|
|
# e.g. DSM_SUBJECTTAG="Email Subject Prefix"
|
2024-07-02 11:56:51 -04:00
|
|
|
SenderName=$(grep 'smtp_from_name' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
|
|
|
|
|
SenderMail=$(grep 'smtp_from_mail' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
|
|
|
|
|
SenderMail=${SenderMail:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')}
|
2024-01-01 13:46:09 -05:00
|
|
|
|
2024-10-05 08:03:33 +02:00
|
|
|
$MailPkg $SendMailTo << __EOF
|
2024-07-02 11:56:51 -04:00
|
|
|
From: "$SenderName" <$SenderMail>
|
2024-01-01 13:46:09 -05:00
|
|
|
date:$(date -R)
|
|
|
|
|
To: <$SendMailTo>
|
2025-05-25 12:26:13 -04:00
|
|
|
Subject: $SubjectTag $MessageTitle
|
2024-01-01 13:46:09 -05:00
|
|
|
Content-Type: text/plain; charset=UTF-8; format=flowed
|
|
|
|
|
Content-Transfer-Encoding: 7bit
|
|
|
|
|
|
2024-10-10 10:22:17 +02:00
|
|
|
$MessageBody
|
2024-07-02 11:56:51 -04:00
|
|
|
From $SenderName
|
2024-01-01 13:46:09 -05:00
|
|
|
__EOF
|
2025-06-24 09:16:48 -04:00
|
|
|
|
|
|
|
|
if [[ $? -gt 0 ]]; then
|
|
|
|
|
NotifyError=true
|
|
|
|
|
fi
|
|
|
|
|
|
2024-12-01 20:51:51 +01:00
|
|
|
# This ensures DSM's container manager will also see the update
|
|
|
|
|
/var/packages/ContainerManager/target/tool/image_upgradable_checker
|
2024-01-03 11:01:41 +01:00
|
|
|
}
|