[LON-CAPA-cvs] cvs: loncom /build/system_dependencies sqltest.pl
harris41
lon-capa-cvs@mail.lon-capa.org
Wed, 07 Aug 2002 18:43:42 -0000
harris41 Wed Aug 7 14:43:42 2002 EDT
Modified files:
/loncom/build/system_dependencies sqltest.pl
Log:
VERSION information; also testing exit code of /etc/rc.d/init.d/mysqld status
Index: loncom/build/system_dependencies/sqltest.pl
diff -u loncom/build/system_dependencies/sqltest.pl:1.7 loncom/build/system_dependencies/sqltest.pl:1.8
--- loncom/build/system_dependencies/sqltest.pl:1.7 Tue Aug 6 19:38:27 2002
+++ loncom/build/system_dependencies/sqltest.pl Wed Aug 7 14:43:42 2002
@@ -2,7 +2,7 @@
# sqltest.pl - script to test MySQL database connectivity for LON-CAPA
#
-# $Id: sqltest.pl,v 1.7 2002/08/06 23:38:27 harris41 Exp $
+# $Id: sqltest.pl,v 1.8 2002/08/07 18:43:42 harris41 Exp $
#
###
@@ -41,45 +41,49 @@
=head2 ORGANIZATION OF THIS PERL SCRIPT
-The script is organized into the following sections
+The script is organized into the following sections.
=over 4
=item 1.
-Modules used by this script,
+Process version information of this file.
=item 2.
-Initializations.
+Modules used by this script,
=item 3.
-Read in current configuration.
+Initializations.
=item 4.
+Read in current configuration.
+
+=item 5.
+
Is this a library or access server?
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
be required to have MySQL.
-=item 5.
+=item 6.
Make sure that the database can be accessed.
If not, a variety of possible problems should be tested for, and a status
report should be issued to standard output.
-=item 6.
+=item 7.
Close database connection.
This part of the script is only reached if the database was successfully
connected to.
-=item 7.
+=item 8.
Subroutines.
@@ -130,6 +134,12 @@
=cut
+# =================================== Process version information of this file.
+my $VERSION = sprintf("%d.%02d", q$Revision: 1.8 $ =~ /(\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.
use strict;
use DBI; # Needed to interface with the database.
@@ -186,6 +196,7 @@
my $checkDBImodule=`perl pmvers DBI 2>/dev/null`;
my $checkMYSQLmodule=`perl pmvers Mysql 2>/dev/null`;
my $checkprocess=`/etc/rc.d/init.d/mysqld status`;
+ my $process_ecode=system('/etc/rc.d/init.d/mysqld status');
# ---------------------------------------------- Issue a status report.
if (!$checkDBImodule) {
@@ -238,6 +249,19 @@
shutdown the mysqld processes.
END
$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) {
print('**** ERROR **** IT APPEARS THAT WWW@LOCALHOST AND/OR '.