diff --git a/client/install_backuppc_windows_bash_on_linux.sh b/client/install_backuppc_windows_bash_on_linux.sh index d1af899..cb8c9d0 100755 --- a/client/install_backuppc_windows_bash_on_linux.sh +++ b/client/install_backuppc_windows_bash_on_linux.sh @@ -36,12 +36,31 @@ RESET='\033[0m' ## }}} # }}} # Fonctions {{{ +function getMainBackupDir() ## {{{ +{ + local input_dir + local backup_dir + + printf '%b' "${GREEN}Merci de saisir ici (copier/coller avec le clic droit), le chemin du dossier à sauvegarder :${RESET} " + read -r input_dir + + ### Transform Windows path to Unix path + backup_dir=$(wslpath "${input_dir}") + + ### Verify the directory exist + if [ ! -d "${backup_dir}" ]; then + printf '%b' "${BOLD}${input_dir} ne semble pas être un dossier. Merci de vérifier votre saisie.${RESET}\\n" + return "${ERROR}" + fi +} +## }}} + function addUserForBackuppc() ## {{{ { local userLogin="${1}" ### eg. 'backuppc' local userHomedir="${2}" ### eg. '/var/lib/backuppc' if ! getent passwd "${userLogin}" > /dev/null 2>&1; then - printf '%b\n' "${BOLD}L'utilisateur ${userLogin} n'existe pas, tentative de création.${RESET}\\n" + printf '%b' "${BOLD}L'utilisateur ${userLogin} n'existe pas, tentative de création.${RESET}\\n" useradd --system --shell /bin/sh --home-dir "${userHomedir}/" --create-home -- "${userLogin}" fi chown -R -- "${userLogin}:" "${userHomedir}" @@ -69,7 +88,7 @@ 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' "${BOLD}openssh-server non installé, tentative d'installation.${RESET}\\n" + printf '%b' "${BOLD}openssh-server non installé, tentative d'installation.${RESET}\\n" 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 @@ -91,6 +110,13 @@ function ensureSshdIsRunning() ## {{{ # }}} +# Récupération des informations de l'utilisateur {{{ +getMainBackupDir +if [ "$?" != "${SUCCESS}" ]; then + printf '%b' "${REDB}La récupération du dossier principal à sauvegarder a échouée, installation annulée.${RESET}\\n" + exit "${ERROR}" +fi +# }}} # Gestion des paquets {{{ ## Mettre à jour les dépôts apt update -- > /dev/null 2>&1