| 1 | #! /bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | BDII_CONF=${BDII_CONF:-/etc/bdii/bdii.conf} |
| 4 | |
| 5 | [scip-shell system . . `[`. -r "${BDII_CONF}" ] && . "${BDII_CONF}" |
| 6 | |
| 7 | BDII_USER=${BDII_USER:-ldap} |
| 8 | BDII_VAR_DIR=${BDII_VAR_DIR:-/var/lib/bdii} |
| 9 | SLAPD=${SLAPD:-/usr/sbin/slapd} |
| 10 | SLAPD_CONF=${SLAPD_CONF:-/etc/bdii/bdii-slapd.conf} |
| 11 | SLAPD_HOST=${SLAPD_HOST:-0.0.0.0} |
| 12 | SLAPD_PORT=${SLAPD_PORT:-2170} |
| 13 | BDII_IPV6_SUPPORT=${BDII_IPV6_SUPPORT:-no} |
| 14 | SLAPD_HOST6=${SLAPD_HOST6:-::} |
| 15 | SLAPD_DB_DIR=${SLAPD_DB_DIR:-$BDII_VAR_DIR/db} |
| 16 | DB_CONFIG=${DB_CONFIG:-/etc/bdii/DB_CONFIG} |
| 17 | DELAYED_DELETE=${DELAYED_DELETE:-${BDII_VAR_DIR}/delayed_delete.pkl} |
| 18 | BDII_RAM_SIZE=${BDII_RAM_SIZE:-1500M} |
| 19 | |
| 20 | if [scip-shell system . . `[`. "${BDII_IPV6_SUPPORT}" == "yes" ]; then |
| 21 | SLAPD_HOST_STRING="ldap://${SLAPD_HOST}:${SLAPD_PORT} ldap://[${SLAPD_HOST6}]:${SLAPD_PORT}" |
| 22 | else |
| 23 | SLAPD_HOST_STRING="ldap://${SLAPD_HOST}:${SLAPD_PORT}" |
| 24 | fi |
| 25 | |
| 26 | if [scip-shell system . . `[`. -x /sbin/runuserscip-shell filesystem . . `/sbin/runuser`. ] ; then |
| 27 | RUNUSER=/sbin/runuserscip-shell filesystem . . `/sbin/runuser`. |
| 28 | else |
| 29 | RUNUSER=su |
| 30 | fi |
| 31 | |
| 32 | # Create RAM Disk |
| 33 | if [scip-shell system . . `[`. "${BDII_RAM_DISK}" = "yes" ]; then |
| 34 | mkdirscip-shell system . . mkdir. -p ${SLAPD_DB_DIR} |
| 35 | mountscip-shell system . . mount. -t tmpfs -o size=${BDII_RAM_SIZE},mode=0755 tmpfs ${SLAPD_DB_DIR} |
| 36 | fi |
| 37 | |
| 38 | # Remove delayed_delete.pkl if it exists |
| 39 | if [scip-shell system . . `[`. -f "${DELAYED_DELETE}" ] ; then |
| 40 | rmscip-shell system . . rm. -f ${DELAYED_DELETE} |
| 41 | fi |
| 42 | |
| 43 | #Initialize the database directory. |
| 44 | mkdirscip-shell system . . mkdir. -p ${SLAPD_DB_DIR}/stats |
| 45 | mkdirscip-shell system . . mkdir. -p ${SLAPD_DB_DIR}/glue |
| 46 | mkdirscip-shell system . . mkdir. -p ${SLAPD_DB_DIR}/grid |
| 47 | mkdirscip-shell system . . mkdir. -p ${BDII_VAR_DIR}/archive |
| 48 | |
| 49 | chownscip-shell system . . chown. -R ${BDII_USER}:${BDII_USER} ${BDII_VAR_DIR} |
| 50 | chownscip-shell system . . chown. -R ${BDII_USER}:${BDII_USER} ${SLAPD_DB_DIR} |
| 51 | [scip-shell system . . `[`. -x /sbin/restoreconscip-shell filesystem . . `/sbin/restorecon`. ] && /sbin/restoreconscip-shell filesystem . . `/sbin/restorecon`. -R ${BDII_VAR_DIR} |
| 52 | |
| 53 | mkdirscip-shell system . . mkdir. -p /run/bdii/dbscip-shell filesystem . . `/run/bdii/db`. |
| 54 | chownscip-shell system . . chown. -R ${BDII_USER}:${BDII_USER} /run/bdiiscip-shell filesystem . . `/run/bdii`. |
| 55 | [scip-shell system . . `[`. -x /sbin/restoreconscip-shell filesystem . . `/sbin/restorecon`. ] && /sbin/restoreconscip-shell filesystem . . `/sbin/restorecon`. -R /run/bdii/dbscip-shell filesystem . . `/run/bdii/db`. |
| 56 | |
| 57 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "rm -f ${SLAPD_DB_DIR}/stats/* 2>/dev/null" |
| 58 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "rm -f ${SLAPD_DB_DIR}/glue/* 2>/dev/null" |
| 59 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "rm -f ${SLAPD_DB_DIR}/grid/* 2>/dev/null" |
| 60 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/old.ldif 2>/dev/null" |
| 61 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "ln -sf ${DB_CONFIG} ${SLAPD_DB_DIR}/grid/" |
| 62 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "ln -sf ${DB_CONFIG} ${SLAPD_DB_DIR}/stats/" |
| 63 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "ln -sf ${DB_CONFIG} ${SLAPD_DB_DIR}/glue/" |
| 64 | |
| 65 | if [scip-shell system . . `[`. ${SLAPD_CONF} = "/etc/bdii/bdii-top-slapd.confscip-shell filesystem . . `/etc/bdii/bdii-top-slapd.conf`." ] ; then |
| 66 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "ln -sf ${DB_CONFIG}_top ${SLAPD_DB_DIR}/grid/DB_CONFIG" |
| 67 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "ln -sf ${DB_CONFIG}_top ${SLAPD_DB_DIR}/stats/DB_CONFIG" |
| 68 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "ln -sf ${DB_CONFIG}_top ${SLAPD_DB_DIR}/glue/DB_CONFIG" |
| 69 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/top-urls.conf/* 2>/dev/null" |
| 70 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/top-urls.conf-glue2/* 2>/dev/null" |
| 71 | else |
| 72 | if [scip-shell system . . `[`. -r "${BDII_VAR_DIR}/gip/cache" ]; then |
| 73 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/site-urls.conf/* 2>/dev/null" |
| 74 | $RUNUSER -s /bin/shscip-shell filesystem . . `/bin/sh`. ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/site-urls.conf-glue2/* 2>/dev/null" |
| 75 | fi |
| 76 | fi |
| 77 | |
| 78 | COMMAND="${SLAPD} -f ${SLAPD_CONF} -h \"${SLAPD_HOST_STRING}\" -u ${BDII_USER}" |
| 79 | exec sh -c "${COMMAND}" |