2020-08-19 08:46:04 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-08-26 09:35:18 +00:00
|
|
|
set -e
|
|
|
|
|
2020-08-19 08:46:04 +00:00
|
|
|
# Based on alpine's tunnel configuration script.
|
|
|
|
# Copyright (c) 2017 Kaarle Ritvanen
|
2020-08-20 08:09:01 +00:00
|
|
|
# Copyright (c) 2020 Ariadne Conill (extended for ifupdown-ng)
|
|
|
|
|
|
|
|
[ -z "$IF_TUNNEL_LOCAL" ] && exit 1
|
|
|
|
[ -z "$IF_TUNNEL_REMOTE" ] && exit 1
|
|
|
|
[ -z "$IF_TUNNEL_MODE" ] && exit 1
|
|
|
|
|
|
|
|
COMMAND="tunnel"
|
|
|
|
FAMILY="-4"
|
|
|
|
|
|
|
|
case "$IF_TUNNEL_MODE" in
|
|
|
|
gretap)
|
|
|
|
COMMAND="link"
|
|
|
|
;;
|
|
|
|
vti6|ipip6|ip6*)
|
|
|
|
FAMILY="-6"
|
|
|
|
;;
|
|
|
|
esac
|
2020-08-19 08:46:04 +00:00
|
|
|
|
|
|
|
PARAMS=$(set | sed -E '
|
|
|
|
s/^IF_TUNNEL_([A-Z0-9_]+)=(.+)/\1\n\2/
|
|
|
|
ta
|
|
|
|
d
|
|
|
|
:a
|
|
|
|
h
|
|
|
|
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
|
|
|
|
P
|
|
|
|
g
|
|
|
|
s/.*\n//
|
|
|
|
')
|
|
|
|
|
|
|
|
[ "$PARAMS" ] || exit 0
|
|
|
|
|
|
|
|
case "$PHASE" in
|
|
|
|
pre-up)
|
2020-08-20 08:09:01 +00:00
|
|
|
${MOCK} eval ip $FAMILY $COMMAND add $IFACE $PARAMS
|
2020-08-19 08:46:04 +00:00
|
|
|
;;
|
|
|
|
post-down)
|
2020-08-20 08:09:01 +00:00
|
|
|
${MOCK} ip $FAMILY $COMMAND del $IFACE
|
2020-08-19 08:46:04 +00:00
|
|
|
;;
|
|
|
|
depend)
|
|
|
|
echo "$IF_TUNNEL_DEV"
|
|
|
|
;;
|
|
|
|
esac
|