From 72e0dfed8669ba2ce3174ff82e41e6c8c8f2f4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 6 May 2019 15:29:02 +0200 Subject: [PATCH] Ensure to install sshd --- .../install_backuppc_windows_bash_on_linux.sh | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) 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}"