Allow to define LDAP group_base
This commit is contained in:
parent
6c134757cf
commit
aac9641c04
|
@ -17,7 +17,7 @@ readonly NBARGS="${#}"
|
|||
export DEBUG
|
||||
|
||||
# Default values for some vars
|
||||
#readonly MY_VAR_XY_DEFAULT="666"
|
||||
readonly LDAP_GROUP_BASE_DEFAULT="ou=grouper,dc=univ-rennes1,dc=fr"
|
||||
|
||||
## Colors
|
||||
readonly PURPLE='\033[1;35m'
|
||||
|
@ -28,15 +28,18 @@ readonly COLOR_DEBUG="${PURPLE}"
|
|||
usage() { # {{{
|
||||
|
||||
cat <<- EOF
|
||||
usage: $PROGNAME [-d|-g|-h]
|
||||
usage: $PROGNAME [-b|-d|-g|-h]
|
||||
|
||||
Create homedir for members of the given LDAP group
|
||||
Create homedir for members of the given LDAP group.
|
||||
|
||||
EXAMPLES :
|
||||
- Create homedir for members of "ldap:group:my_group"
|
||||
${PROGNAME} --group "ldap:group:my_group"
|
||||
|
||||
OPTIONS :
|
||||
-b,--base LDAP_BASE
|
||||
Set different LDAP base (default: ${LDAP_GROUP_BASE_DEFAULT}).
|
||||
|
||||
-d,--debug
|
||||
Enable debug messages.
|
||||
|
||||
|
@ -81,6 +84,12 @@ define_vars() { # {{{
|
|||
ldap_group_cn=""
|
||||
fi
|
||||
# }}}
|
||||
# If ldap_group_base wasn't defined (argument) {{{
|
||||
if [ -z "${ldap_group_base}" ]; then
|
||||
## Use default value
|
||||
ldap_group_base="${LDAP_GROUP_BASE_DEFAULT}"
|
||||
fi
|
||||
# }}}
|
||||
|
||||
}
|
||||
# }}}
|
||||
|
@ -124,6 +133,10 @@ main() { # {{{
|
|||
&& usage \
|
||||
&& error_message "Please enter a GROUP with -g|--group option." "1"
|
||||
|
||||
|
||||
## Information message
|
||||
debug_message "Search for members in ${ldap_group_cn},${ldap_group_base} group."
|
||||
|
||||
}
|
||||
# }}}
|
||||
|
||||
|
@ -149,6 +162,12 @@ if [ ! "${NBARGS}" -eq "0" ]; then
|
|||
while printf -- '%s' "${1}" | grep -q -E -- "^-+"; do
|
||||
|
||||
case "${1}" in
|
||||
-b|--base ) ## Define ldap_group_base
|
||||
## Move to the next argument
|
||||
shift
|
||||
## Define var
|
||||
readonly ldap_group_base="${1}"
|
||||
;;
|
||||
-d|--debug ) ## debug
|
||||
DEBUG=0
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue