[LON-CAPA-cvs] cvs: doc /loncapafiles chkconfig.piml

raeburn raeburn@source.lon-capa.org
Tue, 14 Jul 2009 12:26:29 -0000


raeburn		Tue Jul 14 12:26:29 2009 EDT

  Modified files:              
    /doc/loncapafiles	chkconfig.piml 
  Log:
  - Merge functionality from sysv-rc-conf.piml (used fro debian/ubuntu) into chkconfig.piml.
  - Eliminate duplicated code for separate checks for webserver and loncontrol.
  
  
Index: doc/loncapafiles/chkconfig.piml
diff -u doc/loncapafiles/chkconfig.piml:1.7 doc/loncapafiles/chkconfig.piml:1.8
--- doc/loncapafiles/chkconfig.piml:1.7	Sun Jul  5 21:23:42 2009
+++ doc/loncapafiles/chkconfig.piml	Tue Jul 14 12:26:29 2009
@@ -1,9 +1,9 @@
 <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN" 
 	"http://lpml.sourceforge.net/DTD/piml.dtd">
-<!-- phpcheck.piml -->
+<!-- checkconfig.piml -->
 <!-- Matthew Hall -->
 
-<!-- $Id: chkconfig.piml,v 1.7 2009/07/05 21:23:42 raeburn Exp $ -->
+<!-- $Id: chkconfig.piml,v 1.8 2009/07/14 12:26:29 raeburn Exp $ -->
 
 <!--
 
@@ -33,70 +33,54 @@
 <targetroot>/</targetroot>
 <files>
 <file>
-<target dist="default">/home/httpd/lonUsers</target>
+<target dist="default"></target>
 <perlscript mode="fg">
-my $chkconfig_bin = '/sbin/chkconfig';
-exit if (! -x $chkconfig_bin);
-
-my $webserver = 'httpd';
+my $checker_bin = '/sbin/chkconfig';
+my $webserver ='httpd';
+my @services = ('apache2','loncontrol');
 my @runlevels = qw/3 4 5/;
+my $rlstr = join('',@runlevels);
+
 if ('<DIST />' eq 'suse9.3' || '<DIST />' eq 'suse9.2' || '<DIST />' eq 'sles9') {
+    $checker_bin = '/';
     $webserver = 'apache';
     @runlevels = qw/3 5/;
 } elsif ('<DIST />' eq 'sles10' || '<DIST />' eq 'suse10.1' || '<DIST />' eq 'suse10.2' || '<DIST />' eq 'suse10.3' || '<DIST />' eq 'suse11.1') {
     $webserver = 'apache2';
+} elsif ('<DIST />' eq 'debian5' ||  '<DIST />' eq 'ubuntu6' ||  '<DIST />' eq 'ubuntu8') {
+    $checker_bin = '/usr/sbin/sysv-rc-conf';
+    $webserver = 'apache2';
 }
-my $command = $chkconfig_bin.' --list '.$webserver;
-my $results = `$command`;
-if ($results eq '') {
-    print "**** WARNING: $webserver is not set to run on boot.$/".
-        "    Execute the following commands to fix this:".$/.
-        "        $chkconfig_bin --add $webserver".$/.
-        "        $chkconfig_bin $webserver on".$/;
-} else {
-    my %httpd_runlevels;
-    for (my $rl = 0;$rl &lt;=6;$rl++) {
-        if ($results =~ /$rl:on/) { $httpd_runlevels{$rl}++; }
-    }
-    #
-    my $warning;
-    foreach my $rl (@runlevels) {
-        if (! exists($httpd_runlevels{$rl}) ) {
-            $warning .= 
-               "**** WARNING: $webserver is not set to run at runlevel $rl".$/;
-        }
-    }
-    if ($warning) {
-        print $warning.
-            "    Execute the following command to fix this:".$/.
-            "        /sbin/chkconfig $webserver on ".$/;
-    }
-}
+exit if (! -x $checker_bin);
 
-$command = $chkconfig_bin.' --list loncontrol';
-$results = `$command`;
-if ($results eq '') {
-    print "**** WARNING: loncontrol is not set to run on boot.$/".
-        "    Execute the following commands to fix this:".$/.
-        "        $chkconfig_bin --add loncontrol".$/.
-        "        $chkconfig_bin loncontrol on".$/;
-} else {
-    my %loncontrol_runlevels;
-    for (my $rl = 0;$rl&lt;=6;$rl++) {
-        if ($results =~ /$rl:on/) { $loncontrol_runlevels{$rl}++; }
-    }
-    #
-    $warning = '';
-    foreach my $rl (@runlevels) {
-        if (! exists($loncontrol_runlevels{$rl})) {
-            $warning .= 
-                "**** WARNING: loncontrol is not set to run at runlevel $rl\n";
+foreach my $service (@services) {
+    my $command = $checker_bin.' --list '.$service;
+    my $results = `$command`;
+    if ($results eq '') {
+        print "**** WARNING: $service is not set to run on boot.$/".
+        "    Execute the following commands to fix this:".$/;
+        unless ('<DIST />' eq 'debian5' ||  '<DIST />' eq 'ubuntu6' ||  '<DIST />' eq 'ubuntu8') {
+             print "        $checker_bin --add $webserver".$/;
+        }
+        print "        $checker_bin --level $rlstr $service on".$/;
+    } else {
+        my %curr_runlevels;
+        for (my $rl = 0;$rl &lt;=6;$rl++) {
+           if ($results =~ /$rl:on/) { $curr_runlevels{$rl}++; }
+        }
+        #
+        my $warning;
+        foreach my $rl (@runlevels) {
+            if (! exists($curr_runlevels{$rl}) ) {
+                $warning .=
+                   "**** WARNING: $service is not set to run at runlevel $rl".$/;
+            }
+        }
+        if ($warning) {
+            print $warning.
+                  "    Execute the following command to fix this:".$/.
+                  "        $checker_bin --level $rlstr $service on".$/;
         }
-    }
-    if ($warning) {
-        print $warning.
-            "    Execute the following command to fix this:".$/.
-            "        /sbin/chkconfig loncontrol on ".$/;
     }
 }