From: Frank Brehm Date: Thu, 25 Jun 2020 16:21:05 +0000 (+0200) Subject: Adding bin/waitfor X-Git-Tag: 2.1.2^2~7^2~4 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=95f1260b0096ab7ce2e922469bb63b7e7e77fb87;p=pixelpark%2Fcreate-vmware-tpl.git Adding bin/waitfor --- diff --git a/bin/waitfor b/bin/waitfor new file mode 100755 index 0000000..a6ebf9e --- /dev/null +++ b/bin/waitfor @@ -0,0 +1,51 @@ +#!/bin/bash + +set -e +set -u + +BASENAME=$(basename "${0}" ) + +#------------------------------------------------------------------------------ +usage() { + + cat <<-EOF + Usage: ${BASENAME} SECONDS_TO_WAIT [SECONDS_POINT_INTERVAL] + + EOF + +} + +if [[ "$#" -le "0" ]] ; then + echo "No seconds to wait for given." >&2 + echo + usage >&2 + exit 1 +fi + +WAIT_SECONDS="$1" +WAIT_INTERVAL="3" +# LINE_LEN=80 + +if [[ "$#" -gt 2 ]] ; then + WAIT_INTERVAL="$2" +fi + +printf "Waiting for %d seconds ...\n" "${WAIT_SECONDS}" +i=0 +ticks=0 + +while [[ "$i" -lt "${WAIT_SECONDS}" ]] ; do + i_modulus=$(( $i % ${WAIT_INTERVAL} )) + i=$(( $i + 1 )) + if [[ "${i_modulus}" == "0" ]] ; then + printf "." + fi + sleep 1 +done +echo +echo "Continuing ..." + + +exit 0 + +# vim: ts=4 list