[package] ruby: fix path to libiconv
[openwrt/svn-archive/archive.git] / ipv6 / 6scripts / files / 6tunnel.init
1 #!/bin/sh /etc/rc.common
2 START=46
3 STOP=46
4
5 start_service() {
6 local section="$1"
7
8 include /lib/network
9 scan_interfaces
10 config_load /var/state/network
11
12 config_get LAN lan ifname
13 config_get tnlifname "$section" tnlifname
14 config_get remoteip4 "$section" remoteip4
15 config_get localip4 "$section" localip4
16 config_get localip6 "$section" localip6
17 config_get remoteip6 "$section" remoteip6
18 config_get ttl "$section" ttl
19 config_get mtu "$section" mtu
20 config_get delegatedip6 "$section" delegatedip6
21
22 ip tunnel add $tnlifname mode sit remote $remoteip4 local $localip4 ttl 255
23 ifconfig $tnlifname up
24 ip link set mtu $mtu dev $tnlifname
25 ip tunnel change $tnlifname ttl $ttl
26 ip addr add $localip6 dev $tnlifname
27 ip -6 route add ::/0 dev $tnlifname
28 ip -6 route add 2000::/3 via $remoteip6
29 ip -6 route add $delegatedip6 dev $LAN
30 }
31
32 stop_service() {
33 local section="$1"
34
35 include /lib/network
36 scan_interfaces
37 config_load /var/state/network
38
39 config_get LAN lan ifname
40 config_get tnlifname "$section" tnlifname
41 config_get remoteip4 "$section" remoteip4
42 config_get localip4 "$section" localip4
43 config_get localip6 "$section" localip6
44 config_get remoteip6 "$section" remoteip6
45 config_get ttl "$section" ttl
46 config_get mtu "$section" mtu
47 config_get delegatedip6 "$section" delegatedip6
48
49 ip -6 ro del $delegatedip6 dev $LAN
50 ip -6 ro del 2000::/3 via $remoteip6
51 ip -6 ro del ::/0 dev $tnlifname
52 ip addr del $localip6 dev $tnlifname
53 ifconfig $tnlifname down
54 ip tunnel del $tnlifname
55 }
56 start() {
57 if ! [ -x /usr/sbin/ip ]; then
58 echo "ip is required to setup the tunnel";
59 exit 1;
60 fi
61 config_load "6tunnel"
62 config_foreach start_service 6tunnel
63 }
64
65 stop () {
66 config_load "6tunnel"
67 config_foreach stop_service 6tunnel
68 }