Add some colors in diplayed messages

This commit is contained in:
Jeremy Gardais 2019-05-06 15:39:17 +02:00
parent 72e0dfed86
commit a641f8b125
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 20 additions and 3 deletions

View File

@ -11,9 +11,26 @@
## bash -c "./install_backuppc_windows_bash_on_linux.sh" ## bash -c "./install_backuppc_windows_bash_on_linux.sh"
# }}} # }}}
# Variable {{{
## Valeur de fin
SUCCESS=0 SUCCESS=0
ERROR=1 ERROR=1
## Couleur {{{
BLACK='\033[49;30m'
BLACKB='\033[49;90m'
RED='\033[0;31m'
REDB='\033[1;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[94;49m'
MAGENTA='\033[0;35m'
CYAN='\033[36;49m'
WHITE='\033[0;37m'
BOLD='\033[1m'
RESET='\033[0m'
## }}}
# }}}
# Fonctions {{{ # Fonctions {{{
function ensureSshdIsInstalled() ## {{{ function ensureSshdIsInstalled() ## {{{
@ -21,14 +38,14 @@ function ensureSshdIsInstalled() ## {{{
### `command -v sshd` still return old value even after openssh-server was removed ### `command -v sshd` still return old value even after openssh-server was removed
### So we can't be sure of openssh-server state. ### So we can't be sure of openssh-server state.
if ! hash sshd 2>/dev/null; then if ! hash sshd 2>/dev/null; then
printf '%b\n' "openssh-server non installé, tentative d'installation." printf '%b\n' "${BOLD}openssh-server non installé, tentative d'installation.${RESET}\\n"
if [ $(command -v aptitude) ]; then aptitude install -y openssh-server if [ $(command -v aptitude) ]; then aptitude install -y openssh-server
elif [ $(command -v apt) ]; then apt install -y openssh-server elif [ $(command -v apt) ]; then apt install -y openssh-server
elif [ $(command -v yum) ]; then yum install -y openssh-server elif [ $(command -v yum) ]; then yum install -y openssh-server
elif [ $(command -v zypper) ]; then zypper install -y openssh-server elif [ $(command -v zypper) ]; then zypper install -y openssh-server
else else
printf '\e[1;31m%-6s\e[m' "Merci dinstaller openssh-server sur votre machine, installation annulée." printf '%b' "${REDB}Merci dinstaller openssh-server sur votre machine, installation annulée.${RESET}\\n"
return "$ERROR" return "$ERROR"
fi fi
fi fi
@ -52,7 +69,7 @@ aptitude full-upgrade -y
# Gestion de SSH {{{ # Gestion de SSH {{{
ensureSshdIsInstalled ensureSshdIsInstalled
if [ "$?" != "${SUCCESS}" ]; then if [ "$?" != "${SUCCESS}" ]; then
printf '\e[1;31m%-6s\e[m' "L'installation du serveur ssh a échoué, installation annulée." printf '%b' "${REDB}L'installation du serveur ssh a échoué, installation annulée.${RESET}\\n"
exit "${ERROR}" exit "${ERROR}"
fi fi