From 5676fca64490fbb567840ae640c12ec5983f9622 Mon Sep 17 00:00:00 2001 From: hhf Date: Sun, 22 Dec 2024 22:14:35 +0530 Subject: [PATCH] Add DockerUtilities/ContainerTools --- DockerUtilities/ContainerTools | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 DockerUtilities/ContainerTools diff --git a/DockerUtilities/ContainerTools b/DockerUtilities/ContainerTools new file mode 100644 index 0000000..4dd2727 --- /dev/null +++ b/DockerUtilities/ContainerTools @@ -0,0 +1,25 @@ +#!/usr/bin/bash + +# Receive inputs, either single- or multi-line, and print them cleanly to the Docker logfile +function log () { + if [ -n "$@" ]; then + readarray -t input <<< "$@" + printf "[$SNAME] %s\n" "${input[@]}" + fi +} + +# Test the given container variable against variations of true/false, then return a single format usable by scripts +isEnabled() { + case "${1,,}" in + f|false|n|no|0|off) + false + ;; + t|true|y|yes|1|on) + true + ;; + *) + log "ERROR: Input value '$1' was not expected. Please check the accepted inputs" + exit 1 + esac + return +}