From 326e27cdb45757e24095e71ffaf981eeaabc62e7 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 26 Jul 2020 04:13:25 -0600 Subject: [PATCH] executors: static: bring down routes before addresses --- executor-scripts/linux/static | 38 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/executor-scripts/linux/static b/executor-scripts/linux/static index 7fc3fdf..f6b75b6 100755 --- a/executor-scripts/linux/static +++ b/executor-scripts/linux/static @@ -1,11 +1,5 @@ #!/bin/sh -case "$PHASE" in -up) cmd="add" ;; -down) cmd="del" ;; -*) exit 0 ;; -esac - addr_family() { if [ "$1" != "${1#*[0-9].[0-9]}" ]; then echo "-4" @@ -16,14 +10,28 @@ addr_family() { fi } -for i in $(ifquery -p address -i $INTERFACES_FILE $IFACE); do - addrfam=$(addr_family $i) +configure_addresses() { + for i in $(ifquery -p address -i $INTERFACES_FILE $IFACE); do + addrfam=$(addr_family $i) + ${MOCK} ip $addrfam addr $1 $i dev $IFACE + done +} - ${MOCK} ip $addrfam addr $cmd $i dev $IFACE -done +configure_gateways() { + for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do + addrfam=$(addr_family $i) + ${MOCK} ip $addrfam route $1 default via $i + done +} -for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do - addrfam=$(addr_family $i) - - ${MOCK} ip $addrfam route $cmd default via $i -done +case "$PHASE" in +up) + configure_addresses add + configure_gateways add + ;; +down) + configure_gateways del + configure_addresses del + ;; +*) exit 0 ;; +esac