Eric Shubert wrote:

I didn't want to be critical, but since you asked,
.) the semicolons are all superfluous (although they'd be required in perl)

Corrected.

.) ~vpopmail is typically used to specify vpopmail's home (not $vpopmail)

Corrected.

.) the touch command seems unnecessary to me

Corrected.

.) 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.

Corrected.

.) indentation between do...done would be nice

Corrected.

.) should probably check to be sure that $1 is a valid domain and echo an
nice message if it's not

I do not know how to do this.

Currently it is reading the current directory name then use that as the domain name. Any thoughts on this? Is that a good idea or is it better to type the domain name.

.) 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

Really do not know how to do this.


.) $() is preferred to `` (primarily because it can be nested)

Corrected.

Have added some commands to change the owner,group and permissions of the dotqmail files.

Then again, if it works, why mess with it? There's always more than one way
to skin a cat. ;)

Actually I really do appreciate the comments. The comments has taught me more. Please continue to comment and teach.

The community has taught me much. I am very happy that I can a least contribute in a small way.

Nice work for a rookie, PVA!

Thank you for the encouragement.

Below is the corrected code.

---------------------- 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 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 ---------------------------------------

P.V.Anthony


---------------------------------------------------------------------
    QmailToaster hosted by: VR Hosted <http://www.vr.org>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to