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

raeburn raeburn at source.lon-capa.org
Mon Oct 24 22:03:16 EDT 2011


raeburn		Tue Oct 25 02:03:16 2011 EDT

  Modified files:              
    /doc/install/linux	install.pl 
  Log:
  - Support for Fedora 16.
  - systemctl replacing chkconfig and service for mysqld and httpd. 
  
  
Index: doc/install/linux/install.pl
diff -u doc/install/linux/install.pl:1.22 doc/install/linux/install.pl:1.23
--- doc/install/linux/install.pl:1.22	Tue Sep 20 20:54:47 2011
+++ doc/install/linux/install.pl	Tue Oct 25 02:03:16 2011
@@ -72,7 +72,7 @@
           &mt('Stopping execution.')."\n";
     exit;
 } else {
-    print LOG '$Id: install.pl,v 1.22 2011/09/20 20:54:47 raeburn Exp $'."\n";
+    print LOG '$Id: install.pl,v 1.23 2011/10/25 02:03:16 raeburn Exp $'."\n";
 }
 
 #
@@ -405,6 +405,7 @@
 
 sub check_mysql_running {
     my ($distro) = @_;
+    my $use_systemctl;
     my $mysqldaemon ='mysqld';
     if ($distro =~ /^(suse|sles|debian|ubuntu)/) {
         $mysqldaemon = 'mysql';
@@ -417,6 +418,13 @@
             $proc_owner = 'mysql';
         }
     }
+    if ($distro =~ /^fedora(\d+)/) {
+        if ($1 >= 16) {
+            $process = 'mysqld';
+            $proc_owner = 'mysql';
+            $use_systemctl = 1;
+        }
+    }
     if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) {
         my $status = <PIPE>;
         close(PIPE);
@@ -425,7 +433,11 @@
             print_and_log(&mt('MySQL is running.')."\n");
             return 1;
         } else {
-            system("/etc/init.d/$mysqldaemon start >/dev/null 2>&1 "); 
+            if ($use_systemctl) {
+                system("/bin/systemctl start $mysqldaemon.service >/dev/null 2>&1 ");
+            } else {
+                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,"ps -ef |grep $process |grep -v grep 2>&1 |")) {
@@ -460,8 +472,9 @@
 
 sub chkconfig {
     my ($distro,$instdir) = @_;
-    my (%needfix,%tostop);
+    my (%needfix,%tostop,%uses_systemctl);
     my $checker_bin = '/sbin/chkconfig';
+    my $sysctl_bin = '/bin/systemctl';
     my %daemon = (
                   mysql     => 'mysqld',
                   apache    => 'httpd',
@@ -491,66 +504,82 @@
         if (($distro =~ /^ubuntu/) && ($version <= 8)) {
             $daemon{'cups'} = 'cupsys';
         }
+    } elsif ($distro =~ /^(?:fedora)(\d+)/) {
+        my $version = $1;
+        if ($version >= 15) {
+            $uses_systemctl{'ntp'} = 1;
+        }
+        if ($version >= 16) {
+            $uses_systemctl{'mysql'} = 1;
+            $uses_systemctl{'apache'} = 1;
+        }
     }
+    my $nocheck;
     if (! -x $checker_bin) {
+        if ($uses_systemctl{'mysql'} && $uses_systemctl{'apache'}) {
+            if (! -x $sysctl_bin) {
+                $nocheck = 1;       
+            }
+        } else {
+            $nocheck = 1;
+        }
+    }
+    if ($nocheck) {
         print &mt('Could not check runlevel status for MySQL or Apache')."\n";
         return;
     }
     my $rlstr = join('', at runlevels);
     my $nrlstr = join('', at norunlevels);
+
     foreach my $type ('apache','mysql','ntp','cups','memcached') {
         my $service = $daemon{$type};
-        if ($type eq 'ntp') {
-            if ($distro =~ /^(?:fedora)(\d+)/) {
-                my $version = $1;
-                if ($version >= 15) {
-                    if (!-l "/etc/systemd/system/multi-user.target.wants/ntpd.service") {
-                        $needfix{$type} = 'systemctl enable ntpd.service';
+        if ($uses_systemctl{$type}) {
+            if (!-l "/etc/systemd/system/multi-user.target.wants/$service.service") {
+                $needfix{$type} = "systemctl enable $service.service";
+            }
+            next;
+        } else {
+            my $command = $checker_bin.' --list '.$service.' 2>/dev/null';
+            if ($type eq 'cups') { 
+                if ($distro =~ /^(?:debian|ubuntu)(\d+)/) {
+                    my $version = $1;
+                    if (($distro =~ /^ubuntu/) && ($version <= 8)) {
+                        $command = $checker_bin.' --list cupsys 2>/dev/null';
                     }
-                    next;
-                }
-            }
-        }
-        my $command = $checker_bin.' --list '.$service.' 2>/dev/null';
-        if ($type eq 'cups') { 
-            if ($distro =~ /^(?:debian|ubuntu)(\d+)/) {
-                my $version = $1;
-                if (($distro =~ /^ubuntu/) && ($version <= 8)) {
-                    $command = $checker_bin.' --list cupsys 2>/dev/null';
-                }
-            }
-        }
-        my $results = `$command`;
-        my $tofix;
-        if ($results eq '') {
-            if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) {
-                if ($distro  =~ /^(debian|ubuntu)/) {
-                    $tofix = "update-rc.d $type defaults";
-                } else {
-                    $tofix = "$checker_bin --add $service\n";
                 }
             }
-        } else {
-            my %curr_runlevels;
-            for (my $rl=0; $rl<=6; $rl++) {
-                if ($results =~ /$rl:on/) { $curr_runlevels{$rl}++; }
-            }
-            if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) {
-                my $warning;
-                foreach my $rl (@runlevels) {
-                    if (!exists($curr_runlevels{$rl})) {
-                        $warning = 1;
+            my $results = `$command`;
+            my $tofix;
+            if ($results eq '') {
+                if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) {
+                    if ($distro  =~ /^(debian|ubuntu)/) {
+                        $tofix = "update-rc.d $type defaults";
+                    } else {
+                        $tofix = "$checker_bin --add $service\n";
                     }
                 }
-                if ($warning) {
-                    $tofix = "$checker_bin --level $rlstr $service on\n";
+            } else {
+                my %curr_runlevels;
+                for (my $rl=0; $rl<=6; $rl++) {
+                    if ($results =~ /$rl:on/) { $curr_runlevels{$rl}++; }
+                }
+                if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) {
+                    my $warning;
+                    foreach my $rl (@runlevels) {
+                        if (!exists($curr_runlevels{$rl})) {
+                            $warning = 1;
+                        }
+                    }
+                    if ($warning) {
+                        $tofix = "$checker_bin --level $rlstr $service on\n";
+                    }
+                } elsif (keys(%curr_runlevels) > 0) {
+                    $tostop{$type} = 1;
                 }
-            } elsif (keys(%curr_runlevels) > 0) {
-                $tostop{$type} = 1;
             }
-        }
-        if ($tofix) {
-            $needfix{$type} = $tofix;
+            if ($tofix) {
+                $needfix{$type} = $tofix;
+            }
         }
     }
     if ($distro =~ /^(suse|sles)([\d\.]+)$/) {




More information about the LON-CAPA-cvs mailing list