From 6fefcbc3dd5b62eced46b7165575442c3dc0e2bb Mon Sep 17 00:00:00 2001 From: mag37 Date: Thu, 13 Nov 2025 16:30:46 +0100 Subject: [PATCH] added new variables, options and setup --- dockcheck.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index a0150df..590451b 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -42,6 +42,7 @@ Help() { echo "-h Print this Help." 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 "-k N Number of days to store image backups before pruning - this also enables the backup function." echo "-l Only include containers with label set. See readme." echo "-m Monochrome mode, no printf colour codes and hides progress bar." echo "-M Prints custom releasenote urls as markdown (requires template support)." @@ -77,6 +78,7 @@ Stopped=${Stopped:-""} CollectorTextFileDirectory=${CollectorTextFileDirectory:-} Exclude=${Exclude:-} DaysOld=${DaysOld:-} +DaysKept=${DaysKept:-} OnlySpecific=${OnlySpecific:-false} SpecificContainer=${SpecificContainer:-""} SkipRecreate=${SkipRecreate:-false} @@ -97,7 +99,7 @@ c_blue="\033[0;34m" c_teal="\033[0;36m" c_reset="\033[0m" -while getopts "ayfFhiIlmMnprsuvc:e:d:t:x:R" options; do +while getopts "ayfFhiIlmMnprsuvc:e:d:k:t:x:R" options; do case "${options}" in a|y) AutoMode=true ;; c) CollectorTextFileDirectory="${OPTARG}" ;; @@ -107,6 +109,7 @@ while getopts "ayfFhiIlmMnprsuvc:e:d:t:x:R" options; do F) OnlySpecific=true ;; i) Notify=true ;; I) PrintReleaseURL=true ;; + k) DaysKept="${OPTARG}" ;; l) OnlyLabel=true ;; m) MonoMode=true ;; M) PrintMarkdownURL=true ;; @@ -156,6 +159,12 @@ if [[ -n "$DaysOld" ]]; then exit 2 fi fi +if [[ -n "$DaysKept" ]]; then + if ! [[ $DaysKept =~ ^[0-9]+$ ]]; then + printf "-k argument given (%s) is not a number.\n" "$DaysKept" + exit 2 + fi +fi if [[ -n "$CollectorTextFileDirectory" ]]; then if ! [[ -d $CollectorTextFileDirectory ]]; then printf "The directory (%s) does not exist.\n" "$CollectorTextFileDirectory"