diff --git a/duplicati/create.homedir.sh b/duplicati/create.homedir.sh index 92b0510..9d58d2b 100755 --- a/duplicati/create.homedir.sh +++ b/duplicati/create.homedir.sh @@ -18,6 +18,7 @@ export DEBUG # Default values for some vars readonly LDAP_GROUP_BASE_DEFAULT="ou=grouper,dc=univ-rennes1,dc=fr" +readonly LDAP_SERVER_DEFAULT="ldap://ldap.univ-rennes1.fr" ## Colors readonly PURPLE='\033[1;35m' @@ -28,7 +29,7 @@ readonly COLOR_DEBUG="${PURPLE}" usage() { # {{{ cat <<- EOF -usage: $PROGNAME [-b|-d|-g|-h] +usage: $PROGNAME [-b|-d|-g|-h|-s] Create homedir for members of the given LDAP group. @@ -51,6 +52,9 @@ OPTIONS : -h,--help Print this help message. + -s,--server ldap://ldap.domain.tld + LDAP url to use for ldapsearch request (default: ${LDAP_SERVER_DEFAULT}). + EOF } @@ -90,6 +94,12 @@ define_vars() { # {{{ ldap_group_base="${LDAP_GROUP_BASE_DEFAULT}" fi # }}} + # If ldap_server wasn't defined (argument) {{{ + if [ -z "${ldap_server}" ]; then + ## Use default value + ldap_server="${LDAP_SERVER_DEFAULT}" + fi + # }}} } # }}} @@ -135,7 +145,8 @@ main() { # {{{ ## Information message - debug_message "Search for members in ${ldap_group_cn},${ldap_group_base} group." + debug_message "Search for members in ${RED}${ldap_group_cn},${ldap_group_base}${COLOR_DEBUG} group \ +on ${RED}${ldap_server}${COLOR_DEBUG} LDAP server." } # }}} @@ -182,6 +193,12 @@ if [ ! "${NBARGS}" -eq "0" ]; then ## Exit after help informations exit 0 ;; + -s|--server) ## Define ldap_server + ## Move to the next argument + shift + ## Define var + readonly ldap_server="${1}" + ;; * ) ## unknow option printf '%b\n' "${RED}Invalid option: ${1}${RESET}" printf '%b\n' "---"