OpenLDAP-FusionDirectory-Do.../start.sh

46 lines
2.1 KiB
Bash
Raw Normal View History

2022-01-20 09:53:06 +01:00
#!/bin/bash
if [ -z "$URL" ] || [ -z "$CONF_DIR" ] || [ -z "$DB_DIR" ] || [ -z "$DEBUG_LEVEL" ]; then
echo "Missing environment variable !"
exit 1
fi
2022-01-20 09:53:06 +01:00
if [ -z "$(ls -A "$CONF_DIR")" ] || [ -z "$(ls -A "$DB_DIR")" ]; then
if [ -z "$LDPA_ADMINPWD" ] || [ -z "$LDAP_DOMAIN" ] || [ -z "$LDAP_ORGANIZATION" ]; then
echo "Missing environment variable for LDAP configuration !"
exit 1
fi
2022-01-20 09:53:06 +01:00
echo "Reconfigure slapd"
echo -e "slapd slapd/password1 password $LDPA_ADMINPWD" | debconf-set-selections
echo -e "slapd slapd/internal/adminpw password $LDPA_ADMINPWD" | debconf-set-selections
echo -e "slapd slapd/internal/generated_adminpw password $LDPA_ADMINPWD" | debconf-set-selections
echo -e "slapd slapd/password2 password $LDPA_ADMINPWD" | debconf-set-selections
echo -e "slapd slapd/unsafe_selfwrite_acl note" | debconf-set-selections
echo -e "slapd slapd/purge_database boolean false" | debconf-set-selections
echo -e "slapd slapd/domain string $LDAP_DOMAIN" | debconf-set-selections
echo -e "slapd slapd/ppolicy_schema_needs_update select abort installation" | debconf-set-selections
echo -e "slapd slapd/invalid_config boolean true" | debconf-set-selections
echo -e "slapd slapd/move_old_database boolean false" | debconf-set-selections
echo -e "slapd slapd/backend select MDB" | debconf-set-selections
echo -e "slapd shared/organization string $LDAP_ORGANIZATION" | debconf-set-selections
echo -e "slapd slapd/dump_database_destdir string /var/backups/slapd-VERSION" | debconf-set-selections
echo -e "slapd slapd/no_configuration boolean false" | debconf-set-selections
echo -e "slapd slapd/dump_database select when needed" | debconf-set-selections
echo -e "slapd slapd/password_mismatch note" | debconf-set-selections
dpkg-reconfigure slapd
2022-01-20 09:53:06 +01:00
slapd -F "$CONF_DIR" -u openldap -g openldap -h "$URL" -d "$DEBUG_LEVEL" &
slapd_pid=$!
sleep 2
2022-01-20 09:53:06 +01:00
fusiondirectory-insert-schema
kill -9 "$slapd_pid"
sleep 2
fi
echo "Starting slapd"
slapd -F "$CONF_DIR" -u openldap -g openldap -h "$URL" -d "$DEBUG_LEVEL"
echo "Slapd exited with code $?"