From e374edcb7463a3059a211604b32c759a13888870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 27 May 2019 13:47:53 +0200 Subject: [PATCH] Manage main directory with global var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Get value from a function doesn't want to work with bash on ubuntu on Windows 10… --- .../install_backuppc_windows_bash_on_linux.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/client/install_backuppc_windows_bash_on_linux.sh b/client/install_backuppc_windows_bash_on_linux.sh index cb8c9d0..0562a41 100755 --- a/client/install_backuppc_windows_bash_on_linux.sh +++ b/client/install_backuppc_windows_bash_on_linux.sh @@ -20,6 +20,8 @@ backuppc_user="backuppc" backuppc_homedir="/var/lib/backuppc" backuppc_sshkey="from=\"129.20.203.16\" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIhMc8ixQXfWDACJy4q0v8T877UxahhCjO51PQFzylwVpf88LX3yWeDrWIW0NRu0zoSm396mig918OpD5ggqML/QbYbQsoDdAFUV/tK4JU6UJgEQIl25MOcUBCFepsFBGS09CH/V07xSUqSP/+beeTRLNO2CQzk3S2y3YfkXpM7KmOGfeLgoCaQAcxIkgLXeM3TpCZEzJDlZ8c8k/DjVvsgwCpQktYzNo2b37KHLLfgyW9KSo6N9sReUuNQjS6lu8rjrXfc6+J0pY2D6IxWptTWL/JVrhFCUqe4QQy+xYjoR41wqnAQyl/kOcyBNhSvojMKwQT6vlPwru6pOno16/X backuppc@backuppc.ipr.univ-rennes1.fr" +user_main_backup_dir="" + ## Couleur {{{ BLACK='\033[49;30m' BLACKB='\033[49;90m' @@ -39,19 +41,24 @@ RESET='\033[0m' function getMainBackupDir() ## {{{ { local input_dir - local backup_dir + local return_value 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}") + user_main_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}" + if [ ! -d "${user_main_backup_dir}" ]; then + printf '%b' "${BOLD}${input_dir}${RESET} ne semble ${BOLD}pas${RESET} être un dossier. Merci de vérifier votre saisie.${RESET}\\n" + return_value="${ERROR}" + else + #printf '%b' "${GREEN}Le dossier à sauvegarder est : ${input_dir}.${RESET}\\n" + return_value="${SUCCESS}" fi + + return "${return_value}" } ## }}} @@ -112,7 +119,7 @@ function ensureSshdIsRunning() ## {{{ # Récupération des informations de l'utilisateur {{{ getMainBackupDir -if [ "$?" != "${SUCCESS}" ]; then +if [ "$?" == "${ERROR}" ]; then printf '%b' "${REDB}La récupération du dossier principal à sauvegarder a échouée, installation annulée.${RESET}\\n" exit "${ERROR}" fi