# 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
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
#
-# $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.
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"
#
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
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
}
#
+++ /dev/null
-#!/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