├── extras ├── temp ├── example.gif ├── apprise-ex1.png ├── apprise-ex2.png ├── example_old.gif ├── dockcheck_colour.png ├── dockcheck_logo_by_booYah187.png ├── dc_brief.sh ├── errorCheck.sh └── apprise_quickstart.md ├── addons ├── DSM │ ├── dsm1.png │ ├── dsm2.png │ ├── dsm3.png │ └── README.md └── prometheus │ ├── grafana │ ├── grafana_dashboard.png │ └── grafana_dashboard.json │ ├── prometheus_collector.sh │ └── README.md ├── .gitignore ├── notify_templates ├── notify_generic.sh ├── notify_file.sh ├── notify_discord.sh ├── notify_slack.sh ├── notify_pushbullet.sh ├── notify_ntfy.sh ├── notify_HA.sh ├── notify_pushover.sh ├── notify_matrix.sh ├── notify_gotify.sh ├── notify_apprise.sh ├── notify_smtp.sh ├── notify_telegram.sh ├── notify_DSM.sh ├── urls.list └── notify_v2.sh ├── .pre-commit-config.yaml ├── default.config ├── README.md ├── dockcheck.sh └── LICENSE /extras/temp: -------------------------------------------------------------------------------- 1 | temp 2 | -------------------------------------------------------------------------------- /extras/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/extras/example.gif -------------------------------------------------------------------------------- /addons/DSM/dsm1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/addons/DSM/dsm1.png -------------------------------------------------------------------------------- /addons/DSM/dsm2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/addons/DSM/dsm2.png -------------------------------------------------------------------------------- /addons/DSM/dsm3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/addons/DSM/dsm3.png -------------------------------------------------------------------------------- /extras/apprise-ex1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/extras/apprise-ex1.png -------------------------------------------------------------------------------- /extras/apprise-ex2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/extras/apprise-ex2.png -------------------------------------------------------------------------------- /extras/example_old.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/extras/example_old.gif -------------------------------------------------------------------------------- /extras/dockcheck_colour.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/extras/dockcheck_colour.png -------------------------------------------------------------------------------- /extras/dockcheck_logo_by_booYah187.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/extras/dockcheck_logo_by_booYah187.png -------------------------------------------------------------------------------- /addons/prometheus/grafana/grafana_dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mag37/dockcheck/HEAD/addons/prometheus/grafana/grafana_dashboard.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore users custom notify.sh 2 | /notify*.sh 3 | /urls.list 4 | # ignore user config 5 | /dockcheck.config 6 | # ignore the auto-installed regctl 7 | regctl 8 | # ignore snooze file 9 | snooze.list 10 | # ignore updates file 11 | updates_available.txt -------------------------------------------------------------------------------- /notify_templates/notify_generic.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_GENERIC_VERSION="v0.2" 3 | # 4 | # generic sample, the "Hello World" of notification addons 5 | 6 | trigger_generic_notification() { 7 | printf "\n$MessageTitle\n" 8 | printf "\n$MessageBody\n" 9 | } -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.6.0 4 | hooks: 5 | - id: check-yaml 6 | - id: check-added-large-files 7 | - id: trailing-whitespace 8 | args: [--markdown-linebreak-ext=md] 9 | - id: end-of-file-fixer 10 | - id: mixed-line-ending 11 | args: ['--fix=lf'] 12 | -------------------------------------------------------------------------------- /notify_templates/notify_file.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_FILE_VERSION="v0.1" 3 | # 4 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 5 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 6 | 7 | trigger_file_notification() { 8 | if [[ -n "$1" ]]; then 9 | file_channel="$1" 10 | UpperChannel=$(tr '[:lower:]' '[:upper:]' <<< "$file_channel") 11 | else 12 | file_channel="file" 13 | UpperChannel="FILE" 14 | fi 15 | 16 | FilePathVar="${UpperChannel}_PATH" 17 | 18 | NotifyFile="${!FilePathVar:=${ScriptWorkDir}/updates_available.txt}" 19 | 20 | echo "${MessageBody}" > ${NotifyFile} 21 | 22 | } 23 | -------------------------------------------------------------------------------- /addons/prometheus/prometheus_collector.sh: -------------------------------------------------------------------------------- 1 | prometheus_exporter() { 2 | checkedImages=$(($1 + $2 + $3)) 3 | checkTimestamp=$(date +%s) 4 | 5 | promFileContent=() 6 | promFileContent+=("# HELP dockcheck_images_analyzed Docker images that have been analyzed") 7 | promFileContent+=("# TYPE dockcheck_images_analyzed gauge") 8 | promFileContent+=("dockcheck_images_analyzed $checkedImages") 9 | 10 | promFileContent+=("# HELP dockcheck_images_outdated Docker images that are outdated") 11 | promFileContent+=("# TYPE dockcheck_images_outdated gauge") 12 | promFileContent+=("dockcheck_images_outdated ${#GotUpdates[@]}") 13 | 14 | promFileContent+=("# HELP dockcheck_images_latest Docker images that are outdated") 15 | promFileContent+=("# TYPE dockcheck_images_latest gauge") 16 | promFileContent+=("dockcheck_images_latest ${#NoUpdates[@]}") 17 | 18 | promFileContent+=("# HELP dockcheck_images_error Docker images with analysis errors") 19 | promFileContent+=("# TYPE dockcheck_images_error gauge") 20 | promFileContent+=("dockcheck_images_error ${#GotErrors[@]}") 21 | 22 | promFileContent+=("# HELP dockcheck_images_analyze_timestamp_seconds Last dockercheck run time") 23 | promFileContent+=("# TYPE dockcheck_images_analyze_timestamp_seconds gauge") 24 | promFileContent+=("dockcheck_images_analyze_timestamp_seconds $checkTimestamp") 25 | 26 | printf "%s\n" "${promFileContent[@]}" > "$CollectorTextFileDirectory/dockcheck_info.prom\$\$" 27 | mv -f "$CollectorTextFileDirectory/dockcheck_info.prom\$\$" "$CollectorTextFileDirectory/dockcheck_info.prom" 28 | } 29 | -------------------------------------------------------------------------------- /notify_templates/notify_discord.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_DISCORD_VERSION="v0.5" 3 | # 4 | # Required receiving services must already be set up. 5 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 6 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 7 | # Do not modify this file directly within the "notify_templates" subdirectory. Set DISCORD_WEBHOOK_URL in your dockcheck.config file. 8 | 9 | trigger_discord_notification() { 10 | if [[ -n "$1" ]]; then 11 | discord_channel="$1" 12 | else 13 | discord_channel="discord" 14 | fi 15 | 16 | UpperChannel="${discord_channel^^}" 17 | 18 | DiscordWebhookUrlVar="${UpperChannel}_WEBHOOK_URL" 19 | 20 | if [[ -z "${!DiscordWebhookUrlVar:-}" ]]; then 21 | printf "The ${discord_channel} notification channel is enabled, but required configuration variables are missing. Discord notifications will not be sent.\n" 22 | 23 | remove_channel discord 24 | return 0 25 | fi 26 | 27 | DiscordWebhookUrl="${!DiscordWebhookUrlVar}" # e.g. DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/ 28 | 29 | JsonData=$( "$jqbin" -n \ 30 | --arg username "$FromHost" \ 31 | --arg body "$MessageBody" \ 32 | '{"username": $username, "content": $body}' ) 33 | 34 | curl -S -o /dev/null ${CurlArgs} -X POST -H "Content-Type: application/json" -d "$JsonData" "$DiscordWebhookUrl" 35 | 36 | if [[ $? -gt 0 ]]; then 37 | NotifyError=true 38 | fi 39 | } 40 | -------------------------------------------------------------------------------- /notify_templates/notify_slack.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_SLACK_VERSION="v0.4" 3 | # 4 | # Setup app and token at https://api.slack.com/tutorials/tracks/posting-messages-with-curl 5 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 6 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 7 | # Do not modify this file directly within the "notify_templates" subdirectory. Set SLACK_ACCESS_TOKEN, and SLACK_CHANNEL_ID in your dockcheck.config file. 8 | 9 | trigger_slack_notification() { 10 | if [[ -n "$1" ]]; then 11 | slack_channel="$1" 12 | else 13 | slack_channel="slack" 14 | fi 15 | 16 | UpperChannel="${slack_channel^^}" 17 | 18 | AccessTokenVar="${UpperChannel}_ACCESS_TOKEN" 19 | ChannelIDVar="${UpperChannel}_CHANNEL_ID" 20 | 21 | if [[ -z "${!AccessTokenVar:-}" ]] || [[ -z "${!ChannelIDVar:-}" ]]; then 22 | printf "The ${slack_channel} notification channel is enabled, but required configuration variables are missing. Slack notifications will not be sent.\n" 23 | 24 | remove_channel slack 25 | return 0 26 | fi 27 | 28 | AccessToken="${!AccessTokenVar}" # e.g. SLACK_ACCESS_TOKEN=some-token 29 | ChannelID="${!ChannelIDVar}" # e.g. CHANNEL_ID=mychannel 30 | SlackUrl="https://slack.com/api/chat.postMessage" 31 | 32 | curl -S -o /dev/null ${CurlArgs} \ 33 | -d "text=$MessageBody" -d "channel=$ChannelID" \ 34 | -H "Authorization: Bearer $AccessToken" \ 35 | -X POST $SlackUrl 36 | 37 | if [[ $? -gt 0 ]]; then 38 | NotifyError=true 39 | fi 40 | } 41 | -------------------------------------------------------------------------------- /extras/dc_brief.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ### If not in PATH, set full path. Else just "regctl" 4 | regbin="regctl" 5 | ### options to allow exclude: 6 | while getopts "e:" options; do 7 | case "${options}" in 8 | e) Exclude=${OPTARG} ;; 9 | *) exit 0 ;; 10 | esac 11 | done 12 | shift "$((OPTIND-1))" 13 | ### Create array of excludes 14 | IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS 15 | 16 | SearchName="$1" 17 | 18 | for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do 19 | for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done 20 | printf ". " 21 | RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}') 22 | LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}') 23 | ### Checking for errors while setting the variable: 24 | if RegHash=$($regbin image digest --list "$RepoUrl" 2>/dev/null) ; then 25 | if [[ "$LocalHash" = *"$RegHash"* ]] ; then NoUpdates+=("$i"); else GotUpdates+=("$i"); fi 26 | else 27 | GotErrors+=("$i") 28 | fi 29 | done 30 | 31 | ### Sort arrays alphabetically 32 | IFS=$'\n' 33 | NoUpdates=($(sort <<<"${NoUpdates[*]}")) 34 | GotUpdates=($(sort <<<"${GotUpdates[*]}")) 35 | GotErrors=($(sort <<<"${GotErrors[*]}")) 36 | unset IFS 37 | 38 | ### List what containers got updates or not 39 | if [[ -n ${NoUpdates[*]} ]] ; then 40 | printf "\n\033[0;32mContainers on latest version:\033[0m\n" 41 | printf "%s\n" "${NoUpdates[@]}" 42 | fi 43 | if [[ -n ${GotErrors[*]} ]] ; then 44 | printf "\n\033[0;31mContainers with errors, wont get updated:\033[0m\n" 45 | printf "%s\n" "${GotErrors[@]}" 46 | fi 47 | if [[ -n ${GotUpdates[*]} ]] ; then 48 | printf "\n\033[0;33mContainers with updates available:\033[0m\n" 49 | printf "%s\n" "${GotUpdates[@]}" 50 | fi 51 | printf "\n\n" 52 | -------------------------------------------------------------------------------- /notify_templates/notify_pushbullet.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_PUSHBULLET_VERSION="v0.4" 3 | # 4 | # Required receiving services must already be set up. 5 | # Requires jq installed and in PATH. 6 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 7 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 8 | # Do not modify this file directly within the "notify_templates" subdirectory. Set PUSHBULLET_TOKEN and PUSHBULLET_URL in your dockcheck.config file. 9 | 10 | trigger_pushbullet_notification() { 11 | if [[ -n "$1" ]]; then 12 | pushbullet_channel="$1" 13 | else 14 | pushbullet_channel="pushbullet" 15 | fi 16 | 17 | UpperChannel="${pushbullet_channel^^}" 18 | 19 | PushUrlVar="${UpperChannel}_URL" 20 | PushTokenVar="${UpperChannel}_TOKEN" 21 | 22 | if [[ -z "${!PushUrlVar:-}" ]] || [[ -z "${!PushTokenVar:-}" ]]; then 23 | printf "The ${pushbullet_channel} notification channel is enabled, but required configuration variables are missing. Pushbullet notifications will not be sent.\n" 24 | 25 | remove_channel pushbullet 26 | return 0 27 | fi 28 | 29 | PushUrl="${!PushUrlVar}" # e.g. PUSHBULLET_URL=https://api.pushbullet.com/v2/pushes 30 | PushToken="${!PushTokenVar}" # e.g. PUSHBULLET_TOKEN=token-value 31 | 32 | # Requires jq to process json data 33 | "$jqbin" -n --arg title "$MessageTitle" --arg body "$MessageBody" '{body: $body, title: $title, type: "note"}' | curl -S -o /dev/null ${CurlArgs} -X POST -H "Access-Token: $PushToken" -H "Content-type: application/json" $PushUrl -d @- 34 | 35 | if [[ $? -gt 0 ]]; then 36 | NotifyError=true 37 | fi 38 | } 39 | -------------------------------------------------------------------------------- /extras/errorCheck.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SearchName="$1" 3 | for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do 4 | echo "------------ $i ------------" 5 | ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}') 6 | ContImage=$(docker inspect "$i" --format='{{.Config.Image}}') 7 | ContPath=$(jq -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels") 8 | [ "$ContPath" == "null" ] && ContPath="" 9 | [ -z "$ContPath" ] && { "$i has no compose labels - skipping" ; continue ; } 10 | ContConfigFile=$(jq -r '."com.docker.compose.project.config_files"' <<< "$ContLabels") 11 | [ "$ContConfigFile" == "null" ] && ContConfigFile="" 12 | ContName=$(jq -r '."com.docker.compose.service"' <<< "$ContLabels") 13 | [ "$ContName" == "null" ] && ContName="" 14 | ContEnv=$(jq -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels") 15 | [ "$ContEnv" == "null" ] && ContEnv="" 16 | ContUpdateLabel=$(jq -r '."mag37.dockcheck.update"' <<< "$ContLabels") 17 | [ "$ContUpdateLabel" == "null" ] && ContUpdateLabel="" 18 | ContRestartStack=$(jq -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels") 19 | [ "$ContRestartStack" == "null" ] && ContRestartStack="" 20 | 21 | if [[ $ContConfigFile = '/'* ]] ; then 22 | ComposeFile="$ContConfigFile" 23 | else 24 | ComposeFile="$ContPath/$ContConfigFile" 25 | fi 26 | 27 | echo -e "Service name:\t\t$ContName" 28 | echo -e "Project working dir:\t$ContPath" 29 | echo -e "Compose files:\t\t$ComposeFile" 30 | echo -e "Environment files:\t$ContEnv" 31 | echo -e "Container image:\t$ContImage" 32 | echo -e "Update label:\t$ContUpdateLabel" 33 | echo -e "Restart Stack label:\t$ContRestartStack" 34 | echo 35 | echo "Mounts:" 36 | docker inspect -f '{{ range .Mounts }}{{ .Source }}:{{ .Destination }}{{ printf "\n" }}{{ end }}' "$i" 37 | echo 38 | done 39 | -------------------------------------------------------------------------------- /notify_templates/notify_ntfy.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_NTFYSH_VERSION="v0.7" 3 | # 4 | # Setup app and subscription at https://ntfy.sh 5 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 6 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 7 | # Do not modify this file directly within the "notify_templates" subdirectory. Set NTFY_DOMAIN and NTFY_TOPIC_NAME in your dockcheck.config file. 8 | 9 | trigger_ntfy_notification() { 10 | if [[ -n "$1" ]]; then 11 | ntfy_channel="$1" 12 | else 13 | ntfy_channel="ntfy" 14 | fi 15 | 16 | UpperChannel="${ntfy_channel^^}" 17 | 18 | NtfyDomainVar="${UpperChannel}_DOMAIN" 19 | NtfyTopicNameVar="${UpperChannel}_TOPIC_NAME" 20 | NtfyAuthVar="${UpperChannel}_AUTH" 21 | 22 | if [[ -z "${!NtfyDomainVar:-}" ]] || [[ -z "${!NtfyTopicNameVar:-}" ]]; then 23 | printf "The ${ntfy_channel} notification channel is enabled, but required configuration variables are missing. Ntfy notifications will not be sent.\n" 24 | 25 | remove_channel ntfy 26 | return 0 27 | fi 28 | 29 | NtfyUrl="${!NtfyDomainVar}/${!NtfyTopicNameVar}" 30 | # e.g. 31 | # NTFY_DOMAIN=ntfy.sh 32 | # NTFY_TOPIC_NAME=YourUniqueTopicName 33 | 34 | if [[ "$PrintMarkdownURL" == true ]]; then 35 | ContentType="Markdown: yes" 36 | else 37 | ContentType="Markdown: no" #text/plain 38 | fi 39 | 40 | if [[ -n "${!NtfyAuthVar:-}" ]]; then 41 | NtfyAuth="-u ${!NtfyAuthVar}" 42 | else 43 | NtfyAuth="" 44 | fi 45 | 46 | curl -S -o /dev/null ${CurlArgs} \ 47 | -H "Title: $MessageTitle" \ 48 | -H "$ContentType" \ 49 | -d "$MessageBody" \ 50 | $NtfyAuth \ 51 | -L "$NtfyUrl" 52 | 53 | if [[ $? -gt 0 ]]; then 54 | NotifyError=true 55 | fi 56 | } 57 | -------------------------------------------------------------------------------- /notify_templates/notify_HA.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_HA_VERSION="v0.2" 3 | # 4 | # This is an integration that makes it possible to send notifications via Home Assistant (https://www.home-assistant.io/integrations/notify/) 5 | # You need to generate a long-lived access token in Home Sssistant to be used here (https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token) 6 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 7 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 8 | # Do not modify this file directly within the "notify_templates" subdirectory. Set HA_ENTITY, HA_URL and HA_TOKEN in your dockcheck.config file. 9 | 10 | trigger_HA_notification() { 11 | if [[ -n "$1" ]]; then 12 | HA_channel="$1" 13 | else 14 | HA_channel="HA" 15 | fi 16 | 17 | UpperChannel="${HA_channel^^}" 18 | 19 | HAEntityVar="${UpperChannel}_ENTITY" 20 | HAUrlVar="${UpperChannel}_URL" 21 | HATokenVar="${UpperChannel}_TOKEN" 22 | 23 | if [[ -z "${!HAEntityVar:-}" ]] || [[ -z "${!HAUrlVar:-}" ]] || [[ -z "${!HATokenVar:-}" ]]; then 24 | printf "The ${HA_channel} notification channel is enabled, but required configuration variables are missing. Home assistant notifications will not be sent.\n" 25 | 26 | remove_channel HA 27 | return 0 28 | fi 29 | 30 | AccessToken="${!HATokenVar}" 31 | Url="${!HAUrlVar}/api/services/notify/${!HAEntityVar}" 32 | JsonData=$( "$jqbin" -n \ 33 | --arg body "$MessageBody" \ 34 | '{"title": "dockcheck update", "message": $body}' ) 35 | 36 | curl -S -o /dev/null ${CurlArgs} \ 37 | -H "Authorization: Bearer $AccessToken" \ 38 | -H "Content-Type: application/json" \ 39 | -d "$JsonData" -X POST $Url 40 | 41 | if [[ $? -gt 0 ]]; then 42 | NotifyError=true 43 | fi 44 | } 45 | -------------------------------------------------------------------------------- /notify_templates/notify_pushover.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_PUSHOVER_VERSION="v0.4" 3 | # 4 | # Required receiving services must already be set up. 5 | # Requires jq installed and in PATH. 6 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 7 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 8 | # Do not modify this file directly within the "notify_templates" subdirectory. Set PUSHOVER_USER_KEY, PUSHOVER_TOKEN, and PUSHOVER_URL in your dockcheck.config file. 9 | 10 | trigger_pushover_notification() { 11 | if [[ -n "$1" ]]; then 12 | pushover_channel="$1" 13 | else 14 | pushover_channel="pushover" 15 | fi 16 | 17 | UpperChannel="${pushover_channel^^}" 18 | 19 | PushoverUrlVar="${UpperChannel}_URL" 20 | PushoverUserKeyVar="${UpperChannel}_USER_KEY" 21 | PushoverTokenVar="${UpperChannel}_TOKEN" 22 | 23 | if [[ -z "${!PushoverUrlVar:-}" ]] || [[ -z "${!PushoverUserKeyVar:-}" ]] || [[ -z "${!PushoverTokenVar:-}" ]]; then 24 | printf "The ${pushover_channel} notification channel is enabled, but required configuration variables are missing. Pushover notifications will not be sent.\n" 25 | 26 | remove_channel pushover 27 | return 0 28 | fi 29 | 30 | PushoverUrl="${!PushoverUrlVar}" # e.g. PUSHOVER_URL=https://api.pushover.net/1/messages.json 31 | PushoverUserKey="${!PushoverUserKeyVar}" # e.g. PUSHOVER_USER_KEY=userkey 32 | PushoverToken="${!PushoverTokenVar}" # e.g. PUSHOVER_TOKEN=token-value 33 | 34 | # Sending the notification via Pushover 35 | curl -S -o /dev/null ${CurlArgs} -X POST \ 36 | -F "token=$PushoverToken" \ 37 | -F "user=$PushoverUserKey" \ 38 | -F "title=$MessageTitle" \ 39 | -F "message=$MessageBody" \ 40 | $PushoverUrl 41 | 42 | if [[ $? -gt 0 ]]; then 43 | NotifyError=true 44 | fi 45 | } -------------------------------------------------------------------------------- /notify_templates/notify_matrix.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_MATRIX_VERSION="v0.5" 3 | # 4 | # Required receiving services must already be set up. 5 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 6 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 7 | # Do not modify this file directly within the "notify_templates" subdirectory. Set MATRIX_ACCESS_TOKEN, MATRIX_ROOM_ID, and MATRIX_SERVER_URL in your dockcheck.config file. 8 | 9 | trigger_matrix_notification() { 10 | if [[ -n "$1" ]]; then 11 | matrix_channel="$1" 12 | else 13 | matrix_channel="matrix" 14 | fi 15 | 16 | UpperChannel="${matrix_channel^^}" 17 | 18 | AccessTokenVar="${UpperChannel}_ACCESS_TOKEN" 19 | RoomIdVar="${UpperChannel}_ROOM_ID" 20 | MatrixServerVar="${UpperChannel}_SERVER_URL" 21 | 22 | if [[ -z "${!AccessTokenVar:-}" ]] || [[ -z "${!RoomIdVar:-}" ]] || [[ -z "${!MatrixServerVar:-}" ]]; then 23 | printf "The ${matrix_channel} notification channel is enabled, but required configuration variables are missing. Matrix notifications will not be sent.\n" 24 | 25 | remove_channel matrix 26 | return 0 27 | fi 28 | 29 | AccessToken="${!AccessTokenVar}" # e.g. MATRIX_ACCESS_TOKEN=token-value 30 | RoomId="${!RoomIdVar}" # e.g. MATRIX_ROOM_ID=myroom 31 | MatrixServer="${!MatrixServerVar}" # e.g. MATRIX_SERVER_URL=http://matrix.yourdomain.tld 32 | MsgBody=$($jqbin -Rn --arg body "$MessageBody" '{msgtype:"m.text", body:$body}') 33 | 34 | # URL Example: https://matrix.org/_matrix/client/r0/rooms/!xxxxxx:example.com/send/m.room.message?access_token=xxxxxxxx 35 | curl -S -o /dev/null ${CurlArgs} -X POST "$MatrixServer/_matrix/client/r0/rooms/$RoomId/send/m.room.message?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody" 36 | 37 | if [[ $? -gt 0 ]]; then 38 | NotifyError=true 39 | fi 40 | } 41 | -------------------------------------------------------------------------------- /notify_templates/notify_gotify.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_GOTIFY_VERSION="v0.5" 3 | # 4 | # Required receiving services must already be set up. 5 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 6 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 7 | # Do not modify this file directly within the "notify_templates" subdirectory. Set GOTIFY_TOKEN and GOTIFY_DOMAIN in your dockcheck.config file. 8 | 9 | trigger_gotify_notification() { 10 | if [[ -n "$1" ]]; then 11 | gotify_channel="$1" 12 | else 13 | gotify_channel="gotify" 14 | fi 15 | 16 | UpperChannel="${gotify_channel^^}" 17 | 18 | GotifyTokenVar="${UpperChannel}_TOKEN" 19 | GotifyUrlVar="${UpperChannel}_DOMAIN" 20 | 21 | if [[ -z "${!GotifyTokenVar:-}" ]] || [[ -z "${!GotifyUrlVar:-}" ]]; then 22 | printf "The ${gotify_channel} notification channel is enabled, but required configuration variables are missing. Gotify notifications will not be sent.\n" 23 | 24 | remove_channel gotify 25 | return 0 26 | fi 27 | 28 | GotifyToken="${!GotifyTokenVar}" # e.g. GOTIFY_TOKEN=token-value 29 | GotifyUrl="${!GotifyUrlVar}/message?token=${GotifyToken}" # e.g. GOTIFY_URL=https://gotify.domain.tld 30 | 31 | if [[ "$PrintMarkdownURL" == true ]]; then 32 | ContentType="text/markdown" 33 | else 34 | ContentType="text/plain" 35 | fi 36 | 37 | JsonData=$( "$jqbin" -n \ 38 | --arg body "$MessageBody" \ 39 | --arg title "$MessageTitle" \ 40 | --arg type "$ContentType" \ 41 | '{message: $body, title: $title, priority: 5, extras: {"client::display": {"contentType": $type}}}' ) 42 | 43 | curl -S -o /dev/null ${CurlArgs} --data "${JsonData}" -H 'Content-Type: application/json' -X POST "${GotifyUrl}" 1> /dev/null 44 | 45 | if [[ $? -gt 0 ]]; then 46 | NotifyError=true 47 | fi 48 | } 49 | -------------------------------------------------------------------------------- /notify_templates/notify_apprise.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_APPRISE_VERSION="v0.4" 3 | # 4 | # Required receiving services must already be set up. 5 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 6 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 7 | # Do not modify this file directly within the "notify_templates" subdirectory. Set APPRISE_PAYLOAD in your dockcheck.config file. 8 | # If API, set APPRISE_URL instead. 9 | 10 | trigger_apprise_notification() { 11 | if [[ -n "$1" ]]; then 12 | apprise_channel="$1" 13 | else 14 | apprise_channel="apprise" 15 | fi 16 | 17 | UpperChannel="${apprise_channel^^}" 18 | 19 | ApprisePayloadVar="${UpperChannel}_PAYLOAD" 20 | AppriseUrlVar="${UpperChannel}_URL" 21 | 22 | if [[ -z "${!ApprisePayloadVar:-}" ]] && [[ -z "${!AppriseUrlVar:-}" ]]; then 23 | printf "The ${apprise_channel} notification channel is enabled, but required configuration variables are missing. Apprise notifications will not be sent.\n" 24 | 25 | remove_channel apprise 26 | return 0 27 | fi 28 | 29 | if [[ -n "${!ApprisePayloadVar:-}" ]]; then 30 | apprise -vv -t "$MessageTitle" -b "$MessageBody" \ 31 | ${!ApprisePayloadVar} 32 | 33 | if [[ $? -gt 0 ]]; then 34 | NotifyError=true 35 | fi 36 | fi 37 | 38 | # e.g. APPRISE_PAYLOAD='mailto://myemail:mypass@gmail.com 39 | # mastodons://{token}@{host} 40 | # pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b 41 | # tgram://{bot_token}/{chat_id}/' 42 | 43 | if [[ -n "${!AppriseUrlVar:-}" ]]; then 44 | AppriseURL="${!AppriseUrlVar}" 45 | curl -S -o /dev/null ${CurlArgs} -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL # e.g. APPRISE_URL=http://apprise.mydomain.tld:1234/notify/apprise 46 | 47 | if [[ $? -gt 0 ]]; then 48 | NotifyError=true 49 | fi 50 | fi 51 | } -------------------------------------------------------------------------------- /notify_templates/notify_smtp.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_SMTP_VERSION="v0.5" 3 | # INFO: ssmtp is depcerated - consider to use msmtp instead. 4 | # 5 | # mSMTP/sSMTP has to be installed and configured manually. 6 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 7 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 8 | # Do not modify this file directly within the "notify_templates" subdirectory. Set SMTP_MAIL_FROM, SMTP_MAIL_TO, and SMTP_SUBJECT_TAG in your dockcheck.config file. 9 | 10 | MSMTP=$(which msmtp) 11 | SSMTP=$(which ssmtp) 12 | SENDMAIL=$(which sendmail) 13 | 14 | if [ -n "$MSMTP" ] ; then 15 | MailPkg=$MSMTP 16 | elif [ -n "$SSMTP" ] ; then 17 | MailPkg=$SSMTP 18 | elif [ -n "$SENDMAIL" ] ; then 19 | MailPkg=$SENDMAIL 20 | else 21 | echo "No msmtp, ssmtp or sendmail binary found in PATH: $PATH" ; exit 1 22 | fi 23 | 24 | trigger_smtp_notification() { 25 | if [[ -n "$1" ]]; then 26 | smtp_channel="$1" 27 | else 28 | smtp_channel="smtp" 29 | fi 30 | 31 | UpperChannel="${smtp_channel^^}" 32 | 33 | SendMailFromVar="${UpperChannel}_MAIL_FROM" 34 | SendMailToVar="${UpperChannel}_MAIL_TO" 35 | SubjectTagVar="${UpperChannel}_SUBJECT_TAG" 36 | 37 | if [[ -z "${!SendMailFromVar:-}" ]] || [[ -z "${!SendMailToVar:-}" ]] || [[ -z "${!SubjectTagVar:-}" ]]; then 38 | printf "The ${smtp_channel} notification channel is enabled, but required configuration variables are missing. SMTP notifications will not be sent.\n" 39 | 40 | remove_channel smtp 41 | return 0 42 | fi 43 | 44 | SendMailFrom="${!SendMailFromVar}" # e.g. MAIL_FROM=me@mydomain.tld 45 | SendMailTo="${!SendMailToVar}" # e.g. MAIL_TO=me@mydomain.tld 46 | SubjectTag="${!SubjectTagVar}" # e.g. SUBJECT_TAG=dockcheck 47 | 48 | $MailPkg $SendMailTo << __EOF 49 | From: "$FromHost" <$SendMailFrom> 50 | date:$(date -R) 51 | To: <$SendMailTo> 52 | Subject: [$SubjectTag] $MessageTitle $FromHost 53 | Content-Type: text/plain; charset=UTF-8; format=flowed 54 | Content-Transfer-Encoding: 7bit 55 | 56 | $MessageBody 57 | 58 | __EOF 59 | 60 | if [[ $? -gt 0 ]]; then 61 | NotifyError=true 62 | fi 63 | } 64 | -------------------------------------------------------------------------------- /notify_templates/notify_telegram.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_TELEGRAM_VERSION="v0.5" 3 | # 4 | # Required receiving services must already be set up. 5 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 6 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 7 | # Do not modify this file directly within the "notify_templates" subdirectory. Set TELEGRAM_CHAT_ID and TELEGRAM_TOKEN in your dockcheck.config file. 8 | 9 | trigger_telegram_notification() { 10 | if [[ -n "$1" ]]; then 11 | telegram_channel="$1" 12 | else 13 | telegram_channel="telegram" 14 | fi 15 | 16 | UpperChannel="${telegram_channel^^}" 17 | 18 | TelegramTokenVar="${UpperChannel}_TOKEN" 19 | TelegramChatIdVar="${UpperChannel}_CHAT_ID" 20 | TelegramTopicIdVar="${UpperChannel}_TOPIC_ID" 21 | 22 | if [[ -z "${!TelegramChatIdVar:-}" ]] || [[ -z "${!TelegramTokenVar:-}" ]]; then 23 | printf "The ${telegram_channel} notification channel is enabled, but required configuration variables are missing. Telegram notifications will not be sent.\n" 24 | 25 | remove_channel telegram 26 | return 0 27 | fi 28 | 29 | if [[ "$PrintMarkdownURL" == true ]]; then 30 | ParseMode="Markdown" 31 | else 32 | ParseMode="HTML" 33 | fi 34 | 35 | TelegramToken="${!TelegramTokenVar}" # e.g. TELEGRAM_TOKEN=token-value 36 | TelegramChatId="${!TelegramChatIdVar}" # e.g. TELEGRAM_CHAT_ID=mychatid 37 | TelegramUrl="https://api.telegram.org/bot$TelegramToken" 38 | TelegramTopicID=${!TelegramTopicIdVar:="0"} 39 | 40 | JsonData=$( "$jqbin" -n \ 41 | --arg chatid "$TelegramChatId" \ 42 | --arg text "$MessageBody" \ 43 | --arg thread "$TelegramTopicID" \ 44 | --arg parse_mode "$ParseMode" \ 45 | '{"chat_id": $chatid, "text": $text, "message_thread_id": $thread, "disable_notification": false, "parse_mode": $parse_mode, "disable_web_page_preview": true}' ) 46 | 47 | curl -S -o /dev/null ${CurlArgs} -X POST "$TelegramUrl/sendMessage" -H 'Content-Type: application/json' -d "$JsonData" 48 | 49 | if [[ $? -gt 0 ]]; then 50 | NotifyError=true 51 | fi 52 | } 53 | -------------------------------------------------------------------------------- /addons/DSM/README.md: -------------------------------------------------------------------------------- 1 | ## Using Dockcheck in DSM 2 | Dockcheck cannot directly update containers managed in the Container Manager GUI, but it can still be used to notify you of containers with updates available. There are two ways to be notified, each with their own caveats: 3 | 4 | 1. Enabling email notifications within the Task Scheduler (_step 6i below_) will send an email that includes the entire script as run. This will not include the `urls.list` links to release notes, but it will show a full list of containers checked, up to date, and needing updates (following the args included in the scheduled task). 5 | 2. The [DSM notification template](https://github.com/mag37/dockcheck/blob/main/notify_templates/notify_DSM.sh) will enable Dockcheck to directly send an email when using the `-i` flag. This is most useful when paired with an accurate [urls.list](https://github.com/mag37/dockcheck/blob/next063/notify_templates/urls.list) file, and results in a neat succinct email notification of only containers to be updated. 6 | 7 | This is a user preference, and both notifications are not necessary. However, regardless of the notification method, it is necessary to set up a scheduled task to run Dockcheck at a set interval (otherwise it will only run when manually triggered). 8 | 9 | 10 | ## Automate Dockcheck with DSM Task Scheduler: 11 | 12 | 1. Open Control Panel and navigate to Task Scheduler 13 | 2. Create a Scheduled Task > User-defined script 14 | 3. Task Name: Dockcheck 15 | 4. User: root 16 | 5. Schedule: _User Preference_ 17 | 6. Task Settings: 18 | 1. ✔ Send run details by email (include preferred email) _This is the optional step as described above)_ 19 | 2. User-defined script: `export HOME=/root && cd /path/to/dockcheck && ./dockcheck.sh -n -i -I ` _or other custom args_ 20 | 8. Click OK, accept warning message 21 | 22 | 23 | ## Set up the DSM Notification template 24 | 25 | Copy the [dockcheck/notify_templates/notify_DSM.sh](https://github.com/mag37/dockcheck/blob/main/notify_templates/notify_DSM.sh) to the same directory as where you keep `dockcheck.sh`. 26 | Use as is (uses your default notification email setting) or edit and override manually. 27 | 28 | ![](./dsm1.png) 29 | 30 | ![](./dsm2.png) 31 | 32 | ![](./dsm3.png) 33 | 34 | 35 | Made with much help and contribution from [@firmlyundecided](https://github.com/firmlyundecided) and [@yoyoma2](https://github.com/yoyoma2). 36 | -------------------------------------------------------------------------------- /notify_templates/notify_DSM.sh: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. 2 | NOTIFY_DSM_VERSION="v0.5" 3 | # INFO: ssmtp is deprecated - consider to use msmtp instead. 4 | # 5 | # mSMTP/sSMTP has to be installed and configured manually. 6 | # The existing DSM Notification Email configuration will be used automatically. 7 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 8 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script. 9 | # Do not modify this file directly within the "notify_templates" subdirectory. Set DSM_SENDMAILTO and DSM_SUBJECTTAG in your dockcheck.config file. 10 | 11 | MSMTP=$(which msmtp) 12 | SSMTP=$(which ssmtp) 13 | SENDMAIL=$(which sendmail) 14 | 15 | if [ -n "$MSMTP" ] ; then 16 | MailPkg=$MSMTP 17 | elif [ -n "$SSMTP" ] ; then 18 | MailPkg=$SSMTP 19 | elif [ -n "$SENDMAIL" ] ; then 20 | MailPkg=$SENDMAIL 21 | else 22 | echo "No msmtp, ssmtp or sendmail binary found in PATH: $PATH" ; exit 1 23 | fi 24 | 25 | trigger_DSM_notification() { 26 | if [[ -n "$1" ]]; then 27 | DSM_channel="$1" 28 | else 29 | DSM_channel="DSM" 30 | fi 31 | 32 | UpperChannel="${DSM_channel^^}" 33 | 34 | DSMSendmailToVar="${UpperChannel}_SENDMAILTO" 35 | DSMSubjectTagVar="${UpperChannel}_SUBJECTTAG" 36 | 37 | CfgFile="/usr/syno/etc/synosmtp.conf" 38 | 39 | # User variables: 40 | # Automatically sends to your usual destination for synology DSM notification emails. 41 | # You can also manually override by assigning something else to DSM_SENDMAILTO in dockcheck.config. 42 | SendMailTo=${!DSMSendmailToVar:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')} 43 | # e.g. DSM_SENDMAILTO="me@mydomain.com" 44 | 45 | SubjectTag=${!DSMSubjectTagVar:-$(grep 'eventsubjectprefix' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')} 46 | # e.g. DSM_SUBJECTTAG="Email Subject Prefix" 47 | SenderName=$(grep 'smtp_from_name' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p') 48 | SenderMail=$(grep 'smtp_from_mail' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p') 49 | SenderMail=${SenderMail:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')} 50 | 51 | $MailPkg $SendMailTo << __EOF 52 | From: "$SenderName" <$SenderMail> 53 | date:$(date -R) 54 | To: <$SendMailTo> 55 | Subject: $SubjectTag $MessageTitle 56 | Content-Type: text/plain; charset=UTF-8; format=flowed 57 | Content-Transfer-Encoding: 7bit 58 | 59 | $MessageBody 60 | From $SenderName 61 | __EOF 62 | 63 | if [[ $? -gt 0 ]]; then 64 | NotifyError=true 65 | fi 66 | 67 | # This ensures DSM's container manager will also see the update 68 | /var/packages/ContainerManager/target/tool/image_upgradable_checker 69 | } 70 | -------------------------------------------------------------------------------- /addons/prometheus/README.md: -------------------------------------------------------------------------------- 1 | ## [Prometheus](https://github.com/prometheus/prometheus) and [node_exporter](https://github.com/prometheus/node_exporter) 2 | Dockcheck is capable to export metrics to prometheus via the text file collector provided by the node_exporter. 3 | In order to do so the -c flag has to be specified followed by the file path that is configured in the text file collector of the node_exporter. 4 | A simple cron job can be configured to export these metrics on a regular interval as shown in the sample below: 5 | 6 | ``` 7 | 0 1 * * * /root/dockcheck.sh -n -c /var/lib/node_exporter/textfile_collector 8 | ``` 9 | 10 | The following metrics are exported to prometheus 11 | 12 | ``` 13 | # HELP dockcheck_images_analyzed Docker images that have been analyzed 14 | # TYPE dockcheck_images_analyzed gauge 15 | dockcheck_images_analyzed 22 16 | # HELP dockcheck_images_outdated Docker images that are outdated 17 | # TYPE dockcheck_images_outdated gauge 18 | dockcheck_images_outdated 7 19 | # HELP dockcheck_images_latest Docker images that are outdated 20 | # TYPE dockcheck_images_latest gauge 21 | dockcheck_images_latest 14 22 | # HELP dockcheck_images_error Docker images with analysis errors 23 | # TYPE dockcheck_images_error gauge 24 | dockcheck_images_error 1 25 | # HELP dockcheck_images_analyze_timestamp_seconds Last dockercheck run time 26 | # TYPE dockcheck_images_analyze_timestamp_seconds gauge 27 | dockcheck_images_analyze_timestamp_seconds 1737924029 28 | ``` 29 | 30 | Once those metrics are exported they can be used to define alarms as shown below 31 | 32 | ``` 33 | - alert: dockcheck_images_outdated 34 | expr: sum by(instance) (dockcheck_images_outdated) > 0 35 | for: 15s 36 | labels: 37 | severity: warning 38 | annotations: 39 | summary: "{{ $labels.instance }} has {{ $value }} outdated docker images." 40 | description: "{{ $labels.instance }} has {{ $value }} outdated docker images." 41 | - alert: dockcheck_images_error 42 | expr: sum by(instance) (dockcheck_images_error) > 0 43 | for: 15s 44 | labels: 45 | severity: warning 46 | annotations: 47 | summary: "{{ $labels.instance }} has {{ $value }} docker images having an error." 48 | description: "{{ $labels.instance }} has {{ $value }} docker images having an error." 49 | - alert: dockercheck_image_last_analyze 50 | expr: (time() - dockcheck_images_analyze_timestamp_seconds) > (3600 * 24 * 3) 51 | for: 15s 52 | labels: 53 | severity: warning 54 | annotations: 55 | summary: "{{ $labels.instance }} has not updated the dockcheck statistics for more than 3 days." 56 | description: "{{ $labels.instance }} has not updated the dockcheck statistics for more than 3 days." 57 | ``` 58 | 59 | There is a reference Grafana dashboard in [grafana/grafana_dashboard.json](./grafana/grafana_dashboard.json). 60 | 61 | ![](./grafana/grafana_dashboard.png) 62 | -------------------------------------------------------------------------------- /extras/apprise_quickstart.md: -------------------------------------------------------------------------------- 1 | # A small guide on getting started with Apprise notifications. 2 | 3 | 4 | ## Standalone docker container: [linuxserver/apprise-api](https://hub.docker.com/r/linuxserver/apprise-api) 5 | 6 | Set up the docker compose as preferred: 7 | ```yaml 8 | --- 9 | version: "2.1" 10 | services: 11 | apprise-api: 12 | image: lscr.io/linuxserver/apprise-api:latest 13 | container_name: apprise-api 14 | environment: 15 | - PUID=1000 16 | - PGID=1000 17 | - TZ=Etc/UTC 18 | volumes: 19 | - /path/to/apprise-api/config:/config 20 | ports: 21 | - 8000:8000 22 | restart: unless-stopped 23 | ``` 24 | 25 | Then browse to the webui. 26 | ![](apprise-ex1.png) 27 | Here you'll click **Configuration Manager**, read the overview and then click on **Configuration**. 28 | Under **Configuration** you'll craft/paste your notification config. 29 | 30 | ![](apprise-ex2.png) 31 | The simplest way is just paste the url's as is (like in the example above). 32 | There are many ways to customize with tags, groups, json and more. Read [caronc/apprise-api](https://github.com/caronc/apprise-api) for more info! 33 | 34 | Look at the [apprise wiki: Notification Services](https://github.com/caronc/apprise/wiki) for more info about how the url syntax for different services works. 35 | 36 | 37 | You can also use the [caronc/apprise-api](https://github.com/caronc/apprise-api) to host the api as a frontend to an already existing **Apprise**-setup on the host. 38 | 39 | 40 | ### Customize the **notify.sh** file. 41 | After you're done with the setup of the container and tried your notifications, you need to follow the configuration setup (explained in detail in the README). 42 | Briefly: Copy `default.config` to `dockcheck.config` then edit it to change the following, `APPRISE_URL` matching your environment: 43 | 44 | ```bash 45 | NOTIFY_CHANNELS="apprise" 46 | APPRISE_URL="http://apprise.mydomain.tld:1234/notify/apprise" 47 | ``` 48 | 49 | That's it! 50 | ___ 51 | ___ 52 | 53 | 54 | ## On host installed **Apprise** 55 | Follow the official guide on [caronc/apprise](https://github.com/caronc/apprise)! 56 | 57 | ### A brief, basic "get started" 58 | 59 | - Install **apprise** 60 | - python package `pip install apprise` 61 | - packaged in EPEL/Fedora `dnf install apprise` 62 | - packaged in AUR `[yay/pikaur/paru/other] apprise` 63 | 64 | - Create a config file with your notification credentials (source of notifications): 65 | ```ini 66 | mailto://user:password@yahoo.com 67 | slack://token_a/token_b/token_c 68 | kodi://example.com 69 | ``` 70 | Then either source the notifications with `-c=/path/to/config/apprise` or store them in *PATH* to skip referencing (`~/.apprise` or `~/.config/apprise`). 71 | 72 | - Test apprise with a single notification: 73 | - `apprise -vv -t 'test title' -b 'test notification body' 'mailto://myemail:mypass@gmail.com'` 74 | - Set up your notification URL's and test them. 75 | - Look at the [apprise wiki: Notification Services](https://github.com/caronc/apprise/wiki) for more info about how the url syntax for different services works. 76 | 77 | ### When done, customize the **notify.sh** file. 78 | After you're done with the setup of the container and tried your notifications, you can copy the `notify_apprise.sh` file to `notify.sh` and start editing it. 79 | 80 | Replace the url's corresponding to the services you've configured. 81 | ```bash 82 | send_notification() { 83 | Updates=("$@") 84 | UpdToString=$( printf "%s\n" "${Updates[@]}" ) 85 | FromHost=$(hostname) 86 | 87 | printf "\nSending Apprise notification\n" 88 | 89 | MessageTitle="$FromHost - updates available." 90 | # Setting the MessageBody variable here. 91 | read -d '\n' MessageBody << __EOF 92 | Containers on $FromHost with updates available: 93 | 94 | $UpdToString 95 | 96 | __EOF 97 | 98 | # Modify to fit your setup: 99 | apprise -vv -t "$MessageTitle" -b "$MessageBody" \ 100 | mailto://myemail:mypass@gmail.com \ 101 | mastodons://{token}@{host} \ 102 | pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b \ 103 | tgram://{bot_token}/{chat_id}/ 104 | 105 | } 106 | ``` 107 | 108 | That's all! 109 | ___ 110 | ___ 111 | -------------------------------------------------------------------------------- /default.config: -------------------------------------------------------------------------------- 1 | ### Custom user variables 2 | ## Copy this file to "dockcheck.config" to make it active 3 | ## Can be placed in ~/.config/ or alongside dockcheck.sh 4 | ## 5 | ## Uncomment and set your preferred configuration variables here 6 | ## This will not be replaced on updates 7 | 8 | #Timeout=10 # Set a timeout (in seconds) per container for registry checkups. 9 | #MaxAsync=10 # Set max asynchronous subprocesses, 1 default, 0 to disable. 10 | #BarWidth=50 # The character width of the progress bar 11 | #AutoMode=true # Automatic updates, without interaction. 12 | #DontUpdate=true # No updates; only checking availability without interaction. 13 | #AutoPrune=true # Auto-Prune dangling images after update. 14 | #AutoSelfUpdate=true # Allow automatic self updates - caution as this will pull new code and autorun it. 15 | #Notify=true # Inform - send a preconfigured notification. 16 | #Exclude="one,two" # Exclude containers, separated by comma. 17 | #DaysOld="5" # Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower. 18 | #Stopped="-a" # Include stopped containers in the check. (Logic: docker ps -a). 19 | #OnlyLabel=true # Only update if label is set. See readme. 20 | #ForceRestartStacks=true # Force stop+start stack after update. Caution: restarts once for every updated container within stack. 21 | #DRunUp=true # Allow updating images for docker run, wont update the container. 22 | #SkipRecreate # Skip container recreation after pulling images. 23 | #MonoMode=true # Monochrome mode, no printf colour codes and hides progress bar. 24 | #PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)` 25 | #PrintMarkdownURL=true # Prints custom releasenote urls as markdown 26 | #OnlySpecific=true # Only compose up the specific container, not the whole compose. (useful for master-compose structure). 27 | #CurlRetryDelay=1 # Time between curl retries 28 | #CurlRetryCount=3 # Max number of curl retries 29 | #CurlConnectTimeout=5 # Time to wait for curl to establish a connection before failing 30 | #DisplaySourcedFiles=false # Display what files are being sourced/used 31 | #BackupForDays=7 # Enable backups of images and removes backups older than N days. 32 | 33 | ### Notify settings 34 | ## All commented values are examples only. Modify as needed. 35 | ## 36 | ## Uncomment the line below and specify the notification channels you wish to enable in a space separated string 37 | # NOTIFY_CHANNELS="apprise discord DSM file generic HA gotify matrix ntfy pushbullet pushover slack smtp telegram file" 38 | # 39 | ## Uncomment the line below and specify the number of seconds to delay notifications to enable snooze 40 | # SNOOZE_SECONDS=86400 41 | # 42 | ## Uncomment and set to true to disable notifications when dockcheck itself has updates. 43 | # DISABLE_DOCKCHECK_NOTIFICATION=false 44 | ## Uncomment and set to true to disable notifications when notify scripts themselves have updates. 45 | # DISABLE_NOTIFY_NOTIFICATION=false 46 | # 47 | ## Apprise configuration variables. Set APPRISE_PAYLOAD to make a CLI call or set APPRISE_URL to make an API request instead. 48 | # APPRISE_PAYLOAD='mailto://myemail:mypass@gmail.com 49 | # mastodons://{token}@{host} 50 | # pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b 51 | # tgram://{bot_token}/{chat_id}/' 52 | # APPRISE_URL="http://apprise.mydomain.tld:1234/notify/apprise" 53 | # 54 | # DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/" 55 | # 56 | # DSM_SENDMAILTO="me@mydomain.com" 57 | # DSM_SUBJECTTAG="Email Subject Prefix" 58 | # 59 | # GOTIFY_DOMAIN="https://gotify.domain.tld" 60 | # GOTIFY_TOKEN="token-value" 61 | # 62 | # HA_ENTITY="entity" 63 | # HA_TOKEN="token" 64 | # HA_URL="https://your.homeassistant.url" 65 | # 66 | # MATRIX_ACCESS_TOKEN="token-value" 67 | # MATRIX_ROOM_ID="myroom" 68 | # MATRIX_SERVER_URL="https://matrix.yourdomain.tld" 69 | # 70 | ## https://ntfy.sh or your custom domain with https:// and no trailing / 71 | # NTFY_DOMAIN="https://ntfy.sh" 72 | # NTFY_TOPIC_NAME="YourUniqueTopicName" 73 | # NTFY_AUTH="" # set to either format -> "user:password" OR ":tk_12345678". If using tokens, don't forget the ":" 74 | # 75 | # PUSHBULLET_URL="https://api.pushbullet.com/v2/pushes" 76 | # PUSHBULLET_TOKEN="token-value" 77 | # 78 | # PUSHOVER_URL="https://api.pushover.net/1/messages.json" 79 | # PUSHOVER_USER_KEY="userkey" 80 | # PUSHOVER_TOKEN="token-value" 81 | # 82 | # SLACK_CHANNEL_ID=mychannel 83 | # SLACK_ACCESS_TOKEN=xoxb-token-value 84 | # 85 | # SMTP_MAIL_FROM="me@mydomain.tld" 86 | # SMTP_MAIL_TO="you@yourdomain.tld" 87 | # SMTP_SUBJECT_TAG="dockcheck" 88 | # 89 | # TELEGRAM_CHAT_ID="mychatid" 90 | # TELEGRAM_TOKEN="token-value" 91 | # TELEGRAM_TOPIC_ID="0" 92 | # 93 | # FILE_PATH="${ScriptWorkDir}/updates_available.txt" 94 | -------------------------------------------------------------------------------- /notify_templates/urls.list: -------------------------------------------------------------------------------- 1 | # Additions are welcome! Append your list to the git-repo, use generic names and sensible urls. 2 | # Modify, add and (if necessary) remove to fit your needs. 3 | # This is a list of container names and releasenote urls, separated by space. 4 | 5 | actual_server https://actualbudget.org/blog 6 | apprise-api https://github.com/linuxserver/docker-apprise-api/releases 7 | audiobookshelf https://github.com/advplyr/audiobookshelf/releases 8 | bazarr https://github.com/morpheus65535/bazarr/releases 9 | bazarr-ls https://github.com/linuxserver/docker-bazarr/releases 10 | beszel https://github.com/henrygd/beszel/releases 11 | bookstack https://github.com/BookStackApp/BookStack/releases 12 | bruceforce-vaultwarden-backup https://github.com/Bruceforce/vaultwarden-backup/blob/main/CHANGELOG.md 13 | caddy https://github.com/caddyserver/caddy/releases 14 | calibre https://github.com/linuxserver/docker-calibre/releases 15 | calibre-web https://github.com/linuxserver/docker-calibre-web/releases 16 | cleanuperr https://github.com/flmorg/cleanuperr/releases 17 | cross-seed https://github.com/cross-seed/cross-seed/releases 18 | crowdsec https://github.com/crowdsecurity/crowdsec/releases 19 | cup https://github.com/sergi0g/cup/releases 20 | dockge https://github.com/louislam/dockge/releases 21 | dozzle https://github.com/amir20/dozzle/releases 22 | flatnotes https://github.com/dullage/flatnotes/releases 23 | forgejo https://codeberg.org/forgejo/forgejo/releases 24 | fressrss https://github.com/FreshRSS/FreshRSS/releases 25 | gerbil https://github.com/fosrl/gerbil/releases 26 | gluetun https://github.com/qdm12/gluetun/releases 27 | go2rtc https://github.com/AlexxIT/go2rtc/releases 28 | gotify https://github.com/gotify/server/releases 29 | hbbr https://github.com/rustdesk/rustdesk-server/releases 30 | hbbs https://github.com/rustdesk/rustdesk-server/releases 31 | homarr https://github.com/homarr-labs/homarr/releases 32 | home-assistant https://github.com/home-assistant/core/releases/ 33 | homer https://github.com/bastienwirtz/homer/releases 34 | immich_machine_learning https://github.com/immich-app/immich/releases 35 | immich_postgres https://github.com/tensorchord/VectorChord/releases 36 | immich_redis https://github.com/valkey-io/valkey/releases 37 | immich_server https://github.com/immich-app/immich/releases 38 | jellyfin https://github.com/jellyfin/jellyfin/releases 39 | jellyseerr https://github.com/Fallenbagel/jellyseerr/releases 40 | jellystat https://github.com/CyferShepard/Jellystat/releases 41 | librespeed https://github.com/librespeed/speedtest/releases 42 | lidarr https://github.com/Lidarr/Lidarr/releases/ 43 | lidarr-ls https://github.com/linuxserver/docker-lidarr/releases 44 | lubelogger https://github.com/hargata/lubelog/releases 45 | mattermost https://github.com/mattermost/mattermost/releases 46 | mealie https://github.com/mealie-recipes/mealie/releases 47 | meilisearch https://github.com/meilisearch/meilisearch/releases 48 | monica https://github.com/monicahq/monica/releases 49 | mqtt https://github.com/eclipse/mosquitto/tags 50 | newt https://github.com/fosrl/newt/releases 51 | nextcloud-aio-mastercontainer https://github.com/nextcloud/all-in-one/releases 52 | nginx https://github.com/docker-library/official-images/blob/master/library/nginx 53 | owncast https://github.com/owncast/owncast/releases 54 | pangolin https://github.com/fosrl/pangolin/releases 55 | prowlarr https://github.com/Prowlarr/Prowlarr/releases 56 | prowlarr-ls https://github.com/linuxserver/docker-prowlarr/releases 57 | qbittorrent https://www.qbittorrent.org/news 58 | qbittorrent-nox https://www.qbittorrent.org/news 59 | radarr https://github.com/Radarr/Radarr/releases/ 60 | radarr-ls https://github.com/linuxserver/docker-radarr/releases 61 | readarr https://github.com/Readarr/Readarr/releases 62 | readeck https://codeberg.org/readeck/readeck/releases 63 | recyclarr https://github.com/recyclarr/recyclarr/releases 64 | roundcubemail https://github.com/roundcube/roundcubemail/releases 65 | sabnzbd https://github.com/linuxserver/docker-sabnzbd/releases 66 | scrutiny https://github.com/AnalogJ/scrutiny/releases 67 | sftpgo https://github.com/drakkan/sftpgo/releases 68 | slskd https://github.com/slskd/slskd/releases 69 | snappymail https://github.com/the-djmaze/snappymail/releases 70 | sonarr https://github.com/Sonarr/Sonarr/releases/ 71 | sonarr-ls https://github.com/linuxserver/docker-sonarr/releases 72 | syncthing https://github.com/syncthing/syncthing/releases 73 | tailscale https://github.com/tailscale/tailscale/releases 74 | tautulli https://github.com/Tautulli/Tautulli/releases 75 | thelounge https://github.com/thelounge/thelounge/releases 76 | traefik https://github.com/traefik/traefik/releases 77 | vaultwarden-server https://github.com/dani-garcia/vaultwarden/releases 78 | watchtower https://github.com/beatkind/watchtower/releases 79 | wud https://github.com/getwud/wud/releases 80 | zigbee2mqtt https://github.com/Koenkk/zigbee2mqtt/releases 81 | -------------------------------------------------------------------------------- /addons/prometheus/grafana/grafana_dashboard.json: -------------------------------------------------------------------------------- 1 | { 2 | "__inputs": [ 3 | { 4 | "name": "DS_PROMETHEUS", 5 | "label": "prometheus", 6 | "description": "", 7 | "type": "datasource", 8 | "pluginId": "prometheus", 9 | "pluginName": "Prometheus" 10 | } 11 | ], 12 | "__elements": {}, 13 | "__requires": [ 14 | { 15 | "type": "grafana", 16 | "id": "grafana", 17 | "name": "Grafana", 18 | "version": "11.4.0" 19 | }, 20 | { 21 | "type": "datasource", 22 | "id": "prometheus", 23 | "name": "Prometheus", 24 | "version": "1.0.0" 25 | }, 26 | { 27 | "type": "panel", 28 | "id": "table", 29 | "name": "Table", 30 | "version": "" 31 | } 32 | ], 33 | "annotations": { 34 | "list": [ 35 | { 36 | "builtIn": 1, 37 | "datasource": { 38 | "type": "grafana", 39 | "uid": "-- Grafana --" 40 | }, 41 | "enable": true, 42 | "hide": true, 43 | "iconColor": "rgba(0, 211, 255, 1)", 44 | "name": "Annotations & Alerts", 45 | "type": "dashboard" 46 | } 47 | ] 48 | }, 49 | "editable": true, 50 | "fiscalYearStartMonth": 0, 51 | "graphTooltip": 0, 52 | "id": null, 53 | "links": [], 54 | "panels": [ 55 | { 56 | "datasource": { 57 | "type": "prometheus", 58 | "uid": "${DS_PROMETHEUS}" 59 | }, 60 | "fieldConfig": { 61 | "defaults": { 62 | "color": { 63 | "mode": "thresholds" 64 | }, 65 | "custom": { 66 | "align": "auto", 67 | "cellOptions": { 68 | "type": "auto" 69 | }, 70 | "inspect": false 71 | }, 72 | "mappings": [], 73 | "thresholds": { 74 | "mode": "absolute", 75 | "steps": [ 76 | { 77 | "color": "green", 78 | "value": null 79 | }, 80 | { 81 | "color": "red", 82 | "value": 80 83 | } 84 | ] 85 | } 86 | }, 87 | "overrides": [ 88 | { 89 | "matcher": { 90 | "id": "byName", 91 | "options": "last_analyze_timestamp" 92 | }, 93 | "properties": [ 94 | { 95 | "id": "unit", 96 | "value": "dateTimeAsIso" 97 | } 98 | ] 99 | }, 100 | { 101 | "matcher": { 102 | "id": "byName", 103 | "options": "last_analyze_since" 104 | }, 105 | "properties": [ 106 | { 107 | "id": "unit", 108 | "value": "s" 109 | }, 110 | { 111 | "id": "custom.cellOptions", 112 | "value": { 113 | "mode": "gradient", 114 | "type": "color-background" 115 | } 116 | }, 117 | { 118 | "id": "thresholds", 119 | "value": { 120 | "mode": "absolute", 121 | "steps": [ 122 | { 123 | "color": "green", 124 | "value": null 125 | }, 126 | { 127 | "color": "red", 128 | "value": 259200 129 | } 130 | ] 131 | } 132 | } 133 | ] 134 | }, 135 | { 136 | "matcher": { 137 | "id": "byName", 138 | "options": "images_outdated" 139 | }, 140 | "properties": [ 141 | { 142 | "id": "custom.cellOptions", 143 | "value": { 144 | "mode": "gradient", 145 | "type": "color-background" 146 | } 147 | }, 148 | { 149 | "id": "thresholds", 150 | "value": { 151 | "mode": "absolute", 152 | "steps": [ 153 | { 154 | "color": "green", 155 | "value": null 156 | }, 157 | { 158 | "color": "red", 159 | "value": 1 160 | } 161 | ] 162 | } 163 | } 164 | ] 165 | }, 166 | { 167 | "matcher": { 168 | "id": "byName", 169 | "options": "images_error" 170 | }, 171 | "properties": [ 172 | { 173 | "id": "custom.cellOptions", 174 | "value": { 175 | "mode": "gradient", 176 | "type": "color-background" 177 | } 178 | }, 179 | { 180 | "id": "thresholds", 181 | "value": { 182 | "mode": "absolute", 183 | "steps": [ 184 | { 185 | "color": "green", 186 | "value": null 187 | }, 188 | { 189 | "color": "red", 190 | "value": 1 191 | } 192 | ] 193 | } 194 | } 195 | ] 196 | } 197 | ] 198 | }, 199 | "gridPos": { 200 | "h": 14, 201 | "w": 24, 202 | "x": 0, 203 | "y": 0 204 | }, 205 | "id": 2, 206 | "options": { 207 | "cellHeight": "sm", 208 | "footer": { 209 | "countRows": false, 210 | "fields": "", 211 | "reducer": [ 212 | "sum" 213 | ], 214 | "show": false 215 | }, 216 | "frameIndex": 1, 217 | "showHeader": true, 218 | "sortBy": [] 219 | }, 220 | "pluginVersion": "11.4.0", 221 | "targets": [ 222 | { 223 | "disableTextWrap": false, 224 | "editorMode": "code", 225 | "exemplar": false, 226 | "expr": "sum by(instance) (dockcheck_images_analyzed)", 227 | "format": "table", 228 | "fullMetaSearch": false, 229 | "hide": false, 230 | "includeNullMetadata": true, 231 | "instant": true, 232 | "interval": "", 233 | "legendFormat": "{{instance}}", 234 | "range": false, 235 | "refId": "dockcheck_images_analyzed", 236 | "useBackend": false, 237 | "datasource": { 238 | "type": "prometheus", 239 | "uid": "${DS_PROMETHEUS}" 240 | } 241 | }, 242 | { 243 | "datasource": { 244 | "type": "prometheus", 245 | "uid": "${DS_PROMETHEUS}" 246 | }, 247 | "disableTextWrap": false, 248 | "editorMode": "code", 249 | "exemplar": false, 250 | "expr": "sum by(instance) (dockcheck_images_outdated)", 251 | "format": "table", 252 | "fullMetaSearch": false, 253 | "hide": false, 254 | "includeNullMetadata": true, 255 | "instant": true, 256 | "legendFormat": "{{instance}}", 257 | "range": false, 258 | "refId": "dockcheck_images_outdated", 259 | "useBackend": false 260 | }, 261 | { 262 | "datasource": { 263 | "type": "prometheus", 264 | "uid": "${DS_PROMETHEUS}" 265 | }, 266 | "disableTextWrap": false, 267 | "editorMode": "code", 268 | "exemplar": false, 269 | "expr": "sum by(instance) (dockcheck_images_latest)", 270 | "format": "table", 271 | "fullMetaSearch": false, 272 | "hide": false, 273 | "includeNullMetadata": true, 274 | "instant": true, 275 | "legendFormat": "{{instance}}", 276 | "range": false, 277 | "refId": "dockcheck_images_latest", 278 | "useBackend": false 279 | }, 280 | { 281 | "datasource": { 282 | "type": "prometheus", 283 | "uid": "${DS_PROMETHEUS}" 284 | }, 285 | "editorMode": "code", 286 | "exemplar": false, 287 | "expr": "sum by(instance) (dockcheck_images_error)", 288 | "format": "table", 289 | "hide": false, 290 | "instant": true, 291 | "legendFormat": "{{instance}}", 292 | "range": false, 293 | "refId": "dockcheck_images_error" 294 | }, 295 | { 296 | "datasource": { 297 | "type": "prometheus", 298 | "uid": "${DS_PROMETHEUS}" 299 | }, 300 | "editorMode": "code", 301 | "exemplar": false, 302 | "expr": "dockcheck_images_analyze_timestamp_seconds * 1000", 303 | "format": "table", 304 | "hide": false, 305 | "instant": true, 306 | "legendFormat": "{{instance}}", 307 | "range": false, 308 | "refId": "dockcheck_images_analyze_timestamp_seconds" 309 | }, 310 | { 311 | "datasource": { 312 | "type": "prometheus", 313 | "uid": "${DS_PROMETHEUS}" 314 | }, 315 | "editorMode": "code", 316 | "exemplar": false, 317 | "expr": "time() - dockcheck_images_analyze_timestamp_seconds", 318 | "format": "table", 319 | "hide": false, 320 | "instant": true, 321 | "legendFormat": "{{instance}}", 322 | "range": false, 323 | "refId": "dockcheck_images_last_analyze" 324 | } 325 | ], 326 | "title": "Dockcheck Status", 327 | "transformations": [ 328 | { 329 | "id": "merge", 330 | "options": {} 331 | }, 332 | { 333 | "id": "organize", 334 | "options": { 335 | "excludeByName": { 336 | "Time": true, 337 | "__name__": true, 338 | "job": true 339 | }, 340 | "includeByName": {}, 341 | "indexByName": { 342 | "Time": 0, 343 | "Value #dockcheck_images_analyze_timestamp_seconds": 2, 344 | "Value #dockcheck_images_analyzed": 4, 345 | "Value #dockcheck_images_error": 7, 346 | "Value #dockcheck_images_last_analyze": 3, 347 | "Value #dockcheck_images_latest": 5, 348 | "Value #dockcheck_images_outdated": 6, 349 | "instance": 1, 350 | "job": 8 351 | }, 352 | "renameByName": { 353 | "Value #A": "analyze_timestamp", 354 | "Value #dockcheck_images_analyze_timestamp_seconds": "last_analyze_timestamp", 355 | "Value #dockcheck_images_analyzed": "images_analyzed", 356 | "Value #dockcheck_images_error": "images_error", 357 | "Value #dockcheck_images_last_analyze": "last_analyze_since", 358 | "Value #dockcheck_images_latest": "images_latest", 359 | "Value #dockcheck_images_outdated": "images_outdated" 360 | } 361 | } 362 | } 363 | ], 364 | "type": "table" 365 | } 366 | ], 367 | "schemaVersion": 40, 368 | "tags": [], 369 | "templating": { 370 | "list": [] 371 | }, 372 | "time": { 373 | "from": "now-6h", 374 | "to": "now" 375 | }, 376 | "timepicker": {}, 377 | "timezone": "browser", 378 | "title": "Dockcheck Status", 379 | "uid": "feb4pv3kv1hxca", 380 | "version": 17, 381 | "weekStart": "" 382 | } -------------------------------------------------------------------------------- /notify_templates/notify_v2.sh: -------------------------------------------------------------------------------- 1 | NOTIFY_V2_VERSION="v0.6" 2 | # 3 | # If migrating from an older notify template, remove your existing notify.sh file. 4 | # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. 5 | # If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script and rename to notify.sh. 6 | # Enable and configure all required notification variables in your dockcheck.config file, e.g.: 7 | # NOTIFY_CHANNELS=apprise gotify slack 8 | # SLACK_TOKEN=xoxb-some-token-value 9 | # GOTIFY_TOKEN=some.token 10 | 11 | # Number of seconds to snooze identical update notifications based on local image name 12 | # or dockcheck.sh/notify.sh template file updates. 13 | # Actual snooze will be 60 seconds less to avoid the chance of missed notifications due to minor scheduling or script run time issues. 14 | snooze="${SNOOZE_SECONDS:-}" 15 | SnoozeFile="${ScriptWorkDir}/snooze.list" 16 | [[ ! -f "${SnoozeFile}" ]] && touch "${SnoozeFile}" 17 | 18 | enabled_notify_channels=( ${NOTIFY_CHANNELS:-} ) 19 | 20 | # Global output string variable for modification by functions 21 | UpdToString="" 22 | FormattedOutput="" 23 | 24 | get_channel_template() { 25 | local UpperChannel="${1^^}" 26 | local TemplateVar="${UpperChannel}_TEMPLATE" 27 | if [[ -n "${!TemplateVar:-}" ]]; then 28 | printf "${!TemplateVar}" 29 | else 30 | printf "$1" 31 | fi 32 | } 33 | 34 | declare -A unique_templates 35 | 36 | for channel in "${enabled_notify_channels[@]}"; do 37 | template=$(get_channel_template "${channel}") 38 | unique_templates["${template}"]=1 39 | done 40 | 41 | enabled_notify_templates=( "${!unique_templates[@]}" ) 42 | 43 | FromHost=$(cat /etc/hostname) 44 | 45 | CurrentEpochTime=$(date +"%Y-%m-%dT%H:%M:%S") 46 | CurrentEpochSeconds=$(date +%s) 47 | 48 | NotifyError=false 49 | 50 | for template in "${enabled_notify_templates[@]}"; do 51 | source_if_exists_or_fail "${ScriptWorkDir}/notify_${template}.sh" || \ 52 | source_if_exists_or_fail "${ScriptWorkDir}/notify_templates/notify_${template}.sh" || \ 53 | printf "The notification channel template ${template} is enabled, but notify_${template}.sh was not found. Check the ${ScriptWorkDir} directory or the notify_templates subdirectory.\n" 54 | done 55 | 56 | skip_snooze() { 57 | local UpperChannel="${1^^}" 58 | local SkipSnoozeVar="${UpperChannel}_SKIPSNOOZE" 59 | if [[ "${!SkipSnoozeVar:-}" == "true" ]]; then 60 | printf "true" 61 | else 62 | printf "false" 63 | fi 64 | } 65 | 66 | allow_empty() { 67 | local UpperChannel="${1^^}" 68 | local AllowEmptyVar="${UpperChannel}_ALLOWEMPTY" 69 | if [[ "${!AllowEmptyVar:-}" == "true" ]]; then 70 | printf "true" 71 | else 72 | printf "false" 73 | fi 74 | } 75 | 76 | containers_only() { 77 | local UpperChannel="${1^^}" 78 | local ContainersOnlyVar="${UpperChannel}_CONTAINERSONLY" 79 | if [[ "${!ContainersOnlyVar:-}" == "true" ]]; then 80 | printf "true" 81 | else 82 | printf "false" 83 | fi 84 | } 85 | 86 | output_format() { 87 | local UpperChannel="${1^^}" 88 | local OutputFormatVar="${UpperChannel}_OUTPUT" 89 | if [[ -z "${!OutputFormatVar:-}" ]]; then 90 | printf "text" 91 | else 92 | printf "${!OutputFormatVar:-}" 93 | fi 94 | } 95 | 96 | remove_channel() { 97 | local temp_array=() 98 | for channel in "${enabled_notify_channels[@]}"; do 99 | local channel_template=$(get_channel_template "${channel}") 100 | [[ "${channel_template}" != "$1" ]] && temp_array+=("${channel}") 101 | done 102 | enabled_notify_channels=( "${temp_array[@]}" ) 103 | } 104 | 105 | is_snoozed() { 106 | if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then 107 | local found=$(grep -w "$1" "${SnoozeFile}" || printf "") 108 | if [[ -n "${found}" ]]; then 109 | read -a arr <<< "${found}" 110 | CheckEpochSeconds=$(( $(date -d "${arr[1]}" +%s 2>/dev/null) + ${snooze} - 60 )) || CheckEpochSeconds=$(( $(date -f "%Y-%m-%d" -j "${arr[1]}" +%s) + ${snooze} - 60 )) 111 | if [[ "${CurrentEpochSeconds}" -le "${CheckEpochSeconds}" ]]; then 112 | printf "true" 113 | else 114 | printf "false" 115 | fi 116 | else 117 | printf "false" 118 | fi 119 | else 120 | printf "false" 121 | fi 122 | } 123 | 124 | unsnoozed_count() { 125 | unset Unsnoozed 126 | Unsnoozed=() 127 | 128 | for element in "$@" 129 | do 130 | read -a item <<< "${element}" 131 | if [[ $(is_snoozed "${item[0]}") == "false" ]]; then 132 | Unsnoozed+=("${element}") 133 | fi 134 | done 135 | 136 | printf "${#Unsnoozed[@]}" 137 | } 138 | 139 | update_snooze() { 140 | for arg in "$@" 141 | do 142 | read -a entry <<< "${arg}" 143 | found=$(grep -w "${entry[0]}" "${SnoozeFile}" || printf "") 144 | 145 | if [[ -n "${found}" ]]; then 146 | sed -e "s/${entry[0]}.*/${entry[0]} ${CurrentEpochTime}/" "${SnoozeFile}" > "${SnoozeFile}.new" 147 | mv "${SnoozeFile}.new" "${SnoozeFile}" 148 | else 149 | printf "${entry[0]} ${CurrentEpochTime}\n" >> "${SnoozeFile}" 150 | fi 151 | done 152 | } 153 | 154 | cleanup_snooze() { 155 | unset NotifyEntries 156 | NotifyEntries=() 157 | switch="" 158 | 159 | for arg in "$@" 160 | do 161 | read -a entry <<< "${arg}" 162 | NotifyEntries+=("${entry[0]}") 163 | done 164 | 165 | if [[ ! "${NotifyEntries[@]}" == *".sh"* ]]; then 166 | switch="-v" 167 | fi 168 | 169 | while read -r entry datestamp; do 170 | if [[ ! "${NotifyEntries[@]}" == *"$entry"* ]]; then 171 | sed -e "/${entry}/d" "${SnoozeFile}" > "${SnoozeFile}.new" 172 | mv "${SnoozeFile}.new" "${SnoozeFile}" 173 | fi 174 | done <<< "$(grep ${switch} '\.sh ' ${SnoozeFile})" 175 | } 176 | 177 | format_output() { 178 | local UpdateType="$1" 179 | local OutputFormat="$2" 180 | local FormattedTextTemplate="$3" 181 | local tempcsv="" 182 | 183 | if [[ ! "${UpdateType}" == "dockcheck_update" ]]; then 184 | tempcsv="${UpdToString// -> /,}" 185 | tempcsv="${tempcsv//.sh /.sh,}" 186 | else 187 | tempcsv="${UpdToString}" 188 | fi 189 | 190 | if [[ "${OutputFormat}" == "csv" ]]; then 191 | if [[ -z "${UpdToString}" ]]; then 192 | FormattedOutput="None" 193 | else 194 | FormattedOutput="${tempcsv}" 195 | fi 196 | elif [[ "${OutputFormat}" == "json" ]]; then 197 | if [[ -z "${UpdToString}" ]]; then 198 | FormattedOutput='{"updates": []}' 199 | else 200 | if [[ "${UpdateType}" == "container_update" ]]; then 201 | # container updates case 202 | FormattedOutput=$(jq --compact-output --null-input --arg updates "${tempcsv}" '($updates | split("\\n")) | map(split(",")) | {"updates": map({"container_name": .[0], "release_notes": .[1]})} | del(..|nulls)') 203 | elif [[ "${UpdateType}" == "notify_update" ]]; then 204 | # script updates case 205 | FormattedOutput=$(jq --compact-output --null-input --arg updates "${tempcsv}" '($updates | split("\\n")) | map(split(",")) | {"updates": map({"script_name": .[0], "installed_version": .[1], "latest_version": .[2]})}') 206 | elif [[ "${UpdateType}" == "dockcheck_update" ]]; then 207 | # dockcheck update case 208 | FormattedOutput=$(jq --compact-output --null-input --arg updates "${tempcsv}" '($updates | split("\\n")) | map(split(",")) | {"updates": map({"script_name": .[0], "installed_version": .[1], "latest_version": .[2], "release_notes": (.[3:] | join(","))})}') 209 | else 210 | FormattedOutput="Invalid input" 211 | fi 212 | fi 213 | else 214 | if [[ -z "${UpdToString}" ]]; then 215 | FormattedOutput="None" 216 | else 217 | if [[ "${UpdateType}" == "container_update" ]]; then 218 | FormattedOutput="${FormattedTextTemplate//${UpdToString}}" 219 | elif [[ "${UpdateType}" == "notify_update" ]]; then 220 | FormattedOutput="${FormattedTextTemplate//${UpdToString}}" 221 | elif [[ "${UpdateType}" == "dockcheck_update" ]]; then 222 | FormattedOutput="${FormattedTextTemplate//$4}" 223 | FormattedOutput="${FormattedOutput//$5}" 224 | FormattedOutput="${FormattedOutput//$6}" 225 | else 226 | FormattedOutput="Invalid input" 227 | fi 228 | fi 229 | fi 230 | } 231 | 232 | skip_notification() { 233 | # Skip notification logic. Default to false. Handle all cases, and only those cases, where notifications should be skipped. 234 | local SkipNotification="false" 235 | local Channel="$1" 236 | local UnsnoozedCount="$2" 237 | local NotificationType="$3" 238 | 239 | if [[ $(containers_only "${Channel}") == "true" ]] && [[ "${NotificationType}" != "container" ]]; then 240 | # Do not send notifications through channels only configured for container update notifications 241 | SkipNotification="true" 242 | else 243 | # Handle empty update cases separately 244 | if [[ -z "${UpdToString}" ]]; then 245 | if [[ $(allow_empty "${Channel}") == "false" ]]; then 246 | # Do not send notifications if there are none and allow_empty is false 247 | SkipNotification="true" 248 | fi 249 | else 250 | if [[ $(skip_snooze "${Channel}") == "false" ]] && [[ ${UnsnoozedCount} -eq 0 ]]; then 251 | # Do not send notifications if there are any, they are all snoozed, and skip_snooze is false 252 | SkipNotification="true" 253 | fi 254 | fi 255 | fi 256 | 257 | printf "${SkipNotification}" 258 | } 259 | 260 | send_notification() { 261 | [[ -s "$ScriptWorkDir"/urls.list ]] && releasenotes || Updates=("$@") 262 | 263 | [[ -n "${snooze}" ]] && cleanup_snooze "${Updates[@]}" 264 | 265 | UnsnoozedContainers=$(unsnoozed_count "${Updates[@]}") 266 | NotifyError=false 267 | Notified="false" 268 | 269 | # To be added in the MessageBody if "-d X" was used 270 | # Trailing space is left intentionally for clean output 271 | [[ -n "$DaysOld" ]] && msgdaysold="with images ${DaysOld}+ days old " || msgdaysold="" 272 | MessageTitle="$FromHost - updates ${msgdaysold}available." 273 | 274 | UpdToString=$( printf '%s\\n' "${Updates[@]}" ) 275 | UpdToString="${UpdToString%, }" 276 | UpdToString=${UpdToString%\\n} 277 | 278 | for channel in "${enabled_notify_channels[@]}"; do 279 | local SkipNotification=$(skip_notification "${channel}" "${UnsnoozedContainers}" "container") 280 | if [[ "${SkipNotification}" == "false" ]]; then 281 | local template=$(get_channel_template "${channel}") 282 | 283 | # Formats UpdToString variable per channel settings 284 | format_output "container_update" "$(output_format "${channel}")" "🐋 Containers on $FromHost with updates available:\n\n" 285 | 286 | # Setting the MessageBody variable here. 287 | printf -v MessageBody "${FormattedOutput}" 288 | 289 | printf "\nSending ${channel} notification" 290 | exec_if_exists_or_fail trigger_${template}_notification "${channel}" || \ 291 | printf "\nAttempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${template}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory." 292 | Notified="true" 293 | fi 294 | done 295 | 296 | if [[ "${Notified}" == "true" ]]; then 297 | [[ -n "${snooze}" ]] && [[ -n "${UpdToString}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${Updates[@]}" 298 | printf "\n" 299 | fi 300 | 301 | return 0 302 | } 303 | 304 | ### Set DISABLE_DOCKCHECK_NOTIFICATION=false in dockcheck.config 305 | ### to not send notifications when dockcheck itself has updates. 306 | dockcheck_notification() { 307 | if [[ ! "${DISABLE_DOCKCHECK_NOTIFICATION:-}" == "true" ]]; then 308 | UnsnoozedDockcheck=$(unsnoozed_count "dockcheck\.sh") 309 | NotifyError=false 310 | Notified=false 311 | 312 | MessageTitle="$FromHost - New version of dockcheck available." 313 | UpdToString="dockcheck.sh,$1,$2,\"$3\"" 314 | 315 | for channel in "${enabled_notify_channels[@]}"; do 316 | local SkipNotification=$(skip_notification "${channel}" "${UnsnoozedDockcheck}" "dockcheck") 317 | if [[ "${SkipNotification}" == "false" ]]; then 318 | local template=$(get_channel_template "${channel}") 319 | 320 | # Formats UpdToString variable per channel settings 321 | format_output "dockcheck_update" "$(output_format "${channel}")" "Installed version: \nLatest version: \n\nChangenotes: \n" "$1" "$2" "$3" 322 | 323 | # Setting the MessageBody variable here. 324 | printf -v MessageBody "${FormattedOutput}" 325 | 326 | printf "\nSending dockcheck update notification - ${channel}" 327 | exec_if_exists_or_fail trigger_${template}_notification "${channel}" || \ 328 | printf "\nAttempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${template}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory." 329 | Notified="true" 330 | fi 331 | done 332 | 333 | if [[ "${Notified}" == "true" ]]; then 334 | [[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "dockcheck.sh" 335 | printf "\n" 336 | fi 337 | fi 338 | 339 | return 0 340 | } 341 | 342 | ### Set DISABLE_NOTIFY_NOTIFICATION=false in dockcheck.config 343 | ### to not send notifications when notify scripts themselves have updates. 344 | notify_update_notification() { 345 | if [[ ! "${DISABLE_NOTIFY_NOTIFICATION:-}" == "true" ]]; then 346 | NotifyError=false 347 | NotifyUpdates=() 348 | Notified=false 349 | 350 | UpdateChannels=( "${enabled_notify_templates[@]}" "v2" ) 351 | 352 | for NotifyScript in "${UpdateChannels[@]}"; do 353 | UpperChannel="${NotifyScript^^}" 354 | VersionVar="NOTIFY_${UpperChannel}_VERSION" 355 | if [[ -n "${!VersionVar:-}" ]]; then 356 | RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_${NotifyScript}.sh" 357 | LatestNotifySnippet="$(curl ${CurlArgs} -r 0-150 "$RawNotifyUrl" || printf "undefined")" 358 | if [[ ! "${LatestNotifySnippet}" == "undefined" ]]; then 359 | LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')" 360 | 361 | if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then 362 | NotifyUpdates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}") 363 | fi 364 | fi 365 | fi 366 | done 367 | 368 | UpdatesPlusDockcheck=("${NotifyUpdates[@]}") 369 | UpdatesPlusDockcheck+=("dockcheck.sh") 370 | [[ -n "${snooze}" ]] && cleanup_snooze "${UpdatesPlusDockcheck[@]}" 371 | 372 | UnsnoozedTemplates=$(unsnoozed_count "${NotifyUpdates[@]}") 373 | 374 | MessageTitle="$FromHost - New version of notify templates available." 375 | 376 | UpdToString=$( printf '%s\\n' "${NotifyUpdates[@]}" ) 377 | UpdToString="${UpdToString%, }" 378 | UpdToString=${UpdToString%\\n} 379 | 380 | for channel in "${enabled_notify_channels[@]}"; do 381 | local SkipNotification=$(skip_notification "${channel}" "${UnsnoozedTemplates}" "notify") 382 | 383 | if [[ "${SkipNotification}" == "false" ]]; then 384 | local template=$(get_channel_template "${channel}") 385 | 386 | # Formats UpdToString variable per channel settings 387 | format_output "notify_update" "$(output_format "${channel}")" "Notify templates on $FromHost with updates available:\n\n" 388 | 389 | # Setting the MessageBody variable here. 390 | printf -v MessageBody "${FormattedOutput}" 391 | 392 | printf "\nSending notify template update notification - ${channel}" 393 | exec_if_exists_or_fail trigger_${template}_notification "${channel}" || \ 394 | printf "\nAttempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${template}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory." 395 | Notified="true" 396 | fi 397 | done 398 | 399 | if [[ "${Notified}" == "true" ]]; then 400 | [[ -n "${snooze}" ]] && [[ -n "${UpdToString}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${NotifyUpdates[@]}" 401 | printf "\n" 402 | fi 403 | fi 404 | 405 | return 0 406 | } 407 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 |

