diff --git a/docker-bench-security.sh b/docker-bench-security.sh index 0659d07..11fc412 100755 --- a/docker-bench-security.sh +++ b/docker-bench-security.sh @@ -11,7 +11,6 @@ # ------------------------------------------------------------------------------ # Load dependencies -. ./output_lib.sh . ./helper_lib.sh # Setup the paths @@ -38,6 +37,7 @@ usage () { usage: ${myname} [options] -h optional Print this help message + -m optional Disable colors in output -l PATH optional Log output in PATH EOF } @@ -45,15 +45,20 @@ EOF # Get the flags # If you add an option here, please # remember to update usage() above. -while getopts hl: args +outputlib='output_lib.sh' + +while getopts hml: args do case $args in h) usage; exit 0 ;; + m) outputlib='textout_lib.sh' ;; l) logger="$OPTARG" ;; *) usage; exit 1 ;; esac done +. ./${outputlib} + if [ -z "$logger" ]; then logger="${myname}.log" fi diff --git a/textout_lib.sh b/textout_lib.sh new file mode 100644 index 0000000..45a8836 --- /dev/null +++ b/textout_lib.sh @@ -0,0 +1,26 @@ +#!/bin/sh +bldred='' +bldgrn='' +bldblu='' +bldylw='' +txtrst='' + +logit () { + printf "%b\n" "$1" | tee -a "$logger" +} + +info () { + printf "%b\n" "${bldblu}[INFO]${txtrst} $1" | tee -a "$logger" +} + +pass () { + printf "%b\n" "${bldgrn}[PASS]${txtrst} $1" | tee -a "$logger" +} + +warn () { + printf "%b\n" "${bldred}[WARN]${txtrst} $1" | tee -a "$logger" +} + +yell () { + printf "%b\n" "${bldylw}$1${txtrst}\n" +}