Saturday, October 2, 2010

bash script for Qmail&Vpopmail Uers Quota Refresh

#!/bin/sh
#Author: Tanveer Hussain Khan
#Function:Referesh User Quota for all user and domain for qmmail and vpopmail
#output=$(/usr/local/bin/mysql --password=rootpassword --exec="select pw_name,pw_domain,pw_shell from vpopmaildb.vpopmail")
output=$(/usr/bin/mysql --exec="select pw_name,pw_domain,pw_shell from vpopmaildb.vpopmail")

array=$(echo $output | tr " " "\n")
record=""
x=0
for a in $array
do
        record[x]=$a
        let "x+=1"
done

let "count=$x-1"
echo $count
for ((i=3;i<=$count;i+=3))
do
        let "name=$i"
        let "domain=$i+1"
        let "quota=$i+2"
        echo "Setting Quota To ${record[$quota]} For User ${record[$name]}@${record[$domain]}"
#       echo ${record[$name]}@${record[$domain]} ${record[$quota]}
#       echo "/var/qmail/vpopmail/bin/vsetuserquota ${record[$name]}@${record[$domain]} ${record[$quota]}
        /var/qmail/vpopmail/bin/vsetuserquota ${record[$name]}@${record[$domain]} ${record[$quota]}
done

No comments:

Post a Comment