backuppc_client/client/install_backuppc_windows_ba...

77 lines
2.0 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"
# }}}
2019-05-06 15:39:17 +02:00
# Variable {{{
## Valeur de fin
SUCCESS=0
ERROR=1
2019-05-06 15:39:17 +02:00
## 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'
## }}}
# }}}
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
2019-05-06 15:39:17 +02:00
printf '%b\n' "${BOLD}openssh-server non installé, tentative d'installation.${RESET}\\n"
2019-05-06 15:29:02 +02:00
2019-05-06 15:48:16 +02:00
if [ $(command -v aptitude) ]; then aptitude install -y --quiet=5 -- openssh-server > /dev/null
elif [ $(command -v apt) ]; then apt install -y openssh-server > /dev/null
2019-05-06 15:29:02 +02:00
elif [ $(command -v yum) ]; then yum install -y openssh-server
elif [ $(command -v zypper) ]; then zypper install -y openssh-server
else
2019-05-06 15:39:17 +02:00
printf '%b' "${REDB}Merci dinstaller openssh-server sur votre machine, installation annulée.${RESET}\\n"
2019-05-06 15:29:02 +02:00
return "$ERROR"
fi
fi
}
## }}}
# }}}
# Gestion des paquets {{{
## Mettre à jour les dépôts
2019-05-06 15:48:16 +02:00
apt update -- > /dev/null 2>&1
## 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
2019-05-06 15:48:16 +02:00
apt install -y -- aptitude > /dev/null 2>&1
## Mettre à jour le système
2019-05-06 15:48:16 +02:00
aptitude full-upgrade -y --quiet=5 > /dev/null
# }}}
2019-05-06 15:29:02 +02:00
# Gestion de SSH {{{
ensureSshdIsInstalled
if [ "$?" != "${SUCCESS}" ]; then
2019-05-06 15:39:17 +02:00
printf '%b' "${REDB}L'installation du serveur ssh a échoué, installation annulée.${RESET}\\n"
2019-05-06 15:29:02 +02:00
exit "${ERROR}"
fi
2019-05-06 15:29:02 +02:00
# }}}
exit "${SUCCESS}"