Diff for /loncom/init.d/loncontrol between versions 1.20 and 1.22

version 1.20, 2004/12/02 18:49:55 version 1.22, 2004/12/02 21:16:56
Line 2 Line 2
 #  #
 # The LearningOnline Network with CAPA  # The LearningOnline Network with CAPA
 #  #
   # Copyright Michigan State University Board of Trustees
   #
   # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   #
   # LON-CAPA is free software; you can redistribute it and/or modify
   # it under the terms of the GNU General Public License as published by
   # the Free Software Foundation; either version 2 of the License, or
   # (at your option) any later version.
   #
   # LON-CAPA is distributed in the hope that it will be useful,
   # but WITHOUT ANY WARRANTY; without even the implied warranty of
   # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   # GNU General Public License for more details.
   #
   # You should have received a copy of the GNU General Public License
   # along with LON-CAPA; if not, write to the Free Software
   # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   #
   # /home/httpd/html/adm/gpl.txt
   #
   # http://www.lon-capa.org/
   #
 # Startup script for the LON-CAPA network processes  # Startup script for the LON-CAPA network processes
 #  #
 # YEAR=2000  
 # YEAR=2001  
 # YEAR=2002  
   
 # chkconfig: 345 95 5  # chkconfig: 345 95 5
 # description: LON-CAPA is a "network of knowledge".  It is used to  # description: LON-CAPA is a "network of knowledge".  It is used to \
 # distribute knowledge resources and instructional management.  # distribute knowledge resources and instructional management.
 # processnames: lonc, lond, lonsql  # processnames: lonc, lond, lonsql
 # pidfiles: /home/httpd/perl/logs/lon*.pid  # pidfiles: /home/httpd/perl/logs/lon*.pid
Line 26  $ENV{'BASH_ENV'}=""; Line 45  $ENV{'BASH_ENV'}="";
     # Firewall code is based on the code in FC2 /etc/init.d/ntpd      # Firewall code is based on the code in FC2 /etc/init.d/ntpd
     my $fw_chain = 'RH-Firewall-1-INPUT';      my $fw_chain = 'RH-Firewall-1-INPUT';
     my $iptables = '/sbin/iptables';      my $iptables = '/sbin/iptables';
     my $port = 5663;      my $lond_port = 5663;
       my $lonhttpd_port = 8080;
   
 sub firewall_open_port {  sub firewall_open_port {
     return if (! &firewall_is_active);      return if (! &firewall_is_active);
     print "Opening firewall access on port $port\n";  
     if (! `$iptables -L -n 2>/dev/null | grep $fw_chain | wc -l`) { return; }      if (! `$iptables -L -n 2>/dev/null | grep $fw_chain | wc -l`) { return; }
     # iptables is running with our chain      # iptables is running with our chain
     #      #
     # We could restrict the servers allowed to attempt to communicate      # We could restrict the servers allowed to attempt to communicate
     # here, but the logistics of updating the /home/httpd/lonTabs/host.tab      # here, but the logistics of updating the /home/httpd/lonTabs/host.tab
     # file are likely to be a problem      # file are likely to be a problem
     my $firewall_command =       foreach my $port ($lond_port,$lonhttpd_port) {
         "$iptables -I $fw_chain -p tcp -d 0/0 --dport $port -j ACCEPT";          print "Opening firewall access on port $port.\n";
     system($firewall_command);  
     my $return_status = $?>>8;          my $firewall_command = 
     if ($return_status == 1) {              "$iptables -I $fw_chain -p tcp -d 0/0 --dport $port -j ACCEPT";
         # Error          system($firewall_command);
         print "Error opening port.\n";          my $return_status = $?>>8;
     } elsif ($return_status == 2) {          if ($return_status == 1) {
         # Bad command              # Error
         print "Bad command error opening port.  Command was\n".              print "Error opening port.\n";
             "  ".$firewall_command."\n";          } elsif ($return_status == 2) {
               # Bad command
               print "Bad command error opening port.  Command was\n".
                   "  ".$firewall_command."\n";
           }
     }      }
       
 }  }
   
 sub firewall_is_port_open {  sub firewall_is_port_open {
Line 73  sub firewall_is_active { Line 97  sub firewall_is_active {
   
 sub firewall_close_port {  sub firewall_close_port {
     return if (! &firewall_is_active);      return if (! &firewall_is_active);
     print "Closing firewall access on port $port\n";      foreach my $port ($lond_port,$lonhttpd_port) {
     my $firewall_command =           print "Closing firewall access on port $port.\n";
         "$iptables -D $fw_chain -p tcp -d 0/0 --dport $port -j ACCEPT";          my $firewall_command = 
     system($firewall_command);              "$iptables -D $fw_chain -p tcp -d 0/0 --dport $port -j ACCEPT";
     my $return_status = $?>>8;          system($firewall_command);
     if ($return_status == 1) {          my $return_status = $?>>8;
         # Error          if ($return_status == 1) {
         print "Error closing port.\n";              # Error
     } elsif ($return_status == 2) {              print "Error closing port.\n";
         # Bad command          } elsif ($return_status == 2) {
         print "Bad command error closing port.  Command was\n".              # Bad command
             "  ".$firewall_command."\n";              print "Bad command error closing port.  Command was\n".
                   "  ".$firewall_command."\n";
           }
     }      }
 }  }
   

Removed from v.1.20  
changed lines
  Added in v.1.22


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>