Debian Codegraph @

etc/systemd/bdii-slapd-start

raw symbols SCIP
1 #! /bin/bash
2
3 BDII_CONF=${BDII_CONF:-/etc/bdii/bdii.conf}
4
5 [ -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 [ "${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 [ -x /sbin/runuser ] ; then
27 RUNUSER=/sbin/runuser
28 else
29 RUNUSER=su
30 fi
31
32 # Create RAM Disk
33 if [ "${BDII_RAM_DISK}" = "yes" ]; then
34 mkdir -p ${SLAPD_DB_DIR}
35 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 [ -f "${DELAYED_DELETE}" ] ; then
40 rm -f ${DELAYED_DELETE}
41 fi
42
43 #Initialize the database directory.
44 mkdir -p ${SLAPD_DB_DIR}/stats
45 mkdir -p ${SLAPD_DB_DIR}/glue
46 mkdir -p ${SLAPD_DB_DIR}/grid
47 mkdir -p ${BDII_VAR_DIR}/archive
48
49 chown -R ${BDII_USER}:${BDII_USER} ${BDII_VAR_DIR}
50 chown -R ${BDII_USER}:${BDII_USER} ${SLAPD_DB_DIR}
51 [ -x /sbin/restorecon ] && /sbin/restorecon -R ${BDII_VAR_DIR}
52
53 mkdir -p /run/bdii/db
54 chown -R ${BDII_USER}:${BDII_USER} /run/bdii
55 [ -x /sbin/restorecon ] && /sbin/restorecon -R /run/bdii/db
56
57 $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${SLAPD_DB_DIR}/stats/* 2>/dev/null"
58 $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${SLAPD_DB_DIR}/glue/* 2>/dev/null"
59 $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${SLAPD_DB_DIR}/grid/* 2>/dev/null"
60 $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/old.ldif 2>/dev/null"
61 $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG} ${SLAPD_DB_DIR}/grid/"
62 $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG} ${SLAPD_DB_DIR}/stats/"
63 $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG} ${SLAPD_DB_DIR}/glue/"
64
65 if [ ${SLAPD_CONF} = "/etc/bdii/bdii-top-slapd.conf" ] ; then
66 $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG}_top ${SLAPD_DB_DIR}/grid/DB_CONFIG"
67 $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG}_top ${SLAPD_DB_DIR}/stats/DB_CONFIG"
68 $RUNUSER -s /bin/sh ${BDII_USER} -c "ln -sf ${DB_CONFIG}_top ${SLAPD_DB_DIR}/glue/DB_CONFIG"
69 $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/top-urls.conf/* 2>/dev/null"
70 $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/top-urls.conf-glue2/* 2>/dev/null"
71 else
72 if [ -r "${BDII_VAR_DIR}/gip/cache" ]; then
73 $RUNUSER -s /bin/sh ${BDII_USER} -c "rm -f ${BDII_VAR_DIR}/gip/cache/gip/site-urls.conf/* 2>/dev/null"
74 $RUNUSER -s /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}"