Label bugfix, search filtering fix (#216)

* search filtering fix
* skip recreation if no label when -l option used + clarification
* changed readme + help to correctly show help example
This commit is contained in:
mag37 2025-07-25 10:35:49 +02:00 committed by GitHub
parent 31bb2008b9
commit 563dbb8b42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 21 deletions

View file

@ -22,6 +22,10 @@
___
## :bell: Changelog
- **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
@ -30,20 +34,6 @@ ___
- Added configurable default curl arguments
- Consolidated and standardized notify template update notifications
- Added curl error handling
- **v0.6.6**: Notify_v2 bugfixes
- Clearer readme and error messages
- Sourcing templates from either project root or subdirectory
- Consistent newline handling
- Added (when using `-d`) days old message to notification title
- Added ntfy self hosted domain option to config
- jq fixes to templates (and properly using $jqbin)
- **v0.6.5**: Refactored notification logic. See notify_templates/notify_v2.sh for upgrade steps.
- Added helper functions to simplify sourcing files and executing functions if they exist.
- Created notify_v2.sh wrapper script.
- Simplified and consolidated notification logic within notify_v2.sh.
- Added support for notification management via environment variables.
- Moved notification secrets to **dockcheck.config**.
- Added retries to wget/curl to not get empty responses when github is slow.
___
@ -52,7 +42,7 @@ ___
## :mag_right: `dockcheck.sh`
```
$ ./dockcheck.sh -h
Syntax: dockcheck.sh [OPTION] [part of name to filter]
Syntax: dockcheck.sh [OPTION] [comma separated names to include]
Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall
Options:

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERSION="v0.6.8"
# ChangeNotes: bugfix unbound variable in notify_v2, new option "DisplaySourcedFiles" added to config
VERSION="v0.6.9"
# ChangeNotes: bugfix label logic and added comma separated search filtering
Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
@ -29,7 +29,7 @@ source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists_
# Help Function
Help() {
echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]"
echo "Syntax: dockcheck.sh [OPTION] [comma separated names to include]"
echo "Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall"
echo
echo "Options:"
@ -121,8 +121,11 @@ while getopts "ayfFhiIlmMnprsuvc:e:d:t:x:" options; do
done
shift "$((OPTIND-1))"
# Set $1 to a variable for name filtering later
# Set $1 to a variable for name filtering later, rewriting if multiple
SearchName="${1:-}"
if [[ ! -z "$SearchName" ]]; then
SearchName="^(${SearchName//,/|})$"
fi
# Check if there's a new release of the script
LatestSnippet="$(curl ${CurlArgs} -r 0-200 "$RawUrl" || printf "undefined")"
@ -570,8 +573,11 @@ if [[ -n "${GotUpdates:-}" ]]; then
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"
# Checking if compose-values are empty - hence started with docker run
[[ -z "$ContPath" ]] && 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 "$ContPath" || { printf "\n%bPath error - skipping%b %s" "$c_red" "$c_reset" "$i"; continue; }
@ -587,7 +593,6 @@ if [[ -n "${GotUpdates:-}" ]]; then
# Set variable when compose up should only target the specific container, not the stack
if [[ $OnlySpecific == true ]] || [[ $ContOnlySpecific == true ]]; then SpecificContainer="$ContName"; fi
printf "\n%bNow recreating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
# Check if the whole stack should be restarted
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; }