[LON-CAPA-cvs] cvs: loncom /init.d loncontrol

raeburn raeburn@source.lon-capa.org
Sun, 15 May 2011 01:10:02 -0000


raeburn		Sun May 15 01:10:02 2011 EDT

  Modified files:              
    /loncom/init.d	loncontrol 
  Log:
  - loncontrol restart now echoes loncron by closing port 5663 for IP 
    addresses no longer in the cluster, and opens port 5663 for IP 
    addresses of servers added to cluster since loncron last ran.
  
  
Index: loncom/init.d/loncontrol
diff -u loncom/init.d/loncontrol:1.42 loncom/init.d/loncontrol:1.43
--- loncom/init.d/loncontrol:1.42	Fri May 13 01:36:30 2011
+++ loncom/init.d/loncontrol	Sun May 15 01:10:02 2011
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 #
-# $Id: loncontrol,v 1.42 2011/05/13 01:36:30 raeburn Exp $
+# $Id: loncontrol,v 1.43 2011/05/15 01:10:02 raeburn Exp $
 #
 # The LearningOnline Network with CAPA
 #
@@ -107,23 +107,41 @@
     }
 }
 
-if ($command eq "restart") {
-    print 'Restarting LON-CAPA'."\n";
-    print 'Ending LON-CAPA client and daemon processes'."\n";
-    foreach my $daemon ('lonsql','lond','lonc','lonmemcached','lonmaxima','lonr') {
-	my $killallname=$daemon;
-	if ($daemon eq 'lonc') { $killallname='loncnew'; }
-	&stop_daemon($daemon,$killallname);
-    }
-    print 'Starting LON-CAPA client and daemon processes (please be patient)'.
-	"\n";
-    system("su www -c '/home/httpd/perl/loncron --justcheckdaemons'");
-} elsif (($command eq "stop") || ($command eq 'start') || ($command eq 'status')) {
+if (($command eq "restart") || ($command eq 'stop') || 
+    ($command eq 'start') || ($command eq "status")) {
     my $iptables = &LONCAPA::Firewall::get_pathto_iptables();
     my @fw_chains = &LONCAPA::Firewall::get_fw_chains($iptables);
     my $lond_port = &LONCAPA::Firewall::get_lond_port();
     my %iphost;
-    if ($command eq 'stop') {
+    if ($command eq 'restart') {
+        print 'Restarting LON-CAPA'."\n";
+        print 'Ending LON-CAPA client and daemon processes'."\n";
+        foreach my $daemon ('lonsql','lond','lonc','lonmemcached','lonmaxima','lonr') {
+            my $killallname=$daemon;
+            if ($daemon eq 'lonc') { $killallname='loncnew'; }
+            &stop_daemon($daemon,$killallname);
+        }
+        %iphost = &Apache::lonnet::get_iphost();
+        my $firewall_result =
+            &LONCAPA::Firewall::firewall_close_port($iptables,\@fw_chains,
+                                             $lond_port,\%iphost,[$lond_port]);
+        if ($firewall_result) {
+            print "$firewall_result\n";
+        }
+        $firewall_result =
+            &LONCAPA::Firewall::firewall_open_port($iptables,\@fw_chains,
+                                            $lond_port, \%iphost,[$lond_port]);
+        if (($firewall_result eq 'ok') || ($firewall_result eq 'inactive firewall')) {
+            if ($firewall_result eq 'inactive firewall') {
+                print "WARNING: iptables firewall is currently inactive\n";
+            }
+        } elsif ($firewall_result) {
+            print "$firewall_result\n";
+        }
+        print 'Starting LON-CAPA client and daemon processes (please be patient)'.
+              "\n";
+        system("su www -c '/home/httpd/perl/loncron --justcheckdaemons'");
+    } elsif ($command eq 'stop') {
         print 'Stopping LON-CAPA'."\n";
         foreach my $daemon ('lonsql','lond','lonc','lonmemcached','lonmaxima','lonr') {
 	    my $killallname=$daemon;