#! /bin/bash BDII_CONF=${BDII_CONF:-/etc/bdii/bdii.conf} [ -r "${BDII_CONF}" ] && . "${BDII_CONF}" BDII_USER=${BDII_USER:-ldap} BDII_VAR_DIR=${BDII_VAR_DIR:-/var/lib/bdii} SLAPD=${SLAPD:-/usr/sbin/slapd} SLAPD_CONF=${SLAPD_CONF:-/etc/bdii/bdii-slapd.conf} SLAPD_HOST=${SLAPD_HOST:-0.0.0.0} SLAPD_PORT=${SLAPD_PORT:-2170} BDII_IPV6_SUPPORT=${BDII_IPV6_SUPPORT:-no} SLAPD_HOST6=${SLAPD_HOST6:-::} SLAPD_DB_DIR=${SLAPD_DB_DIR:-$BDII_VAR_DIR/db} DB_CONFIG=${DB_CONFIG:-/etc/bdii/DB_CONFIG} DELAYED_DELETE=${DELAYED_DELETE:-${BDII_VAR_DIR}/delayed_delete.pkl} BDII_RAM_SIZE=${BDII_RAM_SIZE:-1500M} if [ "${BDII_IPV6_SUPPORT}" == "yes" ]; then SLAPD_HOST_STRING="'ldap://${SLAPD_HOST}:${SLAPD_PORT} ldap://[${SLAPD_HOST6}]:${SLAPD_PORT}'" else SLAPD_HOST_STRING="ldap://${SLAPD_HOST}:${SLAPD_PORT}" fi if [ -x /sbin/runuser ] ; then RUNUSER=/sbin/runuser else RUNUSER=su fi # Create RAM Disk if [ "${BDII_RAM_DISK}" = "yes" ]; then mkdir -p ${SLAPD_DB_DIR} mount -t tmpfs -o size=${BDII_RAM_SIZE},mode=0744 tmpfs ${SLAPD_DB_DIR} fi # Remove delayed_delete.pkl if it exists if [ -f "${DELAYED_DELETE}" ] ; then rm -f ${DELAYED_DELETE} fi #Initialize the database directory. mkdir -p ${SLAPD_DB_DIR}/stats mkdir -p ${SLAPD_DB_DIR}/glue mkdir -p ${SLAPD_DB_DIR}/grid mkdir -p ${BDII_VAR_DIR}/archive chown -R ${BDII_USER}:${BDII_USER} ${BDII_VAR_DIR} chown -R ${BDII_USER}:${BDII_USER} ${SLAPD_DB_DIR} [ -x /sbin/restorecon ] && /sbin/restorecon -R ${BDII_VAR_DIR} mkdir -p /var/run/bdii/db chown -R ${BDII_USER}:${BDII_USER} /var/run/bdii [ -x /sbin/restorecon ] && /sbin/restorecon -R /var/run/bdii/db $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${SLAPD_DB_DIR}/stats/* 2>/dev/null" $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${SLAPD_DB_DIR}/glue/* 2>/dev/null" $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${SLAPD_DB_DIR}/grid/* 2>/dev/null" $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/old.ldif 2>/dev/null" $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG} ${SLAPD_DB_DIR}/grid/" $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG} ${SLAPD_DB_DIR}/stats/" $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG} ${SLAPD_DB_DIR}/glue/" if [ ${SLAPD_CONF} = "/etc/bdii/bdii-top-slapd.conf" ] ; then $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG}_top ${SLAPD_DB_DIR}/grid/DB_CONFIG" $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG}_top ${SLAPD_DB_DIR}/stats/DB_CONFIG" $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG}_top ${SLAPD_DB_DIR}/glue/DB_CONFIG" $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/top-urls.conf/* 2>/dev/null" $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/top-urls.conf-glue2/* 2>/dev/null" else if [ -r "${BDII_VAR_DIR}/gip/cache" ]; then $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/site-urls.conf/* 2>/dev/null" $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/site-urls.conf-glue2/* 2>/dev/null" fi fi COMMAND="${SLAPD} -f ${SLAPD_CONF} -h ${SLAPD_HOST_STRING} -u ${BDII_USER}" exec ${COMMAND}