Diff for /loncom/build/system_dependencies/sqltest.pl between versions 1.6 and 1.11

version 1.6, 2002/08/06 23:18:25 version 1.11, 2003/02/03 18:03:52
Line 17  B<sqltest.pl> - Test interoperability of Line 17  B<sqltest.pl> - Test interoperability of
 # Written to help LON-CAPA (The LearningOnline Network with CAPA)  # Written to help LON-CAPA (The LearningOnline Network with CAPA)
 #  #
 # YEAR=2001  # YEAR=2001
 # 9/25,9/30 Scott Harrison  
 # YEAR=2002  # YEAR=2002
 # 5/10,5/11 Scott Harrison  
 # 8/6/2002 and onwards, Scott Harrison, sharrison@users.sourceforge.net  
   
 =pod  =pod
   
Line 41  avoid indirectly testing software depend Line 38  avoid indirectly testing software depend
   
 =head2 ORGANIZATION OF THIS PERL SCRIPT  =head2 ORGANIZATION OF THIS PERL SCRIPT
   
 The script is organized into the following sections  The script is organized into the following sections.
   
 =over 4  =over 4
   
 =item 1.  =item 1.
   
 Modules used by this script,  Process version information of this file.
   
 =item 2.  =item 2.
   
 Initializations.  Modules used by this script,
   
 =item 3.  =item 3.
   
 Read in current configuration.  Initializations.
   
 =item 4.  =item 4.
   
   Read in current configuration.
   
   =item 5.
   
 Is this a library or access server?  Is this a library or access server?
   
 This step in the script is both a sanity check and also allows for other  This step in the script is both a sanity check and also allows for other
 future LON-CAPA server types (e.g. "admin", "backup", "firewall") to not  future LON-CAPA server types (e.g. "admin", "backup", "firewall") to not
 be required to have MySQL.  be required to have MySQL.
   
 =item 5.  =item 6.
   
 Make sure that the database can be accessed.  Make sure that the database can be accessed.
   
 If not, a variety of possible problems should be tested for, and a status  If not, a variety of possible problems should be tested for, and a status
 report should be issued to standard output.  report should be issued to standard output.
   
 =item 6.  =item 7.
   
 Close database connection.  Close database connection.
   
 This part of the script is only reached if the database was successfully  This part of the script is only reached if the database was successfully
 connected to.  connected to.
   
 =item 7.  =item 8.
   
 Subroutines.  Subroutines.
   
Line 109  Ratings: 1=horrible 2=poor 3=fair 4=good Line 110  Ratings: 1=horrible 2=poor 3=fair 4=good
   
 =head1 AUTHOR  =head1 AUTHOR
   
 Scott Harrison, sharrison@users.sourceforge.net, 2001, 2002  
   
 This software is distributed under the General Public License,  This software is distributed under the General Public License,
 version 2, June 1991 (which is the same terms as LON-CAPA).  version 2, June 1991 (which is the same terms as LON-CAPA).
   
Line 130  Foundation, Inc., 59 Temple Place, Suite Line 129  Foundation, Inc., 59 Temple Place, Suite
   
 =cut  =cut
   
   # =================================== Process version information of this file.
   my $VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/);
   
   print('Running sqltest.pl, version '.$VERSION.'.'."\n");
   print('(Test interoperability of the MySQL server for use by LON-CAPA.)'."\n");
   
 # ================================================ Modules used by this script.  # ================================================ Modules used by this script.
 use strict;  use strict;
 use DBI;    # Needed to interface with the database.  use DBI;    # Needed to interface with the database.
   
 # ============================================================ Initializations.  # ============================================================ Initializations.
 $|=1;  $|=1;
 print 'Probing for SQL metadata database'."\n\n";  print 'Probing for SQL loncapa database'."\n\n";
   
 # ============================================== Read in current configuration.  # ============================================== Read in current configuration.
 my %perlvar;  my %perlvar;
   
 my $webconfdir='/etc/httpd/conf/';  my $webconfdir='/etc/httpd/conf/';
   
 # NOTE: DEPRECATED scanning of access.conf  
 &configuration_scan(\%perlvar,$webconfdir.'access.conf');  
   
 # Scanning the standard loncapa configuration files.  # Scanning the standard loncapa configuration files.
 &configuration_scan(\%perlvar,$webconfdir.'loncapa.conf');  &configuration_scan(\%perlvar,$webconfdir.'loncapa.conf');
 &configuration_scan(\%perlvar,$webconfdir.'loncapa_apache.conf');  &configuration_scan(\%perlvar,$webconfdir.'loncapa_apache.conf');
