[enh] include aleks script to reset ldap password

This commit is contained in:
Alexandre Aubin 2016-12-17 21:17:23 +01:00 committed by Laurent Peuch
parent 198bc51128
commit 7bed005ac0

29
bin/reset-ldap-password Normal file
View file

@ -0,0 +1,29 @@
# Generate new password hash
NEW_PASSWORD_HASH=`slappasswd -h {SSHA}`
# Stop slapd service...
service slapd stop
# Backup slapd.conf (to be restored at the end of script)
cp /etc/ldap/slapd.conf /root/slapd.conf.bkp
# Append lines to slapd.conf to manually define root password hash
echo 'rootdn "cn=admin,dc=yunohost,dc=org"' >> /etc/ldap/slapd.conf
echo "rootpw $NEW_PASSWORD_HASH" >> /etc/ldap/slapd.conf
# Test conf (might not be entirely necessary though :P)
slaptest -Q -u -f /etc/ldap/slapd.conf
# Regenerate slapd.d directory
rm -Rf /etc/ldap/slapd.d
mkdir /etc/ldap/slapd.d
slaptest -f /etc/ldap/slapd.conf -F /etc/ldap/slapd.d/ 2>&1
# Set permissions to slapd.d
chown -R openldap:openldap /etc/ldap/slapd.d/
# Restore slapd.conf
mv /root/slapd.conf.bkp /etc/ldap/slapd.conf
# Restart slapd service
service slapd start