#!/usr/bin/perl --
############################################################################
# Soupermail Install Helper
#
# Internal build version:
# $Id: souperinstall.pl,v 1.19 2001/02/07 08:31:30 aithalv Exp $
#
# Something to take the pain out of installing Soupermail
# Copyright (C) 2000, 2001
# Vittal Aithal Below is some diagnostic information that can be used to help install
Soupermail.
Text displayed in GREY is diagnostic information, which you can ignore (even
if it says software error).
Text written in BLUE contains information messages that you
should read. However they are NOT critical.
Text written in RED is critical, and contains information
you MUST act on.
Done\n";
if ($srvRoot && $soupermail && $cf->{'tmp'} && $mimeOk &&
($os eq "win" ||($os eq "unix" && $cf->{'perl'})) &&
($cf->{'mprog'} || $cf->{'mhost'})) {
if (-f "${cgiPath}/$scrName" && -r "${cgiPath}/$scrName") {
print " \n";
}
printValues();
print " Once you have successfully installed " .
"soupermail, remove the installer files (script and HTML file). ".
"THIS IS IMPORTANT as it will stop people from seeing " .
"your server configuration and you won't interfere with other " .
"people installing Soupermail.Soupermail Installer Helper
END_OF_HEADER
print "Webserver $_\n";
}
if (/\bapache\b/i) {
$srv = "apache";
} elsif (/\biis\d/i) {
$srv = "iis";
} elsif (/\b(netscape|iplanet)\d/i) {
$srv = "ns";
}
# try and determine the OS
$_ =$^O;
if (/\bmswin/i) {
$os = "win";
} elsif (/bsd/i) {
$os = "unix";
$fhBug = 1;
} elsif (/\b(.in.x|\w+ix|sunos|solaris)/i) {
$os = "unix";
}
(!$make) && print "
Perl $]\n";
if ($os eq "unix") {
(!$make) && print "
Operating system UNIX ($^O)\n";
@path = qw(/usr/local/bin /usr/bin /bin /usr/local/share/bin);
@tmpList = qw(/var/tmp /tmp /usr/tmp);
$dirCmd = "/bin/pwd";
$mailUser = "root";
my @smDirs = qw(/usr/lib /var/lib /usr/local/lib /usr/local/bin /usr/sbin /sbin);
while (!$cf->{'mprog'} && ($_ = shift (@smDirs))) {
if (-f "$_/sendmail" && -x "$_/sendmail") {
$cf->{'mprog'} = "$_/sendmail";
}
}
$binFiles = {
'pgp' => 'pgp2',
'pgpe' => 'pgp5',
'gpg' => 'gpg',
'ps2pdf' => 'ps2pdf',
'lout' => 'lout'
};
} elsif ($os eq "win") {
(!$make) && print "
Operating system Windows ($^O)\n";
@path = ("c:/program files", "d:/program files", "c:/", "d:/", "e:/", "f:/");
@tmpList = qw(c:/temp d:/temp c:/tmp d:/tmp c:/winnt/temp
c:/windows/temp c:/winnt40/temp);
$dirCmd = "cd";
$mailUser = "administrator";
$binFiles = {
'pgp.exe' => 'pgp2',
'pgpe.exe' => 'pgp5',
'gpg.exe' => 'gpg',
'ps2pdf.bat' => 'ps2pdf',
'lout.exe' => 'lout'
};
}
# find the temp directory
while ($_ = shift @tmpList) {
if (-d $_ && -w $_) {
$cf->{'tmp'} = $_;
last;
}
}
# try and figure out where we're being called from
if ($0) {
my $cgi = $0;
(!$make) && print "
Found \$0 $cgi\n";
$cgi =~ s#\\#/#g;
if ($cgi =~ m#/#) {
$cgi =~ s#/([^/]*)$##;
$cgiPath = $cgi;
my @cgi = split(m#/#, $cgi);
my $buildPath = "";
$buildPath = shift(@cgi);
if ($os ne "win") {
$buildPath .= "/" . shift(@cgi);
}
while (my $p = shift(@cgi)) {
$buildPath .= "/$p";
unshift(@dirList, $buildPath);
}
}
} else {
(!$make) && print "
Didn't find \$0\n";
}
# see if we can find the document root
if ($dirCmd) {
my $startDir = "";
open(DC, "$dirCmd |");
$_ =
Found starting directory $startDir\n";
my $startPath = $startDir;
my @cgi = split(m#/#, $startDir);
my $depth = ($startDir =~ tr#/#/#);
my $buildPath = "";
if ($depth > 2) {
$buildPath = shift(@cgi);
$buildPath .= "/" . shift(@cgi);
}
my $p;
foreach $p (@cgi) {
$buildPath .= "/$p";
$buildPath =~ s#/+#/#g;
(!$make) && print "
paths... $buildPath\n";
unshift(@dirList, $buildPath);
}
(!$make) && print "
Environment DOCUMENT_ROOT is: $ENV{DOCUMENT_ROOT}\n";
push(@dirList, $ENV{'DOCUMENT_ROOT'});
(!$make) && print "
Installer searching these paths... " . join(", ", @dirList);
searchForPage();
if ($srvRoot) {
$srvRoot =~ /^(.*[\/\\])/;
$pvtRoot = "${1}private";
}
}
my $soupermail = "$cgiPath/$scrName";
if (-f "$soupermail") {
(!$make) && print "
Found $scrName $soupermail\n";
}
# Stop local errors being sent to the browser (???)
$SIG{__WARN__} = sub { };
# Look for MIME::Lite
(!$make) && print "
Looking for the required perl module MIME::Lite\n";
eval("use lib qw(. $cgiPath);\nuse MIME::Lite;");
if ($@) {
print<<"EOT";
Trouble, the MIME::Lite module doesn't seem to be installed.
Install it on the webserver before proceeding. See the MIME::Lite section of
install.txt included with Soupermail and read
${faq}#mimelite, the MIME::Lite section of the FAQ, for
instructions.
EOT
} else {
(!$make) && print "
Found the MIME::Lite module\n";
$mimeOk = 1;
}
# Look for DBI
(!$make) && print "
Looking for the optional perl module DBI\n";
eval("use lib qw(. $cgiPath);\nuse DBI;");
if ($@) {
print<<"EOT";
It doesn't look like DBI is available on your server.
This means that you won't be able to use Soupermail's database features.
Please read ${faq}#dbi, the DBI section of the FAQ,
for more information. If you are not going to use Soupermail's database features,
you can safely ignore this message.
EOT
} else {
(!$make) && print "
Found the DBI module\n";
$dbiOk = 1;
}
(!$make) && print "
Looking for a mailserver\n";
eval("use lib qw(. $cgiPath);\nuse Net::SMTP;");
if ($@ && !$cf->{'mprog'}) {
print<<"EOT";
Trouble, the Net::SMTP module doesn't seem to be installed.
Install it on the webserver before proceeding. See the last section of
install.txt included with Soupermail and read
${faq}#libnet, the Net::SMTP section of the FAQ,
for instructions.
EOT
} elsif (!$@) {
(!$make) && print "
Found the Net::SMTP module\n";
my @hosts = qw(localhost mail-fwd relay smtp mail mailhost relay1 smtp-relay
mail-relay imap);
(param('mailserver')) && unshift(@hosts, param('mailserver'));
(!$make) && print "
Looking through these mailservers " .
join(", ", @hosts) . "\n";
while (my $mhost = shift(@hosts)) {
if ($mhost =~ /^[\w\d\-]+(\.[\w\d\-]+)*$/) {
if (checkMailHost($mhost)) {
$cf->{mhost} = $mhost;
(!$make) && print "
Found mail server $mhost\n";
last;
}
} else {
$mhost =~ s/</g;
$mhost =~ s/>/>/g;
print "
Trouble, the mail server name $mhost doesn't look valid.\n";
}
}
}
(!$make && $cf->{'mprog'}) && print "
Found mail program $cf->{mprog}\n";
searchForBins();
my $fh = new FileHandle;
if ($soupermail && -f $soupermail && -r $soupermail) {
if ($fh->open("< $soupermail")) {
$fhBug = ! (eval("-T \$fh"));
}
$fh->close();
} elsif ($cf->{'tmp'}) {
my $tmpFile = "$cf->{tmp}/itmp$$" . time;
$fh->open("> $tmpFile");
$fhBug = ! (eval("-T \$fh"));
$fh->close();
unlink $tmpFile;
} else {
print "
Cannot determine \$fhBug: setting to 1 for safety\n";
$fhBug = 1;
}
if (param('email')) {
my $e = param('email');
my $goodCh = '\w\d\-\.\,\/\xc0-\xd6\xd8-\xf6\xf8-\xff';
if ($e =~ /^[${goodCh}]+\@[$goodCh]+(\.[${goodCh}]+)*$/) {
$cf->{'email'} = $e;
} else {
if (server_name()) {
makeMail();
}
}
} elsif (server_name()) {
makeMail();
}
unless ($make) {
print "
Server name " . server_name() . "\n";
print "
Server IP $ENV{SERVER_ADDR}\n";
print "
Server Port $ENV{SERVER_PORT}\n";
print "
Called From $ENV{HTTP_REFERER}\n";
print "
Path Info $ENV{PATH_INFO}\n";
print "
Path Translated $ENV{PATH_TRANSLATED}\n";
print "
Install Script $0\n";
print "
Postscript to PDF " . $cf->{'ps2pdf'} . "\n";
print "
Lout " . $cf->{'lout'} . "\n";
print "
Temp area " . $cf->{'tmp'} . "\n";
print "
Perl " . $cf->{'perl'} . "\n";
print "
GPG " . $cf->{'gpg'} . "\n";
print "
PGP2 " . $cf->{'pgp2'} . "\n";
print "
PGP5 " . $cf->{'pgp5'} . "\n";
print "
Server Root $srvRoot\n";
print "
Expanded Server Root " . expandSymlinks($srvRoot) . "\n";
print "
Assumed Private Root $pvtRoot\n";
print "
FileHandle bug $fhBug\n";
print "
Admin email $cf->{email}\n";
print "\n
Excellent! Your settings are OK to make a custom install. " .
"Press the button below to generate a copy of Soupermail for " .
"your server. The customised script will be returned to your " .
"browser and you should Save it to file once its downloaded. " .
"\n" .
"If you would like to edit $scrName yourself, these are the " .
"values to use:
";
} else {
print "
The installer cannot fully read the copy " .
"of $scrName installed on your server, so use the " .
"values below to finish your installation.
There was not enough information to make a custom
installation of Soupermail. See if there are any errors
reported above and try and correct them.
However, I did determine the following information:
END_OF_WARNING printValues(); } print "
(c) Vittal Aithal <" . "" . "vittal.aithal\@bigfoot.com> 2000, 2001\n" . " | " .
"" .
"${site} \n" . "In case of trouble, you MUST read this -> " . "". "${faq} |
Support requests to the Help Forum " . "MUST include ALL the information on this " . "page and YOU MUST HAVE READ the FAQ.
"; } # vim: ts=4