head	1.3;
access;
symbols
	RELEASE_4_4_0:1.2
	RELEASE_4_3_0:1.1;
locks; strict;
comment	@# @;


1.3
date	2001.10.21.18.47.20;	author dwcjr;	state dead;
branches;
next	1.2;

1.2
date	2001.05.31.12.08.54;	author olgeni;	state Exp;
branches;
next	1.1;

1.1
date	2001.01.07.07.38.32;	author will;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Update to version 11
Give Seamus Venasse maintainership

PR:		31095
Submitted by:	new maintainer
@
text
@#!/usr/bin/perl
# Roman Shterenzon <roman@@xpert.com> 27/12/2000 
# $FreeBSD: ports/security/amavis-perl/pkg-install,v 1.2 2001/05/31 12:08:54 olgeni Exp $

use strict;

$ENV{'PATH'}='/bin:/usr/bin';

my $cfg;
my $result;

exit 0 if $ARGV[1] ne "POST-INSTALL";

if ( -f '/etc/mail/sendmail.cf' ) {
  $cfg='/etc/mail';
}
elsif ( -f '/etc/sendmail.cf' ) {
  $cfg='/etc';
}
my $cf="$cfg/sendmail.cf";
my $new="$cfg/amavis.cf";

print "===> Adding necessary hooks to sendmail.cf file\n";

open(IN, $cf) || die "Cannot open $cf";
open(OUT, ">$new") || die "Cannot create $new";

my $replace=0;

while(<IN>) {
  if ( /^O QueueDirectory/ ) {
    $_="O QueueDirectory=/var/spool/mqamavis\n";
    $replace++;
  }
  elsif ( /O StatusFile/ ) {
    $_="O StatusFile=/var/log/amavis.st\n";
    $replace++;
  }
  elsif ( /^Mlocal/ ) {
    print OUT <<'EOF';
Mamavis,	P=/usr/local/sbin/amavis, F=mlsACDFMS5:/|@@qhP, S=0, R=0
		T=DNS/RFC822/X-Unix,
		A=amavis $f $u 

EOF
    $replace++;
  }
  elsif ( /\s+final\s+parsing$/ ) {
    print OUT "R\$*\t\t\t\$#amavis \$:\$1\n";
    $replace++;
  }
  s/^(DZ.*)/$1av/;
  print OUT;
}
close(OUT);
close(IN);
die "I couldn't patch the sendmail.cf file, its format is unknown to me\n"
	unless ( $replace == 4 );

print "===> Adding alias for virusalert to the aliases file\n";
if ( ! -f "$cfg/aliases" ) {
  print "Can't find aliases file, you have to add an alias for virusalert by yourself\n";
}
else {
  open (IN, "$cfg/aliases") || die "Cannot open aliases file for reading\n";
  my $found;
  while(<IN>) {
    $found=1, last if /^virusalert/;
  }
  close(IN);
  unless ($found) {
    open(OUT, ">>$cfg/aliases") || die "Cannot open aliases file for writing\n";
    print OUT "virusalert:\troot\n";
    close(OUT);
    $result=system("newaliases");
    die "Failed to run newaliases command\n" if $result;
  }
}

print "===> Creating /var/spool/mqamavis directory\n";
if ( ! -d "/var/spool/mqamavis" ) {
  mkdir "/var/spool/mqamavis",0755 || die "Can't create /var/spool/mqamavis\n";
}
my $gid=getgrnam('daemon');
chown 0, $gid, "/var/spool/mqamavis";

print "===> Creating /var/spool/quarantine directory\n";
if ( ! -d "/var/spool/quarantine" ) {
  mkdir "/var/spool/quarantine",0755 || die "Can't create /var/spool/quarantine\n";
}
chown 0, $gid, "/var/spool/quarantine";

die "There's already a $cf.pre-amavis, is amavis already installed?\n"
  if -f "$cf.pre-amavis";
$result=system("cp $cf $cf.pre-amavis");
die "Failed to copy $cf to $cf.pre-amavis\n" if $result;
rename "$cf", "${cfg}/sendmail.orig.cf" ||
  die "Unable to rename $cf to ${cfg}/sendmail.orig.cf\n";
rename "$new", "$cf" || die "Unable to rename $new to $cf\n";
@


1.2
log
@Fix typo: neccessary -> necessary.
@
text
@d3 1
a3 1
# $FreeBSD: ports/security/amavis-perl/pkg-install,v 1.1 2001/01/07 07:38:32 will Exp $
@


1.1
log
@Add amavis-perl 10, a mail virus scanner (uses external antivirus).

PR:		23978
Submitted by:	Roman Shterenzon <roman@@xpert.com>
@
text
@d3 1
a3 1
# $FreeBSD$
d23 1
a23 1
print "===> Adding neccessary hooks to sendmail.cf file\n";
@

