mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-23 04:40:40 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37575cad98 |
+1
-3
@@ -34,7 +34,7 @@
|
|||||||
## All commented values are examples only. Modify as needed.
|
## All commented values are examples only. Modify as needed.
|
||||||
##
|
##
|
||||||
## Uncomment the line below and specify the notification channels you wish to enable in a space separated string
|
## Uncomment the line below and specify the notification channels you wish to enable in a space separated string
|
||||||
# NOTIFY_CHANNELS="apprise discord DSM file generic HA gotify matrix ntfy pushbullet pushover slack smtp telegram bark file"
|
# NOTIFY_CHANNELS="apprise discord DSM file generic HA gotify matrix ntfy pushbullet pushover slack smtp telegram file"
|
||||||
#
|
#
|
||||||
## Uncomment the line below and specify the number of seconds to delay notifications to enable snooze
|
## Uncomment the line below and specify the number of seconds to delay notifications to enable snooze
|
||||||
# SNOOZE_SECONDS=86400
|
# SNOOZE_SECONDS=86400
|
||||||
@@ -90,6 +90,4 @@
|
|||||||
# TELEGRAM_TOKEN="token-value"
|
# TELEGRAM_TOKEN="token-value"
|
||||||
# TELEGRAM_TOPIC_ID="0"
|
# TELEGRAM_TOPIC_ID="0"
|
||||||
#
|
#
|
||||||
# BARK_KEY=""
|
|
||||||
#
|
|
||||||
# FILE_PATH="${ScriptWorkDir}/updates_available.txt"
|
# FILE_PATH="${ScriptWorkDir}/updates_available.txt"
|
||||||
|
|||||||
+28
-6
@@ -582,6 +582,25 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
|||||||
|
|
||||||
NumberofUpdates="${#SelectedUpdates[@]}"
|
NumberofUpdates="${#SelectedUpdates[@]}"
|
||||||
|
|
||||||
|
# TODO: move this to proper place + setup optarg etc.
|
||||||
|
# Digest log setup
|
||||||
|
LogDigestChanges="true"
|
||||||
|
LogPath="$ScriptWorkDir/updatelog"
|
||||||
|
if [[ -n "${LogDigestChanges}" ]]; then
|
||||||
|
LogStore=()
|
||||||
|
LogStore+=("$(printf "%-30s %s > %s\n" "IMAGE:TAG" "OLD DIGEST" "NEW DIGEST")")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: move this to proper place
|
||||||
|
get_image_facts(){
|
||||||
|
ImageConfig=$(docker image inspect "$ImageId" --format '{{ json . }}')
|
||||||
|
ContRepoDigests=$($jqbin -r '.RepoDigests[0]' <<< "$ImageConfig")
|
||||||
|
[[ "$ContRepoDigests" == "null" ]] && ContRepoDigests=""
|
||||||
|
ContRepo=${ContImage%:*}
|
||||||
|
ContApp=${ContRepo#*/}
|
||||||
|
[[ "$ContImage" =~ ":" ]] && ContTag=${ContImage#*:} || ContTag="latest"
|
||||||
|
}
|
||||||
|
|
||||||
CurrentQue=0
|
CurrentQue=0
|
||||||
for i in "${SelectedUpdates[@]}"; do
|
for i in "${SelectedUpdates[@]}"; do
|
||||||
((CurrentQue+=1))
|
((CurrentQue+=1))
|
||||||
@@ -592,19 +611,17 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
|||||||
ContPath=$($jqbin -r '."Config"."Labels"."com.docker.compose.project.working_dir"' <<< "$ContConfig")
|
ContPath=$($jqbin -r '."Config"."Labels"."com.docker.compose.project.working_dir"' <<< "$ContConfig")
|
||||||
[[ "$ContPath" == "null" ]] && ContPath=""
|
[[ "$ContPath" == "null" ]] && ContPath=""
|
||||||
|
|
||||||
|
|
||||||
# Add new backup tag prior to pulling if option is set
|
# Add new backup tag prior to pulling if option is set
|
||||||
if [[ -n "${BackupForDays:-}" ]]; then
|
if [[ -n "${BackupForDays:-}" ]]; then
|
||||||
ImageConfig=$(docker image inspect "$ImageId" --format '{{ json . }}')
|
get_image_facts
|
||||||
ContRepoDigests=$($jqbin -r '.RepoDigests[0]' <<< "$ImageConfig")
|
|
||||||
[[ "$ContRepoDigests" == "null" ]] && ContRepoDigests=""
|
|
||||||
ContRepo=${ContImage%:*}
|
|
||||||
ContApp=${ContRepo#*/}
|
|
||||||
[[ "$ContImage" =~ ":" ]] && ContTag=${ContImage#*:} || ContTag="latest"
|
|
||||||
BackupName="dockcheck/${ContApp}:${RunTimestamp}_${ContTag}"
|
BackupName="dockcheck/${ContApp}:${RunTimestamp}_${ContTag}"
|
||||||
docker tag "$ImageId" "$BackupName"
|
docker tag "$ImageId" "$BackupName"
|
||||||
printf "%b%s backed up as %s%b\n" "$c_teal" "$i" "$BackupName" "$c_reset"
|
printf "%b%s backed up as %s%b\n" "$c_teal" "$i" "$BackupName" "$c_reset"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[[ -n "${LogDigestChanges}" ]] && get_image_facts
|
||||||
|
|
||||||
# Checking if compose-values are empty - hence started with docker run
|
# Checking if compose-values are empty - hence started with docker run
|
||||||
if [[ -z "$ContPath" ]]; then
|
if [[ -z "$ContPath" ]]; then
|
||||||
if [[ "$DRunUp" == true ]]; then
|
if [[ "$DRunUp" == true ]]; then
|
||||||
@@ -619,12 +636,17 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
|||||||
if docker pull "$ContImage"; then
|
if docker pull "$ContImage"; then
|
||||||
# Removal of the <none>-tag image left behind from backup
|
# Removal of the <none>-tag image left behind from backup
|
||||||
if [[ ! -z "${ContRepoDigests:-}" ]] && [[ -n "${BackupForDays:-}" ]]; then docker rmi "$ContRepoDigests"; fi
|
if [[ ! -z "${ContRepoDigests:-}" ]] && [[ -n "${BackupForDays:-}" ]]; then docker rmi "$ContRepoDigests"; fi
|
||||||
|
if [[ -n "${LogDigestChanges}" ]]; then
|
||||||
|
NewDigest=$(docker image inspect "$ContImage" --format '{{index .RepoDigests 0 }}')
|
||||||
|
LogStore+=("$(printf "%-30s %s > %s\n" "$i:$ContTag" "$ContRepoDigests" "$NewDigest")")
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1
|
printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
printf "\n%bDone pulling updates.%b\n" "$c_green" "$c_reset"
|
printf "\n%bDone pulling updates.%b\n" "$c_green" "$c_reset"
|
||||||
|
[[ -n "${LogDigestChanges}" ]] && { printf "%s\n" "${LogStore[@]}" > "${LogPath}_$(date +'%Y-%m-%d_%H%M')"; }
|
||||||
|
|
||||||
if [[ "$SkipRecreate" == true ]]; then
|
if [[ "$SkipRecreate" == true ]]; then
|
||||||
printf "%bSkipping container recreation due to -R.%b\n" "$c_yellow" "$c_reset"
|
printf "%bSkipping container recreation due to -R.%b\n" "$c_yellow" "$c_reset"
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# NOTIFY_BARK_VERSION="v1.0"
|
|
||||||
|
|
||||||
trigger_bark_notification() {
|
|
||||||
local channel="$1"
|
|
||||||
|
|
||||||
if [[ -z "$jqbin" ]]; then
|
|
||||||
for path in "$jqbin" "jq" "./jq" "../jq" "./jq-linux-TEMP" "../jq-linux-TEMP"; do
|
|
||||||
if command -v "$path" &>/dev/null; then jqbin="$path"; break; fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
[[ -z "$jqbin" ]] && { echo "Error: jq missing"; return 1; }
|
|
||||||
|
|
||||||
[[ -z "$BARK_KEY" ]] && { echo "Error: Key not set"; return 1; }
|
|
||||||
|
|
||||||
local sound="${BARK_SOUND:-hello}"
|
|
||||||
local group="${BARK_GROUP:-Dockcheck}"
|
|
||||||
local icon_url="${BARK_ICON_URL:-https://raw.githubusercontent.com/mag37/dockcheck/main/logo.png}"
|
|
||||||
|
|
||||||
|
|
||||||
local title="${MessageTitle%.}"
|
|
||||||
local newline=$'\n'
|
|
||||||
local formatted_body="## $title${newline}${newline}---${newline}${newline}$MessageBody"
|
|
||||||
|
|
||||||
local json_payload=$( "$jqbin" -n \
|
|
||||||
--arg title "$title" \
|
|
||||||
--arg body "$formatted_body" \
|
|
||||||
--arg group "$group" \
|
|
||||||
--arg sound "$sound" \
|
|
||||||
--arg icon "$icon_url" \
|
|
||||||
'{
|
|
||||||
"title": $title,
|
|
||||||
"markdown": $body,
|
|
||||||
"group": $group,
|
|
||||||
"sound": $sound,
|
|
||||||
"icon": $icon,
|
|
||||||
}' )
|
|
||||||
|
|
||||||
|
|
||||||
if curl -s -f -X POST "https://api.day.app/$BARK_KEY" \
|
|
||||||
-H "Content-Type: application/json; charset=utf-8" \
|
|
||||||
-d "$json_payload" > /dev/null 2>&1; then
|
|
||||||
echo "Bark notification sent successfully (Markdown): $title"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
NOTIFY_V2_VERSION="v0.7"
|
NOTIFY_V2_VERSION="v0.6"
|
||||||
#
|
#
|
||||||
# If migrating from an older notify template, remove your existing notify.sh file.
|
# If migrating from an older notify template, remove your existing notify.sh file.
|
||||||
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
|
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
|
||||||
@@ -40,7 +40,7 @@ done
|
|||||||
|
|
||||||
enabled_notify_templates=( "${!unique_templates[@]}" )
|
enabled_notify_templates=( "${!unique_templates[@]}" )
|
||||||
|
|
||||||
FromHost="$(cat /etc/hostname 2>/dev/null)" || FromHost="$(hostname 2>/dev/null)" || FromHost="UNKNOWN"
|
FromHost=$(cat /etc/hostname)
|
||||||
|
|
||||||
CurrentEpochTime=$(date +"%Y-%m-%dT%H:%M:%S")
|
CurrentEpochTime=$(date +"%Y-%m-%dT%H:%M:%S")
|
||||||
CurrentEpochSeconds=$(date +%s)
|
CurrentEpochSeconds=$(date +%s)
|
||||||
|
|||||||
Reference in New Issue
Block a user