feat: Color output in terminal if running in TTY

This commit is contained in:
Gerald Pinder 2024-08-30 23:18:20 -04:00
parent 54c35a870f
commit 74d99f2b17
7 changed files with 58 additions and 3 deletions

View file

@ -6,7 +6,7 @@ source /tmp/scripts/exports.sh
# Function to print a centered text banner within a specified width
print_banner() {
local term_width=120
local term_width=80
local text=" ${1} " # Text to print
local padding="$(printf '%0.1s' '='{1..600})"
@ -23,7 +23,17 @@ module="$1"
params="$2"
script_path="/tmp/modules/${module}/${module}.sh"
print_banner "Start '${module}' Module"
color_string "$(print_banner "Start '${module}' Module")" "33"
chmod +x ${script_path}
set +e
${script_path} "${params}"
print_banner "End '${module}' Module"
RETVAL=$?
set -e
if [ $RETVAL ]; then
color_string "$(print_banner "End '${module}' Module")" "32"
else
color_string "$(print_banner "Failed '${module}' Module")" "31"
exit 1
fi