Turn on notification feature.
git-svn-id: svn://10.0.0.236/trunk@33759 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
90348e63ec
commit
6cad802029
@ -10,3 +10,5 @@
|
|||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
#ALL mail %s -s "CVS notification"
|
#ALL mail %s -s "CVS notification"
|
||||||
|
|
||||||
|
ALL $CVSROOT/CVSROOT/sendnotification.pl %s
|
||||||
|
|||||||
78
CVSROOT/sendnotification.pl
Executable file
78
CVSROOT/sendnotification.pl
Executable file
@ -0,0 +1,78 @@
|
|||||||
|
#! /tools/ns/bin/perl5
|
||||||
|
|
||||||
|
use Socket;
|
||||||
|
|
||||||
|
sub get_response_code {
|
||||||
|
my ($expecting) = @_;
|
||||||
|
# if ($flag_debug) {
|
||||||
|
# print STDERR "SMTP: Waiting for code $expecting\n";
|
||||||
|
# }
|
||||||
|
while (1) {
|
||||||
|
my $line = <S>;
|
||||||
|
# if ($flag_debug) {
|
||||||
|
# print STDERR "SMTP: $line";
|
||||||
|
# }
|
||||||
|
if ($line =~ /^[0-9]*-/) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if ($line =~ /(^[0-9]*) /) {
|
||||||
|
my $code = $1;
|
||||||
|
if ($code == $expecting) {
|
||||||
|
# if ($flag_debug) {
|
||||||
|
# print STDERR "SMTP: got it.\n";
|
||||||
|
# }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
die "Bad response from SMTP -- $line";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my @mailto;
|
||||||
|
my $i;
|
||||||
|
foreach $i (@ARGV) {
|
||||||
|
# Deal with our "%" encoding of email addresses.
|
||||||
|
if ($i !~ /\@/) {
|
||||||
|
$i =~ s/%/\@/;
|
||||||
|
}
|
||||||
|
push(@mailto, $i);
|
||||||
|
}
|
||||||
|
|
||||||
|
chop(my $hostname = `hostname`);
|
||||||
|
|
||||||
|
my ($remote,$port, $iaddr, $paddr, $proto, $line);
|
||||||
|
|
||||||
|
$remote = $mailhost;
|
||||||
|
$port = 25;
|
||||||
|
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
|
||||||
|
die "No port" unless $port;
|
||||||
|
$iaddr = inet_aton($remote) || die "no host: $remote";
|
||||||
|
$paddr = sockaddr_in($port, $iaddr);
|
||||||
|
|
||||||
|
$proto = getprotobyname('tcp');
|
||||||
|
socket(S, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
|
||||||
|
connect(S, $paddr) || die "connect: $!";
|
||||||
|
select(S); $| = 1; select(STDOUT);
|
||||||
|
|
||||||
|
get_response_code(220);
|
||||||
|
print S "EHLO $hostname\n";
|
||||||
|
get_response_code(250);
|
||||||
|
print S "MAIL FROM: cvs-notify-daemon@$hostname\n";
|
||||||
|
get_response_code(250);
|
||||||
|
foreach $i (@mailto) {
|
||||||
|
print S "RCPT TO: $i\n";
|
||||||
|
get_response_code(250);
|
||||||
|
}
|
||||||
|
print S "DATA\n";
|
||||||
|
get_response_code(354);
|
||||||
|
# Get one line starting with "354 ".
|
||||||
|
print S "Subject: CVS notification\n";
|
||||||
|
print S "To: " . join(',', @mailto) . "\n";
|
||||||
|
print S "\n";
|
||||||
|
while (<STDIN>) {
|
||||||
|
print S $_;
|
||||||
|
}
|
||||||
|
print S ".\n";
|
||||||
|
get_response_code(250);
|
||||||
|
print S "QUIT\n";
|
||||||
|
close(S);
|
||||||
Loading…
x
Reference in New Issue
Block a user