[LON-CAPA-cvs] cvs: doc /install/linux install.pl

raeburn raeburn@source.lon-capa.org
Sun, 08 May 2011 13:20:03 -0000


raeburn		Sun May  8 13:20:03 2011 EDT

  Modified files:              
    /doc/install/linux	install.pl 
  Log:
  - Fix typos.
  - Consistent method for checking if mysql is running.
  - Allow ten seconds total for mysql to start (check after 5s, then 10s).
  - distro-specific location for memcached executable.
  - Trap output to STDERR that does not need to be displayed to user.
  
  
Index: doc/install/linux/install.pl
diff -u doc/install/linux/install.pl:1.11 doc/install/linux/install.pl:1.12
--- doc/install/linux/install.pl:1.11	Thu May  5 16:38:07 2011
+++ doc/install/linux/install.pl	Sun May  8 13:20:03 2011
@@ -72,7 +72,7 @@
           &mt('Stopping execution.')."\n";
     exit;
 } else {
-    print LOG '$Id: install.pl,v 1.11 2011/05/05 16:38:07 raeburn Exp $'."\n";
+    print LOG '$Id: install.pl,v 1.12 2011/05/08 13:20:03 raeburn Exp $'."\n";
 }
 
 #
@@ -219,7 +219,7 @@
             }
         } elsif ($versionstring =~ /^SuSE Linux ([\d\.]+) /i) {
             $distro = 'suse'.$1;
-            $updatecmd = 'yast -i LONCAPA-preprequisites';
+            $updatecmd = 'yast -i LONCAPA-prerequisites';
         } elsif ($versionstring =~ /^openSUSE ([\d\.]+) /i) {
             $distro = 'suse'.$1;
             if ($1 >= 10.3 ) {
@@ -425,21 +425,31 @@
             print_and_log(&mt('MySQL is running.')."\n");
             return 1;
         } else {
-            system("/etc/rc.d/init.d/$mysqldaemon start"); 
+            system("/etc/init.d/$mysqldaemon start >/dev/null 2>&1 "); 
             print_and_log(&mt('Waiting for MySQL to start.')."\n");
             sleep 5;
-            if (open (PIPE, "/etc/init.d/$mysqldaemon 2>&1 |")) {
-                my $status = <PIPE>;
+            if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) {
+                $status = <PIPE>;
                 close(PIPE);
                 chomp($status);
-                if ($status =~ /\(pid\s+\d\)/) {
+                if ($status =~ /^\Q$proc_owner\E\s+\d+\s+/) {
                     print_and_log(&mt('MySQL is running.')."\n");
                     return 1;
                 } else {
-                    print_and_log(&mt('Unable to start MySQL.')."\n"); 
+                    print_and_log(&mt('Still waiting for MySQL to start.')."\n");
+                    sleep 5;
+                    if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) {
+                        $status = <PIPE>;
+                        close(PIPE);
+                        chomp($status);
+                        if ($status =~ /^\Q$proc_owner\E\s+\d+\s+/) {
+                            print_and_log(&mt('MySQL is running.')."\n");
+                            return 1;
+                        } else {
+                            print_and_log(&mt('Given up waiting for MySQL to start.')."\n"); 
+                        }
+                    }
                 }
-            } else {
-                print_and_log(&mt('Unable to start MySQL.')."\n");
             }
         }
     } else {
@@ -678,8 +688,12 @@
             chomp($daemonrunning);
             close(PIPE);
             if ($daemonrunning) {
-                if ($service eq 'memcached') { 
-                    unless ($daemonrunning =~ m{^www[^/]+\Q/usr/sbin/memcached -m 400 -v\E$}) {
+                if ($service eq 'memcached') {
+                    my $cmd = '/usr/sbin/memcached';
+                    if ($distro =~ /^centos|fedora|scientific|rhes/) {
+                        $cmd = '/usr/bin/memcached';  
+                    } 
+                    unless ($daemonrunning =~ m{^www[^/]+\Q$cmd -m 400 -v\E$}) {
                         $stopsrvcs{$service} = 1;
                     }
                 } else {
@@ -823,7 +837,8 @@
 
 sub check_mysql_wwwuser {
     my $mysql_wwwuser;
-    my $dbhn = DBI->connect("DBI:mysql:database=information_schema",'www','localhostkey');
+    my $dbhn = DBI->connect("DBI:mysql:database=information_schema",'www','localhostkey',
+                            {PrintError => +0}) || return;
     if ($dbhn) {
         $mysql_wwwuser = 1;
         $dbhn->disconnect;
@@ -1092,7 +1107,7 @@
     exit;
 }
 if (!$gotprereqs) {
-    print "\n".&mt('The LONCAPA-prequisites package is not installed.')."\n".
+    print "\n".&mt('The LONCAPA-prerequisites package is not installed.')."\n".
           &mt('The following command can be used to install the package (and dependencies):')."\n\n".
           $updatecmd."\n\n";
     if ($installnow eq '') {
@@ -1106,7 +1121,7 @@
                 close(PIPE);
                 $gotprereqs = &check_prerequisites($packagecmd,$distro);
                 if (!$gotprereqs) {
-                    print &mt('The LONCAPA-prequisites package is not installed.')."\n".
+                    print &mt('The LONCAPA-prerequisites package is not installed.')."\n".
                           &mt('Stopping execution.')."\n";
                     exit;
                 } else {
@@ -1116,7 +1131,7 @@
                      &check_required($instdir,$dsn);
                 }
             } else {
-                print &mt('Failed to run command to install LONCAPA-prequisites')."\n";
+                print &mt('Failed to run command to install LONCAPA-prerequisites')."\n";
                 exit;
             }
         } else {
@@ -1461,7 +1476,7 @@
         ## Compile patched pwauth
         ##
         print_and_log(&mt('Compiling pwauth')."\n");
-        my $result = `cd $dir/; make`;
+        my $result = `cd $dir/; make 2>/dev/null `;
         my $expected = <<"END";
 gcc -g    -c -o pwauth.o pwauth.c
 gcc -o pwauth -g  pwauth.o -lcrypt
@@ -1510,16 +1525,24 @@
                             if (($distro =~ /^ubuntu/) && ($version <= 8)) {
                                 $daemon = 'cupsys';
                             }
-                        } elsif ($distro =~ /^(?:suse|sles|scientific)/) {
+                        } else {
                             $daemon = 'cups';
                         }
                     }
-	            &print_and_log(`/etc/init.d/$daemon stop`);
+                    my $cmd = "ps -ef |grep '$daemon' |grep -v grep";
+                    if (open(PIPE,'-|',$cmd)) {
+                        my $daemonrunning = <PIPE>;
+                        chomp($daemonrunning);
+                        close(PIPE);
+                        if ($daemonrunning) {
+                            &print_and_log(`/etc/init.d/$daemon stop`);
+                        }
+                    }
 	            &print_and_log(&mt('Removing [_1] from startup.',$service)."\n");
                     if ($distro =~ /^(debian|ubuntu)/) {
                         &print_and_log(`update-rc.d -f $daemon remove`);
                     } else {
-	                &print_and_log(`chkconfig --del $service`);
+	                &print_and_log(`/sbin/chkconfig --del $service`);
                     }
                 }
             }