Add some colors in diplayed messages
This commit is contained in:
		
							parent
							
								
									72e0dfed86
								
							
						
					
					
						commit
						a641f8b125
					
				|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue