Manage main directory with global var

Get value from a function doesn't want to work with bash on ubuntu on
Windows 10…
This commit is contained in:
Jeremy Gardais 2019-05-27 13:47:53 +02:00
parent 181f06a8fd
commit e374edcb74
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 13 additions and 6 deletions

View File

@ -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