FreeBSD Bugzilla – Attachment 70856 Details for
Bug 103319
Update: mail/mailrep
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
diff.mailrep.pl
diff.mailrep.pl (text/plain), 5.49 KB, created by
Marcelo Araujo
on 2006-09-17 05:10:24 UTC
(
hide
)
Description:
diff.mailrep.pl
Filename:
MIME Type:
Creator:
Marcelo Araujo
Created:
2006-09-17 05:10:24 UTC
Size:
5.49 KB
patch
obsolete
>--- /usr/local/sbin/mailrep.pl Thu Aug 17 20:26:02 2006 >+++ mailrep.pl Sat Sep 16 21:38:46 2006 >@@ -1,10 +1,13 @@ > #!/usr/bin/perl > ## >-# This is mailrep.pl v1.0 >+# This is mailrep.pl v1.1 > # By - Marcelo Araujo (araujo@bsdmail.org) - http://experience.bsdnetwork.org > # >-use strict; >+# Add 16 Setember 2006: >+# Scheduling Crontab support >+# By - araujo > >+use strict; > my @conf; > my @setting; > my $set; >@@ -38,9 +41,12 @@ > my $mail_to_ok; > my $mail_to_nok; > my $from_mail; >- >+my @email; >+my @cron_storage; >+my @crontab; >+my $cron_fluxo; > my $date = localtime time; >- >+my $sendmail = "/usr/sbin/sendmail -t"; > my @stg = (""); > > sub conf() >@@ -63,6 +69,11 @@ > push(@setting, $_); > } > } >+ if (/MAILADDR/) >+ { >+ $_ =~ s/=(..)|\n|#| |\t||:(..)|\|(..)|\"|MAILADDR//g; >+ @email = $_; >+ } > } > } > >@@ -442,13 +453,100 @@ > } > } > >+sub cron_mailrep() >+{ >+ &conf(); >+ for($fluxo=0; $fluxo < scalar(@setting); $fluxo++) >+ { >+ if($setting[$fluxo] eq "CRON_SET") >+ { >+ ##print ("@email\n"); >+ @cron_storage = `mailrep.pl --rbl && mailrep.pl --errors`; >+ open(CRON, "</etc/crontab") || die "No crontab scheduling conf\n"; >+ while(<CRON>) >+ { >+ push(@crontab,$_); >+ } >+ close(CRON); >+ for(@crontab) >+ { >+ if(/mailrep.pl/) >+ { >+ if(/-cron/) >+ { >+ $cron_fluxo = 0; >+ } else { $cron_fluxo = 1; } >+ } else { $cron_fluxo = 1; } >+ } >+ >+ } >+ } >+ if($cron_fluxo == 1) >+ { >+ print("NO SCHEDULING\n"); >+ print("Please: ./mailrep.pl --cronsetting <MINUTE> <HOUR>\n"); >+ } >+ elsif($cron_fluxo == 0) >+ { >+ my $subject = "Subject: MailReport Daily Scheduling"; >+ my $reply_to = "@email"; >+ my $to = "@email"; >+ open(LOG,">/tmp/log.mailrep"); >+ print LOG @cron_storage; >+ close(LOG); >+ open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!"; >+ print SENDMAIL "From: $reply_to\n"; >+ print SENDMAIL "To: $to\n"; >+ print SENDMAIL "$subject\n"; >+ print SENDMAIL "Content-type: text/plain\n\n"; >+ print SENDMAIL @cron_storage; >+ close(SENDMAIL); >+ system("rm -f /tmp/log.mailrep"); >+ } >+} >+ >+sub cron_remove() >+{ >+ open(CRON, "/etc/crontab") || die "No crontab scheduling conf\n"; >+ while(<CRON>) >+ { >+ unless($_ =~ s/mailrep.pl -cron//g) >+ { >+ push(@crontab,$_); >+ } >+ } >+ close(CRON); >+ open(CRON, ">/etc/crontab"); >+ print CRON @crontab; >+ close(CRON); >+} >+ >+sub cron_setting() >+{ >+ if ($ARGV[1] eq "" & $ARGV[2] eq "") >+ { >+ print("Usage: ./mailrep.pl --cronsetting <MINUTE> <HOUR>\n"); >+ print("Example: ./mailrep.pl --cronsetting 15 22\n"); >+ } >+ elsif ($ARGV[2] eq "") >+ { >+ print("Usage: ./mailrep.pl --cronsetting $ARGV[1] <HOUR>\n"); >+ } else { >+ open(CRON,">>/etc/crontab"); >+ print ("$ARGV[1] \t$ARGV[2] \t* \t* \t* \tmailrep.pl -cron\n"); >+ print CRON "$ARGV[1] \t$ARGV[2] \t* \t* \t* \troot \t/usr/local/sbin/mailrep.pl -cron\n"; >+ close(CRON); >+ } >+ >+} >+ > sub help_spamrel() > { > if ($ARGV[0] eq "") > { > print ("\nmailrep --help\n\n"); > } >- elsif ($ARGV[0] ne "--help" & $ARGV[0] ne "--conf" & $ARGV[0] ne "--rbl" & $ARGV[0] ne "--errors" & $ARGV[0] ne "--license" & $ARGV[0] ne "--mail-to" & $ARGV[0] ne "--mail-from") >+ elsif ($ARGV[0] ne "--help" & $ARGV[0] ne "--conf" & $ARGV[0] ne "--rbl" & $ARGV[0] ne "--errors" & $ARGV[0] ne "--license" & $ARGV[0] ne "--mail-to" & $ARGV[0] ne "--mail-from" & $ARGV[0] ne "-cron" & $ARGV[0] ne "--cronsetting") > { > print("\nmailrep --help\n\n"); > } >@@ -459,7 +557,8 @@ > print("mailrep --mail-to --with user\@domain [Number of emails sent for determined account]\n"); > print("mailrep --mail-from --with user\@domain [Number of email of who external sends\n"); > print("mailrep --rbl [To report the number of blockades in the RBLS]\n"); >- print("mailrep --errors [Errors in agreement the configuration archive]\n\n"); >+ print("mailrep --errors [Errors in agreement the configuration archive]\n"); >+ print("mailrep --cronsetting [Setting Minute and Hour for Scheduling in crontab]\n\n"); > } > if ($ARGV[0] eq "--conf") > { >@@ -497,6 +596,45 @@ > if ($ARGV[0] eq "--mail-from") > { > &mail_from(); >+ } >+ if ($ARGV[0] eq "-cron") >+ { >+ &conf(); >+ for($fluxo=0; $fluxo < scalar(@setting); $fluxo++) >+ { >+ if($setting[$fluxo] eq "CRON_SET") >+ { >+ &cron_mailrep(); >+ $cron_fluxo = 3; >+ } else { >+ $cron_fluxo = 2; >+ } >+ } >+ if($cron_fluxo == 2) >+ { >+ &cron_remove(); >+ print("Please set CRON_SET = 1 in /usr/local/etc/mailrep/mailrep.conf\n"); >+ } >+ } >+ if ($ARGV[0] eq "--cronsetting") >+ { >+ &conf(); >+ for($fluxo=0; $fluxo < scalar(@setting); $fluxo++) >+ { >+ if($setting[$fluxo] eq "CRON_SET") >+ { >+ &cron_setting(); >+ $cron_fluxo = 3; >+ } else { >+ $cron_fluxo = 2; >+ } >+ } >+ if($cron_fluxo == 2) >+ { >+ &cron_remove(); >+ print("Please set CRON_SET = 1 in /usr/local/etc/mailrep/mailrep.conf\n"); >+ } >+ > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 103319
: 70856