]> www.wagner.pp.ru Git - oss/stilllife.git/commitdiff
Скрипт, который проверяет, все ли необходимые модули установлены
authorVictor Wagner <vitus@wagner.pp.ru>
Mon, 21 Apr 2008 12:28:35 +0000 (12:28 +0000)
committerVictor Wagner <vitus@wagner.pp.ru>
Mon, 21 Apr 2008 12:28:35 +0000 (12:28 +0000)
forum/hostinfo [new file with mode: 0755]

diff --git a/forum/hostinfo b/forum/hostinfo
new file mode 100755 (executable)
index 0000000..5e60c78
--- /dev/null
@@ -0,0 +1,126 @@
+#!/usr/bin/perl
+use Cwd;
+use strict;
+use CGI;
+use CGI::Carp qw(fatalsToBrowser);
+
+#
+# List of modules, required direcrty by your application
+#
+my @modules=qw(MIME::Lite Image::Size HTML::TreeBuilder
+POSIX Storable HTML::BBReverse Fcntl Date::Parse
+LWP::UserAgent Net::OpenID::Consumer);
+
+#
+# This array have to be filled manually by looking into Makefile.PL:
+# of neccessary CPAN modules and copying contents of PREREQ_PM argument
+# of it. Of course, recursively.
+#
+my %prereq=(
+       "Net::OpenID::Consumer" => {
+                   'LWP::UserAgent' => 0,
+                   'HTTP::Request'  => 0,
+                   'MIME::Base64'   => 0,
+                   'Digest::SHA1'   => 0,
+                   'URI'            => 0,
+                   'Time::Local'    => 0,
+                   'URI::Fetch'     => 0.02,
+                   'Crypt::DH'      => 0.05,
+               },
+        "HTML::TreeBuilder" => {
+               "HTML::Parser" => 2.19,
+               'HTML::Tagset' => 3.02,
+         },
+       'URI::Fetch' => {
+                       'Class::ErrorHandler' =>0,
+                       'LWP'=>0,
+                       'URI'=>0,
+                       'Storable'=>0,
+       },
+       'URI' => {
+               'MIME::Base64' => 2,
+               },
+               'Crypt::DH' => {
+                       'Math::BigInt' =>0,
+               }       
+
+       );
+my %modver;
+
+my $cgi= new CGI;
+print $cgi->header(-type=>'text/html',-charset=>'windows-1251'),
+       $cgi->start_html(-title=>'Hosting information');
+
+print $cgi->h1("Hosting information");
+print $cgi->h2("Perl information");
+print "Perl version:",$cgi->escapeHTML($]),"<br>\n";
+print "\@INC:",$cgi->escapeHTML(join(" ",@INC)),"<br>\n";  
+print "CGI.pm version: $CGI::VERSION<br>";
+print $cgi->h2("Required modules");
+my ($module,$ver);
+for $module (@modules) {
+       if (exists $modver{$module}) {
+               $ver = $modver{$module}
+       } else {        
+               eval "use $module; \$ver=\$${module}::VERSION;";
+               if ($@) {
+                       print "$module : <font color=\"red\">not found</font><br>";
+                       if (exists $prereq{$module}) {
+                               scan_prereq($module);
+                       }
+                       next;   
+               }
+               $modver{$module} = $ver;
+       }       
+       print "$module: $ver<br>";
+}      
+
+print $cgi->h2("Execution environment"),"\n"; 
+
+print "Script execution directory: <tt>",getcwd,"</tt><br>\n";
+print "Invoking user id ",$(+0," name(getpwuid) <tt>".(getpwuid($())[0]."</tt><br>\n";
+print "User home directory (getpwuid): <tt>".(getpwuid($())[7]."</tt><br>\n"; 
+print "User home directory(environment): <tt>",$ENV{'HOME'},"</tt><br>\n";
+print "Script name (\$0): <tt>$0</tt><br>\n";
+print "Script filename (from <b>SCRIPT_FILENAME</b> env var)
+<tt>$ENV{'SCRIPT_FILENAME'}</tt.<br>\n"; 
+print "Document root: <tt>$ENV{'DOCUMENT_ROOT'}</tt><br>\n";
+print "<b>LANG</b>: <tt>$ENV{LANG}</tt><br>\n";
+print "<b>SERVER_ADDR</b>: <tt>$ENV{SERVER_ADDR}</tt><br>\n";
+print "<b>PATH</b>: $ENV{'PATH'}<br>\n";
+eval {
+ use POSIX;    
+ my ($sysname, $nodename, $release, $version, $machine) = POSIX::uname();
+ print "System: $sysname $release $version (from POSIX::uname)<br>\n";
+}; 
+if ($@) {
+       print "System: `uname -a` (from OS uname command)<br>\n";
+} 
+sub scan_prereq {
+       my $module = shift;
+       print "<br><b>Prerequistes for $module</b>:<br><blockquote>\n";
+       my $ver;
+       MODULE:
+       while (my ($mod,$needed_ver) = each %{$prereq{$module}}) {
+               if (exists $modver{$module}) {
+                       $ver = $modver{$module};
+               } else {        
+                       eval "use $mod; \$ver=\$${mod}::VERSION;";
+                       if ($@) {
+                               print "$mod : <font color=\"red\">not found</font><br>";
+                               if (exists $prereq{$mod}) {
+                                       scan_prereq($mod);
+                               }
+                               next MODULE;
+                       }       
+                       $modver{$mod} = $ver;
+               }       
+               if ($ver < $needed_ver) {
+                       print "$mod: <font color=\"red\">$ver</font> (need $needed_ver<br>\n";  
+               } else {        
+                       print "$mod: $ver<br>\n";
+               }
+       }
+       print "</blockquote>\n";
+}      
+