source: projects/initscripts/tags/initscripts-8.91.3/ppp/ip-down.ipv6to4 @ 1108

Revision 1108, 3.2 KB checked in by daisuke, 14 years ago (diff)

import initscripts-8.90.6 from internal cvs repository

Line 
1#!/bin/sh
2#
3# ip-down.ipv6to4
4#
5#
6# Taken from:
7# (P) & (C) 2000-2005 by Peter Bieringer <pb@bieringer.de>
8#
9#  You will find more information on the initscripts-ipv6 homepage at
10#   http://www.deepspace6.net/projects/initscripts-ipv6.html
11#
12# Version 2005-09-22
13#
14# Calling parameters:
15#  $1: interface name
16#
17# Called (mostly) by /etc/ppp/ip-down.local
18#  like: /etc/ppp/ip-down.ipv6to4 $1 >>/var/log/ppp-ipv6to4.log 2>&1
19#
20# Note: this script will *check* whether the existing 6to4 tunnel
21#        was set before by using "ip-up.ipv6to4" comparing IPv4 address
22#        of device with the generated 6to4 prefix
23#
24# Uses following information from /etc/sysconfig/network-scripts/ifcfg-$1:
25#  IPV6TO4INIT=yes|no: controls configuration
26#  IPV6TO4_ROUTING="<device>-<suffix>/<prefix length> ...": information to setup additional interfaces
27#
28#  IPV6_CONTROL_RADVD=yes|no: controls radvd triggering
29#  IPV6_RADVD_PIDFILE=<file>: PID file of radvd for sending signals, default is "/var/run/radvd/radvd.pid"
30#  IPV6_RADVD_TRIGGER_ACTION=startstop|reload|restart|SIGHUP: how to trigger radvd (optional, default is SIGHUP)
31#
32
33
34if [ -z "$1" ]; then
35        echo $"Argument 1 is empty but should contain interface name - skip IPv6to4 initialization"
36        exit 1
37fi
38
39# Get global network configuration
40. /etc/sysconfig/network
41
42# Source IPv4 helper functions
43cd /etc/sysconfig/network-scripts
44. ./network-functions
45
46CONFIG=$1
47[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
48source_config
49
50# IPv6 don't need aliases anymore, config is skipped
51REALDEVICE=`echo ${DEVICE} | sed 's/:.*//g'`
52[ "$DEVICE" != "$REALDEVICE" ] && exit 0
53
54if [ ! -f /etc/sysconfig/network-scripts/network-functions-ipv6 ]; then
55        exit 1
56fi
57
58. /etc/sysconfig/network-scripts/network-functions-ipv6
59
60
61# Run basic IPv6 test, if not ok, skip IPv6 initialization
62ipv6_test testonly || exit 0
63
64# Test status of ppp device
65ipv6_test_device_status $DEVICE
66if [ $? != 0 -a $? != 11 ]; then
67        # device doesn't exist or other problem occurs
68        exit 1
69fi
70
71# Test status of tun6to4 device
72ipv6_test_device_status tun6to4
73if [ $? = 0 -o $? = 11 ]; then
74        # Device exists
75        valid6to4config="yes"
76
77        # Get IPv4 address from interface
78        ipv4addr="`ipv6_get_ipv4addr_of_device $DEVICE`"
79        if [ -z "$ipv4addr" ]; then
80                # Has no IPv4 address
81                valid6to4config="no"
82        fi
83
84        # Get local IPv4 address of dedicated tunnel
85        ipv4addr6to4local="`ipv6_get_ipv4addr_of_tunnel tun6to4 local`"
86
87        # IPv6to4 not enabled on this interface?
88        if [ $IPV6TO4INIT != "yes" ]; then
89                # Check against configured 6to4 tunnel to see if this interface was regardless used before
90                if [ "$ipv4addr" != "$ipv4addr6to4local" ]; then
91                        # IPv4 address of interface does't match local tunnel address, interface was not used for current 6to4 setup
92                        valid6to4config="no"
93                fi
94        fi
95
96fi
97
98if [ "$valid6to4config" = "yes" ]; then
99        if [ "$IPV6_CONTROL_RADVD" = "yes" ]; then
100                # Control running radvd
101                ipv6_trigger_radvd down "$IPV6_RADVD_TRIGGER_ACTION" $IPV6_RADVD_PIDFILE
102        fi
103
104        if [ -n "$IPV6TO4_ROUTING" ]; then
105                # Delete routes to local networks
106                for devsuf in $IPV6TO4_ROUTING; do
107                        dev="`echo $devsuf | awk -F- '{ print $1 }'`"
108                        ipv6_cleanup_6to4_device $dev
109                done
110        fi
111
112        # Delete all configured 6to4 address
113        ipv6_cleanup_6to4_tunnels tun6to4
114fi
Note: See TracBrowser for help on using the repository browser.