PakOgah wrote:
> P.V.Anthony wrote:
>> P.V.Anthony wrote:
>>
>>> I would like to change from mysql to cdb for qmailtoaster. This is
>>> just to reduce the dependences. Furthermore the domain does not have
>>> large number of users.
>>>
>>> The problem I am having is the alias. Currently the alias are store
>>> in mysql. Is there a script that convert valias to dotqmail?
>>>
>>> The reverse of dotqmail2valias script.
>>
>> Wrote a small script and it seems to work.
>> Just incase somebody have the same need could use it.
>>
>> Please note that I am not a programmer. Please check before using.
>>
>> ---------------- start 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: valias2dotqmail domain.com
>> #
>> ################################################################
>>
>> # the location of vpopmail.
>> vpopmail="/home/vpopmail";
>>
>> # file name for the email alias data.
>> aliasFile="email_alias.data";
>>
>> # get all the aliases.
>> $vpopmail/bin/valias -s $1 > $aliasFile;
>>
>> #do the convert now
>> while read addr;
>> do
>> fileName=`echo $addr | cut -d @ -f 1`;
>> touch ".qmail-$fileName" ;
>> echo $addr | cut -d " " -f 3 >> .qmail-$fileName ;
>> done < $aliasFile;
>> --------------------- end -------------------------
>>
>> P.V.Anthony
>>
> waiting for another response which has intermediate or higher Bash
> scripting skill to check Anthony's work :)
> if okay, then I'll put this on wiki
>
> ***but if it working on Anthony's box then it should work on others too..
>
I didn't want to be critical, but since you asked,
.) the semicolons are all superfluous (although they'd be required in perl)
.) ~vpopmail is typically used to specify vpopmail's home (not $vpopmail)
.) the touch command seems unnecessary to me
.) the alias temp file isn't cleaned up. It wouldn't be needed at all if the
output of valias were piped into the read command.
.) indentation between do...done would be nice
.) should probably check to be sure that $1 is a valid domain and echo an
nice message if it's not
.) if 3 fields (or 4 to be safe) are read from the aliasFile in stead of
just one, then the resulting destination address wouldn't need to be 'cut'
out of $addr
.) $() is preferred to `` (primarily because it can be nested)
Then again, if it works, why mess with it? There's always more than one way
to skin a cat. ;)
Nice work for a rookie, PVA!
--
-Eric 'shubes'
---------------------------------------------------------------------
QmailToaster hosted by: VR Hosted <http://www.vr.org>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]