diff --git a/client/install_backuppc_windows_bash_on_linux.sh b/client/install_backuppc_windows_bash_on_linux.sh index 734578d..e1568dc 100755 --- a/client/install_backuppc_windows_bash_on_linux.sh +++ b/client/install_backuppc_windows_bash_on_linux.sh @@ -14,6 +14,29 @@ SUCCESS=0 ERROR=1 +# Fonctions {{{ + +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." + + 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." + return "$ERROR" + fi + fi +} +## }}} + +# }}} + # Gestion des paquets {{{ ## Mettre à jour les dépôts apt update @@ -26,5 +49,12 @@ apt install -y aptitude ## Mettre à jour le système 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." + exit "${ERROR}" +fi +# }}} exit "${SUCCESS}"