From 7ce55bcce12df6b44f5499fa62fca095bb618ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 8 Oct 2018 11:30:30 +0200 Subject: [PATCH] Check if dir already exists This way it's avoid the chown/chmod on an existing home/work directory. --- cluster/create.homedir.sh | 9 +++++++++ cluster/create.workdir.sh | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/cluster/create.homedir.sh b/cluster/create.homedir.sh index f2d4962..b8e48fa 100755 --- a/cluster/create.homedir.sh +++ b/cluster/create.homedir.sh @@ -27,6 +27,15 @@ else exit 1 fi +# }}} +# Check if homedir already exist {{{ +if [ $(ls -1d "${user_homedir_path}" 2> /dev/null) ]; then + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : homedir check — ${user_homedir_path} already exists. Abord this script." + exit 1 +else + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : homedir check — ${user_homedir_path} doesn't exists. Continue." +fi + # }}} # Check group exist {{{ if [ "${user_primary_group}" ]; then diff --git a/cluster/create.workdir.sh b/cluster/create.workdir.sh index 749ef3e..ea22e4c 100755 --- a/cluster/create.workdir.sh +++ b/cluster/create.workdir.sh @@ -27,6 +27,15 @@ else exit 1 fi +# }}} +# Check if workdir already exist {{{ +if [ $(ls -1d "${user_workdir_path}" 2> /dev/null) ]; then + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : workdir check — ${user_workdir_path} already exists. Abord this script." + exit 1 +else + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : workdir check — ${user_workdir_path} doesn't exists. Continue." +fi + # }}} # Check group exist {{{ if [ "${user_primary_group}" ]; then