ifupdown-ng/executor-scripts/linux/tunnel
Maximilian Wilhelm af94d760d0 Update executors to reflect new create/destroy phase.
Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
2020-09-10 00:48:47 +02:00

49 lines
759 B
Bash
Executable file

#!/bin/sh
set -e
# Based on alpine's tunnel configuration script.
# Copyright (c) 2017 Kaarle Ritvanen
# 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
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
create)
${MOCK} eval ip $FAMILY $COMMAND add $IFACE $PARAMS
;;
destroy)
${MOCK} ip $FAMILY $COMMAND del $IFACE
;;
depend)
echo "$IF_TUNNEL_DEV"
;;
esac