From 9f8c62ed96cdc2d71f34b219ef6519a0943c8558 Mon Sep 17 00:00:00 2001 From: mag37 Date: Fri, 4 Oct 2024 14:39:51 +0200 Subject: [PATCH 1/7] first tweaks for a release-notes addition --- dockcheck.sh | 11 +++++++++++ notify_templates/notify_generic.sh | 2 +- notify_templates/urls.list | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 77ad27f..14c5c1f 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -148,6 +148,17 @@ progress_bar() { [[ "$QueTotal" == "$QueCurrent" ]] && printf "\r[%b%s%b] %s/%s \n" "$c_teal" "$BarComplete" "$c_reset" "$QueCurrent" "$QueTotal" } +### Function to add user-provided urls to releasenotes +releasenotes() { + for update in ${Updates[@]}; do + found=false + while read -r container url; do + [[ $update == $container ]] && printf "%s -> %s\n" "$update" "$url" && found=true + done < "$ScriptWorkDir"/urls.list + [[ $found == false ]] && printf "%s -> no url in list\n" "$update" + done +} + ### Version check & initiate self update if [[ "$VERSION" != "$LatestRelease" ]] ; then printf "New version available! %b%s%b ⇒ %b%s%b \n Change Notes: %s \n" "$c_yellow" "$VERSION" "$c_reset" "$c_green" "$LatestRelease" "$c_reset" "$LatestChanges" diff --git a/notify_templates/notify_generic.sh b/notify_templates/notify_generic.sh index 04b508c..9ff6226 100644 --- a/notify_templates/notify_generic.sh +++ b/notify_templates/notify_generic.sh @@ -5,7 +5,7 @@ send_notification() { Updates=("$@") - UpdToString=$( printf "%s\n" "${Updates[@]}" ) + [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" ) FromHost=$(hostname) # platform specific notification code would go here diff --git a/notify_templates/urls.list b/notify_templates/urls.list index c8faef1..e131872 100644 --- a/notify_templates/urls.list +++ b/notify_templates/urls.list @@ -1,3 +1,7 @@ +# This is a list of container names and releasenote urls, separated by space. +# Modify, add and (if necessary) remove to fit your needs. +# Additions are welcome! Append your list to the git-repo, use generic names and sensible urls. + apprise-api https://github.com/linuxserver/docker-apprise-api/releases homer https://github.com/bastienwirtz/homer/releases nginx https://github.com/docker-library/official-images/blob/master/library/nginx From db4431d40a6fe46e26f22a6a47a08379f8061d42 Mon Sep 17 00:00:00 2001 From: mag37 Date: Fri, 4 Oct 2024 14:48:05 +0200 Subject: [PATCH 2/7] Update dockcheck.sh changed missing url-message. --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 14c5c1f..0d66953 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -155,7 +155,7 @@ releasenotes() { while read -r container url; do [[ $update == $container ]] && printf "%s -> %s\n" "$update" "$url" && found=true done < "$ScriptWorkDir"/urls.list - [[ $found == false ]] && printf "%s -> no url in list\n" "$update" + [[ $found == false ]] && printf "%s -> url missing\n" "$update" done } From 0e3210b5610e843cdc1056bbdc1c12eef4c8c5d7 Mon Sep 17 00:00:00 2001 From: mag37 Date: Fri, 4 Oct 2024 14:55:43 +0200 Subject: [PATCH 3/7] added urls.list Added urls.list to be ignored. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fd732aa..f3300e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # ignore users custom notify.sh /notify.sh +/urls.list # ignore the auto-installed regctl regctl From a55099465913d9f05312e4091e18c57b2d7d2518 Mon Sep 17 00:00:00 2001 From: mag37 Date: Fri, 4 Oct 2024 23:07:01 +0200 Subject: [PATCH 4/7] tweaks + version info --- README.md | 14 ++++++++++++++ dockcheck.sh | 6 +++--- notify_templates/urls.list | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3c9b238..071c46f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ ___ ## :bell: Changelog +- **v0.4.9**: Added a function to enrich the notify-message with release note URLs. See [Release notes addon](https://github.com/mag37/dockcheck#date-release-notes-addon-to-Notifications) - **v0.4.8**: Rewrote prune logic to not prompt with options `-a|-y` or `-n`. Auto prune with `-p`. - **v0.4.7**: Notification Template changes to gotify(new!), DSM(improved), SMTP(deprecation alternative). - **v0.4.6**: Compatibility changes to timeout, due to busybox. @@ -114,6 +115,19 @@ Use a `notify_X.sh` template file from the **notify_templates** directory, copy Further additions are welcome - suggestions or PR! Initiated and first contributed by [yoyoma2](https://github.com/yoyoma2). +### :date: Release notes addon to Notifications +There's a function to use a lookup-file to add release note URL's to the notification message. +Copy the notify_templates/`urls.list` file to the script directory and modify it as necessary, it will be used automatically if it's there. +The output of the notification will look something like this: +``` +Containers on hostname with updates available: +apprise-api -> https://github.com/linuxserver/docker-apprise-api/releases +homer -> https://github.com/bastienwirtz/homer/releases +nginx -> https://github.com/docker-library/official-images/blob/master/library/nginx +... +``` +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. + ## :bookmark: Labels Optionally add labels to compose-files. Currently these are the usable labels: ``` diff --git a/dockcheck.sh b/dockcheck.sh index 0d66953..0660af5 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="v0.4.8" -### ChangeNotes: Rewrote prune to not prompt (default no) if -a|-y or -n flags are used. -p will still autoprune. +VERSION="v0.4.9" +### ChangeNotes: Added a function to enrich the notify-message with release note URLs. See README. Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" @@ -155,7 +155,7 @@ releasenotes() { while read -r container url; do [[ $update == $container ]] && printf "%s -> %s\n" "$update" "$url" && found=true done < "$ScriptWorkDir"/urls.list - [[ $found == false ]] && printf "%s -> url missing\n" "$update" + [[ $found == false ]] && printf "%s -> url missing\n" "$update" || continue done } diff --git a/notify_templates/urls.list b/notify_templates/urls.list index e131872..6b999b5 100644 --- a/notify_templates/urls.list +++ b/notify_templates/urls.list @@ -5,3 +5,4 @@ apprise-api https://github.com/linuxserver/docker-apprise-api/releases homer https://github.com/bastienwirtz/homer/releases nginx https://github.com/docker-library/official-images/blob/master/library/nginx +vaultwarden-server https://github.com/dani-garcia/vaultwarden/releases From 6de00a2b9017dff63a47a209c5a4f984bc2ab76a Mon Sep 17 00:00:00 2001 From: mag37 Date: Fri, 4 Oct 2024 23:07:58 +0200 Subject: [PATCH 5/7] removed releasenotes test script --- notify_templates/releasenotes.sh | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 notify_templates/releasenotes.sh diff --git a/notify_templates/releasenotes.sh b/notify_templates/releasenotes.sh deleted file mode 100644 index cce7944..0000000 --- a/notify_templates/releasenotes.sh +++ /dev/null @@ -1,17 +0,0 @@ -### Snippet to use together with notify.sh -# -# Requires a space-separated list-file of container-name and release-note-url, modify the example file "urls.list" -# Copy urls.list and releasenotes.sh to the same directory as dockcheck.sh. -# -# Add the next line (uncommented) to any notification script you're using, after the "UpdToString"-variable setup -# [ -s "$ScriptWorkDir"/releasenotes.sh ] && { source "$ScriptWorkDir"/releasenotes.sh ; UpdToString=$( releasenotes ) ; } - -releasenotes() { - for update in ${Updates[@]}; do - found=false - while read -r container url; do - [[ $update == $container ]] && printf "%s -> %s\n" "$update" "$url" && found=true - done < "$ScriptWorkDir"/urls.list - [[ $found == false ]] && printf "%s\n" "$update" - done -} From 85ee721cd174f72a74122739f65ae8e25482c133 Mon Sep 17 00:00:00 2001 From: mag37 Date: Fri, 4 Oct 2024 23:09:45 +0200 Subject: [PATCH 6/7] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 071c46f..ddef012 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ ___ ## :bell: Changelog -- **v0.4.9**: Added a function to enrich the notify-message with release note URLs. See [Release notes addon](https://github.com/mag37/dockcheck#date-release-notes-addon-to-Notifications) +- **v0.4.9**: Added a function to enrich the notify-message with release note URLs. See [Release notes addon](https://github.com/mag37/dockcheck#date-release-notes-addon-to-notifications) - **v0.4.8**: Rewrote prune logic to not prompt with options `-a|-y` or `-n`. Auto prune with `-p`. - **v0.4.7**: Notification Template changes to gotify(new!), DSM(improved), SMTP(deprecation alternative). - **v0.4.6**: Compatibility changes to timeout, due to busybox. From 62b52796f22d0122738a0512988093a75f22938e Mon Sep 17 00:00:00 2001 From: mag37 Date: Fri, 4 Oct 2024 23:19:41 +0200 Subject: [PATCH 7/7] removed empty lines --- dockcheck.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index 0660af5..d3f5780 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -13,7 +13,6 @@ ScriptWorkDir="$(dirname "$ScriptPath")" LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")" - ### Help Function: Help() { echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]" @@ -150,13 +149,13 @@ progress_bar() { ### Function to add user-provided urls to releasenotes releasenotes() { - for update in ${Updates[@]}; do - found=false - while read -r container url; do - [[ $update == $container ]] && printf "%s -> %s\n" "$update" "$url" && found=true - done < "$ScriptWorkDir"/urls.list - [[ $found == false ]] && printf "%s -> url missing\n" "$update" || continue - done + for update in ${Updates[@]}; do + found=false + while read -r container url; do + [[ $update == $container ]] && printf "%s -> %s\n" "$update" "$url" && found=true + done < "$ScriptWorkDir"/urls.list + [[ $found == false ]] && printf "%s -> url missing\n" "$update" || continue + done } ### Version check & initiate self update @@ -272,7 +271,6 @@ NoUpdates=($(sort <<<"${NoUpdates[*]}")) GotUpdates=($(sort <<<"${GotUpdates[*]}")) unset IFS - ### Define how many updates are available UpdCount="${#GotUpdates[@]}"