#! /usr/bin/perl -w use strict ; my $login = getpwuid $< ; die "can't find your login" unless $login ; my $DEF_CNF = 'mirmon/mirmon.conf' ; my $me = "$login\@apache.org" ; my $SMAIL = '/usr/sbin/sendmail' ; use lib 'mirmon' ; # Mirmon.pm lives in subdir mirmon. use Mirmon ; my $prog = substr $0, rindex ( $0, '/' ) + 1 ; my $Usage = < new ( $opt{c} ) ; my $conf = $M -> conf ; my $state = $M -> state ; my %mirrs = () ; my $to = "To: %MAIL%" ; $to = "X-$to\nTo: $me" if $opt{t} ; my $cc = "Cc: apmirror\@apache.org" ; $cc = "X-$cc" if $opt{t} ; my $templ = < Subject: %URL1% - your apache mirror Reply-To: apmirror\@apache.org MAIL $templ .= "$to\n" ; $templ .= "$cc\n" unless $opt{nocc} ; $templ .= "\n" ; while ( <> ) { chomp ; s/ .*$//; # remove trailing comments last if /-------------/ ; next if /^#/ or /^\s*$/ ; unless ( exists $state -> { $_ } ) { Warn "mirror not found ($_)" ; } else { $mirrs { $_ } = $state -> { $_ } ; } } $templ .= join '', <> ; printf "%s\n", $templ ; my %urls = () ; for my $mirr ( values %mirrs ) { my $mail = $mirr -> mail ; my $url = $mirr -> url ; Error "no mail for $url" unless $mail ; push @{ $urls { $mail } }, $url ; } my $cnt = 0 ; for my $MAIL ( sort keys %urls ) { my @urls = @{ $urls { $MAIL } } ; my $URL1 = $urls [ 0 ] ; my $URLS = join "\n ", @urls ; my $tmp = $templ ; $tmp =~ s/%MAIL%/$MAIL/g ; $tmp =~ s/%URLS%/$URLS/g ; $tmp =~ s/%URL1%/$URL1/g ; printf "%s mail to '%s'\n" , ( $opt{t} ? 'WOULD send' : ( $opt{f} ? 'DID send' : 'NOT sent' ) ) , $MAIL ; print "-------------------------\n" ; if ( $opt{t} or $opt{f} ) { next if $opt{t} and ++ $cnt > 2 ; open SMAIL, "| $SMAIL -fapmirror\@apache.org -t" or Error "can't popen $SMAIL ($!)" ; print SMAIL $tmp ; close $SMAIL ; } else { print "$tmp\n" ; print "-------------------------\n" ; } }