backuppc_client/client/install_backuppc_windows_ba...

61 lines
1.6 KiB
Bash
Raw Normal View History

#!/bin/bash
# Automatisation d'installation et configuration de BackupPC pour Windows 10 {{{
# via Bash on Ubuntu
# Institut de Physique de Rennes UMR6251
# Jérémy Gardais Mail 2019
# }}}
# How-to use {{{
# With PowerShell
## This script can be launch with PowerShell:
## bash -c "./install_backuppc_windows_bash_on_linux.sh"
# }}}
SUCCESS=0
ERROR=1
2019-05-06 15:29:02 +02:00
# 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 dinstaller openssh-server sur votre machine, installation annulée."
return "$ERROR"
fi
fi
}
## }}}
# }}}
# Gestion des paquets {{{
## Mettre à jour les dépôts
apt update
## Installer aptitude
### aptitude permet une meilleure résolution des dépendances/erreurs/... que apt
### apt-get est déprécié au profit de apt ou aptitude
apt install -y aptitude
## Mettre à jour le système
aptitude full-upgrade -y
# }}}
2019-05-06 15:29:02 +02:00
# 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
2019-05-06 15:29:02 +02:00
# }}}
exit "${SUCCESS}"