Create home directory for each user

This commit is contained in:
Jeremy Gardais 2021-11-29 15:27:47 +01:00
parent 71b0499341
commit ec39784e14
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 31 additions and 0 deletions

View File

@ -321,6 +321,26 @@ ${local_similar_file_one} and ${local_similar_file_two} are ${RED}NOT${COLOR_DEB
return "${return_is_file_similar}" return "${return_is_file_similar}"
} }
# }}} # }}}
create_directory() { # {{{
local_directory="${1}"
## Directory creation fail by default
return_create_directory="1"
if mkdir --parents -- "${local_directory}" > /dev/null; then
debug_message "create_directory \
Successfully create ${RED}${local_directory}${COLOR_DEBUG} directory."
return_create_directory="0"
else
debug_message "create_directory \
Error in 'mkdir' command for ${RED}${local_directory}${COLOR_DEBUG} directory."
return_create_directory="1"
fi
return "${return_create_directory}"
}
# }}}
main() { # {{{ main() { # {{{
## If ldapsearch command is not available {{{ ## If ldapsearch command is not available {{{
@ -366,6 +386,17 @@ main() { # {{{
&& exit 0 && exit 0
## }}} ## }}}
## Parse users list {{{
while IFS= read -r username; do
### Create user's home directory {{{
### OR Exit
create_directory "${home_base}/${username}" \
|| error_message "Can't create home directory (${home_base}/${username}) for ${username} user. Please use --debug option." 5
### }}}
done < "${ldap_user_list_path}"
## }}}
## Information message ## Information message
debug_message "Create home directory in ${RED}${home_base}${COLOR_DEBUG}, \ debug_message "Create home directory in ${RED}${home_base}${COLOR_DEBUG}, \
for all members of ${RED}${ldap_group_cn},${ldap_group_base}${COLOR_DEBUG} LDAP group \ for all members of ${RED}${ldap_group_cn},${ldap_group_base}${COLOR_DEBUG} LDAP group \