#!/usr/bin/perl # # Master Pre-Installation Tester # Version 1.0 # October 16, 2000 # Author: William Bontrager # Author's E-mail: william@willmaster.com # Author's Website: http://www.willmaster.com/ # # Master Pre-Installation Tester is designed to test your server in various # ways to assist you in determining directory paths and whether or not # specific Perl scripts will run on your server. # # It is designed to be executed with Perl 5+; it won't work with versions # prior to 5. It was developed and tested on a Unix server. # # COPYRIGHT NOTICE # Copyright 1998-2000 by William Bontrager. All rights reserved. # # Before installing and/or using Master Pre-Installation Tester, # you must agree to the complete license agreement # linked from http://willmaster.com/master # #=============================== # # I N S T R U C T I O N S # # All modifications must be made with an ASCII/plain text word processor (NotePad # and BBEdit are good). Also, when you upload the script, it must be uploaded as # ASCII/plain text. # # The file name of Master Pre-Installation Tester must have the extension your # server requires for Perl CGI scripts. Usually, that will be .cgi but sometimes # .pl is required. If in doubt, try MasterPreInstallationTester.cgi first. # # Step-by-step installation instructions: # # (1) Ensure the first line of this file points toward your Perl 5+ program. # Leave the "#!" at the beginning of the line. # # (2) Upload MasterPreInstallationTester.cgi into a directory allowed to run CGI programs. # # (3) Set file execution permission to MasterPreInstallationTester.cgi. # # If you're setting execution permission with your FTP program, the settings # are: # # owner -- read/write/execute # group -- read/execute # world -- read/execute # (some FTP programs use "other" instead of "world") # # If you're setting execution permission with Telnet, type: # # chmod 0755 MasterPreInstallationTester.cgi # # To use Master Pre-Installation Tester just type its URL into your browser. # Example: http://www.yourdomain.com/cgi-bin/MasterPreInstallationTester.cgi # #=============================== # # No other customization needed. # #=============================== require 5; $ME = $0; $ME =~ s/.*\/(.*?)/$1/; %R = (nflag => '', yflag => ' CHECKED'); @SNDtry = qw( /usr/sbin/sendmail /sbin/sendmail /usr/bin/sendmail /bin/sendmail /usr/lib/sendmail /lib/sendmail /usr/slib/sendmail /slib/sendmail /usr/sendmail /sendmail sendmail ); sub Exit { goto THE_END; } sub ValidEmail { return 0 if $_[0] =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; return 0 if $_[0] !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; return 1; } # sub ValidEmail sub PrintSpace { print '

'; } sub PageTop { print "Content-type: text/html\n\n"; print < Master Pre-Installation Tester

Master Pre-Installation Tester

 

EOT PrintSpace; } # PageTop sub PageBottom { print '
Copyright 2000 William Bontrager.
'; Exit; } sub PrintMainMenu { print <
Main Menu
[?] Report environment variables.
[?] Report Perl version.
[?] Report current directory.
[?] Report location of sendmail.
[?] Report directories included in module search.
[?] Report whether or not module
Socket is installed.
[?] Report whether or not module
LWP::Simple is installed.
[?] Report whether or not module
is installed.
EOT } # sub PrintMainMenu sub Parse { my $buffer; if ($ENV{REQUEST_METHOD} eq 'GET') { $buffer = $ENV{QUERY_STRING}; } else { read(STDIN,$buffer,$ENV{CONTENT_LENGTH}); } my @p = split /&/,$buffer; foreach(@p) { my ($n,$v) = split(/=/,$_,2); $n =~ tr/+/ /; $v =~ tr/+/ /; $v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $In{$n} = $v; } } # sub Parse sub PresentEnv { print <
Environment Variables
EOT for(sort keys %ENV) { print < EOT } print '
$_ $ENV{$_}
'; PrintSpace } # PresentEnv sub PresentVer { print <
Perl Version
$]
EOT PrintSpace } # PresentVer sub PresentInc { print <
Module Search Include Directories
EOT my $break = ''; for(@INC) { print "\n$break$_"; $break = '
'; } print '
'; PrintSpace } # PresentInc sub PresentSnd { print <
Location of Sendmail
EOT my $break = ''; for(@SNDtry) { if(-e $_) { print "\n$break$_"; $break = '
'; } } unless($break) { print <
'; PrintSpace } # PresentSnd sub PresentCwd { my $dir = <
Current Directory
$dir
EOT PrintSpace } # PresentCwd sub PresentMod { my $r = "Sorry, I can not find Perl module $_[0] on this server."; $r = "Yes! Perl module $_[0] is installed on this server." if eval("require $_[0]"); print <
Module $_[0] Availability
$r
EOT PrintSpace } # PresentMod sub env { return < Among other things, the data can be useful to determine the server paths of public and other directories.

SUBenv } # sub env sub ver { return < Socket is a module often used by scripts.

SUBsoc } # sub soc sub smp { return <::Simple" is installed on your server.

LWP::Simple is a module often used by scripts.

SUBsmp } # sub smp sub custom { return < Just type the module's name in the space provided. The module name is case sensitive.

SUBcustom } # sub custom sub ProvideHelp { my $h = eval("$In{h}"); print "Content-type: text/html\n\n"; print <
$h

EOT } # sub ProvideHelp Parse; if($In{h}) { ProvideHelp; Exit; } if($In{flag} eq 'yes') { $R{yflag} = ' CHECKED'; $R{nflag} = ''; } else { $R{yflag} = ''; $R{nflag} = ' CHECKED'; } PageTop; PresentEnv if $In{env}; PresentVer if $In{ver}; PresentCwd if $In{cwd}; PresentSnd if $In{snd}; PresentInc if $In{inc}; PresentMod('Socket') if $In{soc}; PresentMod('LWP::Simple') if $In{smp}; PresentMod($In{module}) if $In{module}; PrintMainMenu; PageBottom; THE_END: