procmail
[Top] [All Lists]

re: procmail configurations

2000-02-14 05:41:00
Sorry for posting this to the list, but the guy's mail address
bounces.

On Sun, 13 Feb 2000 08:39:25 +0800 (PHT), "Julius Ian D. Ponce"
<ian(_at_)predlinux(_dot_)info(_dot_)com(_dot_)ph> wrote:
To: era eriksson <era(_at_)iki(_dot_)fi>

Please refrain from sending me mail to my personal mailbox unless it's
personal.

Hello Folks! Just one more time. Do you know where I can find or
download a copy of a perl script that creates hashed directories
(/mailspool/a/b/)? I'm new to Perl and I can't write one on my own.

Why'd you do this in Perl? Apart from the driving mechanism, this is a
perfect task for a shell script. And even that is moot if you only
want to create directories which have actual users in them, as I
imagine you would.

somehow remove root daemon bin etc from /etc/passwd |
# Trim down to first field, then trim down even that to two first
#  chars, space separated
sed -e 's/:.*//' -e 's/^\(.\)\(.\).*/\1 \2/' |
# Weed out duplicates
sort -u |
# Loop over list of prefixes
while read firstinitial secondinitial ; do
  # Create first dir if it doesn't already exist
  test -d /mailspool/$firstinitial || mkdir /mailspool/$firstinitial
  # Create second dir
  mkdir /mailspool/$firstinitial/$secondinitial
done

Probably you'd do the first step in sed as well. Then piping to a
second instance of sed is probably superfluous; just merge the two
scripts instead.

Perhaps you want to make sure the ownership and the permissions on the
created directories are appropriate for your system. You can put a
chmod and/or chown in the loop, or just chmod 1777 /mailspool/?/?
after you've run this (assuming 1777 is the appropriate mode and the
ownership is already correct -- man chown otherwise).

Hope this helps,

/* era */

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition

<Prev in Thread] Current Thread [Next in Thread>