5 | bash 6 | GPLv3 7 | release 8 |
9 | Buy me a Coffee 10 | LiberaPay 11 | Github Sponsor 12 | PayPal donation 13 |

14 | 15 |

CLI tool to automate docker image updates or notifying when updates are available.

16 |

selective updates, include/exclude containers, image backups, custom labels, notification plugins, prune when done etc.

17 | 18 |

:whale: Docker Hub pull limit :chart_with_downwards_trend: not an issue for checks only for actual pulls - read more

19 | 20 |
For Podman - see the fork sudo-kraken/podcheck!
21 | 22 | ___ 23 | ## Changelog 24 | 25 | - **v0.7.5**: 26 | - Added new option **BackupForDays**; `-b N` and `-B`: 27 | - Backup an image before pulling a new version for easy rollback in case of breakage. 28 | - Removes backed up images older than *N* days. 29 | - List currently backed up images with `-B`. 30 | - Fixes: 31 | - Bugfix for `-s` *Stopped* to not recreate stopped containers after update. 32 | - **v0.7.4**: 33 | - Added new option `-R`: 34 | - Will skip container recreation after pulling images. 35 | - Allows for more control and possible pipeline integration. 36 | - Fixes: 37 | - Bugfix for *value too great* error due to leading zeroes - solved with base10 conversion. 38 | - Clean up of some legacy readme sections. 39 | - **v0.7.3**: Bugfix - unquoted variable in printf list caused occasional issues. 40 | - **v0.7.2**: 41 | - Label rework: 42 | - Moved up label logic to work globally on the current run. 43 | - Only iterating on labeled containers when used with `-l` option, not listing others. 44 | - Clarified messaging and readme/help texts. 45 | - List reformatting for "available updates" numbering to easier highlight and copy: 46 | - Padded with zero, changed `)` to `-`, example: `02 - homer` 47 | - Can be selected by writing `2,3,4` or `02,03,04`. 48 | ___ 49 | 50 | 51 | ![](extras/example.gif) 52 | 53 | ## `dockcheck.sh` 54 | ``` 55 | $ ./dockcheck.sh -h 56 | Syntax: dockcheck.sh [OPTION] [comma separated names to include] 57 | Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall 58 | 59 | Options: 60 | -a|y Automatic updates, without interaction. 61 | -b N Enable image backups and sets number of days to keep from pruning. 62 | -B List currently backed up images, then exit. 63 | -c D Exports metrics as prom file for the prometheus node_exporter. Provide the collector textfile directory. 64 | -d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower. 65 | -e X Exclude containers, separated by comma. 66 | -f Force stop+start stack after update. Caution: restarts once for every updated container within stack. 67 | -F Only compose up the specific container, not the whole compose stack (useful for master-compose structure). 68 | -h Print this Help. 69 | -i Inform - send a preconfigured notification. 70 | -I Prints custom releasenote urls alongside each container with updates in CLI output (requires urls.list). 71 | -l Only include containers with label set. See readme. 72 | -m Monochrome mode, no printf colour codes and hides progress bar. 73 | -M Prints custom releasenote urls as markdown (requires template support). 74 | -n No updates, only checking availability. 75 | -p Auto-Prune dangling images after update. 76 | -r Allow checking for updates/updating images for docker run containers. Won't update the container. 77 | -R Skip container recreation after pulling images. 78 | -s Include stopped containers in the check. (Logic: docker ps -a). 79 | -t N Set a timeout (in seconds) per container for registry checkups, 10 is default. 80 | -u Allow automatic self updates - caution as this will pull new code and autorun it. 81 | -v Prints current version. 82 | -x N Set max asynchronous subprocesses, 1 default, 0 to disable, 32+ tested. 83 | ``` 84 | 85 | ### Basic example: 86 | ``` 87 | $ ./dockcheck.sh 88 | [##################################################] 5/5 89 | 90 | Containers on latest version: 91 | glances 92 | homer 93 | 94 | Containers with updates available: 95 | 01) adguardhome 96 | 02) syncthing 97 | 03) whoogle-search 98 | 99 | Choose what containers to update: 100 | Enter number(s) separated by comma, [a] for all - [q] to quit: 1,2 101 | ``` 102 | Then it proceeds to run `pull` and `up -d` on every container with updates. 103 | After the updates are complete, you'll get prompted if you'd like to prune dangling images. 104 | 105 | ___ 106 | 107 | ## Dependencies 108 | - Running docker (duh) and compose, either standalone or plugin. (see [Podman fork](https://github.com/sudo-kraken/podcheck)) 109 | - Bash shell or compatible shell of at least v4.3 110 | - POSIX `xargs`, usually default but can be installed with the `findutils` package - to enable async. 111 | - [jq](https://github.com/jqlang/jq) 112 | - User will be prompted to install with package manager or download static binary. 113 | - [regclient/regctl](https://github.com/regclient/regclient) (Licensed under [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0)) 114 | - User will be prompted to download `regctl` if not in `PATH` or `PWD`. 115 | - regctl requires `amd64/arm64` - see [workaround](#roller_coaster-workaround-for-non-amd64--arm64) if other architecture is used. 116 | 117 | ## Install Instructions 118 | Download the script to a directory in **PATH**, I'd suggest using `~/.local/bin` as that's usually in **PATH**. 119 | For OSX/macOS preferably use `/usr/local/bin`. 120 | ```sh 121 | # basic example with curl: 122 | curl -L https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh -o ~/.local/bin/dockcheck.sh 123 | chmod +x ~/.local/bin/dockcheck.sh 124 | 125 | # or oneliner with wget: 126 | wget -O ~/.local/bin/dockcheck.sh "https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" && chmod +x ~/.local/bin/dockcheck.sh 127 | 128 | # OSX or macOS version with curl: 129 | curl -L https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh -o /usr/local/bin/dockcheck.sh && chmod +x /usr/local/bin/dockcheck.sh 130 | ``` 131 | Then call the script anywhere with just `dockcheck.sh`. 132 | Add preferred `notify.sh`-template to the same directory - this will not be touched by the scripts self-update function. 133 | 134 | ## Configuration 135 | To modify settings and have them persist through updates - copy the `default.config` to `dockcheck.config` alongside the script or in `~/.config/`. 136 | Alternatively create an alias where specific flags and values are set. 137 | Example `alias dc=dockcheck.sh -p -x 10 -t 3`. 138 | 139 | ## Notifications 140 | Triggered with the `-i` flag. Will send a list of containers with updates available and a notification when `dockcheck.sh` itself has an update. 141 | `notify_templates/notify_v2.sh` is the default notification wrapper, if `notify.sh` is present and configured, it will override. 142 | 143 | Example of a cron scheduled job running non-interactive at 10'oclock excluding 1 container and sending notifications: 144 | `0 10 * * * /home/user123/.local/bin/dockcheck.sh -nix 10 -e excluded_container1` 145 | 146 | #### Installation and configuration: 147 | Set up a directory structure as below. 148 | You only need the `notify_templates/notify_v2.sh` file and any notification templates you wish to enable, but there is no harm in having all of them present. 149 | ``` 150 | . 151 | ├── notify_templates/ 152 | │ ├── notify_DSM.sh 153 | │ ├── notify_apprise.sh 154 | │ ├── notify_discord.sh 155 | │ ├── notify_generic.sh 156 | │ ├── notify_gotify.sh 157 | │ ├── notify_HA.sh 158 | │ ├── notify_matrix.sh 159 | │ ├── notify_ntfy.sh 160 | │ ├── notify_pushbullet.sh 161 | │ ├── notify_pushover.sh 162 | │ ├── notify_slack.sh 163 | │ ├── notify_smtp.sh 164 | │ ├── notify_telegram.sh 165 | │ └── notify_v2.sh 166 | ├── dockcheck.config 167 | ├── dockcheck.sh 168 | └── urls.list # optional 169 | ``` 170 | - Uncomment and set the `NOTIFY_CHANNELS=""` environment variable in `dockcheck.config` to a space separated string of your desired notification channels to enable. 171 | - Uncomment and set the environment variables related to the enabled notification channels. Eg. `GOTIFY_DOMAIN=""` + `GOTIFY_TOKEN=""`. 172 | 173 | It's recommended to only do configuration with variables within `dockcheck.config` and not modify `notify_templates/notify_X.sh` directly. If you wish to customize the notify templates yourself, you may copy them to your project root directory alongside the main `dockcheck.sh` (where they're also ignored by git). 174 | Customizing `notify_v2.sh` is handled the same as customizing the templates, but it must be renamed to `notify.sh` within the `dockcheck.sh` root directory. 175 | 176 | 177 | #### Snooze feature: 178 | Configure to receive scheduled notifications only if they're new since the last notification - within a set time frame. 179 | 180 | **Example:** *Dockcheck is scheduled to run every hour. You will receive an update notification within an hour of availability.* 181 | **Snooze enabled:** You will not receive a repeated notification about an already notified update within the snooze duration. 182 | **Snooze disabled:** You will receive additional (possibly repeated) notifications every hour. 183 | 184 | To enable snooze uncomment the `SNOOZE_SECONDS` variable in your `dockcheck.config` and set it to the number of seconds you wish to prevent duplicate alerts. 185 | Snooze is split into three categories; container updates, `dockcheck.sh` self updates and notification template updates. 186 | 187 | If an update becomes available for an item that is not snoozed, notifications will be sent and include all available updates for that item's category, even snoozed items. 188 | 189 | The actual snooze duration will be 60 seconds less than `SNOOZE_SECONDS` to account for minor scheduling or run time issues. 190 | 191 | 192 | #### Current notify templates: 193 | - Synology [DSM](https://www.synology.com/en-global/dsm) 194 | - Email with [mSMTP](https://wiki.debian.org/msmtp) (or deprecated alternative [sSMTP](https://wiki.debian.org/sSMTP)) 195 | - Apprise (with it's [multitude](https://github.com/caronc/apprise#supported-notifications) of notifications) 196 | - both native [caronc/apprise](https://github.com/caronc/apprise) and the standalone [linuxserver/docker-apprise-api](https://github.com/linuxserver/docker-apprise-api) 197 | - Read the [QuickStart](extras/apprise_quickstart.md) 198 | - [ntfy](https://ntfy.sh/) - HTTP-based pub-sub notifications. 199 | - [Gotify](https://gotify.net/) - a simple server for sending and receiving messages. 200 | - [Home Assistant](https://www.home-assistant.io/integrations/notify/) - Connection to the notify [integrations](https://www.home-assistant.io/integrations/#notifications). 201 | - [Pushbullet](https://www.pushbullet.com/) - connecting different devices with cross-platform features. 202 | - [Telegram](https://telegram.org/) - Telegram chat API. 203 | - [Matrix-Synapse](https://github.com/element-hq/synapse) - [Matrix](https://matrix.org/), open, secure, decentralised communication. 204 | - [Pushover](https://pushover.net/) - Simple Notifications (to your phone, wearables, desktops) 205 | - [Discord](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) - Discord webhooks. 206 | - [Slack](https://api.slack.com/tutorials/tracks/posting-messages-with-curl) - Slack curl api 207 | 208 | Further additions are welcome - suggestions or PRs! 209 | Initiated and first contributed by [yoyoma2](https://github.com/yoyoma2). 210 | 211 | #### Notification channel configuration: 212 | All required environment variables for each notification channel are provided in the default.config file as comments and must be uncommented and modified for your requirements. 213 | For advanced users, additional functionality is available via custom configurations and environment variables. 214 | Use cases - all configured in `dockcheck.config`: 215 | (replace `` with the upper case name of the of the channel as listed in `NOTIFY_CHANNELS` variable, eg `TELEGRAM_SKIPSNOOZE`) 216 | - To bypass the snooze feature, even when enabled, add the variable `_SKIPSNOOZE` and set it to `true`. 217 | - To configure the channel to only send container update notifications, add the variable `_CONTAINERSONLY` and set it to `true`. 218 | - To send notifications even when there are no updates available, add the variable `_ALLOWEMPTY` and set it to `true`. 219 | - To use another notification output format, add the variable `_OUTPUT` and set it to `csv`, `json`, or `text`. If unset or set to an invalid value, defaults to `text`. 220 | - To send multiple notifications using the same notification template: 221 | - Strings in the `NOTIFY_CHANNELS` list are now treated as unique names and do not necessarily refer to the notification template that will be called, though they do by default. 222 | - Add another notification channel to `NOTIFY_CHANNELS` in `dockcheck.config`. The name can contain upper and lower case letters, numbers and underscores, but can't start with a number. 223 | - Add the variable `_TEMPLATE` to `dockcheck.config` where `` is the name of the channel added above and set the value to an available notification template script (`slack`, `apprise`, `gotify`, etc.) 224 | - Add all other environment variables required for the chosen template to function with `` in upper case as the prefix rather than the template name. 225 | - For example, if `` is `mynotification` and the template configured is `slack`, you would need to set `MYNOTIFICATION_CHANNEL_ID` and `MYNOTIFICATION_ACCESS_TOKEN`. 226 | 227 | ### Release notes addon 228 | There's a function to use a lookup-file to add release note URL's to the notification message. 229 | Copy the notify_templates/`urls.list` file to the script directory, it will be used automatically if it's there. 230 | Modify it as necessary, the names of interest in the left column needs to match your container names. 231 | To also list the URL's in the CLI output (choose containers list) use the `-I` option or variable config. 232 | For Markdown formatting also add the `-M` option. (**this requires the template to be compatible - see gotify for example**) 233 | 234 | The output of the notification will look something like this: 235 | ``` 236 | Containers on hostname with updates available: 237 | apprise-api -> https://github.com/linuxserver/docker-apprise-api/releases 238 | homer -> https://github.com/bastienwirtz/homer/releases 239 | nginx -> https://github.com/docker-library/official-images/blob/master/library/nginx 240 | ... 241 | ``` 242 | 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. 243 | 244 | ## Asyncronous update checks with **xargs**; `-x N` option. (default=1) 245 | Pass `-x N` where N is number of subprocesses allowed, experiment in your environment to find a suitable max! 246 | Change the default value by editing the `MaxAsync=N` variable in `dockcheck.sh`. To disable the subprocess function set `MaxAsync=0`. 247 | 248 | ## Image Backups; `-b N` to backup previous images as custom (retagged) images for easy rollback 249 | When the option `BackupForDays` is set **dockcheck** will store the image being updated as a backup, retagged with a different name and removed due to age configured (*BackupForDays*) in a future run. 250 | Let's say we're updating `b4bz/homer:latest` - then before replacing the current image it will be retagged with the name `dockcheck/homer:2025-10-26_1132_latest` 251 | - `dockcheck` as repo name to not interfere with others. 252 | - `homer` is the image. 253 | - `2025-10-26_1132` is the time when running the script. 254 | - `latest` is the tag of the image. 255 | 256 | Then if an update breaks, you could restore the image by stopping the container, delete the new image, eg. `docker rmi b4bz/homer:latest`, then retag the backup as latest `docker tag dockcheck/homer:_latest b4bz/homer:latest`. 257 | After that, start the container again (now with the backup image active) and it will be updated as usual next time you run dockcheck or other updates. 258 | 259 | The backed up images will be removed if they're older than *BackupForDays* value (passed as `-b N` or set in the `dockcheck.config` with `BackupForDays=N`) and then pruned. 260 | If configured for eg. 7 days, force earlier cleaning by just passing a lower number of days, eg. `-b 2` to clean everything older than 2 days. 261 | Backed up images will not be removed if neither `-b` flag nor `BackupForDays` config variable is set. 262 | 263 | Use the capital option `-B` to list currently backed up images. Or list all images with `docker images`. 264 | To manually remove any backed up images, do `docker rmi dockcheck/homer:2025-10-26_1132_latest`. 265 | 266 | ## Extra plugins and tools: 267 | 268 | ### Using dockcheck.sh with the Synology DSM 269 | If you run your container through the *Container Manager GUI* - only notifications are supported. 270 | While if running manual (vanilla docker compose CLI) will allow you to use the update function too. 271 | Some extra setup to tie together with Synology DSM - check out the [addons/DSM/README.md](./addons/DSM/README.md). 272 | 273 | ### Prometheus and node_exporter 274 | 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. 275 | This is done with the `-c` option, like this: 276 | ``` 277 | dockcheck.sh -c /path/to/exporter/directory 278 | ``` 279 | 280 | See the [README.md](./addons/prometheus/README.md) for more detailed information on how to set it up! 281 | Contributed by [tdralle](https://github.com/tdralle). 282 | 283 | ### Zabbix config to monitor docker image updates 284 | If you already use Zabbix - this config will show numbers of available docker image updates on host. 285 | Example: *2 Docker Image updates on host-xyz* 286 | See project: [thetorminal/zabbix-docker-image-updates](https://github.com/thetorminal/zabbix-docker-image-updates) 287 | 288 | ### Serve REST API to list all available updates 289 | A custom python script to serve a REST API to get pulled into other monitoring tools like [homepage](https://github.com/gethomepage/homepage). 290 | See [discussion here](https://github.com/mag37/dockcheck/discussions/146). 291 | 292 | ### Wrapper Script for Unraid's User Scripts 293 | A custom bash wrapper script to allow the usage of dockcheck as a Unraid User Script plugin. 294 | See [discussion here](https://github.com/mag37/dockcheck/discussions/145). 295 | 296 | ## Labels 297 | Optionally add labels to compose-files. Currently these are the usable labels: 298 | ``` 299 | labels: 300 | mag37.dockcheck.update: true 301 | mag37.dockcheck.only-specific-container: true 302 | mag37.dockcheck.restart-stack: true 303 | ``` 304 | - `mag37.dockcheck.update: true` will when used with the `-l` option only check and update containers with this label set and skip the rest. 305 | - `mag37.dockcheck.only-specific-container: true` works instead of the `-F` option, specifying the updated container when doing compose up, like `docker compose up -d homer`. 306 | - `mag37.dockcheck.restart-stack: true` works instead of the `-f` option, forcing stop+restart on the whole compose-stack (Caution: Will restart on every updated container within stack). 307 | 308 | Adding or modifying labels in compose-files requires a restart of the container to take effect. 309 | 310 | ## Workaround for non **amd64** / **arm64** 311 | `regctl` provides binaries for amd64/arm64, to use on other architecture you could try this workaround. 312 | Run regctl in a container wrapped in a shell script. Copied from [regclient/docs/install.md](https://github.com/regclient/regclient/blob/main/docs/install.md): 313 | 314 | ```sh 315 | cat >regctl <Unauthenticated users: 10 pulls/hour 333 | >Authenticated users with a free account: 100 pulls/hour 334 | 335 | This is not an issue for registry checks. But if you have a large stack and pull more than 10 updates at once consider updating more often or to create a free account. 336 | You could use/modify the login-wrapper function in the example below to automate the login prior to running `dockcheck.sh`. 337 | 338 | ### Function to auth with docker hub before running 339 | **Example** - Change names, paths, and remove cat+password flag if you rather get prompted: 340 | ```sh 341 | function dchk { 342 | cat ~/pwd.txt | docker login --username YourUser --password-stdin 343 | ~/dockcheck.sh "$@" 344 | } 345 | ``` 346 | 347 | ## `-r flag` disclaimer and warning 348 | **Wont auto-update the containers, only their images. (compose is recommended)** 349 | `docker run` dont support using new images just by restarting a container. 350 | Containers need to be manually stopped, removed and created again to run on the new image. 351 | Using the `-r` option together with eg. `-i` and `-n` to just check for updates and send notifications and not update is safe though! 352 | 353 | ## Known issues 354 | - No detailed error feedback (just skip + list what's skipped). 355 | - Not respecting `--profile` options when re-creating the container. 356 | - Not working well with containers created by **Portainer**. 357 | - **Watchtower** might cause issues due to retagging images when checking for updates (and thereby pulling new images). 358 | 359 | ## Debugging 360 | If you hit issues, you could check the output of the `extras/errorCheck.sh` script for clues. 361 | Another option is to run the main script with debugging in a subshell `bash -x dockcheck.sh` - if there's a particular container/image that's causing issues you can filter for just that through `bash -x dockcheck.sh nginx`. 362 | 363 | ## License 364 | dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) license. 365 | 366 | ## Sponsorlist 367 | 368 | :small_orange_diamond: [avegy](https://github.com/avegy) 369 | :small_orange_diamond: [eichhorn](https://github.com/eichhorn) 370 | :small_orange_diamond: [stepdg](https://github.com/stepdg) 371 | :small_orange_diamond: [acer2220](https://github.com/acer2220) 372 | :small_orange_diamond: [shgew](https://github.com/shgew) 373 | :small_orange_diamond: [jonas3456](https://github.com/jonas3456) 374 | :small_orange_diamond: [4ndreasH](https://github.com/4ndreasH) 375 | :small_orange_diamond: [markoe01](https://github.com/markoe01) 376 | :small_orange_diamond: [mushrowan](https://github.com/mushrowan) 377 | :small_orange_diamond: 378 | 379 | ___ 380 | 381 | ### The [story](https://mag37.org/posts/project_dockcheck/) behind it. 1 year in retrospect. 382 | -------------------------------------------------------------------------------- /dockcheck.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | VERSION="v0.7.5" 3 | # ChangeNotes: New option -b N to backup image before pulling for easy rollback. 4 | Github="https://github.com/mag37/dockcheck" 5 | RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" 6 | 7 | set -uo pipefail 8 | shopt -s nullglob 9 | shopt -s failglob 10 | 11 | # Variables for self updating 12 | ScriptArgs=( "$@" ) 13 | ScriptPath="$(readlink -f "$0")" 14 | ScriptWorkDir="$(dirname "$ScriptPath")" 15 | 16 | # Source helper functions 17 | source_if_exists_or_fail() { 18 | if [[ -s "$1" ]]; then 19 | source "$1" 20 | [[ "${DisplaySourcedFiles:-false}" == true ]] && echo " * sourced config: ${1}" 21 | return 0 22 | else 23 | return 1 24 | fi 25 | } 26 | 27 | # User customizable defaults 28 | source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists_or_fail "${ScriptWorkDir}/dockcheck.config" 29 | 30 | # Help Function 31 | Help() { 32 | echo "Syntax: dockcheck.sh [OPTION] [comma separated names to include]" 33 | echo "Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall" 34 | echo 35 | echo "Options:" 36 | echo "-a|y Automatic updates, without interaction." 37 | echo "-b N Enable image backups and sets number of days to keep from pruning." 38 | echo "-B List currently backed up images, then exit." 39 | echo "-c Exports metrics as prom file for the prometheus node_exporter. Provide the collector textfile directory." 40 | echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower." 41 | echo "-e X Exclude containers, separated by comma." 42 | echo "-f Force stop+start stack after update. Caution: restarts once for every updated container within stack." 43 | echo "-F Only compose up the specific container, not the whole compose stack (useful for master-compose structure)." 44 | echo "-h Print this Help." 45 | echo "-i Inform - send a preconfigured notification." 46 | echo "-I Prints custom releasenote urls alongside each container with updates in CLI output (requires urls.list)." 47 | echo "-l Only include containers with label set. See readme." 48 | echo "-m Monochrome mode, no printf colour codes and hides progress bar." 49 | echo "-M Prints custom releasenote urls as markdown (requires template support)." 50 | echo "-n No updates; only checking availability without interaction." 51 | echo "-p Auto-prune dangling images after update." 52 | echo "-R Skip container recreation after pulling images." 53 | echo "-r Allow checking for updates/updating images for docker run containers. Won't update the container." 54 | echo "-s Include stopped containers in the check. (Logic: docker ps -a)." 55 | echo "-t Set a timeout (in seconds) per container for registry checkups, 10 is default." 56 | echo "-u Allow automatic self updates - caution as this will pull new code and autorun it." 57 | echo "-v Prints current version." 58 | echo "-x N Set max asynchronous subprocesses, 1 default, 0 to disable, 32+ tested." 59 | echo 60 | echo "Project source: $Github" 61 | } 62 | 63 | # Print current backups function 64 | print_backups() { 65 | printf "\n%b---%b Currently backed up images %b---%b\n\n" "$c_teal" "$c_blue" "$c_teal" "$c_reset" 66 | docker images | sed -ne '/^REPOSITORY/p' -ne '/^dockcheck/p' 67 | } 68 | 69 | # Initialise variables 70 | Timeout=${Timeout:-10} 71 | MaxAsync=${MaxAsync:-1} 72 | BarWidth=${BarWidth:-50} 73 | AutoMode=${AutoMode:-false} 74 | DontUpdate=${DontUpdate:-false} 75 | AutoPrune=${AutoPrune:-false} 76 | AutoSelfUpdate=${AutoSelfUpdate:-false} 77 | OnlyLabel=${OnlyLabel:-false} 78 | Notify=${Notify:-false} 79 | ForceRestartStacks=${ForceRestartStacks:-false} 80 | DRunUp=${DRunUp:-false} 81 | MonoMode=${MonoMode:-false} 82 | PrintReleaseURL=${PrintReleaseURL:-false} 83 | PrintMarkdownURL=${PrintMarkdownURL:-false} 84 | Stopped=${Stopped:-""} 85 | CollectorTextFileDirectory=${CollectorTextFileDirectory:-} 86 | Exclude=${Exclude:-} 87 | DaysOld=${DaysOld:-} 88 | BackupForDays=${BackupForDays:-} 89 | OnlySpecific=${OnlySpecific:-false} 90 | SpecificContainer=${SpecificContainer:-""} 91 | SkipRecreate=${SkipRecreate:-false} 92 | Excludes=() 93 | GotUpdates=() 94 | NoUpdates=() 95 | GotErrors=() 96 | SelectedUpdates=() 97 | CurlArgs="--retry ${CurlRetryCount:=3} --retry-delay ${CurlRetryDelay:=1} --connect-timeout ${CurlConnectTimeout:=5} -sf" 98 | regbin="" 99 | jqbin="" 100 | 101 | # Colours 102 | c_red="\033[0;31m" 103 | c_green="\033[0;32m" 104 | c_yellow="\033[0;33m" 105 | c_blue="\033[0;34m" 106 | c_teal="\033[0;36m" 107 | c_reset="\033[0m" 108 | 109 | # Timestamps 110 | RunTimestamp=$(date +'%Y-%m-%d_%H%M') 111 | RunEpoch=$(date +'%s') 112 | 113 | while getopts "ayb:BfFhiIlmMnprsuvc:e:d:t:x:R" options; do 114 | case "${options}" in 115 | a|y) AutoMode=true ;; 116 | b) BackupForDays="${OPTARG}" ;; 117 | B) print_backups; exit 0 ;; 118 | c) CollectorTextFileDirectory="${OPTARG}" ;; 119 | d) DaysOld=${OPTARG} ;; 120 | e) Exclude=${OPTARG} ;; 121 | f) ForceRestartStacks=true ;; 122 | F) OnlySpecific=true ;; 123 | i) Notify=true ;; 124 | I) PrintReleaseURL=true ;; 125 | l) OnlyLabel=true ;; 126 | m) MonoMode=true ;; 127 | M) PrintMarkdownURL=true ;; 128 | n) DontUpdate=true; AutoMode=true;; 129 | p) AutoPrune=true ;; 130 | R) SkipRecreate=true ;; 131 | r) DRunUp=true ;; 132 | s) Stopped="-a" ;; 133 | t) Timeout="${OPTARG}" ;; 134 | u) AutoSelfUpdate=true ;; 135 | v) printf "%s\n" "$VERSION"; exit 0 ;; 136 | x) MaxAsync=${OPTARG} ;; 137 | h|*) Help; exit 2 ;; 138 | esac 139 | done 140 | shift "$((OPTIND-1))" 141 | 142 | # Set $1 to a variable for name filtering later, rewriting if multiple 143 | SearchName="${1:-}" 144 | if [[ ! -z "$SearchName" ]]; then 145 | SearchName="^(${SearchName//,/|})$" 146 | fi 147 | 148 | # Check if there's a new release of the script 149 | LatestSnippet="$(curl ${CurlArgs} -r 0-200 "$RawUrl" || printf "undefined")" 150 | LatestRelease="$(echo "${LatestSnippet}" | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" 151 | LatestChanges="$(echo "${LatestSnippet}" | sed -n "/ChangeNotes/s/# ChangeNotes: //p")" 152 | 153 | # Basic notify configuration check 154 | if [[ "${Notify}" == true ]] && [[ ! -s "${ScriptWorkDir}/notify.sh" ]] && [[ -z "${NOTIFY_CHANNELS:-}" ]]; then 155 | printf "Using v2 notifications with -i flag passed but no notify channels configured in dockcheck.config. This will result in no notifications being sent.\n" 156 | fi 157 | 158 | # Setting up options and sourcing functions 159 | if [[ "$DontUpdate" == true ]]; then AutoMode=true; fi 160 | if [[ "$MonoMode" == true ]]; then declare c_{red,green,yellow,blue,teal,reset}=""; fi 161 | if [[ "$Notify" == true ]]; then 162 | source_if_exists_or_fail "${ScriptWorkDir}/notify.sh" || source_if_exists_or_fail "${ScriptWorkDir}/notify_templates/notify_v2.sh" || Notify=false 163 | fi 164 | if [[ -n "$Exclude" ]]; then 165 | IFS=',' read -ra Excludes <<< "$Exclude" 166 | unset IFS 167 | fi 168 | if [[ -n "$DaysOld" ]]; then 169 | if ! [[ $DaysOld =~ ^[0-9]+$ ]]; then 170 | printf "Days -d argument given (%s) is not a number.\n" "$DaysOld" 171 | exit 2 172 | fi 173 | fi 174 | if [[ -n "$BackupForDays" ]]; then 175 | if ! [[ $BackupForDays =~ ^[0-9]+$ ]]; then 176 | printf "-b argument given (%s) is not a number.\n" "$BackupForDays" 177 | exit 2 178 | fi 179 | [[ "$AutoPrune" == true ]] && printf "%bWARNING: When -b option is used, -p has no function.%b\n" "$c_yellow" "$c_reset" 180 | fi 181 | if [[ -n "$CollectorTextFileDirectory" ]]; then 182 | if ! [[ -d $CollectorTextFileDirectory ]]; then 183 | printf "The directory (%s) does not exist.\n" "$CollectorTextFileDirectory" 184 | exit 2 185 | else 186 | source "${ScriptWorkDir}/addons/prometheus/prometheus_collector.sh" 187 | fi 188 | fi 189 | 190 | exec_if_exists() { 191 | if [[ $(type -t $1) == function ]]; then "$@"; fi 192 | } 193 | 194 | exec_if_exists_or_fail() { 195 | [[ $(type -t $1) == function ]] && "$@" 196 | } 197 | 198 | self_update_curl() { 199 | cp "$ScriptPath" "$ScriptPath".bak 200 | if command -v curl &>/dev/null; then 201 | curl ${CurlArgs} -L $RawUrl > "$ScriptPath"; chmod +x "$ScriptPath" || { printf "ERROR: Failed to curl updated Dockcheck.sh script. Skipping update.\n"; return 1; } 202 | printf "\n%b---%b starting over with the updated version %b---%b\n" "$c_yellow" "$c_teal" "$c_yellow" "$c_reset" 203 | exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments 204 | exit 1 # Exit the old instance 205 | elif command -v wget &>/dev/null; then 206 | wget --waitretry=1 --timeout=15 -t 10 $RawUrl -O "$ScriptPath"; chmod +x "$ScriptPath" 207 | printf "\n%b---%b starting over with the updated version %b---%b\n" "$c_yellow" "$c_teal" "$c_yellow" "$c_reset" 208 | exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments 209 | exit 0 # exit the old instance 210 | else 211 | printf "\n%bcurl/wget not available %b- download the update manually: %b%s %b\n" "$c_red" "$c_reset" "$c_teal" "$Github" "$c_reset" 212 | fi 213 | } 214 | 215 | self_update() { 216 | cd "$ScriptWorkDir" || { printf "%bPath error,%b skipping update.\n" "$c_red" "$c_reset"; return; } 217 | if command -v git &>/dev/null && [[ "$(git ls-remote --get-url 2>/dev/null)" =~ .*"mag37/dockcheck".* ]]; then 218 | printf "\n%s\n" "Pulling the latest version." 219 | git pull --force || { printf "%bGit error,%b manually pull/clone.\n" "$c_red" "$c_reset"; return; } 220 | printf "\n%s\n" "--- starting over with the updated version ---" 221 | cd - || { printf "%bPath error.%b\n" "$c_red" "$c_reset"; return; } 222 | exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments 223 | exit 0 # exit the old instance 224 | else 225 | cd - || { printf "%bPath error.%b\n" "$c_red" "$c_reset"; return; } 226 | self_update_curl 227 | fi 228 | } 229 | 230 | choosecontainers() { 231 | while [[ -z "${ChoiceClean:-}" ]]; do 232 | read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice 233 | if [[ "$Choice" =~ [qQnN] ]]; then 234 | [[ -n "${BackupForDays:-}" ]] && remove_backups 235 | exit 0 236 | elif [[ "$Choice" =~ [aAyY] ]]; then 237 | SelectedUpdates=( "${GotUpdates[@]}" ) 238 | ChoiceClean=${Choice//[,.:;]/ } 239 | else 240 | ChoiceClean=${Choice//[,.:;]/ } 241 | for CC in $ChoiceClean; do 242 | CC=$((10#$CC)) # Base 10 interpretation to strip leading zeroes 243 | if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]]; then # Reset choice if out of bounds 244 | echo "Number not in list: $CC"; unset ChoiceClean; break 1 245 | else 246 | SelectedUpdates+=( "${GotUpdates[$CC-1]}" ) 247 | fi 248 | done 249 | fi 250 | done 251 | } 252 | 253 | datecheck() { 254 | ImageDate="$1" 255 | DaysMax="$2" 256 | ImageEpoch=$(date -d "$ImageDate" +%s 2>/dev/null) || ImageEpoch=$(date -f "%Y-%m-%d" -j "$ImageDate" +%s) 257 | ImageAge=$(( ( RunEpoch - ImageEpoch )/86400 )) 258 | if [[ "$ImageAge" -gt "$DaysMax" ]]; then 259 | return 0 260 | else 261 | return 1 262 | fi 263 | } 264 | 265 | remove_backups() { 266 | IFS=$'\n' 267 | CleanupCount=0 268 | for backup_img in $(docker images --format "{{.Repository}} {{.Tag}}" | sed -n '/^dockcheck/p'); do 269 | repo_name=${backup_img% *} 270 | backup_tag=${backup_img#* } 271 | backup_date=${backup_tag%%_*} 272 | # UNTAGGING HERE 273 | if datecheck "$backup_date" "$BackupForDays"; then 274 | [[ "$CleanupCount" == 0 ]] && printf "\n%bRemoving backed up images older then %s days.%b\n" "$c_blue" "$BackupForDays" "$c_reset" 275 | docker rmi "${repo_name}:${backup_tag}" && ((CleanupCount+=1)) 276 | fi 277 | done 278 | unset IFS 279 | if [[ "$CleanupCount" == 0 ]]; then 280 | printf "\nNo backup images to remove.\n" 281 | else 282 | [[ "$CleanupCount" -gt 1 ]] && b_phrase="backups" || b_phrase="backup" 283 | printf "\n%b%s%b %s removed.%b\n" "$c_green" "$CleanupCount" "$c_teal" "$b_phrase" "$c_reset" 284 | fi 285 | } 286 | 287 | progress_bar() { 288 | QueCurrent="$1" 289 | QueTotal="$2" 290 | BarWidth=${BarWidth:-50} 291 | ((Percent=100*QueCurrent/QueTotal)) 292 | ((Complete=BarWidth*Percent/100)) 293 | ((Left=BarWidth-Complete)) || true # to not throw error when result is 0 294 | BarComplete=$(printf "%${Complete}s" | tr " " "#") 295 | BarLeft=$(printf "%${Left}s" | tr " " "-") 296 | if [[ "$QueTotal" != "$QueCurrent" ]]; then 297 | printf "\r[%s%s] %s/%s " "$BarComplete" "$BarLeft" "$QueCurrent" "$QueTotal" 298 | else 299 | printf "\r[%b%s%b] %s/%s \n" "$c_teal" "$BarComplete" "$c_reset" "$QueCurrent" "$QueTotal" 300 | fi 301 | } 302 | 303 | # Function to add user-provided urls to releasenotes 304 | releasenotes() { 305 | unset Updates 306 | for update in "${GotUpdates[@]}"; do 307 | found=false 308 | while read -r container url; do 309 | if [[ "$update" == "$container" ]] && [[ "$PrintMarkdownURL" == true ]]; then Updates+=("- [$update]($url)"); found=true; 310 | elif [[ "$update" == "$container" ]]; then Updates+=("$update -> $url"); found=true; 311 | fi 312 | done < "${ScriptWorkDir}/urls.list" 313 | if [[ "$found" == false ]] && [[ "$PrintMarkdownURL" == true ]]; then Updates+=("- $update -> url missing"); 314 | elif [[ "$found" == false ]]; then Updates+=("$update -> url missing"); 315 | else continue; 316 | fi 317 | done 318 | } 319 | 320 | # Static binary downloader for dependencies 321 | binary_downloader() { 322 | BinaryName="$1" 323 | BinaryUrl="$2" 324 | case "$(uname -m)" in 325 | x86_64|amd64) architecture="amd64" ;; 326 | arm64|aarch64) architecture="arm64";; 327 | *) printf "\n%bArchitecture not supported, exiting.%b\n" "$c_red" "$c_reset"; exit 1;; 328 | esac 329 | GetUrl="${BinaryUrl/TEMP/"$architecture"}" 330 | if command -v curl &>/dev/null; then curl ${CurlArgs} -L "$GetUrl" > "$ScriptWorkDir/$BinaryName" || { printf "ERROR: Failed to curl binary dependency. Rerun the script to retry.\n"; exit 1; } 331 | elif command -v wget &>/dev/null; then wget --waitretry=1 --timeout=15 -t 10 "$GetUrl" -O "$ScriptWorkDir/$BinaryName"; 332 | else printf "\n%bcurl/wget not available - get %s manually from the repo link, exiting.%b" "$c_red" "$BinaryName" "$c_reset"; exit 1; 333 | fi 334 | [[ -f "$ScriptWorkDir/$BinaryName" ]] && chmod +x "$ScriptWorkDir/$BinaryName" 335 | } 336 | 337 | distro_checker() { 338 | isRoot=false 339 | [[ ${EUID:-} == 0 ]] && isRoot=true 340 | if [[ -f /etc/alpine-release ]] ; then 341 | [[ "$isRoot" == true ]] && PkgInstaller="apk add" || PkgInstaller="doas apk add" 342 | elif [[ -f /etc/arch-release ]]; then 343 | [[ "$isRoot" == true ]] && PkgInstaller="pacman -S" || PkgInstaller="sudo pacman -S" 344 | elif [[ -f /etc/debian_version ]]; then 345 | [[ "$isRoot" == true ]] && PkgInstaller="apt-get install" || PkgInstaller="sudo apt-get install" 346 | elif [[ -f /etc/redhat-release ]]; then 347 | [[ "$isRoot" == true ]] && PkgInstaller="dnf install" || PkgInstaller="sudo dnf install" 348 | elif [[ -f /etc/SuSE-release ]]; then 349 | [[ "$isRoot" == true ]] && PkgInstaller="zypper install" || PkgInstaller="sudo zypper install" 350 | elif [[ $(uname -s) == "Darwin" ]]; then PkgInstaller="brew install" 351 | else PkgInstaller="ERROR"; printf "\n%bNo distribution could be determined%b, falling back to static binary.\n" "$c_yellow" "$c_reset" 352 | fi 353 | } 354 | 355 | # Dependency check + installer function 356 | dependency_check() { 357 | AppName="$1" 358 | AppVar="$2" 359 | AppUrl="$3" 360 | if command -v "$AppName" &>/dev/null; then export "$AppVar"="$AppName"; 361 | elif [[ -f "$ScriptWorkDir/$AppName" ]]; then export "$AppVar"="$ScriptWorkDir/$AppName"; 362 | else 363 | printf "\nRequired dependency %b'%s'%b missing, do you want to install it?\n" "$c_teal" "$AppName" "$c_reset" 364 | read -r -p "y: With packagemanager (sudo). / s: Download static binary. y/s/[n] " GetBin 365 | GetBin=${GetBin:-no} # set default to no if nothing is given 366 | if [[ "$GetBin" =~ [yYsS] ]]; then 367 | [[ "$GetBin" =~ [yY] ]] && distro_checker 368 | if [[ -n "${PkgInstaller:-}" && "${PkgInstaller:-}" != "ERROR" ]]; then 369 | [[ $(uname -s) == "Darwin" && "$AppName" == "regctl" ]] && AppName="regclient" 370 | if $PkgInstaller "$AppName"; then 371 | AppName="$1" 372 | export "$AppVar"="$AppName" 373 | printf "\n%b%b installed.%b\n" "$c_green" "$AppName" "$c_reset" 374 | else 375 | PkgInstaller="ERROR" 376 | printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset" 377 | fi 378 | fi 379 | if [[ "$GetBin" =~ [sS] ]] || [[ "$PkgInstaller" == "ERROR" ]]; then 380 | binary_downloader "$AppName" "$AppUrl" 381 | [[ -f "$ScriptWorkDir/$AppName" ]] && { export "$AppVar"="$ScriptWorkDir/$1" && printf "\n%b%s downloaded.%b\n" "$c_green" "$AppName" "$c_reset"; } 382 | fi 383 | else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset"; exit 1; 384 | fi 385 | fi 386 | # Final check if binary is correct 387 | [[ "$1" == "jq" ]] && VerFlag="--version" 388 | [[ "$1" == "regctl" ]] && VerFlag="version" 389 | ${!AppVar} "$VerFlag" &> /dev/null || { printf "%s\n" "$AppName is not working - try to remove it and re-download it, exiting."; exit 1; } 390 | } 391 | 392 | dependency_check "regctl" "regbin" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP" 393 | dependency_check "jq" "jqbin" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP" 394 | 395 | # Numbered List function - pads with zero 396 | list_options() { 397 | local total="${#Updates[@]}" 398 | [[ ${#total} < 2 ]] && local pads=2 || local pads="${#total}" 399 | local num=1 400 | for update in "${Updates[@]}"; do 401 | printf "%0*d - %s\n" "$pads" "$num" "$update" 402 | ((num++)) 403 | done 404 | } 405 | 406 | # Version check & initiate self update 407 | if [[ "$LatestSnippet" != "undefined" ]]; then 408 | if [[ "$VERSION" != "$LatestRelease" ]]; then 409 | 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" 410 | if [[ "$AutoMode" == false ]]; then 411 | read -r -p "Would you like to update? y/[n]: " SelfUpdate 412 | [[ "$SelfUpdate" =~ [yY] ]] && self_update 413 | elif [[ "$AutoMode" == true ]] && [[ "$AutoSelfUpdate" == true ]]; then self_update; 414 | else 415 | [[ "$Notify" == true ]] && { exec_if_exists_or_fail dockcheck_notification "$VERSION" "$LatestRelease" "$LatestChanges" || printf "Could not source notification function.\n"; } 416 | fi 417 | fi 418 | else 419 | printf "ERROR: Failed to curl latest Dockcheck.sh release version.\n" 420 | fi 421 | 422 | # Version check for notify templates 423 | [[ "$Notify" == true ]] && [[ ! -s "${ScriptWorkDir}/notify.sh" ]] && { exec_if_exists_or_fail notify_update_notification || printf "Could not source notify notification function.\n"; } 424 | 425 | # Check docker compose binary 426 | docker info &>/dev/null || { printf "\n%bYour current user does not have permissions to the docker socket - may require root / docker group. Exiting.%b\n" "$c_red" "$c_reset"; exit 1; } 427 | if docker compose version &>/dev/null; then DockerBin="docker compose" ; 428 | elif docker-compose -v &>/dev/null; then DockerBin="docker-compose" ; 429 | elif docker -v &>/dev/null; then 430 | printf "%s\n" "No docker compose binary available, using plain docker (Not recommended!)" 431 | printf "%s\n" "'docker run' will ONLY update images, not the container itself." 432 | else 433 | printf "%s\n" "No docker binaries available, exiting." 434 | exit 1 435 | fi 436 | 437 | # Listing typed exclusions 438 | if [[ -n ${Excludes[*]:-} ]]; then 439 | printf "\n%bExcluding these names:%b\n" "$c_blue" "$c_reset" 440 | printf "%s\n" "${Excludes[@]}" 441 | printf "\n" 442 | fi 443 | 444 | # Variables for progress_bar function 445 | ContCount=$(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | wc -l) 446 | RegCheckQue=0 447 | 448 | # Testing and setting timeout binary 449 | t_out=$(command -v timeout || echo "") 450 | if [[ $t_out ]]; then 451 | t_out=$(realpath "$t_out" 2>/dev/null || readlink -f "$t_out") 452 | if [[ $t_out =~ "busybox" ]]; then 453 | t_out="timeout ${Timeout}" 454 | else t_out="timeout --foreground ${Timeout}" 455 | fi 456 | else t_out="" 457 | fi 458 | 459 | check_image() { 460 | i="$1" 461 | local Excludes=($Excludes_string) 462 | for e in "${Excludes[@]}"; do 463 | if [[ "$i" == "$e" ]]; then 464 | printf "%s\n" "Skip $i" 465 | return 466 | fi 467 | done 468 | 469 | # Skipping non-compose containers unless option is set 470 | ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}') 471 | ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels") 472 | [[ "$ContPath" == "null" ]] && ContPath="" 473 | if [[ -z "$ContPath" ]] && [[ "$DRunUp" == false ]]; then 474 | printf "%s\n" "NoUpdates !$i - not checked, no compose file" 475 | return 476 | fi 477 | # Checking if Label Only -option is set, and if container got the label 478 | ContUpdateLabel=$($jqbin -r '."mag37.dockcheck.update"' <<< "$ContLabels") 479 | [[ "$ContUpdateLabel" == "null" ]] && ContUpdateLabel="" 480 | [[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "Skip $i"; return; } } 481 | 482 | local NoUpdates GotUpdates GotErrors 483 | ImageId=$(docker inspect "$i" --format='{{.Image}}') 484 | RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}') 485 | LocalHash=$(docker image inspect "$ImageId" --format '{{.RepoDigests}}') 486 | 487 | # Checking for errors while setting the variable 488 | if RegHash=$($t_out "$regbin" -v error image digest --list "$RepoUrl" 2>&1); then 489 | if [[ "$LocalHash" == *"$RegHash"* ]]; then 490 | printf "%s\n" "NoUpdates $i" 491 | else 492 | if [[ -n "${DaysOld:-}" ]] && ! datecheck $("$regbin" -v error image inspect "$RepoUrl" --format='{{.Created}}' | cut -d" " -f1) "$DaysOld" ; then 493 | printf "%s\n" "NoUpdates +$i ${ImageAge}d" 494 | else 495 | printf "%s\n" "GotUpdates $i" 496 | fi 497 | fi 498 | else 499 | printf "%s\n" "GotErrors $i - ${RegHash}" # Reghash contains an error code here 500 | fi 501 | } 502 | 503 | # Make required functions and variables available to subprocesses 504 | export -f check_image datecheck 505 | export Excludes_string="${Excludes[*]:-}" # Can only export scalar variables 506 | export t_out regbin RepoUrl DaysOld DRunUp jqbin OnlyLabel RunTimestamp RunEpoch 507 | 508 | # Check for POSIX xargs with -P option, fallback without async 509 | if (echo "test" | xargs -P 2 >/dev/null 2>&1) && [[ "$MaxAsync" != 0 ]]; then 510 | XargsAsync="-P $MaxAsync" 511 | else 512 | XargsAsync="" 513 | [[ "$MaxAsync" != 0 ]] && printf "%bMissing POSIX xargs, consider installing 'findutils' for asynchronous lookups.%b\n" "$c_yellow" "$c_reset" 514 | fi 515 | 516 | # Asynchronously check the image-hash of every running container VS the registry 517 | while read -r line; do 518 | ((RegCheckQue+=1)) 519 | if [[ "$MonoMode" == false ]]; then progress_bar "$RegCheckQue" "$ContCount"; fi 520 | 521 | Got=${line%% *} # Extracts the first word (NoUpdates, GotUpdates, GotErrors) 522 | item=${line#* } 523 | 524 | case "$Got" in 525 | NoUpdates) NoUpdates+=("$item") ;; 526 | GotUpdates) GotUpdates+=("$item") ;; 527 | GotErrors) GotErrors+=("$item") ;; 528 | Skip) ;; 529 | *) echo "Error! Unexpected output from subprocess: ${line}" ;; 530 | esac 531 | done < <( \ 532 | docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | \ 533 | xargs $XargsAsync -I {} bash -c 'check_image "{}"' \ 534 | ) 535 | 536 | [[ "$OnlyLabel" == true ]] && printf "\n%bLabel option active:%b Only checking containers with labels set.\n" "$c_blue" "$c_reset" 537 | 538 | # Sort arrays alphabetically 539 | IFS=$'\n' 540 | NoUpdates=($(sort <<<"${NoUpdates[*]:-}")) 541 | GotUpdates=($(sort <<<"${GotUpdates[*]:-}")) 542 | unset IFS 543 | 544 | # Run the prometheus exporter function 545 | if [[ -n "${CollectorTextFileDirectory:-}" ]]; then 546 | exec_if_exists_or_fail prometheus_exporter ${#NoUpdates[@]} ${#GotUpdates[@]} ${#GotErrors[@]} || printf "%s\n" "Could not source prometheus exporter function." 547 | fi 548 | 549 | # Define how many updates are available 550 | UpdCount="${#GotUpdates[@]}" 551 | 552 | # List what containers got updates or not 553 | if [[ -n ${NoUpdates[*]:-} ]]; then 554 | printf "\n%bContainers on latest version:%b\n" "$c_green" "$c_reset" 555 | printf "%s\n" "${NoUpdates[@]}" 556 | fi 557 | if [[ -n ${GotErrors[*]:-} ]]; then 558 | printf "\n%bContainers with errors, won't get updated:%b\n" "$c_red" "$c_reset" 559 | printf "%s\n" "${GotErrors[@]}" 560 | printf "%binfo:%b 'unauthorized' often means not found in a public registry.\n" "$c_blue" "$c_reset" 561 | fi 562 | if [[ -n ${GotUpdates[*]:-} ]]; then 563 | printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset" 564 | if [[ -s "$ScriptWorkDir/urls.list" ]] && [[ "$PrintReleaseURL" == true ]]; then releasenotes; else Updates=("${GotUpdates[@]}"); fi 565 | [[ "$AutoMode" == false ]] && list_options || printf "%s\n" "${Updates[@]}" 566 | [[ "$Notify" == true ]] && { exec_if_exists_or_fail send_notification "${GotUpdates[@]}" || printf "\nCould not source notification function.\n"; } 567 | else 568 | [[ "$Notify" == true ]] && [[ ! -s "${ScriptWorkDir}/notify.sh" ]] && { exec_if_exists_or_fail send_notification "${GotUpdates[@]}" || printf "\nCould not source notification function.\n"; } 569 | fi 570 | 571 | # Optionally get updates if there's any 572 | if [[ -n "${GotUpdates:-}" ]]; then 573 | if [[ "$AutoMode" == false ]]; then 574 | printf "\n%bChoose what containers to update.%b\n" "$c_teal" "$c_reset" 575 | choosecontainers 576 | else 577 | SelectedUpdates=( "${GotUpdates[@]}" ) 578 | fi 579 | if [[ "$DontUpdate" == false ]]; then 580 | printf "\n%bUpdating container(s):%b\n" "$c_blue" "$c_reset" 581 | printf "%s\n" "${SelectedUpdates[@]}" 582 | 583 | NumberofUpdates="${#SelectedUpdates[@]}" 584 | 585 | CurrentQue=0 586 | for i in "${SelectedUpdates[@]}"; do 587 | ((CurrentQue+=1)) 588 | printf "\n%bNow updating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset" 589 | ContConfig=$(docker inspect "$i" --format '{{json .}}') 590 | ContImage=$($jqbin -r '."Config"."Image"' <<< "$ContConfig") 591 | ImageId=$($jqbin -r '."Image"' <<< "$ContConfig") 592 | ContPath=$($jqbin -r '."Config"."Labels"."com.docker.compose.project.working_dir"' <<< "$ContConfig") 593 | [[ "$ContPath" == "null" ]] && ContPath="" 594 | 595 | # Add new backup tag prior to pulling if option is set 596 | if [[ -n "${BackupForDays:-}" ]]; then 597 | ImageConfig=$(docker image inspect "$ImageId" --format '{{ json . }}') 598 | ContRepoDigests=$($jqbin -r '.RepoDigests[0]' <<< "$ImageConfig") 599 | [[ "$ContRepoDigests" == "null" ]] && ContRepoDigests="" 600 | ContRepo=${ContImage%:*} 601 | ContApp=${ContRepo#*/} 602 | [[ "$ContImage" =~ ":" ]] && ContTag=${ContImage#*:} || ContTag="latest" 603 | BackupName="dockcheck/${ContApp}:${RunTimestamp}_${ContTag}" 604 | docker tag "$ImageId" "$BackupName" 605 | printf "%b%s backed up as %s%b\n" "$c_teal" "$i" "$BackupName" "$c_reset" 606 | fi 607 | 608 | # Checking if compose-values are empty - hence started with docker run 609 | if [[ -z "$ContPath" ]]; then 610 | if [[ "$DRunUp" == true ]]; then 611 | docker pull "$ContImage" 612 | printf "%s\n" "$i got a new image downloaded, rebuild manually with preferred 'docker run'-parameters" 613 | else 614 | printf "\n%b%s%b has no compose labels, probably started with docker run - %bskipping%b\n\n" "$c_yellow" "$i" "$c_reset" "$c_yellow" "$c_reset" 615 | fi 616 | continue 617 | fi 618 | 619 | if docker pull "$ContImage"; then 620 | # Removal of the -tag image left behind from backup 621 | if [[ ! -z "${ContRepoDigests:-}" ]] && [[ -n "${BackupForDays:-}" ]]; then docker rmi "$ContRepoDigests"; fi 622 | else 623 | printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1 624 | fi 625 | 626 | done 627 | printf "\n%bDone pulling updates.%b\n" "$c_green" "$c_reset" 628 | 629 | if [[ "$SkipRecreate" == true ]]; then 630 | printf "%bSkipping container recreation due to -R.%b\n" "$c_yellow" "$c_reset" 631 | else 632 | printf "%bRecreating updated containers.%b\n" "$c_blue" "$c_reset" 633 | CurrentQue=0 634 | for i in "${SelectedUpdates[@]}"; do 635 | ((CurrentQue+=1)) 636 | unset CompleteConfs 637 | # Extract labels and metadata 638 | ContConfig=$(docker inspect "$i" --format '{{json .}}') 639 | ContLabels=$($jqbin -r '."Config"."Labels"' <<< "$ContConfig") 640 | ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels") 641 | [[ "$ContPath" == "null" ]] && ContPath="" 642 | ContConfigFile=$($jqbin -r '."com.docker.compose.project.config_files"' <<< "$ContLabels") 643 | [[ "$ContConfigFile" == "null" ]] && ContConfigFile="" 644 | ContName=$($jqbin -r '."com.docker.compose.service"' <<< "$ContLabels") 645 | [[ "$ContName" == "null" ]] && ContName="" 646 | ContEnv=$($jqbin -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels") 647 | [[ "$ContEnv" == "null" ]] && ContEnv="" 648 | ContRestartStack=$($jqbin -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels") 649 | [[ "$ContRestartStack" == "null" ]] && ContRestartStack="" 650 | ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels") 651 | [[ "$ContOnlySpecific" == "null" ]] && ContRestartStack="" 652 | ContStateRunning=$($jqbin -r '."State"."Running"' <<< "$ContConfig") 653 | [[ "$ContStateRunning" == "null" ]] && ContStateRunning="" 654 | 655 | if [[ "$ContStateRunning" == "true" ]]; then 656 | printf "\n%bNow recreating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset" 657 | else 658 | printf "\n%bSkipping recreation of %b%s%b as it's not running.%b\n" "$c_yellow" "$c_blue" "$i" "$c_yellow" "$c_reset" 659 | continue 660 | fi 661 | 662 | # Checking if compose-values are empty - hence started with docker run 663 | [[ -z "$ContPath" ]] && { echo "Not a compose container, skipping."; continue; } 664 | 665 | # cd to the compose-file directory to account for people who use relative volumes 666 | cd "$ContPath" || { printf "\n%bPath error - skipping%b %s" "$c_red" "$c_reset" "$i"; continue; } 667 | # Reformatting path + multi compose 668 | if [[ $ContConfigFile == '/'* ]]; then 669 | CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s " "$conf"; done) 670 | else 671 | CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s/%s " "$ContPath" "$conf"; done) 672 | fi 673 | # Check if the container got an environment file set and reformat it 674 | ContEnvs="" 675 | if [[ -n "$ContEnv" ]]; then ContEnvs=$(for env in ${ContEnv//,/ }; do printf -- "--env-file %s " "$env"; done); fi 676 | # Set variable when compose up should only target the specific container, not the stack 677 | if [[ $OnlySpecific == true ]] || [[ $ContOnlySpecific == true ]]; then SpecificContainer="$ContName"; fi 678 | 679 | # Check if the whole stack should be restarted 680 | if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]]; then 681 | ${DockerBin} ${CompleteConfs} stop; ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; } 682 | else 683 | ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d ${SpecificContainer} || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; } 684 | fi 685 | done 686 | fi 687 | printf "\n%bAll updates done!%b\n" "$c_green" "$c_reset" 688 | 689 | # Trigger pruning only when backup-function is not used 690 | if [[ -z "${BackupForDays:-}" ]]; then 691 | if [[ "$AutoPrune" == false ]] && [[ "$AutoMode" == false ]]; then printf "\n"; read -rep "Would you like to prune all dangling images? y/[n]: " AutoPrune; fi 692 | if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then printf "\nAuto pruning.."; docker image prune -f; fi 693 | fi 694 | 695 | else 696 | printf "\nNo updates installed.\n" 697 | fi 698 | else 699 | printf "\nNo updates available.\n" 700 | fi 701 | 702 | # Clean up old backup image tags if -b is used 703 | [[ -n "${BackupForDays:-}" ]] && remove_backups 704 | 705 | exit 0 706 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------