From araujo@bsdmail.org Sun Sep 17 04:04:55 2006 Return-Path: Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3EBEF16A4C8 for ; Sun, 17 Sep 2006 04:04:55 +0000 (UTC) (envelope-from araujo@bsdmail.org) Received: from mail.intelbras.com.br (mail.intelbras.com.br [201.24.77.45]) by mx1.FreeBSD.org (Postfix) with ESMTP id 469DC43D4C for ; Sun, 17 Sep 2006 04:04:54 +0000 (GMT) (envelope-from araujo@bsdmail.org) Received: from localhost (localhost.intelbras.com.br [127.0.0.1]) by mail.intelbras.com.br (Postfix) with ESMTP id 725402DA429 for ; Sun, 17 Sep 2006 01:03:58 -0300 (BRT) Received: from mail.intelbras.com.br ([127.0.0.1]) by localhost (intelbras.com.br [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WW5f4LoCwEVE for ; Sun, 17 Sep 2006 01:03:58 -0300 (BRT) Received: from nagazaki.freebsd.org (200-138-246-77.fnsce7006.dsl.brasiltelecom.net.br [200.138.246.77]) by mail.intelbras.com.br (Postfix) with ESMTP id 6FFC12DA427 for ; Sun, 17 Sep 2006 01:03:57 -0300 (BRT) Message-Id: <1158454699.7594@nagazaki.freebsd.org> Date: Sat, 16 Sep 2006 21:58:19 -0300 From: "Marcelo Araujo" To: "FreeBSD gnats submit" Subject: Update: mail/mailrep X-Send-Pr-Version: gtk-send-pr 0.4.7 X-GNATS-Notify: >Number: 103319 >Category: ports >Synopsis: Update: mail/mailrep >Confidential: no >Severity: non-critical >Priority: low >Responsible: alexbl >State: closed >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Sun Sep 17 04:10:24 GMT 2006 >Closed-Date: Tue Sep 19 16:46:34 GMT 2006 >Last-Modified: Tue Sep 19 16:46:34 GMT 2006 >Originator: Marcelo Araujo >Release: FreeBSD 6.1-STABLE i386 >Organization: BSD Experience >Environment: System: FreeBSD 6.1-STABLE #5: Sun Sep 3 08:49:25 BRT 2006 root@nagazaki.freebsd.org:/usr/src/sys/i386/compile/NAGAZAKI >Description: Update MailRep v1.1 - Add Scheduling report from Crontab support. - Add check variable in Crontab mailrep. >How-To-Repeat: >Fix: --- diff.makefile begins here --- --- /usr/ports/mail/mailrep/Makefile Tue Apr 25 16:50:25 2006 +++ Makefile Sat Sep 16 21:37:25 2006 @@ -6,7 +6,7 @@ # PORTNAME= mailrep -PORTVERSION= 1.0 +PORTVERSION= 1.1 CATEGORIES= mail sysutils MASTER_SITES= http://cs.bon.matrix.com.br/araujo/pub/mailrep/ --- diff.makefile ends here --- --- diff.mailrep.conf begins here --- --- /usr/local/etc/mailrep/mailrep.conf Sat Sep 16 21:36:10 2006 +++ mailrep.conf Sat Sep 16 21:34:00 2006 @@ -26,3 +26,7 @@ # Delivered Local ## relay=local status=sent RELAY_LOCAL = 1 +# Scheduling in CRONTAB +# Send-to RBL and ERRORS +CRON_SET = 1 +MAILADDR = "example@domain" --- diff.mailrep.conf ends here --- --- diff.mailrep.pl begins here --- --- /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, ") + { + 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 \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() + { + 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 \n"); + print("Example: ./mailrep.pl --cronsetting 15 22\n"); + } + elsif ($ARGV[2] eq "") + { + print("Usage: ./mailrep.pl --cronsetting $ARGV[1] \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"); + } + } } --- diff.mailrep.pl ends here --- --- distinfo begins here --- +MD5 (mailrep-1.1.tar.gz) = dc09675eb1b4342f962a1e57a24f8204 +SHA256 (mailrep-1.1.tar.gz) = 8b8cd3d3a2ef68367760ddabe4490dab+211207b464f812de5c39a6c310cee544 +SIZE (mailrep-1.1.tar.gz) = 23552 --- distinfo ends here --- >Release-Note: >Audit-Trail: Class-Changed-From-To: update->maintainer-update Class-Changed-By: edwin Class-Changed-When: Sun Sep 17 04:10:36 UTC 2006 Class-Changed-Why: Fix category (submitter is maintainer) http://www.freebsd.org/cgi/query-pr.cgi?pr=103319 Responsible-Changed-From-To: freebsd-ports-bugs->alexbl Responsible-Changed-By: alexbl Responsible-Changed-When: Sun Sep 17 10:58:18 UTC 2006 Responsible-Changed-Why: I will take it. http://www.freebsd.org/cgi/query-pr.cgi?pr=103319 From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: ports/103319: commit references a PR Date: Tue, 19 Sep 2006 16:37:53 +0000 (UTC) alexbl 2006-09-19 16:37:46 UTC FreeBSD ports repository Modified files: mail/mailrep Makefile distinfo Log: - Update to 1.1 PR: 103319 Submitted by: Marcelo Araujo (maintainer) Approved by: novel (mentor) Revision Changes Path 1.2 +2 -2 ports/mail/mailrep/Makefile 1.2 +3 -3 ports/mail/mailrep/distinfo _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org" State-Changed-From-To: open->closed State-Changed-By: alexbl State-Changed-When: Tue Sep 19 16:46:33 UTC 2006 State-Changed-Why: Committed, thanks! http://www.freebsd.org/cgi/query-pr.cgi?pr=103319 >Unformatted: