#!/usr/bin/perl -w # # TWiki Collaboration Platform, http://TWiki.org/ # # Copyright (C) 2000-2003 Peter Thoeny, peter@thoeny.com # # For licensing info read license.txt file in the TWiki root. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details, published at # http://www.gnu.org/copyleft/gpl.html # # DESCRIPTION: Test utility to see if CGI is running and enabled # for the bin directory, and check a variety of TWiki, Perl and RCS # setup. package TWiki; # Set library paths in @INC, at compile time BEGIN { # Try to use setlib.cfg, use default path if missing if ( -r './setlib.cfg' ) { require './setlib.cfg'; } else { unshift @INC, '../lib'; } } use vars qw( $useLocale ); # =========================== # Read the configuration file at compile time in order to set locale BEGIN { do "TWiki.cfg"; # Includes OS detection # Do a dynamic 'use locale' for this script if( $useLocale ) { require locale; import locale (); } } # use strict; # Recommended for mod_perl, enable for Perl 5.6.1 only # Doesn't work well here, due to 'do "TWiki.cfg"' # use diagnostics; # Debug only my $setlibAvail = -r './setlib.cfg'; &main(); sub checkBasicModules { # Check whether basic CGI modules exist (some broken installations of # Perl don't have this, even though they are standard modules), and warn user my @basicMods = @_; my $modMissing = 0; my $mod; foreach $mod (@basicMods) { eval "use $mod"; if ($@) { unless ($modMissing) { print "Content-type: text/html\n\n"; print "
Warning: "; print "Essential module $mod not installed - please check your Perl\n"; print "installation, including the setting of \@INC, and re-install Perl if necessary.
\n"; } } # If any critical modules missing, display @INC and give up if ($modMissing) { print "\@INC setting:
";
print join "
\n", @INC;
print "
$key | $ENV{$key} |
---|
Operating system: | " . ucfirst(lc($OS)); print " ($detailedOS)" if ( $detailedOS ne '' ); print " |
---|---|
Perl version: | $perlver"; print " ($perltype)" if $perltype ne 'generic'; print " |
Warning: "; print "This version of Perl is too old for use with TWiki - upgrade to at least Perl $perlverRequiredString\n"; print "and preferably to Perl $perlverRecommended.\n"; print " | |
\@INC library path: | " .
( join " \n", @INC ) . " |
Note:\n"; print "This is the Perl library path, used to load TWiki modules, "; print "third-party modules used by some plugins, and Perl built-in modules."; print " | |
TWiki module in \@INC path: | "; $mod = 'TWiki'; eval "use $mod"; print " |
\n";
my $twikiFound = 0;
if ($@) {
print "Warning: ";
print "'$mod.pm' not found - check path to twiki/lib ";
print " and edit twiki/bin/setlib.cfg if necessary" if $setlibAvail;
print ".\n";
print " | |
Required Perl modules: | "; foreach $mod (@requiredMods) { eval "use $mod"; print " |
\n"; if ($@) { print "Warning: "; print "'$mod' not installed - check TWiki documentation to see if this is required.\n"; print " | |
Optional Perl modules: | "; foreach $mod (@optionalMods) { eval "use $mod"; print " |
\n"; if ($@) { print "Note: "; print "Optional module '$mod' not installed - check TWiki documentation to see if your configuration needs this module.\n"; print " | |
PATH_INFO: | $thePathInfo |
Note:\n"; print "For a URL such as $theUrl/foo/bar, \n"; print "the correct PATH_INFO is /foo/bar, without any prefixed path \n"; print "components. Test this now \n"; print "- particularly if you are using Apache or IIS, or are using a web hosting provider.\n"; print "The page resulting from the test link should have a PATH_INFO of /foo/bar.\n"; print " | |
mod_perl: | $USE_MOD_PERL for this script (mod_perl $LOAD_MOD_PERL) |
User: | $usr |
Note: "; print "Your CGI scripts are executing as this user."; print " | |
Warning: "; print "Since your CGI script is not running as user nobody, "; print "you need to change the locks in the *,v RCS files of the TWiki "; print "distribution from nobody to $usr.\n"; print "Otherwise, changes to topics will not be logged by RCS.\n"; print " | |
Group(s): | "; print "$grp"; print " |
\$wikiHomeUrl: | $wikiHomeUrl |
---|---|
Note: "; print "This is the link of the TWiki icon in the upper left corner."; print " | |
\$defaultUrlHost: | $defaultUrlHost |
Note: "; print "This must be the protocol and host part (with optional port number) of "; print "the TWiki URL."; print " | |
Warning: "; print "This does not match HTTP_HOST"; print " | |
\$scriptUrlPath: | $scriptUrlPath |
Note: "; print "This must be the URI of the TWiki cgi-bin directory."; print " | |
Warning: "; print "This does not match REQUEST_URI"; print " | |
\$pubUrlPath: | $pubUrlPath |
Note: ";
print "This must be the URI of the public directory.";
print "This is not set correctly if the ";
print "$pubUrlPath/wikiHome.gif image below is broken: "; print ""; print " | |
\$pubDir: | $pubDir |
Note: "; print "This is the public directory, as seen from the file system. "; print "It must correspond to \$pubUrlPath."; print " | |
Error: "; print "Directory does not exist or file wikiHome.gif does not exist in this directory."; print " | |
Error: "; print "This directory is not writable by $usr user."; print " | |
\$templateDir: | $templateDir |
Note: "; print "This is the TWiki template directory, as seen from the file system. "; print " | |
Error: "; print "Directory does not exist or file view.tmpl does not exist in this directory."; print " | |
Warning: "; print "Security issue: This directory should not be writable by the $usr user."; print " | |
\$dataDir: | $dataDir |
Note: "; print "This is the data directory where TWiki stores all topics."; print " | |
Error: "; print "Directory does not exist."; print " | |
Error: "; print "This directory must be writable by the $usr user."; print " | |
Warning: "; print "Mail program $val not found. Check the path."; print " | |
\$mailProgram: | $mailProgram |
Note: "; if( $OS ne 'WINDOWS' ) { print "This is the mail program TWiki uses to send mail."; } else { print "This is not typically used on Windows - the Perl Net::SMTP module is used instead."; } print " | |
\$rcsDir: | $rcsDir |
Note: "; print "This is the directory where RCS is located."; print " | |
Warning: "; print "RCS program $rcsDir/ci$exeSuffix not found. Check \$rcsDir setting in TWiki.cfg. "; print "TWiki will not work (unless you are "; print "using TWiki's built-in RCS implementation, RcsLite)."; print " | |
RCS Version: | $rcsVerNum"; print " (Cygwin package rcs-$cygwinRcsVerNum)" if defined($cygwinRcsVerNum); print " |
Note: "; print "This is the version of RCS which will be used."; print " | |
Warning: "; print "RCS program is too old, upgrade to version $rcsverRequired or higher."; print " | |
\$lsCmd: | $lsCmd |
Note: "; print "This is the file list program TWiki uses to list topics."; print " | |
Warning: "; print "List program $val not found. Check the path."; print " | |
\$egrepCmd: | $egrepCmd |
Note: "; print "This is a program TWiki uses for search."; print " | |
Warning: "; print "Search program $val not found. Check the path."; print " | |
\$fgrepCmd: | $fgrepCmd |
Note: "; print "This is a program TWiki uses for search."; print " | |
Warning: "; print "Search program $val not found. Check the path."; print " | |
\$safeEnvPath: | $safeEnvPath |
Note: ";
print "This is used to initialise the PATH variable, and is used to run the\n";
print "'diff' program used by RCS, as well as to run shell programs such as\n";
if( $OS eq 'WINDOWS' ) {
print "cmd.exe or Cygwin's 'bash'.\n";
print " \n"; if( $perltype eq 'Cygwin' ) { print "Since you are using Cygwin Perl, 'bash' will be used without any special setup.\n"; } elsif( $perltype eq 'ActiveState' ) { print "To use 'bash' with ActiveState Perl, see the PERL5SHELL section below\n"; print "- this is recommended\n"; print "if Cygwin is installed.\n"; } print " \n"; } else { print "Bourne shell or 'bash'."; } if( $safeEnvPath eq '' ) { print " | |
Warning: \n"; print "Security issue: \$safeEnvPath set to empty string. Check TWiki.cfg.\n"; print " |
Original PATH: | $originalPath |
---|---|
Note: "; print "This is the PATH value passed in from the web server to this script - it is reset by TWiki scripts to the PATH below, and is provided here for comparison purposes only.\n"; print " | |
Current PATH: | $currentPath |
Note: "; print "This is the actual PATH setting that will be used by Perl to run programs.\n"; print "It is normally identical to \$safeEnvPath, unless that variable is empty.\n"; print " | |
diff: | "; my $diffOut = `diff 2>&1` || ""; my $notFound = ( $? == -1 ); if( $notFound ) { print "Warning: "; print "'diff' program was not found on the current PATH.\n"; print " | Warning: "; print "'diff' program was found on the PATH but is not GNU diff - this may cause problems.\n"; print " | "; } else { print "GNU diff was found on the PATH - this is the recommended diff tool."; print " | "; } } # Final table row applies to all cases print "
Note:\n"; print "The 'diff' command is used by RCS to compare files.\n"; print " | |
PERL5SHELL: | $perl5shell |
Note: ";
print "This environment variable is used by ActiveState and other Win32 Perls to run \n";
print "commands from TWiki scripts - it determines which shell\n";
print "program is used to run commands that use 'pipes'. Examples of shell programs are \n";
print "cmd.exe, command.com (aka 'DOS Prompt'), and Cygwin's 'bash'\n";
print "(recommended if Cygwin is installed).\n";
print " \n"; print "To use 'bash' with ActiveState or other Win32 Perls, you should set the \n"; print "PERL5SHELL environment variable to something like c:/YOURCYGWINDIR/bin/bash.exe -c.\n"; print "This should be set in the System Environment, and ideally set \n"; print "directly in the web server (e.g. using the Apache SetEnv \n"; print "command, followed by an Apache restart). Once this is done, you should re-run testenv\n"; print "to check that PERL5SHELL is set properly.\n"; if ($perltype eq 'ActiveState' and Win32::BuildNumber() < $ActivePerlRecommendedBuild ) { print " \n"; print "Warning: "; print "ActiveState Perl must be upgraded to build $ActivePerlRecommendedBuild if you are going to use PERL5SHELL, which was broken in earlier builds."; } print " \n"; print " |
\$useLocale: | $useLocale |
---|---|
Note: "; print "This TWiki.cfg setting controls whether locales are used by Perl and 'grep'.\n"; print " | |
Warning: "; print "Using Perl on Windows, which may have missing or incorrect locales (in Cygwin or ActiveState Perl, respectively)\n"; print "- use of \$useLocale = 0 is recommended unless you know your version of Perl has working locale support.\n"; print " | |
\$siteLocale: | $siteLocale |
Note: ";
print "This TWiki.cfg parameter sets the site-wide locale - for\n";
print "example, de_AT.ISO-8859-1 where 'de' is the language code, 'AT' the country code and 'ISO-8859-1' is the character set. Use the locale -a command on your system to determine available locales.\n";
print " | |
Warning: "; print "Unable to set locale to $siteLocale, actual locale is $currentLocale\n"; print "- please test your locale settings.\n"; print " | |
\$upperNational: | $upperNational |
Note: ";
print "This TWiki.cfg parameter is used when \$useLocale is 0, to work around missing or non-working locales.\n";
print "It is also used with Perl 5.005 for efficiency reasons - upgrading to Perl 5.6.1 with working locales is recommended, and removes the need for this. \n";
print "If required, this parameter should be set to the upper case accented characters you require in your locale.\n";
if ( $forUpperNat ) {
print " The following upper case accented characters have been found in this locale and should be considered for use in this parameter: $forUpperNat \n"; } print " | |
\$lowerNational: | $lowerNational |
Note: ";
print "This TWiki.cfg parameter is used whenever \$upperNational is used.\n";
print "This parameter should be set to the lower case accented characters you require in your locale.\n";
if ( $forLowerNat ) {
print " The following lower case accented characters have been found in this locale and should be considered for use in this parameter: $forLowerNat \n"; } print " |