Compare commits

...

8 Commits

Author SHA1 Message Date
mag37
c34d52bde0 the missing ) 2025-11-01 09:25:11 +01:00
mag37
7ea97d06ce New option -R and bugfix + cleanup (#236)
* Cleaned up legacy structure
* Add -R flag to skip container recreation after pulling images (#235)
* Added new -R option: Skip Container recreation
---------

Co-authored-by: mag37 <robin.ivehult@gmail.com>
Co-authored-by: NapalmZ <willy.baessato@gmail.com>
2025-11-01 09:14:49 +01:00
mag37
8970ee3f20 added to the sponsorlist 2025-10-21 20:47:10 +02:00
mag37
12a51d8e83 added new sponsors 2025-10-08 19:00:29 +02:00
mag37
24cae63b61 bugfix - unquoted var in list
Versionbump.
2025-10-07 08:25:44 +02:00
mag37
05e5b23e7b bugfix - unquoted var in list
Versionbump.
2025-10-07 08:24:31 +02:00
mag37
be58805824 hot-patch unquoted variable in updates list 2025-10-06 10:18:38 +02:00
mag37
af0d0d3f6e label and update list rework (#229)
* Reformatting the updates available list

* rewritten list padding to be dynamic

* Label rework + clearer messages (#228)

- Moved up label check and logic to earlier in the process, to iterate the whole run the same way if `-l` option is passed.
- Added messaging to make it clearer.
- Clarified Readme and --help message.
- Clarified prune message (to mean ALL dangling, not just currently updated).
2025-10-03 09:22:17 +02:00
4 changed files with 108 additions and 111 deletions

View File

@@ -22,6 +22,22 @@
___ ___
## Changelog ## Changelog
- **v0.7.4**:
- Added new option `-R`:
- Will skip container recreation after pulling images.
- Allows for more control and possible pipeline integration.
- Fixes:
- Bugfix for *value too great* error due to leading zeroes - solved with base10 conversion.
- Clean up of some legacy readme sections.
- **v0.7.3**: Bugfix - unquoted variable in printf list caused occasional issues.
- **v0.7.2**:
- Label rework:
- Moved up label logic to work globally on the current run.
- Only iterating on labeled containers when used with `-l` option, not listing others.
- Clarified messaging and readme/help texts.
- List reformatting for "available updates" numbering to easier highlight and copy:
- Padded with zero, changed `)` to `-`, example: `02 - homer`
- Can be selected by writing `2,3,4` or `02,03,04`.
- **v0.7.1**: - **v0.7.1**:
- Added support for multiple notifications using the same template - Added support for multiple notifications using the same template
- Added support for notification output format - Added support for notification output format
@@ -32,22 +48,6 @@ ___
- `<channel>_CONTAINERSONLY` : Only notify for docker container related updates - `<channel>_CONTAINERSONLY` : Only notify for docker container related updates
- `<channel>_ALLOWEMPTY` : Always send notifications, even when empty - `<channel>_ALLOWEMPTY` : Always send notifications, even when empty
- `<channel>_OUTPUT` : Define output format - `<channel>_OUTPUT` : Define output format
- **v0.7.0**:
- Bugfix: snooze dockcheck.sh-self-notification and some config clarification.
- Added authentication support to Ntfy.sh.
- Added suport for sendmail in the SMTP-template.
- **v0.6.9**:
- Bugfix: label logic didn't skip recreation (skipped pulling).
- Added comma separated search filtering so you can selectively search exactly which containers to check/update.
- eg: `dockcheck.sh -yp homer,dozzle`
- **v0.6.8**:
- Bugfix: Unbound variable in notify_v2.sh
- New option: "DisplaySourcedFiles" *config* added to list what files get sourced
- **v0.6.7**: Snooze feature, curl, and consolidation
- Added snooze feature to delay notifications
- Added configurable default curl arguments
- Consolidated and standardized notify template update notifications
- Added curl error handling
___ ___
@@ -69,12 +69,13 @@ Options:
-h Print this Help. -h Print this Help.
-i Inform - send a preconfigured notification. -i Inform - send a preconfigured notification.
-I Prints custom releasenote urls alongside each container with updates in CLI output (requires urls.list). -I Prints custom releasenote urls alongside each container with updates in CLI output (requires urls.list).
-l Only update if label is set. See readme. -l Only include containers with label set. See readme.
-m Monochrome mode, no printf colour codes and hides progress bar. -m Monochrome mode, no printf colour codes and hides progress bar.
-M Prints custom releasenote urls as markdown (requires template support). -M Prints custom releasenote urls as markdown (requires template support).
-n No updates, only checking availability. -n No updates, only checking availability.
-p Auto-Prune dangling images after update. -p Auto-Prune dangling images after update.
-r Allow checking for updates/updating images for docker run containers. Won't update the container. -r Allow checking for updates/updating images for docker run containers. Won't update the container.
-R Skip container recreation after pulling images.
-s Include stopped containers in the check. (Logic: docker ps -a). -s Include stopped containers in the check. (Logic: docker ps -a).
-t N Set a timeout (in seconds) per container for registry checkups, 10 is default. -t N Set a timeout (in seconds) per container for registry checkups, 10 is default.
-u Allow automatic self updates - caution as this will pull new code and autorun it. -u Allow automatic self updates - caution as this will pull new code and autorun it.
@@ -104,7 +105,7 @@ After the updates are complete, you'll get prompted if you'd like to prune dangl
___ ___
## Dependencies ## Dependencies
- Running docker (duh) and compose, either standalone or plugin. (see [Podman fork](https://github.com/sudo-kraken/podcheck) - Running docker (duh) and compose, either standalone or plugin. (see [Podman fork](https://github.com/sudo-kraken/podcheck))
- Bash shell or compatible shell of at least v4.3 - Bash shell or compatible shell of at least v4.3
- POSIX `xargs`, usually default but can be installed with the `findutils` package - to enable async. - POSIX `xargs`, usually default but can be installed with the `findutils` package - to enable async.
- [jq](https://github.com/jqlang/jq) - [jq](https://github.com/jqlang/jq)
@@ -283,10 +284,12 @@ Optionally add labels to compose-files. Currently these are the usable labels:
mag37.dockcheck.only-specific-container: true mag37.dockcheck.only-specific-container: true
mag37.dockcheck.restart-stack: true mag37.dockcheck.restart-stack: true
``` ```
- `mag37.dockcheck.update: true` will when used with the `-l` option only update containers with this label and skip the rest. Will still list updates as usual. - `mag37.dockcheck.update: true` will when used with the `-l` option only check and update containers with this label set and skip the rest.
- `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`. - `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`.
- `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). - `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).
Adding or modifying labels in compose-files requires a restart of the container to take effect.
## Workaround for non **amd64** / **arm64** ## Workaround for non **amd64** / **arm64**
`regctl` provides binaries for amd64/arm64, to use on other architecture you could try this workaround. `regctl` provides binaries for amd64/arm64, to use on other architecture you could try this workaround.
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): 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):
@@ -345,11 +348,17 @@ dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/l
## Sponsorlist ## Sponsorlist
- [avegy](https://github.com/avegy) :small_orange_diamond: [avegy](https://github.com/avegy)
- [eichhorn](https://github.com/eichhorn) :small_orange_diamond: [eichhorn](https://github.com/eichhorn)
- [stepdg](https://github.com/stepdg) :small_orange_diamond: [stepdg](https://github.com/stepdg)
- [acer2220](https://github.com/acer2220) :small_orange_diamond: [acer2220](https://github.com/acer2220)
- [shgew](https://github.com/shgew) :small_orange_diamond: [shgew](https://github.com/shgew)
:small_orange_diamond: [jonas3456](https://github.com/jonas3456)
:small_orange_diamond: [4ndreasH](https://github.com/4ndreasH)
:small_orange_diamond: [markoe01](https://github.com/markoe01)
:small_orange_diamond: [mushrowan](https://github.com/mushrowan)
:small_orange_diamond:
___ ___
### The [story](https://mag37.org/posts/project_dockcheck/) behind it. 1 year in retrospect. ### The [story](https://mag37.org/posts/project_dockcheck/) behind it. 1 year in retrospect.

View File

@@ -19,6 +19,7 @@
#OnlyLabel=true # Only update if label is set. See readme. #OnlyLabel=true # Only update if label is set. See readme.
#ForceRestartStacks=true # Force stop+start stack after update. Caution: restarts once for every updated container within stack. #ForceRestartStacks=true # Force stop+start stack after update. Caution: restarts once for every updated container within stack.
#DRunUp=true # Allow updating images for docker run, wont update the container. #DRunUp=true # Allow updating images for docker run, wont update the container.
#SkipRecreate # Skip container recreation after pulling images.
#MonoMode=true # Monochrome mode, no printf colour codes and hides progress bar. #MonoMode=true # Monochrome mode, no printf colour codes and hides progress bar.
#PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)` #PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)`
#PrintMarkdownURL=true # Prints custom releasenote urls as markdown #PrintMarkdownURL=true # Prints custom releasenote urls as markdown
@@ -89,4 +90,3 @@
# TELEGRAM_TOPIC_ID="0" # TELEGRAM_TOPIC_ID="0"
# #
# FILE_PATH="${ScriptWorkDir}/updates_available.txt" # FILE_PATH="${ScriptWorkDir}/updates_available.txt"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.7.1" VERSION="v0.7.4"
# ChangeNotes: Add support for multiple notifications of the same type, output formatting, and file output # ChangeNotes: New option -R to pull without recreation. Fixes: value too great error, legacy cleanups.
Github="https://github.com/mag37/dockcheck" Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
@@ -42,11 +42,12 @@ Help() {
echo "-h Print this Help." echo "-h Print this Help."
echo "-i Inform - send a preconfigured notification." echo "-i Inform - send a preconfigured notification."
echo "-I Prints custom releasenote urls alongside each container with updates in CLI output (requires urls.list)." echo "-I Prints custom releasenote urls alongside each container with updates in CLI output (requires urls.list)."
echo "-l Only update if label is set. See readme." echo "-l Only include containers with label set. See readme."
echo "-m Monochrome mode, no printf colour codes and hides progress bar." echo "-m Monochrome mode, no printf colour codes and hides progress bar."
echo "-M Prints custom releasenote urls as markdown (requires template support)." echo "-M Prints custom releasenote urls as markdown (requires template support)."
echo "-n No updates; only checking availability without interaction." echo "-n No updates; only checking availability without interaction."
echo "-p Auto-prune dangling images after update." echo "-p Auto-prune dangling images after update."
echo "-R Skip container recreation after pulling images."
echo "-r Allow checking for updates/updating images for docker run containers. Won't update the container." echo "-r Allow checking for updates/updating images for docker run containers. Won't update the container."
echo "-s Include stopped containers in the check. (Logic: docker ps -a)." echo "-s Include stopped containers in the check. (Logic: docker ps -a)."
echo "-t Set a timeout (in seconds) per container for registry checkups, 10 is default." echo "-t Set a timeout (in seconds) per container for registry checkups, 10 is default."
@@ -78,6 +79,7 @@ Exclude=${Exclude:-}
DaysOld=${DaysOld:-} DaysOld=${DaysOld:-}
OnlySpecific=${OnlySpecific:-false} OnlySpecific=${OnlySpecific:-false}
SpecificContainer=${SpecificContainer:-""} SpecificContainer=${SpecificContainer:-""}
SkipRecreate=${SkipRecreate:-false}
Excludes=() Excludes=()
GotUpdates=() GotUpdates=()
NoUpdates=() NoUpdates=()
@@ -95,7 +97,7 @@ c_blue="\033[0;34m"
c_teal="\033[0;36m" c_teal="\033[0;36m"
c_reset="\033[0m" c_reset="\033[0m"
while getopts "ayfFhiIlmMnprsuvc:e:d:t:x:" options; do while getopts "ayfFhiIlmMnprsuvc:e:d:t:x:R" options; do
case "${options}" in case "${options}" in
a|y) AutoMode=true ;; a|y) AutoMode=true ;;
c) CollectorTextFileDirectory="${OPTARG}" ;; c) CollectorTextFileDirectory="${OPTARG}" ;;
@@ -110,6 +112,7 @@ while getopts "ayfFhiIlmMnprsuvc:e:d:t:x:" options; do
M) PrintMarkdownURL=true ;; M) PrintMarkdownURL=true ;;
n) DontUpdate=true; AutoMode=true;; n) DontUpdate=true; AutoMode=true;;
p) AutoPrune=true ;; p) AutoPrune=true ;;
R) SkipRecreate=true ;;
r) DRunUp=true ;; r) DRunUp=true ;;
s) Stopped="-a" ;; s) Stopped="-a" ;;
t) Timeout="${OPTARG}" ;; t) Timeout="${OPTARG}" ;;
@@ -213,6 +216,7 @@ choosecontainers() {
else else
ChoiceClean=${Choice//[,.:;]/ } ChoiceClean=${Choice//[,.:;]/ }
for CC in $ChoiceClean; do for CC in $ChoiceClean; do
CC=$((10#$CC)) # Base 10 interpretation to strip leading zeroes
if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]]; then # Reset choice if out of bounds if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]]; then # Reset choice if out of bounds
echo "Number not in list: $CC"; unset ChoiceClean; break 1 echo "Number not in list: $CC"; unset ChoiceClean; break 1
else else
@@ -342,12 +346,13 @@ dependency_check() {
dependency_check "regctl" "regbin" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP" dependency_check "regctl" "regbin" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
dependency_check "jq" "jqbin" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP" dependency_check "jq" "jqbin" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP"
# Numbered List function # Numbered List function - pads with zero
# if urls.list exists add release note url per line
list_options() { list_options() {
num=1 local total="${#Updates[@]}"
[[ ${#total} < 2 ]] && local pads=2 || local pads="${#total}"
local num=1
for update in "${Updates[@]}"; do for update in "${Updates[@]}"; do
echo "$num) $update" printf "%0*d - %s\n" "$pads" "$num" "$update"
((num++)) ((num++))
done done
} }
@@ -423,6 +428,10 @@ check_image() {
printf "%s\n" "NoUpdates !$i - not checked, no compose file" printf "%s\n" "NoUpdates !$i - not checked, no compose file"
return return
fi fi
# Checking if Label Only -option is set, and if container got the label
ContUpdateLabel=$($jqbin -r '."mag37.dockcheck.update"' <<< "$ContLabels")
[[ "$ContUpdateLabel" == "null" ]] && ContUpdateLabel=""
[[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "Skip $i"; return; } }
local NoUpdates GotUpdates GotErrors local NoUpdates GotUpdates GotErrors
ImageId=$(docker inspect "$i" --format='{{.Image}}') ImageId=$(docker inspect "$i" --format='{{.Image}}')
@@ -448,7 +457,7 @@ check_image() {
# Make required functions and variables available to subprocesses # Make required functions and variables available to subprocesses
export -f check_image datecheck export -f check_image datecheck
export Excludes_string="${Excludes[*]:-}" # Can only export scalar variables export Excludes_string="${Excludes[*]:-}" # Can only export scalar variables
export t_out regbin RepoUrl DaysOld DRunUp jqbin export t_out regbin RepoUrl DaysOld DRunUp jqbin OnlyLabel
# Check for POSIX xargs with -P option, fallback without async # Check for POSIX xargs with -P option, fallback without async
if (echo "test" | xargs -P 2 >/dev/null 2>&1) && [[ "$MaxAsync" != 0 ]]; then if (echo "test" | xargs -P 2 >/dev/null 2>&1) && [[ "$MaxAsync" != 0 ]]; then
@@ -478,6 +487,8 @@ done < <( \
xargs $XargsAsync -I {} bash -c 'check_image "{}"' \ xargs $XargsAsync -I {} bash -c 'check_image "{}"' \
) )
[[ "$OnlyLabel" == true ]] && printf "\n%bLabel option active:%b Only checking containers with labels set.\n" "$c_blue" "$c_reset"
# Sort arrays alphabetically # Sort arrays alphabetically
IFS=$'\n' IFS=$'\n'
NoUpdates=($(sort <<<"${NoUpdates[*]:-}")) NoUpdates=($(sort <<<"${NoUpdates[*]:-}"))
@@ -533,10 +544,6 @@ if [[ -n "${GotUpdates:-}" ]]; then
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}') ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels") ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
[[ "$ContPath" == "null" ]] && ContPath="" [[ "$ContPath" == "null" ]] && ContPath=""
ContUpdateLabel=$($jqbin -r '."mag37.dockcheck.update"' <<< "$ContLabels")
[[ "$ContUpdateLabel" == "null" ]] && ContUpdateLabel=""
# Checking if Label Only -option is set, and if container got the label
[[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "No update label, skipping."; continue; } }
# 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
@@ -551,58 +558,59 @@ if [[ -n "${GotUpdates:-}" ]]; then
docker pull "$ContImage" || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; } docker pull "$ContImage" || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
done done
printf "\n%bDone pulling updates. %bRecreating updated containers.%b\n" "$c_green" "$c_blue" "$c_reset" printf "\n%bDone pulling updates.%b\n" "$c_green" "$c_reset"
CurrentQue=0 if [[ "$SkipRecreate" == true ]]; then
for i in "${SelectedUpdates[@]}"; do printf "%bSkipping container recreation due to -R.%b\n" "$c_yellow" "$c_reset"
((CurrentQue+=1)) else
unset CompleteConfs printf "%bRecreating updated containers.%b\n" "$c_blue" "$c_reset"
# Extract labels and metadata CurrentQue=0
ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}') for i in "${SelectedUpdates[@]}"; do
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}') ((CurrentQue+=1))
ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels") unset CompleteConfs
[[ "$ContPath" == "null" ]] && ContPath="" # Extract labels and metadata
ContConfigFile=$($jqbin -r '."com.docker.compose.project.config_files"' <<< "$ContLabels") ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}')
[[ "$ContConfigFile" == "null" ]] && ContConfigFile="" ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
ContName=$($jqbin -r '."com.docker.compose.service"' <<< "$ContLabels") ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
[[ "$ContName" == "null" ]] && ContName="" [[ "$ContPath" == "null" ]] && ContPath=""
ContEnv=$($jqbin -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels") ContConfigFile=$($jqbin -r '."com.docker.compose.project.config_files"' <<< "$ContLabels")
[[ "$ContEnv" == "null" ]] && ContEnv="" [[ "$ContConfigFile" == "null" ]] && ContConfigFile=""
ContUpdateLabel=$($jqbin -r '."mag37.dockcheck.update"' <<< "$ContLabels") ContName=$($jqbin -r '."com.docker.compose.service"' <<< "$ContLabels")
[[ "$ContUpdateLabel" == "null" ]] && ContUpdateLabel="" [[ "$ContName" == "null" ]] && ContName=""
ContRestartStack=$($jqbin -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels") ContEnv=$($jqbin -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels")
[[ "$ContRestartStack" == "null" ]] && ContRestartStack="" [[ "$ContEnv" == "null" ]] && ContEnv=""
ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels") ContRestartStack=$($jqbin -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
[[ "$ContOnlySpecific" == "null" ]] && ContRestartStack="" [[ "$ContRestartStack" == "null" ]] && ContRestartStack=""
ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels")
[[ "$ContOnlySpecific" == "null" ]] && ContRestartStack=""
printf "\n%bNow recreating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset" printf "\n%bNow recreating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
# Checking if compose-values are empty - hence started with docker run # Checking if compose-values are empty - hence started with docker run
[[ -z "$ContPath" ]] && { echo "Not a compose container, skipping."; continue; } [[ -z "$ContPath" ]] && { echo "Not a compose container, skipping."; continue; }
# Checking if Label Only -option is set, and if container got the label
[[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "No update label, skipping."; continue; } }
# cd to the compose-file directory to account for people who use relative volumes # cd to the compose-file directory to account for people who use relative volumes
cd "$ContPath" || { printf "\n%bPath error - skipping%b %s" "$c_red" "$c_reset" "$i"; continue; } cd "$ContPath" || { printf "\n%bPath error - skipping%b %s" "$c_red" "$c_reset" "$i"; continue; }
## Reformatting path + multi compose ## Reformatting path + multi compose
if [[ $ContConfigFile == '/'* ]]; then if [[ $ContConfigFile == '/'* ]]; then
CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s " "$conf"; done) CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s " "$conf"; done)
else else
CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s/%s " "$ContPath" "$conf"; done) CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s/%s " "$ContPath" "$conf"; done)
fi fi
# Check if the container got an environment file set and reformat it # Check if the container got an environment file set and reformat it
ContEnvs="" ContEnvs=""
if [[ -n "$ContEnv" ]]; then ContEnvs=$(for env in ${ContEnv//,/ }; do printf -- "--env-file %s " "$env"; done); fi if [[ -n "$ContEnv" ]]; then ContEnvs=$(for env in ${ContEnv//,/ }; do printf -- "--env-file %s " "$env"; done); fi
# Set variable when compose up should only target the specific container, not the stack # Set variable when compose up should only target the specific container, not the stack
if [[ $OnlySpecific == true ]] || [[ $ContOnlySpecific == true ]]; then SpecificContainer="$ContName"; fi if [[ $OnlySpecific == true ]] || [[ $ContOnlySpecific == true ]]; then SpecificContainer="$ContName"; fi
# Check if the whole stack should be restarted # Check if the whole stack should be restarted
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]]; then if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]]; then
${DockerBin} ${CompleteConfs} stop; ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; } ${DockerBin} ${CompleteConfs} stop; ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
else else
${DockerBin} ${CompleteConfs} ${ContEnvs} up -d ${SpecificContainer} || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; } ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d ${SpecificContainer} || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
fi fi
done done
if [[ "$AutoPrune" == false ]] && [[ "$AutoMode" == false ]]; then printf "\n"; read -rep "Would you like to prune dangling images? y/[n]: " AutoPrune; fi fi
if [[ "$AutoPrune" == false ]] && [[ "$AutoMode" == false ]]; then printf "\n"; read -rep "Would you like to prune all dangling images? y/[n]: " AutoPrune; fi
if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then printf "\nAuto pruning.."; docker image prune -f; fi if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then printf "\nAuto pruning.."; docker image prune -f; fi
printf "\n%bAll done!%b\n" "$c_green" "$c_reset" printf "\n%bAll done!%b\n" "$c_green" "$c_reset"
else else

View File

@@ -38,35 +38,15 @@ You can also use the [caronc/apprise-api](https://github.com/caronc/apprise-api)
### Customize the **notify.sh** file. ### Customize the **notify.sh** file.
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. 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).
Briefly: Copy `default.config` to `dockcheck.config` then edit it to change the following, `APPRISE_URL` matching your environment:
Comment out/remove the bare metal apprise-command (starting with `apprise -vv -t...`).
Uncomment and edit the `AppriseURL` variable and *curl* line
It should look something like this when curling the API:
```bash ```bash
send_notification() { NOTIFY_CHANNELS="apprise"
Updates=("$@") APPRISE_URL="http://apprise.mydomain.tld:1234/notify/apprise"
UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname)
printf "\nSending Apprise notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
read -d '\n' MessageBody << __EOF
Containers on $FromHost with updates available:
$UpdToString
__EOF
AppriseURL="http://IP.or.mydomain.tld:8000/notify/apprise"
curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL
}
``` ```
That's all! That's it!
___ ___
___ ___