]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
- added function to setup NAT rules
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 2 Sep 1999 12:29:17 +0000 (12:29 +0000)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 2 Sep 1999 12:29:17 +0000 (12:29 +0000)
- modprobing ipv6.o is now done in autoclean mode
- removed ipchains (this script should be in ipchains package)
- better errors handling in run_cmd()

svn-id: @505

rc.d/init.d/Makefile.am
rc.d/init.d/functions
rc.d/init.d/functions.network
rc.d/init.d/ipchains [deleted file]

index 6e447f229b5091a345cc10a1eda317b9150860f3..12bc017bdc503c4e07e20f82f3ae74808acb8d9a 100644 (file)
@@ -5,7 +5,6 @@ initdir = @rcdir@/init.d
 init_SCRIPTS = \
        allowlogin \
        halt \
-       ipchains \
        killall \
        network \
        nfsfs \
index 943571a4a8c320a280c9b9c1cd9e425ecbb17957..918b7e760dcafaf49b994dfa9f1e697301306fb9 100644 (file)
@@ -1,7 +1,7 @@
 # functions    This file contains functions to be used by most or all
 #              shell scripts in the /etc/init.d directory.
 #
-# $Id: functions,v 1.22 1999/08/31 23:12:45 wiget Exp $
+# $Id: functions,v 1.23 1999/09/02 12:29:17 misiek Exp $
 #
 # Author:      Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
 # Hacked by:    Greg Galloway and Marc Ewing
@@ -115,7 +115,7 @@ run_cmd()
        MESSAGE=$1
        show "$MESSAGE"; busy
        shift
-       if _ERRORS="`initlog -c \"$*\"`"; then
+       if _ERRORS="`initlog -c \"$*\" 2>&1`"; then
                deltext; ok
        else
                deltext; fail; echo $_ERRORS
index b8c628e82b8922977874a284372d07259f5777fe..23b1630c0a92f04e9080ac44a01d7326e3906dbd 100755 (executable)
@@ -1,5 +1,5 @@
 #
-# $Id: functions.network,v 1.20 1999/08/31 23:12:45 wiget Exp $
+# $Id: functions.network,v 1.21 1999/09/02 12:29:17 misiek Exp $
 #
 # This is not a shell script; it provides functions to network scripts
 # that source it.
@@ -52,11 +52,28 @@ set_hostname()
     fi
 }
 
-# PLD network functions
+# PLD/Linux network functions
 # (C) 1999 Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
 #
 # All functions must be called "name_of_function on" or "name_of_function off"
 
+# Setup Network Address Translation (NAT)
+setup_nat()
+{
+if [ ! -r /etc/sysconfig/static-nat ]; then
+       exit
+fi
+grep "^[0-9]" /etc/sysconfig/static-nat | while read src via dst; do
+       if [ "$1" == "on" ]; then
+               /sbin/ip route add nat $src via $dst
+               /sbin/ip rule add from $dst nat $src
+       elif [ "$1" == "off" ]; then
+               /sbin/ip rule del from $dst nat $src
+               /sbin/ip route del nat $src via $dst
+       fi
+done
+}
+
 # proc_net <zmien> <start/stop> <co ustaw> <co default> <nazwa_zmiennej> [komunikat]
 # proc_net ipv4/ip_forward start 1         0            IPV4_FORWARDING  "IPv4 forwarding"
 #
@@ -114,7 +131,7 @@ if [ "$IPV4_DYNAMIC_IP_PATCH" == "yes" ] && [ "$1" == "on" ]; then
 show "Enabling dynamic IP patch"; busy
 if echo $IPV4_DYNAMIC_IP_PATCH_VALUE > /proc/sys/net/ipv4/ip_dynaddr; then deltext; ok; else deltext; fail; fi
 else
-show "Diabling dynamic IP patch"; busy
+show "Disabling dynamic IP patch"; busy
 if echo 0 > /proc/sys/net/ipv4/ip_dynaddr; then deltext; ok; else deltext; fail; fi
 fi
 
@@ -169,17 +186,15 @@ ip link set dev lo down
 static_arp()
 {
 if [ "$STATIC_ARP" == "yes" ]; then
-       if [ -f /etc/ethers -a -x /sbin/arp ]; then
+       if [ -r /etc/ethers -a -x /sbin/arp ]; then
                /sbin/arp -f /etc/ethers
        fi
 fi
 }
 
