/
etc
/
mail
/
spamassassin
/
CMAE-SA
/
/etc/mail/spamassassin/CMAE-SA
mkdir
upload
Name
Size
Mode
Actions
cloudmark/
-
0755
rm
CMAE.pm
5685
0444
edit
dl
rm
INSTALL
27033
0644
edit
dl
rm
install.pl
6407
0755
edit
dl
rm
README
6065
0644
edit
dl
rm
sa_cmae_plugin.cfg.sample
4278
0644
edit
dl
rm
SpamDNA.tar.gz
5994664
0700
edit
dl
rm
Edit:
/etc/mail/spamassassin/CMAE-SA/install.pl
(6407B)
#!/usr/bin/perl # verify that CMAE.pm is in the correct system directory (scalar @ARGV == 1) or die "Usage: ./install.pl <SpamDNA Cartridge tarball>\n"; print "Spamassassin plugin integration installation\n"; my ($tarball) = @ARGV; my $path; my $pass; my $libary_path; ################################### ($> == 0) or die "Fail. You must be root to perform installation.\n"; ###################################################### #################### # Check the prereqs #################### print "Checking the prerequisites\n"; $pass = 0; foreach $path (@INC) { if (-e "$path/Mail/SpamAssassin/Plugin") { $pass = 1; last; } } ($pass) or die "Either spamassassin is not installed on your system or the installation has not created a Mail/SpamAssassin/Plugin directory.\n" . "You must install spamassassin and create these directories and rerun this script.\n"; # verify that we have an absolute path to the cartridge if ($tarball =~ /^[^\/]/) { die "\nFail. The path to the SpamDNA Cartridge must be absolute.\n"; } $pass = 0; foreach $path (@INC) { if (-e "$path/Params/Validate.pm") { $pass = 1; last; } } ($pass) or die "\nFail. You must install the perl-Params-Validate package to continue.\n"; # verify that we have all the tools that we need my $up = $ENV{PATH}; my @p = split ':', $up; foreach my $a ('make', 'gunzip', 'tar') { my $got = 0; foreach my $d (@p) { $d='.' if ($d eq ''); if (-x "$d/$a") { $got = 1; last; } } die "Can't find $a in \$PATH, exiting.\n" if (! $got); } print "\tOK.\n"; ############################################# print "Installing the CMAE spamassassin plugin\n"; $pass = 0; foreach $path (@INC) { if (-e "$path/Mail/SpamAssassin/Plugin/CMAE.pm") { my @diff = qx[diff $path/Mail/SpamAssassin/Plugin/CMAE.pm CMAE.pm]; my $date = time(); if (@diff) { print "A previous version of CMAE.pm exists in\n\t$path/Mail/SpamAssassin/Plugin\nand needs to be updated.\n" . "The old version will be moved to /tmp/CMAE.pm.$date\n" . "OK to continue? [Y/n] "; my $ans = <STDIN>; chomp($ans); if ($ans =~ /\s*n\s*/i) { die "Installation aborted.\n"; } system("mv $path/Mail/SpamAssassin/Plugin/CMAE.pm /tmp/CMAE.pm.$date"); if (-e "$path/Mail/SpamAssassin/Plugin/CMAE.pm" || ! -e "/tmp/CMAE.pm.$date") { die "\nFail. Could not move old CMAE.pm.\n"; } last; } else { print "\tOK. $path/Mail/SpamAssassin/Plugin/CMAE.pm is already up-to-date\n"; $pass = 1; last; } } } if (! $pass) { foreach $path (@INC) { if (-e "$path/Mail/SpamAssassin/Plugin") { system("cp CMAE.pm $path/Mail/SpamAssassin/Plugin/"); (-e "$path/Mail/SpamAssassin/Plugin/CMAE.pm") or die "\nFail. Could not install CMAE spamassassin plugin.\n"; print "\tOK. CMAE.pm copied to $path/Mail/SpamAssassin/Plugin/CMAE.pm.\n"; $pass = 1; last; } } } ($pass) or die "Either spamassassin is not installed on your system or the installation has not created a Mail/SpamAssassin/Plugin directory.\n" . "You must install spamassassin and create these directories and rerun this script.\n"; ############################################# ############################################# print "Performing cartridge installation.\n"; # if a cartridge is already installed, remove it, as well as the microupdate directory amd sample files if (-e "cloudmark/lib/cartridge.so") { system("cd ./cloudmark && rm -r etc/*.sample etc/micro_updates && rm lib/cartridge.so"); (! -e "cloudmark/lib/cartridge.so") or die "\nFail. The old SpamDNA Cartridge could not be removed.\n"; } # Unzip the tarball { (0 == system("cd ./cloudmark && gunzip < $tarball | tar xf - ")) or die "\nFail. The SpamDNA cartridge could not be extracted correctly.\n"; (-e "cloudmark/lib/cartridge.so") or die "\nFail. The SpamDNA cartridge could not be extracted correctly.\n"; print "\tOK. SpamDNA cartridge installed correctly.\n"; } my @output = qx[pwd]; $path = join (' ', @output); chomp($path); $libary_path = "$path/cloudmark/lib:$path/cloudmark/syslib"; ############################################# ############################################# print "Installing the CMAE-Client perl package\n"; foreach $path (@INC) { if (-e "$path/Cloudmark/CMAE/Client.pm") { system("rm $path/Cloudmark/CMAE/Client.pm"); (! -e "$path/Cloudmark/CMAE/Client.pm") or die "Fail. Could not remove the old version of CMAE-Client.\n"; last; } } # install a fresh version of the CMAE-Client perl module $pass = 0; { my ($version) = qx[find cloudmark/perl | cut -f3 -d'/' | tail -1]; chomp($version); system("cd ./cloudmark/perl/$version && perl Makefile.PL CMAE=../.. > /dev/null 2>&1 && make > /dev/null && make install > /dev/null"); foreach $path (@INC) { if (-e "$path/Cloudmark/CMAE/Client.pm") { print "\tOK. $version installed correctly at $path/Cloudmark/CMAE/Client.pm\n"; $pass = 1; last; } } ($pass) or die "\nFail. The $version package could not be installed.\n"; } ############################################# ############################################# print "Writing the configuration file to /etc/sa_cmae_plugin.cfg\n"; if (-e "/etc/sa_cmae_plugin.cfg") { print "\tOK. /etc/sa_cmae_plugin.cfg already exists.\n\tLook at sa_cmae_plugin.cfg.sample in the current directory for new options.\n"; } else { (0 == system("cp sa_cmae_plugin.cfg.sample /etc/sa_cmae_plugin.cfg")) or die "\nFail. /etc/sa_cmae_plugin.cfg could not be written.\n"; (-e "/etc/sa_cmae_plugin.cfg") or die "\nFail. /etc/sa_cmae_plugin.cfg could not be written.\n"; print "\tOK. /etc/sa_cmae_plugin.cfg written.\n"; } ############################################# ############################################# print "\nAdd this to your LD_LIBRARY_PATH (see INSTALL file)\n\t$libary_path\n"; print "See the INSTALL file for instructions on configuring SpamAssassin.\n";
Save
cmd:
run