diff --git a/DockerUtilities/ContainerTools b/DockerUtilities/bash/ContainerTools similarity index 100% rename from DockerUtilities/ContainerTools rename to DockerUtilities/bash/ContainerTools diff --git a/DockerUtilities/sh/ContainerTools b/DockerUtilities/sh/ContainerTools new file mode 100644 index 0000000..90ef90d --- /dev/null +++ b/DockerUtilities/sh/ContainerTools @@ -0,0 +1,28 @@ +#!/usr/bin/sh + +# Receive inputs, either single- or multi-line, and print them cleanly to the Docker logfile +log() { + if [ -n "$*" ]; then + input="$*" + echo "$input" | while IFS= read -r line; do + printf "[$SNAME] %s\n" "$line" + done + fi +} + +# Test the given container variable against variations of true/false, then return a single format usable by scripts +isEnabled() { + case "$(echo "$1" | tr '[:upper:]' '[:lower:]')" 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 +}