Ensure to install sshd
This commit is contained in:
parent
13e44b6661
commit
72e0dfed86
|
@ -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}"
|
||||
|
|
Loading…
Reference in New Issue