Script for changing all users password on zimbra for Richa Global
Appearance
Script for Changing password for all user on richaglobal and abcleather.com[edit]
Process[edit]
Create sudo user richa as below
richa ALL=(zimbra) NOPASSWD: /home/richa/pass-change-richaglobal.sh, /home/richa/pass-change-abcleathers.sh
Where pass-change-richaglobal.sh and pass-change-abcleathers.sh are the scripts to change passwords on 2 domains .
The Sample Scripts are
#!/bin/bash
MYDOMAIN="richaglobal.com"
NEWPASS="newpass"
TEMPFILE="/tmp/list.txt"
CMDFILE="/tmp/changepw.cmd"
# Create the work files and set appropriate permissions.
touch ${TEMPFILE}
touch ${CMDFILE}
chmod 0600 ${TEMPFILE}
chmod 0600 ${CMDFILE}
# This will create a list of users in Zimbra for the specified domain.
#su - zimbra -c "zmprov -l getAllAccounts ${MYDOMAIN} > ${TEMPFILE}"
/opt/zimbra/bin/zmprov -l getAllAccounts ${MYDOMAIN} > ${TEMPFILE}
# This will loop through the users and create a password reset command file.
while read -a LINE ; do
echo "modifyAccount ${LINE[0]} userPassword ${NEWPASS}" >> ${CMDFILE}
done < ${TEMPFILE}
rm ${TEMPFILE}
Change " Domain " and "Password" as per the requirement .
Process of Running the Script[edit]
- Change the "Newpass" with actual password .
- Run it by ./pass-change-richaglobal.sh or ./pass-change-abcleathers.sh
- This will create 2 files '/tmp/list.txt" and "/tmp/changepw.cmd"
- '/tmp/list.txt" will contain list of all users , one on each line
- "/tmp/changepw.cmd" will contain the command for the modifying the password like "modifyAccount vaibhav@richaglobal.com userPassword newpass"
- Then run
/opt/zimbra/bin/zmprov < /tmp/changepw.cmd
Check the users for password change .