]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding bin/waitfor
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 25 Jun 2020 16:21:05 +0000 (18:21 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 25 Jun 2020 16:21:05 +0000 (18:21 +0200)
bin/waitfor [new file with mode: 0755]

diff --git a/bin/waitfor b/bin/waitfor
new file mode 100755 (executable)
index 0000000..a6ebf9e
--- /dev/null
@@ -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