Check if dir already exists

This way it's avoid the chown/chmod on an existing home/work directory.
This commit is contained in:
Jeremy Gardais 2018-10-08 11:30:30 +02:00
parent 574d1fc318
commit 7ce55bcce1
2 changed files with 18 additions and 0 deletions

View File

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

View File

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