From 63323685ccf4e4cd9691f3a96a9da6b54ba702da Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Wed, 14 Sep 2022 11:29:46 +0200 Subject: [PATCH] bring back up and down scripts --- scripts/portal-down.sh | 37 +++++++++++++++++++++++++++++++++++++ scripts/portal-up.sh | 6 ++++++ 2 files changed, 43 insertions(+) create mode 100755 scripts/portal-down.sh create mode 100755 scripts/portal-up.sh diff --git a/scripts/portal-down.sh b/scripts/portal-down.sh new file mode 100755 index 00000000..476ce837 --- /dev/null +++ b/scripts/portal-down.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e # exit on first error + +while getopts d:t:r: flag +do + case "${flag}" in + d) delay=${OPTARG};; + t) timeout=${OPTARG};; + r) reason=${OPTARG};; + esac +done +delay=${delay:-0} # default to no delay +timeout=${timeout:-300} # default timeout is 300s + +if [[ -z $reason ]]; then + echo "Please provide a reason for disabling the portal (use '-r ')." + exit 1 +fi + +countdown() { + local secs=$1 + while [ $secs -gt 0 ]; do + echo -ne "Waiting $secs\033[0K\r" + sleep 1 + : $((secs--)) + done +} + +# delay disabling the portal +countdown $delay + +# stop health-check so the server is taken our of load balancer +docker exec health-check cli disable $reason + +# then wait 5 minutes for the load balancer to propagate the dns records +countdown $timeout diff --git a/scripts/portal-up.sh b/scripts/portal-up.sh new file mode 100755 index 00000000..fcd7fe80 --- /dev/null +++ b/scripts/portal-up.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e # exit on first error + +# start the health-checks service +docker exec health-check cli enable