Create home directory for each user
This commit is contained in:
parent
71b0499341
commit
ec39784e14
|
@ -321,6 +321,26 @@ ${local_similar_file_one} and ${local_similar_file_two} are ${RED}NOT${COLOR_DEB
|
|||
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() { # {{{
|
||||
|
||||
## If ldapsearch command is not available {{{
|
||||
|
@ -366,6 +386,17 @@ main() { # {{{
|
|||
&& 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
|
||||
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 \
|
||||
|
|
Loading…
Reference in New Issue