mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-17 18:07:46 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a9d60f4df | ||
|
|
c57923f152 | ||
|
|
fd1769c30f | ||
|
|
965f2dd825 | ||
|
|
48057dfc66 | ||
|
|
98e80854be | ||
|
|
dcbdb5becd | ||
|
|
8fc4f41c49 | ||
|
|
9b0b6137a3 | ||
|
|
7ed4286fe7 | ||
|
|
06ea7fff6d | ||
|
|
c436def448 | ||
|
|
96ebe079a4 | ||
|
|
111cb955b1 | ||
|
|
71967277aa | ||
|
|
1548b03a9e |
16
README.md
16
README.md
@@ -21,19 +21,15 @@
|
|||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
Made MaxAsync=1 the default - edit to change.
|
- **v0.5.8.0**: Added version checks to all templates and a notification if a new template is released.
|
||||||
Added -x option to pass a MaxAsync value on runtime.
|
- **v0.5.7.0**: Rewritten templates - now with a function to notify when there's a new Dockcheck release.
|
||||||
Made it possible to disable xargs -P-flag by setting MaxAsync=0 or passing -x 0 option.
|
- Manually migrate your current `notify.sh` settings to a new template for new functionality.
|
||||||
|
|
||||||
- **v0.5.6.1**: Async xargs hotfix - due to errors `failed to request manifest head ... context canceled`
|
- **v0.5.6.1**: Async xargs hotfix - due to errors `failed to request manifest head ... context canceled`
|
||||||
- Defaulted subprocess to 1 with `MaxAsync=1`, increase to find a stable value in your environment.
|
- Defaulted subprocess to 1 with `MaxAsync=1`, increase to find a stable value in your environment.
|
||||||
- Added `-x N` option to pass `MaxAsync` value at runtime.
|
- Added `-x N` option to pass `MaxAsync` value at runtime.
|
||||||
- To disable xargs `-P` flag (max processes) all together, set `MaxAsync` to 0.
|
- To disable xargs `-P` flag (max processes) all together, set `MaxAsync` to 0.
|
||||||
- **v0.5.6.0**: Heavily improved performance due to async checking for updates.
|
- **v0.5.6.0**: Heavily improved performance due to async checking for updates.
|
||||||
- **v0.5.5.0**: osx and bsd compatibility changes + rewrite of dependency installer
|
- **v0.5.5.0**: osx and bsd compatibility changes + rewrite of dependency installer
|
||||||
- **v0.5.4.0**: Added support for a Prometheus+node_exporter metric collection through a file collector.
|
|
||||||
- **v0.5.3.0**: Local image check changed (use imageId instead of name) and Gotify-template fixed (whale icon removed).
|
|
||||||
- **v0.5.2.1**: Rewrite of dependency downloads, jq can be installed with package manager or static binary.
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|
||||||
@@ -115,6 +111,7 @@ Add preferred `notify.sh`-template to the same directory - this will not be touc
|
|||||||
## :loudspeaker: Notifications
|
## :loudspeaker: Notifications
|
||||||
Trigger with the `-i` flag.
|
Trigger with the `-i` flag.
|
||||||
Run it scheduled with `-ni` to only get notified when there's updates available!
|
Run it scheduled with `-ni` to only get notified when there's updates available!
|
||||||
|
Will also send a notification when `dockcheck.sh` itself has an update.
|
||||||
|
|
||||||
Use a `notify_X.sh` template file from the **notify_templates** directory, copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh is added to .gitignore)
|
Use a `notify_X.sh` template file from the **notify_templates** directory, copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh is added to .gitignore)
|
||||||
**Current templates:**
|
**Current templates:**
|
||||||
@@ -147,6 +144,11 @@ nginx -> https://github.com/docker-library/official-images/blob/master/library
|
|||||||
```
|
```
|
||||||
The `urls.list` file is just an example and I'd gladly see that people contribute back when they add their preferred URLs to their lists.
|
The `urls.list` file is just an example and I'd gladly see that people contribute back when they add their preferred URLs to their lists.
|
||||||
|
|
||||||
|
## :fast_forward: Asyncronous update checks with **xargs**; `-x N` option. (default=1)
|
||||||
|
Pass `-x N` where N is number of subprocesses allowed, experiment in your environment to find a suitable max!
|
||||||
|
Change the default value by editing the `MaxAsync=N` variable in `dockcheck.sh`. To disable the subprocess function set `MaxAsync=0`.
|
||||||
|
|
||||||
|
|
||||||
## :chart_with_upwards_trend: Prometheus and node_exporter
|
## :chart_with_upwards_trend: Prometheus and node_exporter
|
||||||
Dockcheck can be used together with [Prometheus](https://github.com/prometheus/prometheus) and [node_exporter](https://github.com/prometheus/node_exporter) to export metrics via the file collector, scheduled with cron or likely.
|
Dockcheck can be used together with [Prometheus](https://github.com/prometheus/prometheus) and [node_exporter](https://github.com/prometheus/node_exporter) to export metrics via the file collector, scheduled with cron or likely.
|
||||||
This is done with the `-c` option, like this:
|
This is done with the `-c` option, like this:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.5.6.1"
|
VERSION="v0.5.8.0"
|
||||||
### ChangeNotes: Async hotfix, 1 subprocess default, modify MaxAsync variable or pass -x N option to increase.
|
### ChangeNotes: Added version checks to all templates and a notification if a new template is released.
|
||||||
Github="https://github.com/mag37/dockcheck"
|
Github="https://github.com/mag37/dockcheck"
|
||||||
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
||||||
|
|
||||||
@@ -174,6 +174,8 @@ if [[ "$VERSION" != "$LatestRelease" ]] ; then
|
|||||||
if [[ -z "$AutoUp" ]] ; then
|
if [[ -z "$AutoUp" ]] ; then
|
||||||
read -r -p "Would you like to update? y/[n]: " SelfUpdate
|
read -r -p "Would you like to update? y/[n]: " SelfUpdate
|
||||||
[[ "$SelfUpdate" =~ [yY] ]] && self_update
|
[[ "$SelfUpdate" =~ [yY] ]] && self_update
|
||||||
|
else
|
||||||
|
[[ -n "$Notify" ]] && { [[ $(type -t dockcheck_notification) == function ]] && dockcheck_notification "$VERSION" "$LatestRelease" "$LatestChanges" || printf "Could not source notification function.\n" ; }
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
# INFO: ssmtp is depcerated - consider to use msmtp instead.
|
NOTIFY_DSM_VERSION="v0.1"
|
||||||
|
# INFO: ssmtp is deprecated - consider to use msmtp instead.
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snipppet.
|
# Copy/rename this file to notify.sh to enable the notification snipppet.
|
||||||
# mSMTP/sSMTP has to be installed and configured manually.
|
# mSMTP/sSMTP has to be installed and configured manually.
|
||||||
@@ -17,10 +18,9 @@ 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() {
|
||||||
CfgFile="/usr/syno/etc/synosmtp.conf"
|
CfgFile="/usr/syno/etc/synosmtp.conf"
|
||||||
|
|
||||||
# User variables:
|
# User variables:
|
||||||
@@ -34,15 +34,11 @@ SenderName=$(grep 'smtp_from_name' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
|
|||||||
SenderMail=$(grep 'smtp_from_mail' $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')}
|
SenderMail=${SenderMail:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')}
|
||||||
|
|
||||||
printf "\nSending email notification.\n"
|
|
||||||
|
|
||||||
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
|
|
||||||
|
|
||||||
$MailPkg $SendMailTo << __EOF
|
$MailPkg $SendMailTo << __EOF
|
||||||
From: "$SenderName" <$SenderMail>
|
From: "$SenderName" <$SenderMail>
|
||||||
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
|
||||||
|
|
||||||
@@ -52,3 +48,35 @@ __EOF
|
|||||||
# This ensures DSM's container manager will also see the update
|
# This ensures DSM's container manager will also see the update
|
||||||
/var/packages/ContainerManager/target/tool/image_upgradable_checker
|
/var/packages/ContainerManager/target/tool/image_upgradable_checker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_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\n"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_DSM.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_DSM_VERSION/s/NOTIFY_DSM_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_DSM_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_DSM.sh update avialable:\n $NOTIFY_DSM_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,21 +1,15 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_APPRISE_VERSION="v0.1"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# Modify to fit your setup - if API, set AppriseURL to your Apprise ip/domain.
|
# Modify to fit your setup - if API, set AppriseURL to your Apprise ip/domain.
|
||||||
|
|
||||||
send_notification() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
printf "\nSending Apprise notification\n"
|
trigger_notification() {
|
||||||
|
|
||||||
MessageTitle="$FromHost - updates available."
|
### Modify to fit your setup:
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
|
||||||
apprise -vv -t "$MessageTitle" -b "$MessageBody" \
|
apprise -vv -t "$MessageTitle" -b "$MessageBody" \
|
||||||
mailto://myemail:mypass@gmail.com \
|
mailto://myemail:mypass@gmail.com \
|
||||||
mastodons://{token}@{host} \
|
mastodons://{token}@{host} \
|
||||||
@@ -26,5 +20,36 @@ apprise -vv -t "$MessageTitle" -b "$MessageBody" \
|
|||||||
### Uncomment the AppriseURL and the curl-line below:
|
### Uncomment the AppriseURL and the curl-line below:
|
||||||
# AppriseURL="http://apprise.mydomain.tld:1234/notify/apprise"
|
# AppriseURL="http://apprise.mydomain.tld:1234/notify/apprise"
|
||||||
# curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL
|
# curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL
|
||||||
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
printf "\nSending Apprise notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - updates available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_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"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_apprise.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_APPRISE_VERSION/s/NOTIFY_APPRISE_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_APPRISE_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_apprise.sh update avialable:\n $NOTIFY_APPRISE_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,43 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_DISCORD_VERSION="v0.1"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# Modify to fit your setup - set DiscordWebhookUrl
|
# Modify to fit your setup - set DiscordWebhookUrl
|
||||||
|
|
||||||
send_notification() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
|
|
||||||
echo "$UpdToString"
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# platform specific notification code would go here
|
trigger_notification() {
|
||||||
printf "\nSending Discord notification\n"
|
|
||||||
|
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
DiscordWebhookUrl="PasteYourFullDiscordWebhookURL"
|
DiscordWebhookUrl="PasteYourFullDiscordWebhookURL"
|
||||||
|
|
||||||
MsgBody="{\"username\":\"$FromHost\",\"content\":\"$MessageBody\"}"
|
MsgBody="{\"username\":\"$FromHost\",\"content\":\"$MessageBody\"}"
|
||||||
|
|
||||||
curl -sS -o /dev/null --fail -X POST -H "Content-Type: application/json" -d "$MsgBody" "$DiscordWebhookUrl"
|
curl -sS -o /dev/null --fail -X POST -H "Content-Type: application/json" -d "$MsgBody" "$DiscordWebhookUrl"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
printf "\nSending Discord notification\n"
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending Discord dockcheck notification\n"
|
||||||
|
MessageBody="$FromHost - New version of dockcheck available: \n Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_discord.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_DISCORD_VERSION/s/NOTIFY_DISCORD_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_DISCORD_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_discord.sh update avialable:\n $NOTIFY_DISCORD_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,16 +1,44 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_GENERIC_VERSION="v0.1"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# generic sample, the "Hello World" of notification addons
|
# generic sample, the "Hello World" of notification addons
|
||||||
|
|
||||||
|
FromHost=$(hostname)
|
||||||
|
|
||||||
|
trigger_notification() {
|
||||||
|
# Modify to fit your setup:
|
||||||
|
printf "\n$MessageTitle\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[@]}" )
|
||||||
|
|
||||||
FromHost=$(hostname)
|
|
||||||
|
|
||||||
# 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"
|
||||||
printf "\nThe following docker containers on %s need to be updated:\n" "$FromHost"
|
MessageTitle="$FromHost - updates available."
|
||||||
printf "$UpdToString"
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nGeneric 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"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_generic.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_GENERIC_VERSION/s/NOTIFY_GENERIC_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_GENERIC_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_generic.sh update avialable:\n $NOTIFY_GENERIC_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,13 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_GOTIFY_VERSION="v0.1"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# Modify to fit your setup - set GotifyUrl and GotifyToken.
|
# Modify to fit your setup - set GotifyUrl and GotifyToken.
|
||||||
|
|
||||||
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 Gotify notification\n"
|
|
||||||
|
|
||||||
# Setting the MessageTitle and MessageBody variable here.
|
|
||||||
MessageTitle="${FromHost} - updates available."
|
|
||||||
printf -v MessageBody "Containers on $FromHost with updates available:\n$UpdToString"
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
GotifyToken="Your Gotify token here"
|
GotifyToken="Your Gotify token here"
|
||||||
GotifyUrl="https://api.gotify/message?token=${GotifyToken}"
|
GotifyUrl="https://api.gotify/message?token=${GotifyToken}"
|
||||||
@@ -25,5 +17,37 @@ send_notification() {
|
|||||||
-F "message=${MessageBody}" \
|
-F "message=${MessageBody}" \
|
||||||
-F "priority=5" \
|
-F "priority=5" \
|
||||||
-X POST "${GotifyUrl}" 1> /dev/null
|
-X POST "${GotifyUrl}" 1> /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
# platform specific notification code would go here
|
||||||
|
printf "\nSending Gotify notification\n"
|
||||||
|
|
||||||
|
# Setting the MessageTitle and MessageBody variable here.
|
||||||
|
MessageTitle="${FromHost} - updates available."
|
||||||
|
printf -v MessageBody "Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending Gotify 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"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_gotify.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_GOTIFY_VERSION/s/NOTIFY_GOTIFY_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_GOTIFY_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_gotify.sh update avialable:\n $NOTIFY_GOTIFY_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,13 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_MATRIX_VERSION="v0.1"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# Modify to fit your setup - set MatrixServer, Room_id and AccessToken
|
# Modify to fit your setup - set MatrixServer, Room_id and AccessToken
|
||||||
|
|
||||||
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 Matrix notification\n"
|
|
||||||
|
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
AccessToken="Your Matrix token here"
|
AccessToken="Your Matrix token here"
|
||||||
Room_id="Enter Room_id here"
|
Room_id="Enter Room_id here"
|
||||||
@@ -22,7 +15,37 @@ send_notification() {
|
|||||||
MsgBody="{\"msgtype\":\"m.text\",\"body\":\"$MessageBody\"}"
|
MsgBody="{\"msgtype\":\"m.text\",\"body\":\"$MessageBody\"}"
|
||||||
|
|
||||||
# URL Example: https://matrix.org/_matrix/client/r0/rooms/!xxxxxx:example.com/send/m.room.message?access_token=xxxxxxxx
|
# URL Example: https://matrix.org/_matrix/client/r0/rooms/!xxxxxx:example.com/send/m.room.message?access_token=xxxxxxxx
|
||||||
|
|
||||||
curl -sS -o /dev/null --fail -X POST "$MatrixServer/_matrix/client/r0/rooms/$Room_id/send/m.room.message?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody"
|
curl -sS -o /dev/null --fail -X POST "$MatrixServer/_matrix/client/r0/rooms/$Room_id/send/m.room.message?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody"
|
||||||
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
# platform specific notification code would go here
|
||||||
|
printf "\nSending Matrix notification\n"
|
||||||
|
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_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 "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_matrix.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_MATRIX_VERSION/s/NOTIFY_MATRIX_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_MATRIX_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_matrix.sh update avialable:\n $NOTIFY_MATRIX_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,13 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_NTFYSH_VERSION="v0.1"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# 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() {
|
||||||
|
|
||||||
MessageTitle="$FromHost - updates available."
|
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
NtfyUrl="ntfy.sh/YourUniqueTopicName"
|
NtfyUrl="ntfy.sh/YourUniqueTopicName"
|
||||||
|
|
||||||
@@ -22,5 +15,36 @@ curl -sS -o /dev/null --show-error --fail \
|
|||||||
-H "Title: $MessageTitle" \
|
-H "Title: $MessageTitle" \
|
||||||
-d "$MessageBody" \
|
-d "$MessageBody" \
|
||||||
$NtfyUrl
|
$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
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_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"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_ntfy-sh.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_NTFYSH_VERSION/s/NOTIFY_NTFYSH_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_NTFYSH_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_ntfy-sh.sh update avialable:\n $NOTIFY_NTFYSH_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,25 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_PUSHBULLET_VERSION="v0.1"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# 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.
|
||||||
|
|
||||||
|
FromHost=$(hostname)
|
||||||
|
|
||||||
|
trigger_notification() {
|
||||||
|
# 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 @-
|
||||||
|
}
|
||||||
|
|
||||||
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[@]}" )
|
||||||
FromHost=$(hostname)
|
|
||||||
|
|
||||||
# platform specific notification code would go here
|
# platform specific notification code would go here
|
||||||
printf "\nSending pushbullet notification\n"
|
printf "\nSending pushbullet notification\n"
|
||||||
@@ -17,11 +28,24 @@ MessageTitle="$FromHost - updates available."
|
|||||||
# Setting the MessageBody variable here.
|
# Setting the MessageBody variable here.
|
||||||
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
# Modify to fit your setup:
|
trigger_notification
|
||||||
PushUrl="https://api.pushbullet.com/v2/pushes"
|
}
|
||||||
PushToken="Your Pushbullet token here"
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
# Requires jq to process json data
|
### to not send notifications when dockcheck itself has updates.
|
||||||
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 @-
|
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"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_pushbullet.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_PUSHBULLET_VERSION/s/NOTIFY_PUSHBULLET_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_PUSHBULLET_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_pushbullet.sh update avialable:\n $NOTIFY_PUSHBULLET_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,14 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_PUSHOVER_VERSION="v0.1"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# 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 pushover notification\n"
|
|
||||||
|
|
||||||
MessageTitle="$FromHost - updates available."
|
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
|
||||||
|
|
||||||
# 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 +22,36 @@ 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
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending pushover 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"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_pushover.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_PUSHOVER_VERSION/s/NOTIFY_PUSHOVER_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_PUSHOVER_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_pushover.sh update avialable:\n $NOTIFY_PUSHOVER_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_SMTP_VERSION="v0.1"
|
||||||
# INFO: ssmtp is depcerated - consider to use msmtp instead.
|
# INFO: ssmtp is depcerated - consider to use msmtp instead.
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snipppet.
|
# Copy/rename this file to notify.sh to enable the notification snipppet.
|
||||||
@@ -16,25 +17,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 +37,35 @@ $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
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_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"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_smtp.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_SMTP_VERSION/s/NOTIFY_SMTP_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_SMTP_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_smtp.sh update avialable:\n $NOTIFY_SMTP_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,20 +1,13 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_TELEGRAM_VERSION="v0.1"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# 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() {
|
|
||||||
[ -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 Telegram notification\n"
|
|
||||||
|
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
|
||||||
|
|
||||||
# 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"
|
||||||
@@ -23,5 +16,36 @@ send_notification() {
|
|||||||
TelegramData="{\"chat_id\":\"$TelegramChatId\",\"text\":\"$MessageBody\",\"message_thread_id\":\"$TelegramTopicID\",\"disable_notification\": false}"
|
TelegramData="{\"chat_id\":\"$TelegramChatId\",\"text\":\"$MessageBody\",\"message_thread_id\":\"$TelegramTopicID\",\"disable_notification\": false}"
|
||||||
|
|
||||||
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
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending Telegram 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"
|
||||||
|
|
||||||
|
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_telegram.sh"
|
||||||
|
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_TELEGRAM_VERSION/s/NOTIFY_TELEGRAM_VERSION=//p" | tr -d '"')"
|
||||||
|
if [[ "$NOTIFY_TELEGRAM_VERSION" != "$LatestNotifyRelease" ]] ; then
|
||||||
|
printf -v NotifyUpdate "\n\nnotify_telegram.sh update avialable:\n $NOTIFY_TELEGRAM_VERSION -> $LatestNotifyRelease\n"
|
||||||
|
MessageBody="${MessageBody}${NotifyUpdate}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user