]> git.giorgioravera.it Git - docker.git/commitdiff
Added script to force update
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Wed, 10 Nov 2021 17:09:24 +0000 (18:09 +0100)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Wed, 10 Nov 2021 17:09:24 +0000 (18:09 +0100)
watchtower/force.sh [new file with mode: 0755]

diff --git a/watchtower/force.sh b/watchtower/force.sh
new file mode 100755 (executable)
index 0000000..b35d1b2
--- /dev/null
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+NAME=watchtower_check
+
+function usage ()
+{
+  echo "Usage:    $NAME <arguments>"
+  echo "Run watchtower standonle to check container update"
+  echo
+  echo "Example:  $NAME"
+  echo "     or:  $NAME -n"
+  echo "     or:  $NAME --notifications"
+  echo
+  echo "Arguments:"
+  echo "    <no arguments>        Run without sending email notifications"
+  echo "    -n, --notifications   Run sending email notifications"
+}
+
+function parse_options ()
+{
+       # Check Options
+       OPT=$(getopt -o nh --long notifications,help -n "$NAME parse-error" -- "$@")
+       # Bad arguments
+       if [ $? -ne 0 ]; then
+               usage
+       fi
+
+       # No Arguments
+       if [ $# -eq 0 ]; then
+               run_without_notifications
+       fi
+
+       eval set -- "$OPT"
+
+       # Parse Options
+       while [ $# -gt 0 ]; do
+               case $1 in
+                       -n | --notifications )
+                               run_with_notifications
+                               shift
+                               ;;
+                       -h | --help )
+                               usage
+                               shift
+                               ;;
+                       * ) shift ;;
+               esac
+       done
+}
+
+run_without_notifications()
+{
+       docker run --rm \
+                       -v /var/run/docker.sock:/var/run/docker.sock \
+                       containrrr/watchtower \
+                               --cleanup \
+                               --run-once \
+                               --no-startup-message
+}
+
+run_with_notifications()
+{
+       docker run --rm \
+                       -v /var/run/docker.sock:/var/run/docker.sock \
+                       containrrr/watchtower \
+                               --cleanup \
+                               --run-once \
+                               --no-startup-message \
+                               --notifications=email \
+                               --notification-email-from=docker@giorgioravera.it \
+                               --notification-email-to=giorgio.ravera@gmail.com \
+                               --notification-email-server=mail.giorgioravera.it
+}
+
+parse_options $@