Convert Vpopmail alias into qmail alias

From QmailToaster
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

From P.V.Anthony <pvanthony@singnet.com.sg>

 ---------------------- valias2dotqmail --------------------------------
 !/bin/bash
 #################################################################
 # script to convert alias stored in database back to .qmail-alias
 #
 # Example.
 # copy the script into the /home/vpopmail/domains/domain.com
 # then run: sh valias2dotqmail
 #
 ################################################################
 # file name for the email alias data.
 aliasFile="email_alias.data"
 # owners of the files
 owner="vpopmail"
 # group of the files
 group="vchkpw"
 # get the domain name from the current directory name
 domainName=$(basename $(pwd))
 # get all the aliases.
 ~vpopmail/bin/valias -s $domainName > $aliasFile
 #do the convert now
 while read addr
 do
       fileName=$(echo $addr | cut -d @ -f 1)
       echo $addr | cut -d " " -f 3 >> .qmail-$fileName
      
       # change the owner and group for the dotqmail file
       chown $owner:$group .qmail-$fileName
      
       # change permission of the dotqmail file
       chmod 600 .qmail-$fileName
      
 done < $aliasFile
 # remove the data as we do not need it anymore
 rm $aliasFile
 --------------------------- end ---------------------------------------