From 4e78e7870481cea55379a5cc75ba3b6c7ecc732f Mon Sep 17 00:00:00 2001 From: Giorgio Ravera Date: Wed, 10 Nov 2021 18:09:24 +0100 Subject: [PATCH] Added script to force update --- watchtower/force.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 watchtower/force.sh diff --git a/watchtower/force.sh b/watchtower/force.sh new file mode 100755 index 0000000..b35d1b2 --- /dev/null +++ b/watchtower/force.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +NAME=watchtower_check + +function usage () +{ + echo "Usage: $NAME " + echo "Run watchtower standonle to check container update" + echo + echo "Example: $NAME" + echo " or: $NAME -n" + echo " or: $NAME --notifications" + echo + echo "Arguments:" + echo " 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 $@ -- 2.47.3