#!/bin/sh
#Author: Tanveer Hussain Khan(tanveerhk@hotmail.com)
#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")
/bin/date
echo "Going Referesh Quota For All Users & Domains"
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"
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
/bin/date
echo "Quota Refereshed For All Users & Domains"
echo "***********************************************************"