As I am learning Perl and curious about procmail I thought it would be fun
to write a procmail installer for users. This is a working draft, it needs
some cleaning and perhaps a few more comments. I plan to extend it to
include a prompted tool for writing simple recipes.
I'm interested in hearing any suggestions or comments you might have.
______________________________________________________________________________
Joel Bremson # www.wenet.net
Whole Earth Networks # www.wenet.net/well
Team Leader # www.wenet.net/hooked
staffjb(_at_)wenet(_dot_)net
------------------------------------------------------------------------------
#!/usr/bin/perl5
###############################################################################
# Before this portion is run there should be a section that checks for file
# existance of procmail config files.
###############################################################################
# create .forward
###############################################################################
$name=$ENV{USER};
srand;
if (-e ".forward") { #does the user have .forward? if so move the
file
$random=int(rand 89999) + 10000;
if (-e ".forward.$random"){die "file match. try again.\n"}
rename ('.forward', ".forward.$random");
$forward_exist=1;
}
open (FORWARD,">.forward")||die "error opening .forward:$!\n";
print FORWARD qq@"|IFS=' '&&exec /usr/local/bin/procmail -f-||exit 75 #$name"
@;
if ($forward_exist){
print FORWARD "\\ \n";
open (APPEND, ".forward.$random") || die "can't open
.forward.$random:$!\n";
while (<APPEND>){
print FORWARD;
}
close APPEND;
}
else {print FORWARD "\n"}
unlink ".forward.$random" || print " no unlink \n";
#################################################################################
# make the .procmailrc, associated dirs and files
#################################################################################
#procmailrc variables
$SET_SHELL="/bin/shell\n";
$SET_VERBOSE="NO\n";
$SET_MAILDIR="\$HOME/mail\n";
$SET_LOGFILE="\$HOME/.prepend.log/procmail.log\n";
if (! -d '.prepend.log'){
mkdir ('.prepend.log', 0770) || print "unable to make .prepend.log";
chdir ('.prepend.log');
open (SETUP, ">.prependrc")|| die "prependrc -unable to make:$!\n";#
for future check of if
#
set procmail has been run
open (PROCLOG, ">procmail.log")||die "procmail.log didn't open";
}
# create .procmailrc
chdir ();
#check for already existing procmailrc
if (-e '.procmailrc'){ die "A .procmailrc already exist. Error:$!\n"}
open (PROCMAILRC, ">.procmailrc")|| die "could not create .procmailrc:$!\n";
print PROCMAILRC "SHELL=$SET_SHELL";
print PROCMAILRC "VERBOSE=$SET_VERBOSE";
print PROCMAILRC "MAILDIR=$SET_MAILDIR";
print PROCMAILRC "LOGFILE=$SET_LOGFILE";