File: redirects

package info (click to toggle)
ifupdown-scripts-zg2 0.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 484 kB
  • ctags: 55
  • sloc: sh: 4,037; makefile: 37
file content (44 lines) | stat: -rwxr-xr-x 1,144 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# $Header: /var/local/cvs/debian/ifupdown-scripts-zg2/scripts/ifupdown-scripts-zg2.d/redirects,v 1.1 2004/09/12 18:00:04 mh Exp $

# IFACE                = Logical interface name
# MODE                 = start | stop
# METHOD               = manual, otherwise exit!
# IF_DEVICE	       = device to be used
# IF_ACCEPT_REDIRECTS  = 0/1 - should this interface accept redirects
# IF_SEND_REDIRECTS    = 0/1 - should this interface issue redirects

. /etc/network/ifupdown-scripts-zg2.d/common-functions

# set_bool_value key{0/1} value, where key is a path in
# /proc/sys/net/ipv4/conf/$IF_DEVICE
set_bool_value()
{
  KEY="$1"
  VAL="$2"

  [ -z "$VAL" ] && exit 0

  IFACEDIR="/proc/sys/net/ipv4/conf/$IF_DEVICE"

  if ! echo $VAL | grep -s -q '\(0\|1\)'; then
    abort "no valid value $VAL for key $KEY"
  fi
  
  if [ -e "$IFACEDIR/$KEY" ]; then
    echo $VAL > $IFACEDIR/$KEY
  else
    abort "No such key $KEY in $IFACEDIR for $IF_DEVICE"
  fi
}

case "$MODE" in
  start)
    set_bool_value "accept_redirects" "$IF_ACCEPT_REDIRECTS"
    set_bool_value "send_redirects" "$IF_SEND_REDIRECTS"
    ;;
  *)
    ;;
esac

# end of file