]> git.pld-linux.org Git - projects/rc-scripts.git/blame - lib/tnlup
- fix sysctl setting for interfaces with dot in name, patch by Adam Osuchowski <adwol>
[projects/rc-scripts.git] / lib / tnlup
CommitLineData
d29c401a
AM
1#!/bin/sh
2#
de1fc6ce 3# tnlup - tunnel configuration script
fdc764ae 4# Copyright (C) 1999, 2000 Arkadiusz Miśkiewicz <misiek@pld-linux.org>
b0443108 5#
de1fc6ce
JR
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
d29c401a 10#
de1fc6ce
JR
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19#
ec8b15cb 20# $Id$
de1fc6ce
JR
21#
22
23. /etc/sysconfig/network
24. /etc/rc.d/init.d/functions
f67ce454 25. /lib/rc-scripts/functions.network
d29c401a 26
111f7a0d 27DEV=$1
beb24638 28
111f7a0d 29[ -z "$DEV" ] && {
5e6dfc29
JR
30 nls "Usage: %s <device name>" "tnlup" >&2
31 exit 1
beb24638
AM
32}
33
a51d5138
JR
34TNLCONFIGS=$(LC_ALL=C ls /etc/sysconfig/interfaces/tnlcfg-* 2>/dev/null | grep -vE '~$')
35TNLCONFIGS=$(grep -LE '^#!' $TNLCONFIGS)
36CONFIG=$(grep -lE "^DEVICE=[\"\']*$DEV[\"\']*\$" $TNLCONFIGS)
111f7a0d
AF
37
38if [ -z "$CONFIG" ]; then
5e6dfc29 39 CONFIG="$DEV"
111f7a0d
AF
40fi
41
42if false; then
5e6dfc29
JR
43 [ -f "/etc/sysconfig/interfaces/$CONFIG" ] || CONFIG=tnlcfg-$CONFIG
44 [ -f "/etc/sysconfig/interfaces/$CONFIG" ] || {
45 echo "usage: tnlup <device name>" >&2
46 exit 1
47 }
111f7a0d 48fi
beb24638 49
d29c401a
AM
50source_config
51
de1fc6ce 52if [ "foo$2" = "fooboot" -a -n "${ONBOOT}" ] && is_no "${ONBOOT}"; then
5e6dfc29 53 exit
d29c401a
AM
54fi
55
de1fc6ce 56case "${MODE}" in
5e6dfc29 57 sit|four)
74a7f2e4 58 is_no "${IPV6_NETWORKING}" && exit 0
59 is_no "${IPV6_TUNNELCONFIG}" && exit 0
170103c8 60 [ "${MODE}" = "sit" ] && is_module "sit" && modprobe -s sit
61 [ "${MODE}" = "four" ] && is_module "fourtun" && modprobe -s fourtun
74a7f2e4 62 ;;
5e6dfc29 63 ipip)
74a7f2e4 64 is_no "${IPV4_NETWORKING}" && exit 0
170103c8 65 is_module "ipip" && modprobe -s ipip
74a7f2e4 66 ;;
5e6dfc29 67 gre)
74a7f2e4 68 is_no "${IPV4_NETWORKING}" && exit 0
170103c8 69 is_module "ip_gre" && modprobe -s ip_gre
74a7f2e4 70 ;;
5e6dfc29 71 ipxip|ipipx)
74a7f2e4 72 is_no "${IPX}" && exit 0
73 ;;
de1fc6ce
JR
74esac
75
76RESULT=0
d29c401a
AM
77[ -z "${LOCALADDR}" ] && LOCALADDR=any
78[ -z "${REMOTEADDR}" ] && REMOTEADDR=any
4b3c2539
AM
79[ -n "${TTL}" ] && TTL="ttl ${TTL}"
80[ -n "${TOS}" ] && TOS="tos ${TOS}"
81[ -n "${BIND_DEV}" ] && BIND_DEV="dev ${BIND_DEV}"
de1fc6ce
JR
82[ -n "${PRIORITY}" ] && PRIORITY="priority ${PRIORITY}"
83[ -n "${HOPLIMIT}" ] && HOPLIMIT="hoplimit ${HOPLIMIT}"
84[ -n "${ENCAPLIMIT}" ] && ENCAPLIMIT="encaplimit ${ENCAPLIMIT}"
d29c401a 85
dd4a755f 86if is_yes "${SEQ}"; then
5e6dfc29 87 SEQ=seq
d29c401a 88else
5e6dfc29
JR
89 is_yes "${ISEQ}" && SEQ=iseq
90 is_yes "${OSEQ}" && SEQ="${SEQ} oseq"
d29c401a
AM
91fi
92
dd4a755f 93if is_yes "${CSUM}"; then
5e6dfc29 94 CSUM=csum
d29c401a 95else
5e6dfc29
JR
96 is_yes "${ICSUM}" && CSUM=icsum
97 is_yes "${ICSUM}" && CSUM="${SEQ} ocsum"
d29c401a
AM
98fi
99
dd4a755f 100is_yes "${ISEQ}" && ISEQ=iseq
d29c401a 101
de1fc6ce 102[ -z "${PMTUDISC}" -a "${TTL}" != "0" -a "${TTL}" != "inherit" ] && PMTUDISC=yes
d29c401a 103
dd4a755f 104if is_yes "${PMTUDISC}"; then
5e6dfc29 105 PMTUDISC=pmtudisc
dd4a755f 106elif is_no "${PMTUDISC}"; then
5e6dfc29 107 PMTUDISC=nopmtudisc
d29c401a
AM
108fi
109
110if [ -n "${KEY}" ]; then
5e6dfc29
JR
111 IKEY=""
112 OKEY=""
d29c401a
AM
113fi
114
de1fc6ce 115case "${MODE}" in
5e6dfc29 116 ipip|sit)
74a7f2e4 117 ip tunnel add ${DEVICE} mode ${MODE} local ${LOCALADDR} \
5e6dfc29 118 remote ${REMOTEADDR} ${TTL} ${TOS} ${PMTUDISC} ${BIND_DEV}
74a7f2e4 119 RESULT=$?
120 ;;
5e6dfc29 121 gre)
74a7f2e4 122 ip tunnel add ${DEVICE} mode ${MODE} local ${LOCALADDR} \
5e6dfc29
JR
123 remote ${REMOTEADDR} ${TTL} ${TOS} ${PMTUDISC} ${BIND_DEV} \
124 ${CSUM} ${ISEQ} ${KEY} ${IKEY} ${OKEY}
74a7f2e4 125 RESULT=$?
126 ;;
5e6dfc29 127 fourtun)
74a7f2e4 128 fourcfg add ${DEVICE} saddr ${LOCALADDR} daddr ${REMOTEADDR} \
5e6dfc29 129 ${PRIORITY} ${HOPLIMIT} ${ENCAPLIMIT}
74a7f2e4 130 RESULT=$?
131 ;;
5e6dfc29 132 ipxip|ipipx)
74a7f2e4 133 ;;
de1fc6ce
JR
134esac
135
136exit $RESULT
This page took 0.101322 seconds and 4 git commands to generate.