From a641f8b125ad6e50487f9fd9bb860e5c4cc112ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 6 May 2019 15:39:17 +0200 Subject: [PATCH] Add some colors in diplayed messages --- .../install_backuppc_windows_bash_on_linux.sh | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/client/install_backuppc_windows_bash_on_linux.sh b/client/install_backuppc_windows_bash_on_linux.sh index e1568dc..add2bbe 100755 --- a/client/install_backuppc_windows_bash_on_linux.sh +++ b/client/install_backuppc_windows_bash_on_linux.sh @@ -11,9 +11,26 @@ ## bash -c "./install_backuppc_windows_bash_on_linux.sh" # }}} +# Variable {{{ +## Valeur de fin SUCCESS=0 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 {{{ function ensureSshdIsInstalled() ## {{{ @@ -21,14 +38,14 @@ function ensureSshdIsInstalled() ## {{{ ### `command -v sshd` still return old value even after openssh-server was removed ### So we can't be sure of openssh-server state. 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 elif [ $(command -v apt) ]; then apt install -y openssh-server elif [ $(command -v yum) ]; then yum install -y openssh-server elif [ $(command -v zypper) ]; then zypper install -y openssh-server else - printf '\e[1;31m%-6s\e[m' "Merci d’installer openssh-server sur votre machine, installation annulée." + printf '%b' "${REDB}Merci d’installer openssh-server sur votre machine, installation annulée.${RESET}\\n" return "$ERROR" fi fi @@ -52,7 +69,7 @@ aptitude full-upgrade -y # Gestion de SSH {{{ ensureSshdIsInstalled 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}" fi