]> git.pld-linux.org Git - projects/rc-scripts.git/blame - lib/tnlup
remove $Id$ lines
[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#
de1fc6ce
JR
20#
21
22. /etc/sysconfig/network
23. /etc/rc.d/init.d/functions
f67ce454 24. /lib/rc-scripts/functions.network
d29c401a 25
111f7a0d 26DEV=$1
beb24638 27
111f7a0d 28[ -z "$DEV" ] && {
5e6dfc29
JR
29 nls "Usage: %s <device name>" "tnlup" >&2
30 exit 1
beb24638
AM
31}
32
a51d5138
JR
33TNLCONFIGS=$(LC_ALL=C ls /etc/sysconfig/interfaces/tnlcfg-* 2>/dev/null | grep -vE '~$')
34TNLCONFIGS=$(grep -LE '^#!' $TNLCONFIGS)
35CONFIG=$(grep -lE "^DEVICE=[\"\']*$DEV[\"\']*\$" $TNLCONFIGS)
111f7a0d
AF
36
37if [ -z "$CONFIG" ]; then
5e6dfc29 38 CONFIG="$DEV"
111f7a0d
AF
39fi
40
41if false; then
5e6dfc29
JR
42 [ -f "/etc/sysconfig/interfaces/$CONFIG" ] || CONFIG=tnlcfg-$CONFIG
43 [ -f "/etc/sysconfig/interfaces/$CONFIG" ] || {
44 echo "usage: tnlup <device name>" >&2
45 exit 1
46 }
111f7a0d 47fi
beb24638 48
d29c401a
AM
49source_config
50
de1fc6ce 51if [ "foo$2" = "fooboot" -a -n "${ONBOOT}" ] && is_no "${ONBOOT}"; then
5e6dfc29 52 exit
d29c401a
AM
53fi
54
de1fc6ce 55case "${MODE}" in
5e6dfc29 56 sit|four)
74a7f2e4 57 is_no "${IPV6_NETWORKING}" && exit 0
58 is_no "${IPV6_TUNNELCONFIG}" && exit 0
170103c8 59 [ "${MODE}" = "sit" ] && is_module "sit" && modprobe -s sit
60 [ "${MODE}" = "four" ] && is_module "fourtun" && modprobe -s fourtun
74a7f2e4 61 ;;
5e6dfc29 62 ipip)
74a7f2e4 63 is_no "${IPV4_NETWORKING}" && exit 0
170103c8 64 is_module "ipip" && modprobe -s ipip
74a7f2e4 65 ;;
5e6dfc29 66 gre)
74a7f2e4 67 is_no "${IPV4_NETWORKING}" && exit 0
170103c8 68 is_module "ip_gre" && modprobe -s ip_gre
74a7f2e4 69 ;;
5e6dfc29 70 ipxip|ipipx)
74a7f2e4 71 is_no "${IPX}" && exit 0
72 ;;
de1fc6ce
JR
73esac
74
75RESULT=0
d29c401a
AM
76[ -z "${LOCALADDR}" ] && LOCALADDR=any
77[ -z "${REMOTEADDR}" ] && REMOTEADDR=any
4b3c2539
AM
78[ -n "${TTL}" ] && TTL="ttl ${TTL}"
79[ -n "${TOS}" ] && TOS="tos ${TOS}"
80[ -n "${BIND_DEV}" ] && BIND_DEV="dev ${BIND_DEV}"
de1fc6ce
JR
81[ -n "${PRIORITY}" ] && PRIORITY="priority ${PRIORITY}"
82[ -n "${HOPLIMIT}" ] && HOPLIMIT="hoplimit ${HOPLIMIT}"
83[ -n "${ENCAPLIMIT}" ] && ENCAPLIMIT="encaplimit ${ENCAPLIMIT}"
d29c401a 84
dd4a755f 85if is_yes "${SEQ}"; then
5e6dfc29 86 SEQ=seq
d29c401a 87else
5e6dfc29
JR
88 is_yes "${ISEQ}" && SEQ=iseq
89 is_yes "${OSEQ}" && SEQ="${SEQ} oseq"
d29c401a
AM
90fi
91
dd4a755f 92if is_yes "${CSUM}"; then
5e6dfc29 93 CSUM=csum
d29c401a 94else
5e6dfc29
JR
95 is_yes "${ICSUM}" && CSUM=icsum
96 is_yes "${ICSUM}" && CSUM="${SEQ} ocsum"
d29c401a
AM
97fi
98
dd4a755f 99is_yes "${ISEQ}" && ISEQ=iseq
d29c401a 100
de1fc6ce 101[ -z "${PMTUDISC}" -a "${TTL}" != "0" -a "${TTL}" != "inherit" ] && PMTUDISC=yes
d29c401a 102
dd4a755f 103if is_yes "${PMTUDISC}"; then
5e6dfc29 104 PMTUDISC=pmtudisc
dd4a755f 105elif is_no "${PMTUDISC}"; then
5e6dfc29 106 PMTUDISC=nopmtudisc
d29c401a
AM
107fi
108
109if [ -n "${KEY}" ]; then
5e6dfc29
JR
110 IKEY=""
111 OKEY=""
d29c401a
AM
112fi
113
de1fc6ce 114case "${MODE}" in
5e6dfc29 115 ipip|sit)
74a7f2e4 116 ip tunnel add ${DEVICE} mode ${MODE} local ${LOCALADDR} \
5e6dfc29 117 remote ${REMOTEADDR} ${TTL} ${TOS} ${PMTUDISC} ${BIND_DEV}
74a7f2e4 118 RESULT=$?
119 ;;
5e6dfc29 120 gre)
74a7f2e4 121 ip tunnel add ${DEVICE} mode ${MODE} local ${LOCALADDR} \
5e6dfc29
JR
122 remote ${REMOTEADDR} ${TTL} ${TOS} ${PMTUDISC} ${BIND_DEV} \
123 ${CSUM} ${ISEQ} ${KEY} ${IKEY} ${OKEY}
74a7f2e4 124 RESULT=$?
125 ;;
5e6dfc29 126 fourtun)
74a7f2e4 127 fourcfg add ${DEVICE} saddr ${LOCALADDR} daddr ${REMOTEADDR} \
5e6dfc29 128 ${PRIORITY} ${HOPLIMIT} ${ENCAPLIMIT}
74a7f2e4 129 RESULT=$?
130 ;;
5e6dfc29 131 ipxip|ipipx)
74a7f2e4 132 ;;
de1fc6ce
JR
133esac
134
135exit $RESULT
This page took 0.68525 seconds and 4 git commands to generate.