Troca de senha em massa (MTA vpopmail)

De Wiki Hackstore

Para trocar a senha de todas as contas de email, execute o script abaixo.


#!/bin/bash

mysql vpopmail -e "select pw_domain from vpopmail"|sort|uniq|grep -v "pw_domain" > domains.txt

> all.txt

while read dominio;do
        domain=`echo $dominio | sed 's/_/./g'`
        mysql -h 127.0.0.1 vpopmail -e "select pw_name from vpopmail where pw_domain='$domain'"|grep -v "pw_name" | egrep -v "^$|[#;]"  |awk '{print $1 "@'$domain'"}' >> all.txt
done < domains.txt

while IFS=@ read mail;do
        senha=$(echo $mail |cut -d'@' -f1)
        /var/qmail/vpopmail/bin/vpasswd $mail ${senha}1234@
done < all.txt