aboutsummaryrefslogtreecommitdiffstats
path: root/ppp/ip-down.ipv6to4
blob: 29a4e8a0a0d82f09fe552cb184d7c6e761d753ad (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
#
# ip-down.ipv6to4
#
#
# Taken from:
# (P) & (C) 2000-2001 by Peter Bieringer <pb@bieringer.de>
#
# Version 2001-07-15a
#
# Calling parameters:
#  $1: interface name
#
# Called by (mostly) /etc/ppp/ip-down.local
#  like: /etc/ppp/ip-down.ipv6to4 $1 >>/var/log/ppp-ipv6to4.log 2>&1
#
# Uses following information from /etc/sysconfig/network:
#  NETWORKING_IPV6=yes|no: controls IPv6 initialization (global setting)
#
# Uses following information from /etc/sysconfig/network-scripts/ifcfg-$1:
#  IPV6TO4INIT=yes|no: controls configuration
#  IPV6TO4_RELAY=IPv4addr: remote IPv6to4 relay address
#  IPV6TO4_ROUTING="eth0-:f101::0/64 eth1-:f102::0/64": information to setup local subnetting
#  IPV6TO4_CONTROL_RADVD=yes|no: controls radvd triggering
#  IPV6TO4_RADVD_PIDFILE=file: PID file of radvd for sending signals, default is "/var/run/radvd/radvd.pid"
#


if [ -z "$1" ]; then
  	echo $"Arg 1 is empty but should contain interface name - skip IPv6to4 initialization" >/dev/stderr
	exit 1
fi

# Get global network configuration
. /etc/sysconfig/network 

# Source IPv4 helper functions
cd /etc/sysconfig/network-scripts
. network-functions 

CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
source_config                                                                   

# Test whether IPv6 should be configured, else stop
[ "${NETWORKING_IPV6}" = "yes" ] || exit 0

if [ ! -f /etc/sysconfig/network-scripts/network-functions-ipv6 ]; then
	exit 1
fi

. /etc/sysconfig/network-scripts/network-functions-ipv6

# Run basic IPv6 test, if not ok, skip IPv6 initialization
test_ipv6 testonly || exit 0


# Shutdown of 6to4, if configured
valid6to4config="yes"
if [ -z "$IPV6TO4_RELAY" ]; then
	valid6to4config="no"
fi
if [ "$valid6to4config" = "yes" ]; then
	# Beep
	if [ -x /usr/bin/beep ]; then /usr/bin/beep -f 2666; else echo -en "\a" >/dev/console; fi

	if [ "$IPV6TO4_CONTROL_RADVD" = "yes" ]; then
		# stop RADVD from distributing no longer usable 6to4 prefixes
		if [ -z "$IPV6TO4_RADVD_PIDFILE" ]; then
			IPV6TO4_RADVD_PIDFILE="/var/run/radvd/radvd.pid"
		fi
		# Send SIGHUP to radvd
		if [ -f "$IPV6TO4_RADVD_PIDFILE" ]; then
			pid="`cat $IPV6TO4_RADVD_PIDFILE`"
			if [ ! -z "$pid" ]; then
				#  still waiting for feature enabling: stopping distribution of prefixes in RADVD....		
				# kill -SOMETHING $pid
				false
			else
				false
			fi
		fi
	fi

	# Delete all static IPv6to4 routes to relay
	ifdown_ipv6_route_all sit0 ::$IPV6TO4_RELAY

	if [ ! -z "$IPV6TO4_ROUTING" ]; then
		# Delete routes to local networks
		for devsuf in $IPV6TO4_ROUTING; do
			dev="`echo $devsuf | awk -F- '{ print $1 }'`"
			ifdown_ipv6_route_all $dev ::
		done
	fi

	# Delete all configured 6to4 address
	ifdown_ipv6to4_all sit0 

	# Beep
	if [ -x /usr/bin/beep ]; then /usr/bin/beep -f 2000; else echo -en "\a" >/dev/console; fi
fi