Line 186  my $dbh; Line 188  my $dbh;
  my $checkDBImodule=`perl pmvers DBI 2>/dev/null`;   my $checkDBImodule=`perl pmvers DBI 2>/dev/null`;
  my $checkMYSQLmodule=`perl pmvers Mysql 2>/dev/null`;   my $checkMYSQLmodule=`perl pmvers Mysql 2>/dev/null`;
  my $checkprocess=`/etc/rc.d/init.d/mysqld status`;   my $checkprocess=`/etc/rc.d/init.d/mysqld status`;
    my $process_ecode=system('/etc/rc.d/init.d/mysqld status');
   
  # ---------------------------------------------- Issue a status report.   # ---------------------------------------------- Issue a status report.
  if (!$checkDBImodule) {   if (!$checkDBImodule) {
Line 239  shutdown the mysqld processes. Line 242  shutdown the mysqld processes.
 END  END
     $problem_flag=1;      $problem_flag=1;
  }   }
    if ($process_ecode) { # The exit code for mysqld status was abnormal.
       print('**** ERROR **** MYSQLD IS NOT AVAILABLE'."\n");
       print(<<END);
   To check (and fix), try running these commands:
        /etc/rc.d/init.d/mysqld start
        /etc/rc.d/init.d/mysqld status
   
   You may also want to check and see that mysqld is started on boot time.
      /sbin/chkconfig --list mysqld
   If everything is off, you should run "/sbin/chkconfig --level 345 mysqld on".
   END
               $problem_flag=1;
    }
  unless ($problem_flag) {   unless ($problem_flag) {
     print('**** ERROR **** IT APPEARS THAT WWW@LOCALHOST AND/OR '.      print('**** ERROR **** IT APPEARS THAT WWW@LOCALHOST AND/OR '.
   'PASSWORD ARE NOT CORRECTLY ENABLED'."\n");    'PASSWORD ARE NOT CORRECTLY ENABLED'."\n");
Line 268  END Line 284  END
 }  }
 %perlvar=(); # clear memory  %perlvar=(); # clear memory
   
 print('SQL metadata database is found and is accessible'."\n");  print('SQL loncapa database is found and is accessible'."\n");
   
 # ================================================== Close database connection.  # ================================================== Close database connection.
 $dbh->disconnect();  $dbh->disconnect();
Line 278  $dbh->disconnect(); Line 294  $dbh->disconnect();
 # --------- configuration_scan: look for PerlSetVar and store in hash variable.  # --------- configuration_scan: look for PerlSetVar and store in hash variable.
 sub configuration_scan {  sub configuration_scan {
     my ($storagehashref,$filename)=@_;      my ($storagehashref,$filename)=@_;
     open(CONFIG,$filename) ||       open(CONFIG,$filename) or
  (print "Can't read $filename\n" && exit);   (print("Can't read $filename\n") && exit(1));
     while (my $configline=<CONFIG>) {      while (my $configline=<CONFIG>) {
  if ($configline =~ /^[^\#]*PerlSetVar/) {   if ($configline =~ /^[^\#]*PerlSetVar/) {
     my ($dummy,$varname,$varvalue)=split(/\s+/,$configline);      my ($dummy,$varname,$varvalue)=split(/\s+/,$configline);

Removed from v.1.6  
changed lines
  Added in v.1.11


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>