#!/bin/sh set -e # Some variable values SLAPDCONF="ldap-server/slapd.conf" SLAPD_SYNCREPL="ldap-server/slapd-syncrepl.conf" SLAPDIR="/etc/ldap/" SLAPDCONFMODE="644" SLAPDUSER="openldap" SLAPDGROUP="$SLAPDUSER" # VALUES: LIB_FILE="/usr/share/lliurex/llxcfg-ldap/common.sh" # MAIN [ -e $LIB_FILE ] || exit_message "File not Found Exception: $LIB_FILE not present" . $LIB_FILE # Test if database have some variations exists_and_unchanged || exit_message "ERROR: Some of the required variables are changed or NOT present, the configuration not be regenerated until you run llxcfg-ldap init --force because is a new LDAP DATABASE " # Now we must install the slapd.conf file with especiall options # the 640 default mode is not valid for the current LDAP version eval $(llxcfg-showvars LDAP_REPLICATOR_PASS CAP_ZERO_CAPNAME CAP_NET_ADDRESS SRV_HOST_ID) if [ "$LDAP_REPLICATOR_PASS" ] && [ -r "$LDAP_REPLICATOR_PASS" ] ; then export PASSWORD_REPLICANT="$(cat "$LDAP_REPLICATOR_PASS")" fi NUMBERMIRROR=0 SYNCFILE="$(tempfile)" if [ -r "/var/lib/lliurex-cap/$CAP_ZERO_CAPNAME/config/hosts.cap" ]; then AUX="$(cat /var/lib/lliurex-cap/$CAP_ZERO_CAPNAME/config/hosts.cap | cut -f2 | tr "\n" " ")" for RID in $AUX; do if [ "$RID" != "$SRV_HOST_ID" ]; then LDAP_REPLY_URI="ldap://$(echo "${CAP_NET_ADDRESS%.*}.${RID}")" export RID LDAP_REPLY_URI llxcfg-config read "$SLAPD_SYNCREPL" | llxcfg-template - >> $SYNCFILE echo "" >> $SYNCFILE NUMBERMIRROR="$(( NUMBERMIRROR + 1 ))" fi done fi if [ $NUMBERMIRROR -gt 0 ]; then llxcfg-systemvars add LDAP_ACTIVE_MIRROR="YES" else llxcfg-systemvars add LDAP_ACTIVE_MIRROR="NO" fi llxcfg-config read "$SLAPDCONF" | llxcfg-template - | skel-install "$SLAPDIR/slapd.conf" --mode="$SLAPDCONFMODE" --owner="$SLAPDUSER" --group="$SLAPDGROUP" cat $SYNCFILE | skel-install "$SLAPDIR/slapd-syncrepl.conf" --mode=640 --owner=root --group="$SLAPDGROUP" unset PASSWORD_REPLICANT rm $SYNCFILE # export ldap vars to clients llxcfg-template ./client-netconfig-vars | llxcfg-config write netconfig/varfiles/client-ldap-vars exit 0