mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 10:27:54 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d80fba750f | ||
|
|
7ce523c37d | ||
|
|
8e444a688f | ||
|
|
ba107a424f | ||
|
|
e4b5aaeb9d |
22
README.md
22
README.md
@@ -20,10 +20,15 @@
|
|||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
|
- **v0.6.4**: Restructured the update process - first pulls all updates, then recreates all containers.
|
||||||
|
- Added logic to skip update check on non-compose containers (unless `-r` option).
|
||||||
|
- Added option `-F` to revert to `compose up -d <ContainerName>` targeting specific container and not the stack.
|
||||||
|
- Also added corresponding label and config-option.
|
||||||
|
- Added markdown formatting to `notify_ntfy-sh.sh` template.
|
||||||
- **v0.6.3**: Some fixes and changes:
|
- **v0.6.3**: Some fixes and changes:
|
||||||
- Stops when a container recreation (compose up -d) fails, also `up`s the whole stack now.
|
- Stops when a container recreation (compose up -d) fails, also `up`s the whole stack now.
|
||||||
- `-M`, Markdown format url-releasenotes in notification (requires template rework, look at gotify!)
|
- `-M`, Markdown format url-releasenotes in notification (requires template rework, look at gotify!)
|
||||||
- Added [addons/DSM/README.md](./addons/DSM/README.md) added for more info Synology DSM info.
|
- Added [addons/DSM/README.md](./addons/DSM/README.md) for more info Synology DSM info.
|
||||||
- Permission checks - graceful exit if no docker permissions + checking if root for pkg-manager.
|
- Permission checks - graceful exit if no docker permissions + checking if root for pkg-manager.
|
||||||
- **v0.6.2**: Style and colour changes, prometheus hotfix, new options:
|
- **v0.6.2**: Style and colour changes, prometheus hotfix, new options:
|
||||||
- `-u`, Allow auto self update of dockcheck.sh
|
- `-u`, Allow auto self update of dockcheck.sh
|
||||||
@@ -33,11 +38,6 @@ ___
|
|||||||
- xargs/pipefail, removed `-set -e` bash option for now.
|
- xargs/pipefail, removed `-set -e` bash option for now.
|
||||||
- unbound variables fixed (hopefully)
|
- unbound variables fixed (hopefully)
|
||||||
- dependency installer from pkgmanager rewritten
|
- dependency installer from pkgmanager rewritten
|
||||||
- **v0.6.0**: Refactored a lot of code, cleaner logic and syntax, safer variables.
|
|
||||||
- Safer bash options with `set -euo pipefail`, `shopt -s nullglob` and `failglob`.
|
|
||||||
- Added a `default.conf` for user settings - persistent through updates.
|
|
||||||
- Added `notify_slack.sh` template for slack curl api.
|
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +54,8 @@ Options:
|
|||||||
-c D Exports metrics as prom file for the prometheus node_exporter. Provide the collector textfile directory.
|
-c D Exports metrics as prom file for the prometheus node_exporter. Provide the collector textfile directory.
|
||||||
-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower.
|
-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower.
|
||||||
-e X Exclude containers, separated by comma.
|
-e X Exclude containers, separated by comma.
|
||||||
-f Force stack restart after update. Caution: restarts once for every updated container within stack.
|
-f Force stop+start stack after update. Caution: restarts once for every updated container within stack.
|
||||||
|
-F Only compose up the specific container, not the whole compose stack (useful for master-compose structure).
|
||||||
-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 (requires urls.list).
|
-I Prints custom releasenote urls alongside each container with updates (requires urls.list).
|
||||||
@@ -204,11 +205,13 @@ See [discussion here](https://github.com/mag37/dockcheck/discussions/145).
|
|||||||
Optionally add labels to compose-files. Currently these are the usable labels:
|
Optionally add labels to compose-files. Currently these are the usable labels:
|
||||||
```
|
```
|
||||||
labels:
|
labels:
|
||||||
mag37.dockcheck.restart-stack: true
|
|
||||||
mag37.dockcheck.update: true
|
mag37.dockcheck.update: true
|
||||||
|
mag37.dockcheck.only-specific-container: true
|
||||||
|
mag37.dockcheck.restart-stack: true
|
||||||
```
|
```
|
||||||
- `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.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 update containers with this label and skip the rest. Will still list updates as usual.
|
||||||
|
- `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).
|
||||||
|
|
||||||
## :roller_coaster: Workaround for non **amd64** / **arm64**
|
## :roller_coaster: 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.
|
||||||
@@ -269,6 +272,7 @@ dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/l
|
|||||||
|
|
||||||
- [avegy](https://github.com/avegy)
|
- [avegy](https://github.com/avegy)
|
||||||
- [eichhorn](https://github.com/eichhorn)
|
- [eichhorn](https://github.com/eichhorn)
|
||||||
|
- [stepdg](https://github.com/stepdg)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,9 @@
|
|||||||
#DaysOld="5" # Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower.
|
#DaysOld="5" # Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower.
|
||||||
#Stopped="-a" # Include stopped containers in the check. (Logic: docker ps -a).
|
#Stopped="-a" # Include stopped containers in the check. (Logic: docker ps -a).
|
||||||
#OnlyLabel=true # Only update if label is set. See readme.
|
#OnlyLabel=true # Only update if label is set. See readme.
|
||||||
#ForceRestartStacks=true # Force stack restart after update. Caution.
|
#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.
|
||||||
#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
|
||||||
|
#OnlySpecific=true # Only compose up the specific container, not the whole compose. (useful for master-compose structure).
|
||||||
|
|||||||
94
dockcheck.sh
94
dockcheck.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.6.3"
|
VERSION="v0.6.4"
|
||||||
### ChangeNotes: Permission checks, now compose up on whole stack, -M markdown option added.
|
### ChangeNotes: Restructured update process - first pulls all images, then recreates all containers. Added -F option.
|
||||||
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"
|
||||||
|
|
||||||
@@ -34,7 +34,8 @@ Help() {
|
|||||||
echo "-c Exports metrics as prom file for the prometheus node_exporter. Provide the collector textfile directory."
|
echo "-c Exports metrics as prom file for the prometheus node_exporter. Provide the collector textfile directory."
|
||||||
echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower."
|
echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower."
|
||||||
echo "-e X Exclude containers, separated by comma."
|
echo "-e X Exclude containers, separated by comma."
|
||||||
echo "-f Force stack restart after update. Caution: restarts once for every updated container within stack."
|
echo "-f Force stop+start stack after update. Caution: restarts once for every updated container within stack."
|
||||||
|
echo "-F Only compose up the specific container, not the whole compose stack (useful for master-compose structure)."
|
||||||
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 (requires urls.list)."
|
echo "-I Prints custom releasenote urls alongside each container with updates (requires urls.list)."
|
||||||
@@ -72,6 +73,8 @@ Stopped=${Stopped:=""}
|
|||||||
CollectorTextFileDirectory=${CollectorTextFileDirectory:-}
|
CollectorTextFileDirectory=${CollectorTextFileDirectory:-}
|
||||||
Exclude=${Exclude:-}
|
Exclude=${Exclude:-}
|
||||||
DaysOld=${DaysOld:-}
|
DaysOld=${DaysOld:-}
|
||||||
|
OnlySpecific=false
|
||||||
|
SpecificContainer=${SpecificContainer:=""}
|
||||||
Excludes=()
|
Excludes=()
|
||||||
GotUpdates=()
|
GotUpdates=()
|
||||||
NoUpdates=()
|
NoUpdates=()
|
||||||
@@ -88,13 +91,14 @@ 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 "ayfhiIlmMnprsuvc:e:d:t:x:" options; do
|
while getopts "ayfFhiIlmMnprsuvc:e:d:t:x:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
a|y) AutoMode=true ;;
|
a|y) AutoMode=true ;;
|
||||||
c) CollectorTextFileDirectory="${OPTARG}" ;;
|
c) CollectorTextFileDirectory="${OPTARG}" ;;
|
||||||
d) DaysOld=${OPTARG} ;;
|
d) DaysOld=${OPTARG} ;;
|
||||||
e) Exclude=${OPTARG} ;;
|
e) Exclude=${OPTARG} ;;
|
||||||
f) ForceRestartStacks=true ;;
|
f) ForceRestartStacks=true ;;
|
||||||
|
F) OnlySpecific=true ;;
|
||||||
i) Notify=true ;;
|
i) Notify=true ;;
|
||||||
I) PrintReleaseURL=true ;;
|
I) PrintReleaseURL=true ;;
|
||||||
l) OnlyLabel=true ;;
|
l) OnlyLabel=true ;;
|
||||||
@@ -195,9 +199,6 @@ choosecontainers() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
printf "\n%bUpdating container(s):%b\n" "$c_blue" "$c_reset"
|
|
||||||
printf "%s\n" "${SelectedUpdates[@]}"
|
|
||||||
printf "\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
datecheck() {
|
datecheck() {
|
||||||
@@ -256,7 +257,7 @@ binary_downloader() {
|
|||||||
GetUrl="${BinaryUrl/TEMP/"$architecture"}"
|
GetUrl="${BinaryUrl/TEMP/"$architecture"}"
|
||||||
if command -v curl &>/dev/null; then curl -L "$GetUrl" > "$ScriptWorkDir/$BinaryName";
|
if command -v curl &>/dev/null; then curl -L "$GetUrl" > "$ScriptWorkDir/$BinaryName";
|
||||||
elif command -v wget &>/dev/null; then wget "$GetUrl" -O "$ScriptWorkDir/$BinaryName";
|
elif command -v wget &>/dev/null; then wget "$GetUrl" -O "$ScriptWorkDir/$BinaryName";
|
||||||
else printf "%s\n" "curl/wget not available - get $BinaryName manually from the repo link, exiting."; exit 1;
|
else printf "\n%bcurl/wget not available - get %s manually from the repo link, exiting.%b" "$c_red" "$BinaryName" "$c_reset"; exit 1;
|
||||||
fi
|
fi
|
||||||
[[ -f "$ScriptWorkDir/$BinaryName" ]] && chmod +x "$ScriptWorkDir/$BinaryName"
|
[[ -f "$ScriptWorkDir/$BinaryName" ]] && chmod +x "$ScriptWorkDir/$BinaryName"
|
||||||
}
|
}
|
||||||
@@ -287,7 +288,7 @@ dependency_check() {
|
|||||||
if command -v "$AppName" &>/dev/null; then export "$AppVar"="$AppName";
|
if command -v "$AppName" &>/dev/null; then export "$AppVar"="$AppName";
|
||||||
elif [[ -f "$ScriptWorkDir/$AppName" ]]; then export "$AppVar"="$ScriptWorkDir/$AppName";
|
elif [[ -f "$ScriptWorkDir/$AppName" ]]; then export "$AppVar"="$ScriptWorkDir/$AppName";
|
||||||
else
|
else
|
||||||
printf "%s\n" "Required dependency %b'%s'%b missing, do you want to install it?\n" "$c_teal" "$AppName" "$c_reset"
|
printf "\nRequired dependency %b'%s'%b missing, do you want to install it?\n" "$c_teal" "$AppName" "$c_reset"
|
||||||
read -r -p "y: With packagemanager (sudo). / s: Download static binary. y/s/[n] " GetBin
|
read -r -p "y: With packagemanager (sudo). / s: Download static binary. y/s/[n] " GetBin
|
||||||
GetBin=${GetBin:-no} # set default to no if nothing is given
|
GetBin=${GetBin:-no} # set default to no if nothing is given
|
||||||
if [[ "$GetBin" =~ [yYsS] ]]; then
|
if [[ "$GetBin" =~ [yYsS] ]]; then
|
||||||
@@ -385,6 +386,15 @@ check_image() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Skipping non-compose containers unless option is set
|
||||||
|
ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}')
|
||||||
|
ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
|
||||||
|
[[ "$ContPath" == "null" ]] && ContPath=""
|
||||||
|
if [[ -z "$ContPath" ]] && [[ "$DRunUp" == false ]]; then
|
||||||
|
printf "%s\n" "NoUpdates !$i - not checked, no compose file"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
local NoUpdates GotUpdates GotErrors
|
local NoUpdates GotUpdates GotErrors
|
||||||
ImageId=$(docker inspect "$i" --format='{{.Image}}')
|
ImageId=$(docker inspect "$i" --format='{{.Image}}')
|
||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
@@ -409,7 +419,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
|
export t_out regbin RepoUrl DaysOld DRunUp jqbin
|
||||||
|
|
||||||
# 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
|
||||||
@@ -471,7 +481,7 @@ if [[ -n ${GotUpdates[*]:-} ]]; then
|
|||||||
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
|
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
|
||||||
if [[ -s "$ScriptWorkDir/urls.list" ]] && [[ "$PrintReleaseURL" == true ]]; then releasenotes; else Updates=("${GotUpdates[@]}"); fi
|
if [[ -s "$ScriptWorkDir/urls.list" ]] && [[ "$PrintReleaseURL" == true ]]; then releasenotes; else Updates=("${GotUpdates[@]}"); fi
|
||||||
[[ "$AutoMode" == false ]] && list_options || printf "%s\n" "${Updates[@]}"
|
[[ "$AutoMode" == false ]] && list_options || printf "%s\n" "${Updates[@]}"
|
||||||
[[ "$Notify" == true ]] && { type -t send_notification &>/dev/null && send_notification "${GotUpdates[@]}" || printf "Could not source notification function.\n"; }
|
[[ "$Notify" == true ]] && { type -t send_notification &>/dev/null && send_notification "${GotUpdates[@]}" || printf "\nCould not source notification function.\n"; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Optionally get updates if there's any
|
# Optionally get updates if there's any
|
||||||
@@ -483,10 +493,41 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
|||||||
SelectedUpdates=( "${GotUpdates[@]}" )
|
SelectedUpdates=( "${GotUpdates[@]}" )
|
||||||
fi
|
fi
|
||||||
if [[ "$DontUpdate" == false ]]; then
|
if [[ "$DontUpdate" == false ]]; then
|
||||||
|
printf "\n%bUpdating container(s):%b\n" "$c_blue" "$c_reset"
|
||||||
|
printf "%s\n" "${SelectedUpdates[@]}"
|
||||||
|
|
||||||
NumberofUpdates="${#SelectedUpdates[@]}"
|
NumberofUpdates="${#SelectedUpdates[@]}"
|
||||||
|
|
||||||
CurrentQue=0
|
CurrentQue=0
|
||||||
for i in "${SelectedUpdates[@]}"
|
for i in "${SelectedUpdates[@]}"; do
|
||||||
do
|
((CurrentQue+=1))
|
||||||
|
printf "\n%bNow updating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
|
||||||
|
ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}')
|
||||||
|
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
|
ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
|
||||||
|
[[ "$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
|
||||||
|
if [[ -z "$ContPath" ]]; then
|
||||||
|
if [[ "$DRunUp" == true ]]; then
|
||||||
|
docker pull "$ContImage"
|
||||||
|
printf "%s\n" "$i got a new image downloaded, rebuild manually with preferred 'docker run'-parameters"
|
||||||
|
else
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker pull "$ContImage" || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
|
||||||
|
done
|
||||||
|
printf "\n%bDone pulling updates. %bRecreating updated containers.%b\n" "$c_green" "$c_blue" "$c_reset"
|
||||||
|
|
||||||
|
CurrentQue=0
|
||||||
|
for i in "${SelectedUpdates[@]}"; do
|
||||||
((CurrentQue+=1))
|
((CurrentQue+=1))
|
||||||
unset CompleteConfs
|
unset CompleteConfs
|
||||||
# Extract labels and metadata
|
# Extract labels and metadata
|
||||||
@@ -504,17 +545,12 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
|||||||
[[ "$ContUpdateLabel" == "null" ]] && ContUpdateLabel=""
|
[[ "$ContUpdateLabel" == "null" ]] && ContUpdateLabel=""
|
||||||
ContRestartStack=$($jqbin -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
|
ContRestartStack=$($jqbin -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
|
||||||
[[ "$ContRestartStack" == "null" ]] && ContRestartStack=""
|
[[ "$ContRestartStack" == "null" ]] && ContRestartStack=""
|
||||||
|
ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels")
|
||||||
|
[[ "$ContRestartStack" == "null" ]] && ContRestartStack=""
|
||||||
|
|
||||||
# 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
|
[[ -z "$ContPath" ]] && continue
|
||||||
if [[ "$DRunUp" == true ]]; then
|
|
||||||
docker pull "$ContImage"
|
|
||||||
printf "%s\n" "$i got a new image downloaded, rebuild manually with preferred 'docker run'-parameters"
|
|
||||||
else
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
# 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
|
||||||
@@ -523,22 +559,22 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
|||||||
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
|
||||||
printf "\n%bNow updating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
|
|
||||||
# Checking if Label Only -option is set, and if container got the label
|
|
||||||
[[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "No update label, skipping."; continue; } }
|
|
||||||
docker pull "$ContImage" || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
|
|
||||||
# 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
|
||||||
|
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
|
# 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
|
${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 || { 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
|
if [[ "$AutoPrune" == false ]] && [[ "$AutoMode" == false ]]; then printf "\n"; read -rep "Would you like to prune dangling images? y/[n]: " AutoPrune; fi
|
||||||
if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then docker image prune -f; fi
|
if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then printf "\n Auto 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
|
||||||
printf "\nNo updates installed, exiting.\n"
|
printf "\nNo updates installed, exiting.\n"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
NOTIFY_NTFYSH_VERSION="v0.1"
|
NOTIFY_NTFYSH_VERSION="v0.2"
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# Setup app and subscription at https://ntfy.sh
|
# Setup app and subscription at https://ntfy.sh
|
||||||
@@ -11,10 +11,17 @@ trigger_notification() {
|
|||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
NtfyUrl="ntfy.sh/YourUniqueTopicName"
|
NtfyUrl="ntfy.sh/YourUniqueTopicName"
|
||||||
|
|
||||||
|
if [[ "$PrintMarkdownURL" == true ]]; then
|
||||||
|
ContentType="Markdown: yes"
|
||||||
|
else
|
||||||
|
ContentType="Markdown: no" #text/plain
|
||||||
|
fi
|
||||||
|
|
||||||
curl -sS -o /dev/null --show-error --fail \
|
curl -sS -o /dev/null --show-error --fail \
|
||||||
-H "Title: $MessageTitle" \
|
-H "Title: $MessageTitle" \
|
||||||
|
-H "$ContentType" \
|
||||||
-d "$MessageBody" \
|
-d "$MessageBody" \
|
||||||
$NtfyUrl
|
"$NtfyUrl"
|
||||||
}
|
}
|
||||||
|
|
||||||
send_notification() {
|
send_notification() {
|
||||||
|
|||||||
Reference in New Issue
Block a user