-# Koniecznie trzeba to usprawnic
 modprobe_net()
 {
-[ "$IPV6_NETWORKING" == "yes" ] && modprobe net-pf-10 2> /dev/null
-#modprobe ipip ip_gre 2> /dev/null
+[ "$IPV6_NETWORKING" == "yes" ] && [ "`ls -R /lib/modules/\`uname -r\`/ | grep ipv6.o`" != "" ] && modprobe -s -k net-pf-10
 }
 
 #
diff --git a/rc.d/init.d/ipchains b/rc.d/init.d/ipchains
deleted file mode 100755 (executable)
index 99b2ab3..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/bin/sh
-#
-# ipchains     Sets ipchains up
-#
-# chkconfig: 2345 09 91
-# description: ipchains  is  used to set up, maintain, and inspect the IP \
-#              firewall rules in the Linux kernel.  These  rules  can  be \
-#              divided  into  4 different categories: the IP input chain, \
-#              the IP output chain, the IP  forwarding  chain,  and  user \
-#             defined chains
-#
-# $Id: ipchains,v 1.3 1999/08/07 10:16:14 wiget Exp $
-
-# Source function library.
-. /etc/rc.d/init.d/functions
-
-
-add_rule () {
-
-  # is this a comment or an empty line?
-  if [ -n "$2" ] && echo "$2" | egrep -v "^[#;]" >/dev/null ; then 
-        
-      # eval allows use  of shell substitutions in rules
-      eval ipchains -A '"$1"' $2 >> $ERRFILE || return 1
-  fi     
-  return 0
-}
-
-add_chain () {
-
-    # create new or flush existing chain
-    ipchains -N "$1" 2>/dev/null || ipchains -F "$1" 2>>$ERRFILE || ERROR=yes
-    { 
-      LINENO=0
-      while read LINE ; do
-        add_rule "$1" "$LINE" $LINENO 2>>$ERRFILE || {
-          echo "Bad line $LINENO of /etc/sysconfig/ipchains.d/$1" >> $ERRFILE
-          ERROR=yes
-        }
-       LINENO=$(($LINENO + 1))
-      done
-    } < "$1"
-}
-
-[ -x /sbin/ipchains ] || exit 1
-[ -d /etc/sysconfig/ipchains.d ] || exit 1
-
-[ -f /etc/sysconfig/ipchains ] && . /etc/sysconfig/ipchains
-
-
-ERRFILE=/tmp/ipchains-init.$$ 
-rm -f $ERRFILE
-touch $ERRFILE || exit 1
-ERROR=no
-
-# See how we were called.
-case "$1" in
-  start)
-       show "Setting up IPchains"
-       busy
-       [ -n "$INPUT_POLICY" ] && ipchains -P input $INPUT_POLICY
-       [ -n "$OUTPUT_POLICY" ] && ipchains -P input $OUTPUT_POLICY
-       [ -n "$FORWARD_POLICY" ] && ipchains -P input $FORWARD_POLICY
-
-       cd /etc/sysconfig/ipchains.d
-       for l in * ; do
-               [ -f "$l" ] && add_chain "$l" 
-       done
-       
-       if [ "$ERROR" != "no" ] ; then
-         deltext ; fail
-         cat $ERRFILE
-         rm -f $ERRFILE
-         exit 1
-       fi  
-       
-       deltext ; ok ;
-       touch /var/lock/subsys/ipchains
-       ;;
-  stop)
-       show "Clearing IPchains"
-       busy
-       
-       # back to the default
-       ipchains -P input ACCEPT
-       ipchains -P input ACCEPT
-       ipchains -P input ACCEPT
-       
-       cd /etc/sysconfig/ipchains.d
-       for l in * ; do
-               [ -f "$l" ] && ipchains -F "$l"
-       done
-       for l in * ; do
-               [ -f "$l" ] && ipchains -X "$l" 2>/dev/null
-       done
-       
-       deltext ; ok ;
-       rm -f /var/lock/subsys/ipchains
-       ;;
-       
-  status)
-       ipchains -L
-       ;;
-       
-  restart)
-       $0 stop
-       $0 start
-       ;;
-       
-  *)
-       echo "Usage: ipchains {start|stop|status|restart}"
-       rm -f $ERRFILE
-       exit 1
-esac
-
-rm -f $ERRFILE
-
-exit 0
This page took 0.058099 seconds and 4 git commands to generate.