check_ssh.sh: some minor changes to script output (add color if running in a terminal).

This commit is contained in:
Christoph 2021-01-11 16:54:54 +01:00
parent 795c4915d8
commit 92e597f3d2

View File

@ -15,9 +15,17 @@ LOCK_DIR=`mktemp -d`
fatal(){ fatal(){
echo "" echo ""
echo -e " [ Fatal ] $*" if $terminal ; then
echo -e " [ \033[31m\033[1mFatal\033[m ] $*"
else
echo -e " [ Fatal ] $*"
fi
echo "" echo ""
echo -e "\tScript terminated.." if $terminal ; then
echo -e " \033[1mScript terminated\033[m.."
else
echo -e " Script terminated.."
fi
echo "" echo ""
rm -rf $LOCK_DIR rm -rf $LOCK_DIR
exit 1 exit 1
@ -25,25 +33,41 @@ fatal(){
error (){ error (){
echo "" echo ""
echo -e " [ Error ] $*" if $terminal ; then
echo -e " [ \033[31m\033[1mError\033[m ] $*"
else
echo " [ Error ] $*"
fi
echo "" echo ""
} }
warn (){ warn (){
echo "" echo ""
echo -e " [ Warn ] $*" if $terminal ; then
echo -e " [ \033[33m\033[1mWarn\033[m ] $*"
else
echo " [ Warn ] $*"
fi
echo "" echo ""
} }
info (){ info (){
echo "" echo ""
echo -e " [ Info ] $*" if $terminal ; then
echo -e " [ \033[32m\033[1mInfo\033[m ] $*"
else
echo " [ Info ] $*"
fi
echo "" echo ""
} }
ok (){ ok (){
echo "" echo ""
echo -e " [ Ok ] $*" if $terminal ; then
echo -e " [ \033[32m\033[1mOk\033[m ] $*"
else
echo " [ Ok ] $*"
fi
echo "" echo ""
} }
@ -64,8 +88,8 @@ trim() {
# - Running in a terminal? # - Running in a terminal?
# - # -
if [[ -t 1 ]] ; then if [[ -t 1 ]] ; then
terminal=true terminal=true
LOGGING=true LOGGING=true
else else
terminal=false terminal=false
LOGGING=false LOGGING=false