[prev in list] [next in list] [prev in thread] [next in thread]
List: ipcop-svn
Subject: [Ipcop-svn] SF.net SVN: ipcop:[2145] ipcop/trunk
From: owes () users ! sourceforge ! net
Date: 2008-11-30 18:58:46
Message-ID: E1L6rVG-0005hP-M3 () d5vjzd1 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 2145
http://ipcop.svn.sourceforge.net/ipcop/?rev=2145&view=rev
Author: owes
Date: 2008-11-30 18:58:44 +0000 (Sun, 30 Nov 2008)
Log Message:
-----------
Add rc.net. The idea is to combine rc.network and rc.netaddress.{down,up} into one rc \
script.
Methods used are:
--init (former rc.network)
--reconfigure when changing network thru setup
Let us see how this works out ...
Need to clean up output of several rc scripts, to make especially booting look \
better.
Modified Paths:
--------------
ipcop/trunk/config/rootfiles/common/misc-progs
ipcop/trunk/src/installer/networking.c
ipcop/trunk/src/rc.d/rc.sysinit
Added Paths:
-----------
ipcop/trunk/src/rc.d/rc.net
Modified: ipcop/trunk/config/rootfiles/common/misc-progs
===================================================================
--- ipcop/trunk/config/rootfiles/common/misc-progs 2008-11-30 18:49:04 UTC (rev 2144)
+++ ipcop/trunk/config/rootfiles/common/misc-progs 2008-11-30 18:58:44 UTC (rev 2145)
@@ -22,9 +22,7 @@
etc/rc.d/rc.halt
etc/rc.d/rc.isdn
etc/rc.d/rc.local
-etc/rc.d/rc.netaddress.down
-etc/rc.d/rc.netaddress.up
-etc/rc.d/rc.network
+etc/rc.d/rc.net
etc/rc.d/rc.pcmcia
etc/rc.d/rc.pulsardsl
etc/rc.d/rc.red
Modified: ipcop/trunk/src/installer/networking.c
===================================================================
--- ipcop/trunk/src/installer/networking.c 2008-11-30 18:49:04 UTC (rev 2144)
+++ ipcop/trunk/src/installer/networking.c 2008-11-30 18:58:44 UTC (rev 2145)
@@ -520,6 +520,7 @@
info, 65, 5, 5, 11, colourchoices, &choice, gettext("TR_OK"), \
gettext("TR_QUIT"), NULL);
if ((rc == 0) || (rc == 1)) {
+ changed_config = 1;
if (!strcmp(colourchoices[choice], gettext("TR_NOT_USED"))) {
if (strcmp(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT - \
1])) { updatesettings(networks[n].colour, -1);
@@ -863,7 +864,7 @@
choice = 0;
for (i = 0; i < CFG_COLOURS_COUNT; i++) {
- snprintf(key, STRING_SIZE, "%s_DEV", ipcop_colours_text[i]);
+ snprintf(key, STRING_SIZE, "%s_1_DEV", ipcop_colours_text[i]);
strcpy(keyvalue, "");
find_kv_default(eth_kv, key, keyvalue);
if (keyvalue[0]) {
@@ -1104,6 +1105,7 @@
*/
choice = 0;
+ mysystem("cp -f /var/ipcop/ethernet/settings /var/ipcop/ethernet/settings.old");
for (;;) {
@@ -1139,6 +1141,9 @@
if (changed_config) {
write_kv_to_file(ð_kv, "/var/ipcop/ethernet/settings");
+ statuswindow(72, 5, gettext("TR_NETWORKING"), \
ipcop_gettext("TR_RECONFIGURE_NETWORK")); + mysystem("/etc/rc.d/rc.net \
--reconfigure"); + newtPopWindow();
}
/* What options have changed and what needs restarting ?? */
Added: ipcop/trunk/src/rc.d/rc.net
===================================================================
--- ipcop/trunk/src/rc.d/rc.net (rev 0)
+++ ipcop/trunk/src/rc.d/rc.net 2008-11-30 18:58:44 UTC (rev 2145)
@@ -0,0 +1,214 @@
+#!/usr/bin/perl
+#
+# This file is part of the IPCop Firewall.
+#
+# IPCop 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.
+#
+# IPCop 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 IPCop; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# (c) 2008, the IPCop team
+#
+# $Id$
+#
+
+use strict;
+require '/var/ipcop/general-functions.pl';
+
+
+my %netsettings;
+my %oldnetsettings;
+my %pppsettings;
+my @INTERFACEs = ('GREEN', 'BLUE', 'ORANGE', 'RED');
+my $counter;
+my $interface;
+
+
+&General::readhash('/var/ipcop/ethernet/settings', \%netsettings);
+if (-e '/var/ipcop/ethernet/settings.old') {
+ &General::readhash('/var/ipcop/ethernet/settings.old', \%oldnetsettings);
+ unlink('/var/ipcop/ethernet/settings.old');
+}
+else {
+ &General::readhash('/var/ipcop/ethernet/settings', \%oldnetsettings);
+}
+&General::readhash('/var/ipcop/ppp/settings', \%pppsettings);
+
+
+if (($ARGV[0] eq 'init') || ($ARGV[0] eq '--init')) {
+ &net_init();
+}
+elsif (($ARGV[0] eq 'reconfigure') || ($ARGV[0] eq '--reconfigure')) {
+ &net_stop();
+ &modules_unload();
+ &modules_load();
+ &net_start();
+
+ # net_stop has killed snort during ifconfig ethx down
+ system('/usr/local/bin/restartsnort blue orange green');
+ # TODO: other services that need restarting ?
+}
+elsif (($ARGV[0] eq 'start') || ($ARGV[0] eq '--start')) {
+ &net_start();
+}
+elsif (($ARGV[0] eq 'stop') || ($ARGV[0] eq '--stop')) {
+ &net_stop();
+}
+elsif (($ARGV[0] eq 'restart') || ($ARGV[0] eq '--restart')) {
+ &net_stop();
+ &net_start();
+}
+elsif (($ARGV[0] eq 'load') || ($ARGV[0] eq '--load')) {
+ &modules_load();
+}
+elsif (($ARGV[0] eq 'unload') || ($ARGV[0] eq '--unload')) {
+ &modules_unload();
+}
+else {
+ print("ERROR: rc.net bad argument $ARGV[0]\n");
+ exit 1;
+}
+
+exit 0;
+
+
+#
+# Called from rc.sysinit when booting
+#
+sub net_init
+{
+ print "Setting up loopback\n";
+ system("/sbin/ifconfig lo localhost up");
+
+ print "Loading iptables helper modules\n";
+
+ # TODO: evaluate iptables modules
+ system("/sbin/modprobe iptable_nat");
+ system("/sbin/modprobe ip_conntrack");
+ system("/sbin/modprobe ip_conntrack_ftp");
+ system("/sbin/modprobe ip_nat_ftp");
+ system("/sbin/modprobe ip_conntrack_h323");
+ system("/sbin/modprobe ip_nat_h323");
+ system("/sbin/modprobe ip_conntrack_irc");
+ system("/sbin/modprobe ip_nat_irc");
+ # system("/sbin/modprobe ip_conntrack_mms");
+ # system("/sbin/modprobe ip_nat_mms");
+ system("/sbin/modprobe ip_conntrack_pptp");
+ system("/sbin/modprobe ip_nat_pptp");
+ system("/sbin/modprobe nf_conntrack_proto_gre");
+ system("/sbin/modprobe nf_nat_proto_gre");
+
+ # Remove possible leftover files
+ unlink "/var/ipcop/red/active";
+ unlink "/var/ipcop/red/device";
+ unlink "/var/ipcop/red/dial-on-demand";
+ unlink "/var/ipcop/red/dns1";
+ unlink "/var/ipcop/red/dns2";
+ unlink "/var/ipcop/red/local-ipaddress";
+ unlink "/var/ipcop/red/remote-ipaddress";
+ unlink "/var/ipcop/red/resolv.conf";
+
+ # TODO: Launch PCMCIA ?
+ # TODO: Relaunch PCMCIA USB ?
+
+ &modules_load();
+
+ &net_start();
+}
+
+
+#
+# Start firewall, ifconfig up, etc.
+#
+sub net_start
+{
+ print "Setting up IPCop firewall rules\n";
+ system("/etc/rc.d/rc.firewall start");
+
+ print "Setting up IP Accounting\n";
+ system("/etc/rc.d/rc.accounting");
+
+ print "Bringing network up\n";
+ foreach $interface (@INTERFACEs) {
+ # RED is handled later in rc.red
+ next if ($interface eq "RED");
+
+ for ($counter = 1; $counter <= $netsettings{"${interface}_COUNT"}; \
$counter++) { + my $ic = "${interface}_${counter}";
+ system('/sbin/ifconfig', $netsettings{"${ic}_DEV"}, \
$netsettings{"${ic}_ADDRESS"}, + 'netmask', \
$netsettings{"${ic}_NETMASK"}, + 'broadcast', \
$netsettings{"${ic}_BROADCAST"}, + 'up');
+ }
+ }
+
+ system("/etc/rc.d/rc.dnsmasq restart");
+
+ if(($pppsettings{'AUTOCONNECT'} eq 'on') ||
+ (($netsettings{'RED_COUNT'} > 0) && (($netsettings{'RED_1_TYPE'} eq 'STATIC') \
|| ($netsettings{'RED_1_TYPE'} eq 'DHCP')))) { + system("/etc/rc.d/rc.red \
start"); + }
+}
+
+
+#
+# ifconfig down, stop red, stop firewall
+#
+sub net_stop
+{
+ foreach $interface (@INTERFACEs) {
+ # RED is handled later in rc.red
+ next if ($interface eq "RED");
+
+ for ($counter = 1; $counter <= $oldnetsettings{"${interface}_COUNT"}; \
$counter++) { + my $ic = "${interface}_${counter}";
+ system('/sbin/ifconfig', $oldnetsettings{"${ic}_DEV"}, 'down');
+ }
+ }
+
+ system("/etc/rc.d/rc.red stop");
+ sleep 3;
+ system("/etc/rc.d/rc.red clear");
+
+ print "Stopping IPCop firewall\n";
+ system('/etc/rc.d/rc.firewall stop');
+}
+
+
+#
+# Modprobe all configured kernel modules
+#
+sub modules_load
+{
+ foreach $interface (@INTERFACEs) {
+ for ($counter = 1; $counter <= $netsettings{"${interface}_COUNT"}; \
$counter++) { + my $ic = "${interface}_${counter}";
+ system('/sbin/modprobe', $netsettings{"${ic}_DRIVER"}, \
$netsettings{"${ic}_DRIVER_OPTIONS"}); + }
+ }
+ system("/sbin/udevadm settle");
+}
+
+
+#
+# Modprobe -r all configured kernel modules
+#
+sub modules_unload
+{
+ foreach $interface (@INTERFACEs) {
+ for ($counter = 1; $counter <= $oldnetsettings{"${interface}_COUNT"}; \
$counter++) { + my $ic = "${interface}_${counter}";
+ system('/sbin/modprobe', '-r', $oldnetsettings{"${ic}_DRIVER"});
+ }
+ }
+ system("/sbin/udevadm settle");
+}
Property changes on: ipcop/trunk/src/rc.d/rc.net
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: ipcop/trunk/src/rc.d/rc.sysinit
===================================================================
--- ipcop/trunk/src/rc.d/rc.sysinit 2008-11-30 18:49:04 UTC (rev 2144)
+++ ipcop/trunk/src/rc.d/rc.sysinit 2008-11-30 18:58:44 UTC (rev 2145)
@@ -268,8 +268,8 @@
/usr/sbin/klogd
#/usr/sbin/klogd -u klogd -j /var/empty
-echo "Running /etc/rc.d/rc.network"
-/etc/rc.d/rc.network
+echo "Running /etc/rc.d/rc.net"
+/etc/rc.d/rc.net --init
echo "Rotate and dump boot messages"
if [ -e /var/log/dmesg ]; then
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic