diff --git a/default.config b/default.config index 04fd592..0a69d00 100644 --- a/default.config +++ b/default.config @@ -21,3 +21,4 @@ #DRunUp=true # Allow updating images for docker run, wont update the container. #MonoMode=true # Monochrome mode, no printf colour codes and hides progress bar. #PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)` +#PrintMarkdownURL=true # Prints custom releasenote urls as markdown diff --git a/dockcheck.sh b/dockcheck.sh index f7b5666..85487ab 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -40,6 +40,7 @@ Help() { echo "-I Prints custom releasenote urls alongside each container with updates (requires urls.list)." echo "-l Only update if label is set. See readme." echo "-m Monochrome mode, no printf colour codes and hides progress bar." + echo "-M Prints custom releasenote urls as markdown." echo "-n No updates; only checking availability without interaction." echo "-p Auto-prune dangling images after update." echo "-r Allow updating images for docker run; won't update the container." @@ -66,6 +67,7 @@ ForceRestartStacks=${ForceRestartStacks:=false} DRunUp=${DRunUp:=false} MonoMode=${MonoMode:=false} PrintReleaseURL=${PrintReleaseURL:=false} +PrintMarkdownURL=${PrintMarkdownURL:=false} Stopped=${Stopped:=""} CollectorTextFileDirectory=${CollectorTextFileDirectory:-} Exclude=${Exclude:-} @@ -86,7 +88,7 @@ c_blue="\033[0;34m" c_teal="\033[0;36m" c_reset="\033[0m" -while getopts "ayfhiIlmnprsuvc:e:d:t:x:" options; do +while getopts "ayfhiIlmMnprsuvc:e:d:t:x:" options; do case "${options}" in a|y) AutoMode=true ;; c) CollectorTextFileDirectory="${OPTARG}" ;; @@ -97,6 +99,7 @@ while getopts "ayfhiIlmnprsuvc:e:d:t:x:" options; do I) PrintReleaseURL=true ;; l) OnlyLabel=true ;; m) MonoMode=true ;; + M) PrintMarkdownURL=true ;; n) DontUpdate=true; AutoMode=true;; p) AutoPrune=true ;; r) DRunUp=true ;; @@ -229,9 +232,14 @@ releasenotes() { for update in "${GotUpdates[@]}"; do found=false while read -r container url; do - if [[ "$update" == "$container" ]]; then Updates+=("$update -> $url"); found=true; fi + if [[ "$update" == "$container" ]] && [[ "$PrintMarkdownURL" == true ]]; then Updates+=("- [$update]($url)"); found=true; + elif [[ "$update" == "$container" ]]; then Updates+=("$update -> $url"); found=true; + fi done < "${ScriptWorkDir}/urls.list" - if [[ "$found" == false ]]; then Updates+=("$update -> url missing"); else continue; fi + if [[ "$found" == false ]] && [[ "$PrintMarkdownURL" == true ]]; then Updates+=("- $update -> url missing"); + elif [[ "$found" == false ]]; then Updates+=("$update -> url missing"); + else continue; + fi done } diff --git a/notify_templates/notify_gotify.sh b/notify_templates/notify_gotify.sh index 3cb4d3e..94d1d97 100644 --- a/notify_templates/notify_gotify.sh +++ b/notify_templates/notify_gotify.sh @@ -1,5 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. -NOTIFY_GOTIFY_VERSION="v0.1" +NOTIFY_GOTIFY_VERSION="v0.2" # # Copy/rename this file to notify.sh to enable the notification snippet. # Required receiving services must already be set up. @@ -12,11 +12,19 @@ trigger_notification() { GotifyToken="Your Gotify token here" GotifyUrl="https://api.gotify/message?token=${GotifyToken}" - curl \ - -F "title=${MessageTitle}" \ - -F "message=${MessageBody}" \ - -F "priority=5" \ - -X POST "${GotifyUrl}" 1> /dev/null + if [[ "$PrintMarkdownURL" == true ]]; then + ContentType="text/markdown" + else + ContentType="text/plain" + fi + + JsonData=$( jq -n \ + --arg body "$MessageBody" \ + --arg title "$MessageTitle" \ + --arg type "$ContentType" \ + '{message: $body, title: $title, priority: 5, extras: {"client::display": {"contentType": $type}}}' ) + + curl -s -S --data "${JsonData}" -H 'Content-Type: application/json' -X POST "${GotifyUrl}" 1> /dev/null } send_notification() {