eMail Server: Version 3.x
#!/bin/bash
echo "modify the password for cyrus"
echo -e "new password: \c"
read PASS
echo -e
if [ -z "$PASS" ]
then
echo "sorry, but a blank password is not allowed"
exit 1
fi
# write new password to /etc/shadow
echo "cyrus:$PASS" | chpasswd
# save created password to slapd.conf
grep -v "^rootpw" /etc/openldap/slapd.conf >/tmp/slapd.conf.new
NEWPW=`grep "^cyrus" /etc/shadow | cut -f 2 -d ":"`
echo -e "rootpw\t{crypt}$NEWPW" >>/tmp/slapd.conf.new
mv /etc/openldap/slapd.conf /etc/openldap/slapd.conf.oldpw
mv /tmp/slapd.conf.new /etc/openldap/slapd.conf
echo "Password changed! Now restart the LDAP Server to apply"
echo "the changes with the command 'rcldap restart'"
exit 0
cyruspw.shopenexchange:~ # chmod u+x cyruspw.sh
openexchange:~ # ./cyruspw.sh
openexchange:~ # rcldap restart