From owner-freebsd-ports-bugs@FreeBSD.ORG Sun Sep 17 04:10:26 2006 Return-Path: X-Original-To: freebsd-ports-bugs@hub.freebsd.org Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B65F16A412 for ; Sun, 17 Sep 2006 04:10:26 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 45A2143D5E for ; Sun, 17 Sep 2006 04:10:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k8H4AOKO070330 for ; Sun, 17 Sep 2006 04:10:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k8H4AOA2070329; Sun, 17 Sep 2006 04:10:24 GMT (envelope-from gnats) Resent-Date: Sun, 17 Sep 2006 04:10:24 GMT Resent-Message-Id: <200609170410.k8H4AOA2070329@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Marcelo Araujo" 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" X-Send-Pr-Version: gtk-send-pr 0.4.7 Cc: Subject: ports/103319: Update: mail/mailrep X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Sep 2006 04:10:26 -0000 >Number: 103319 >Category: ports >Synopsis: Update: mail/mailrep >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sun Sep 17 04:10:24 GMT 2006 >Closed-Date: >Last-Modified: >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: >Unformatted: