Added option -i

This commit is contained in:
mag37
2024-01-06 00:11:33 +01:00
parent 3053304356
commit 47ebb75691
2 changed files with 15 additions and 12 deletions

View File

@ -16,7 +16,7 @@
### :bell: Recent changes
- **v0.3.3**: Notification tweaks, added Apprise template.
- **v0.3.3**: Added Apprise template and the option `-i` inform - to send notifications.
- **v0.3.2**: Added a notify function to wrap a notify-script, currently DSM/Ssmtp + template script.
- **v0.3.1**: Addded option `-m` , monochrome mode - no printf color codes.
- **v0.3.0**: Added option `-d N`, age (days) new images have to be before being pulled and updated.
@ -43,18 +43,20 @@ ___
## `dockcheck.sh`
```
$ ./dockcheck.sh -h
Syntax: dockcheck.sh [OPTION] [part of name to filter]
Syntax: dockcheck.sh [OPTION] [part of name to filter]
Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall
Options:
-h Print this Help.
-a|y Automatic updates, without interaction.
-n No updates, only checking availability.
-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.
-d N Only update to new images that are N+ days old. Lists too recent with +prefix. 2xSlower.
-h Print this Help.
-i Inform - send a preconfigured notification.
-m Monochrome mode, no printf color codes.
-n No updates, only checking availability.
-p Auto-Prune dangling images after update.
-r Allow updating images for docker run, wont update the container.
-s Include stopped containers in the check. (Logic: docker ps -a).
-s Include stopped containers in the check. (Logic: docker ps -a)
```
Basic example:
@ -77,6 +79,7 @@ Then it proceedes to run `pull` and `up -d` on every container with updates.
After the updates are complete, you'll get prompted if you'd like to prune dangling images.
### :loudspeaker: Notifications
Trigger with the `-i` flag.
Use a `notify_X.sh` template file, copy it to `notify.sh`, modify it to your needs!
Current templates:

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERSION="v0.3.2"
### ChangeNotes: Added a notify function - template and email script (DSM etc)
VERSION="v0.3.3"
### ChangeNotes: Added option -i, inform - notify. Added Appraise template.
Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
@ -14,7 +14,6 @@ ScriptWorkDir="$(dirname "$ScriptPath")"
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")"
[ -s $ScriptWorkDir/notify.sh ] && source $ScriptWorkDir/notify.sh
### Help Function:
Help() {
@ -26,6 +25,7 @@ Help() {
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 "-h Print this Help."
echo "-i Inform - send a preconfigured notification."
echo "-m Monochrome mode, no printf color codes."
echo "-n No updates, only checking availability."
echo "-p Auto-Prune dangling images after update."
@ -41,14 +41,14 @@ c_blue="\033[0;34m"
c_teal="\033[0;36m"
c_reset="\033[0m"
Stopped=""
while getopts "aynprhsme:d:" options; do
while getopts "aynprhisme:d:" options; do
case "${options}" in
a|y) AutoUp="yes" ;;
n) AutoUp="no" ;;
r) DRunUp="yes" ;;
p) AutoPrune="yes" ;;
i) [ -s $ScriptWorkDir/notify.sh ] && { source $ScriptWorkDir/notify.sh ; Notify="yes" ; } ;;
e) Exclude=${OPTARG} ;;
m) declare c_{red,green,yellow,blue,teal,reset}="" ;;
s) Stopped="-a" ;;
@ -234,7 +234,7 @@ fi
if [[ -n ${GotUpdates[*]} ]] ; then
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
[[ -z "$AutoUp" ]] && options || printf "%s\n" "${GotUpdates[@]}"
[[ $(type -t send_notification) == function ]] && send_notification "${GotUpdates[@]}"
[[ ! -z "$Notify" ]] && { [[ $(type -t send_notification) == function ]] && send_notification "${GotUpdates[@]}" || printf "Could not source notification function.\n" ; }
fi
### Optionally get updates if there's any