Update executors to reflect new create/destroy phase.

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
This commit is contained in:
Maximilian Wilhelm 2020-09-10 00:48:35 +02:00
parent e6c6f49143
commit af94d760d0
7 changed files with 37 additions and 18 deletions

View file

@ -4,6 +4,7 @@ set -e
# Copyright (C) 2012, 2020 Natanael Copa <ncopa@alpinelinux.org>
# Copyright (C) 2020 Ariadne Conill <ariadne@dereferenced.org>
# Copyright (C) 2020 Maximilian Wilhelm <max@sdn.clinic>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@ -134,8 +135,12 @@ esac
[ -z "$PORTS" ] && ! env | grep -q "^IF_BRIDGE" && exit
case "$PHASE" in
create)
if [ ! -d "/sys/class/net/${IFACE}" ]; then
brctl addbr "${IFACE}"
fi
;;
pre-up)
brctl addbr $IFACE || exit 1
wait_ports
set_bridge_opts
add_ports
@ -144,6 +149,10 @@ pre-up)
post-down)
del_ports
ip link set dev $IFACE down
brctl delbr $IFACE || exit 1
;;
destroy)
if [ -d "/sys/class/net/${IFACE}" ]; then
brctl delbr "${IFACE}"
fi
;;
esac

View file

@ -19,10 +19,10 @@ PARAMS="mode $IF_GRE_MODE local '$IF_GRE_LOCAL' remote '$IF_GRE_REMOTE'"
[ -n "$PARAMS" ] || exit 0
case "$PHASE" in
pre-up)
create)
${MOCK} eval ip $FAMILY $COMMAND add $IFACE $PARAMS
;;
post-down)
destroy)
${MOCK} ip $FAMILY $COMMAND del $IFACE
;;
depend)

View file

@ -28,7 +28,7 @@ is_vlan() {
}
case "$PHASE" in
pre-up)
create)
if [ "${IF_LINK_TYPE}" = "dummy" ]; then
if [ -d "/sys/class/net/${IFACE}" ]; then
iface_type=$(ip -d link show dev "${IFACE}" | head -n3 | tail -n1 | awk '{ print $1 }')
@ -76,7 +76,7 @@ up)
down)
${MOCK} ip link set down dev "${IFACE}"
;;
post-down)
destroy)
if [ "${IF_LINK_TYPE}" = "dummy" ] || is_vlan; then
if [ -z "${MOCK}" -a ! -d "/sys/class/net/${IFACE}" ]; then
exit 0

View file

@ -1,8 +1,16 @@
#!/bin/sh
set -e
[ -z "$IF_PPP_PROVIDER" ] && exit 0
case "$PHASE" in
pre-up) ${MOCK} pon $IF_PPP_PROVIDER ;;
post-down) ${MOCK} poff $IF_PPP_PROVIDER ;;
depend) echo "$IF_PPP_PHYSDEV" ;;
create)
${MOCK} pon $IF_PPP_PROVIDER
;;
destroy)
${MOCK} poff $IF_PPP_PROVIDER
;;
depend)
echo "$IF_PPP_PHYSDEV"
;;
esac

View file

@ -37,10 +37,10 @@ PARAMS=$(set | sed -E '
[ "$PARAMS" ] || exit 0
case "$PHASE" in
pre-up)
create)
${MOCK} eval ip $FAMILY $COMMAND add $IFACE $PARAMS
;;
post-down)
destroy)
${MOCK} ip $FAMILY $COMMAND del $IFACE
;;
depend)

View file

@ -14,14 +14,14 @@ handle_member() {
[ -n "$VERBOSE" ] && set -x
case "$PHASE" in
pre-up)
create)
[ -n "$IF_VRF_TABLE" ] && handle_init "add"
[ -n "$IF_VRF_MEMBER" ] && handle_member
exit 0
;;
post-down)
pre-up)
[ -n "$IF_VRF_MEMBER" ] && handle_member
;;
destroy)
[ -n "$IF_VRF_TABLE" ] && handle_init "del"
exit 0
;;
depend)
echo "$IF_VRF_MEMBER"

View file

@ -6,11 +6,13 @@ set -e
[ -z "$IF_WIREGUARD_CONFIG_PATH" ] && IF_WIREGUARD_CONFIG_PATH="/etc/wireguard/$IFACE.conf"
case "$PHASE" in
pre-up)
create)
${MOCK} ip link add $IFACE type wireguard
;;
pre-up)
${MOCK} wg setconf $IFACE $IF_WIREGUARD_CONFIG_PATH
;;
post-down)
destroy)
${MOCK} ip link delete dev $IFACE
;;
esac