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