X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=functions.sh;h=dc3450d81121e3cc631eacb2cfebe75fae6b5cd9;hb=d098509050870130925512565ac849873ea9d956;hp=24c7cf9209d9d4ce6ba1aeea720d8475922a72d7;hpb=0bfcdc144e63167d37578c6c33b6c4113d1f8c5b;p=carnet-tools-cn.git diff --git a/functions.sh b/functions.sh index 24c7cf9..dc3450d 100644 --- a/functions.sh +++ b/functions.sh @@ -438,7 +438,7 @@ cp_db_get() { fi } -# by ico, Wed, 20 Apr 2005 21:09:54 +0200 +# by ico, Wed, 07 Dec 2011 13:30:02 +0100 cp_get_ldap_suffix() { [ "$CP_SCRIPT_DEBUG" ] && set -vx @@ -448,22 +448,27 @@ cp_get_ldap_suffix() { # but preserving initial state so it could be used afterwards CP_ECHO_RETURN="" - if [ ! -f /etc/ldap/slapd.conf ]; then - echo "cp_get_ldap_suffix: /etc/ldap/slapd.conf: No such file" >&2 + RET="" + + if [ -d /etc/ldap/slapd.d/ ]; then + RET="`grep -r olcSuffix: /etc/ldap/slapd.d/ | awk '{print $2}' | head -1`" + elif [ -f /etc/ldap/slapd.conf ]; then + RET="`awk '/^suffix/ { exit } + END { gsub(/"/, "", $2); print $2 }' \ + < /etc/ldap/slapd.conf`" + else + RET="" + echo "cp_get_ldap_suffix: /etc/ldap/slapd.{d/,conf}: No such file or directory" >&2 return 2 fi - - RET="`awk '/^suffix/ { exit } - END { gsub(/"/, "", $2); print $2 }' \ - < /etc/ldap/slapd.conf`" if [ "`echo $RET | sed 's/,/ /g' | wc -w`" -gt 2 ]; then RET="" - echo "cp_get_ldap_suffix: Invalid LDAP suffix in /etc/ldap/slapd.conf" >&2 + echo "cp_get_ldap_suffix: Invalid LDAP suffix in /etc/ldap/slapd.d/" >&2 return 2 fi - [ -z "$RET" ] && echo "cp_get_ldap_suffix: No LDAP suffix in /etc/ldap/slapd.conf" >&2 + [ -z "$RET" ] && echo "cp_get_ldap_suffix: No LDAP suffix in /etc/ldap/slapd.{d/,conf}" >&2 [ -z "$echo_return" ] || echo $RET CP_ECHO_RETURN="$echo_return" } @@ -478,15 +483,19 @@ cp_get_ldap_realm() { # but preserving initial state so it could be used afterwards CP_ECHO_RETURN="" - if [ ! -f /etc/ldap/slapd.conf ]; then - echo "cp_get_ldap_realm: /etc/ldap/slapd.conf: No such file" >&2 + RET="" + + if [ ! -d /etc/ldap/slapd.d/ -a ! -f /etc/ldap/slapd.conf ]; then + echo "cp_get_ldap_realm: /etc/ldap/slapd.{d/,conf}: No such file or directory" >&2 return 2 fi - + cp_get_ldap_suffix || true RET="`echo $RET | awk -F, '{print $1}' | awk -F= '{print $2}'`" - [ -z "$RET" ] && echo "cp_get_ldap_realm: No LDAP REALM in /etc/ldap/slapd.conf" >&2 + [ -z "$RET" ] && echo "cp_get_ldap_realm: No LDAP REALM in /etc/ldap/slapd.{d/,conf}" >&2 + [ -z "$echo_return" ] || echo $RET + CP_ECHO_RETURN="$echo_return" } # if fqdn is name.dom3.dom2.dom1.hr, check if this host is MX for