#! /bin/bash

DOMAIN=ou=People,`cat /etc/openldap/ldap.conf | grep "^base" | sed 's/^base //'`
cat /var/lib/mysql/passwd-init | grep -v 'auth/ldap' > /var/lib/mysql/passwd-init
echo "update moodle.mdl_config_plugins set value='"$DOMAIN"' where plugin='auth/ldap' and name='contexts'" >> /var/lib/mysql/passwd-init
service mysqld restart
