Update purpose and error code
This commit is contained in:
parent
4301c4c7eb
commit
e504952702
|
@ -3,7 +3,10 @@
|
|||
# Purpose {{{
|
||||
# This script will create homedir for members of an LDAP group
|
||||
# 1. Get members list from LDAP group given as argument
|
||||
# …
|
||||
# 2. Compare current list with previous (if it exists)
|
||||
# 3. Try to create homedir for each user
|
||||
# 4. Fix permissions on homedir
|
||||
# 5. Rename members list for next run
|
||||
#
|
||||
# 2021-11-19
|
||||
# }}}
|
||||
|
@ -44,6 +47,8 @@ EXAMPLES :
|
|||
|
||||
- Use default SSSD user for ldap requests
|
||||
${PROGNAME} --user-cmd "sed -n 's/\(^ldap_default_bind_dn = \)\(.*\)/\2/p' /etc/sssd/sssd.conf"
|
||||
- Create new homedir in a specific path (/mnt/home.remote)
|
||||
${PROGNAME} --home "/mnt/home.remote"
|
||||
|
||||
OPTIONS :
|
||||
-b,--base LDAP_BASE
|
||||
|
@ -368,7 +373,7 @@ main() { # {{{
|
|||
## If ldapsearch command is not available {{{
|
||||
### exit with message and error
|
||||
is_command_available "ldapsearch" \
|
||||
|| error_message "ldapsearch command doesn't seems to be available. Please install ldap-utils package." "3"
|
||||
|| error_message "ldapsearch command doesn't seems to be available. Please install ldap-utils package." 1
|
||||
## }}}
|
||||
|
||||
## Define all vars
|
||||
|
@ -379,25 +384,25 @@ main() { # {{{
|
|||
### AND exit with message and error
|
||||
is_var_empty "${ldap_group_cn}" \
|
||||
&& usage \
|
||||
&& error_message "Please enter a GROUP with -g|--group option." 1
|
||||
&& error_message "Please enter a GROUP with -g|--group option." 10
|
||||
## }}}
|
||||
## If ldap_user or ldap_passwd is empty {{{
|
||||
### Print help message
|
||||
### AND exit with message and error
|
||||
is_var_empty_silent "${ldap_user}" "${ldap_passwd}" \
|
||||
&& usage \
|
||||
&& error_message "LDAP user or password is empty. Please verify your configuration or the --user-cmd|--passwd-cmd options." 2
|
||||
&& error_message "LDAP user or password is empty. Please verify your configuration or the --user-cmd|--passwd-cmd options." 11
|
||||
## }}}
|
||||
## If home_base directory doesn't exists {{{
|
||||
### AND exit with message and error
|
||||
is_directory_absent "${home_base}" \
|
||||
&& error_message "Home base directory (${home_base}) doesn't exists. Check your configuration or use -h|--home option." 3
|
||||
&& error_message "Home base directory (${home_base}) doesn't exists. Check your configuration or use -h|--home option." 12
|
||||
## }}}
|
||||
|
||||
## Try to get the user list of LDAP group {{{
|
||||
### OR Exit
|
||||
get_ldap_user_list \
|
||||
|| error_message "Can't get the user list of ${ldap_group_cn} LDAP group. Please use --debug option." 4
|
||||
|| error_message "Can't get the user list of ${ldap_group_cn} LDAP group. Please use --debug option." 20
|
||||
## }}}
|
||||
## If a previous list of users exists {{{
|
||||
### If the two lists are the same
|
||||
|
@ -411,16 +416,16 @@ main() { # {{{
|
|||
## Parse users list {{{
|
||||
while IFS= read -r username; do
|
||||
user_groupname=$(id --group -- "${username}" \
|
||||
|| error_message "Can't get the primary group uid for ${username} user." 6)
|
||||
|| error_message "Can't get the primary group uid for ${username} user." 21)
|
||||
### 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
|
||||
|| error_message "Can't create home directory (${home_base}/${username}) for ${username} user. Please use --debug option." 22
|
||||
### }}}
|
||||
### Fix permissions for this directory {{{
|
||||
### OR Exit
|
||||
fix_directory_permissions "${home_base}/${username}" "${username}" "${user_groupname}" \
|
||||
|| error_message "Can't fix permissions for ${username} home directory (path: ${home_base}/${username}, username: ${username}, group: ${user_groupname}. Please use --debug option." 7
|
||||
|| error_message "Can't fix permissions for ${username} home directory (path: ${home_base}/${username}, username: ${username}, group: ${user_groupname}. Please use --debug option." 23
|
||||
### }}}
|
||||
|
||||
done < "${ldap_user_list_path}"
|
||||
|
|
Loading…
Reference in New Issue