From e29e552cc2410114b8d4c23407395e4600415d0c Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 26 Jul 2020 03:05:46 -0600 Subject: [PATCH] port iproute2 configuration from C to shell --- executor-scripts/static | 29 +++++++++++++++++++++++++++++ tests/executors/static | 19 +------------------ 2 files changed, 30 insertions(+), 18 deletions(-) create mode 100755 executor-scripts/static mode change 100755 => 120000 tests/executors/static diff --git a/executor-scripts/static b/executor-scripts/static new file mode 100755 index 0000000..7fc3fdf --- /dev/null +++ b/executor-scripts/static @@ -0,0 +1,29 @@ +#!/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" + elif [ "$1" != "${1#*:[0-9a-fA-F]}" ]; then + echo "-6" + else + exit 1 + fi +} + +for i in $(ifquery -p address -i $INTERFACES_FILE $IFACE); do + addrfam=$(addr_family $i) + + ${MOCK} ip $addrfam addr $cmd $i dev $IFACE +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 diff --git a/tests/executors/static b/tests/executors/static deleted file mode 100755 index b649c11..0000000 --- a/tests/executors/static +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -case "$PHASE" in -up) - cmd="add" - ;; -down) - cmd="del" - ;; -esac - -for i in $(ifquery -p address -i $INTERFACES_FILE $IFACE); do - echo ip addr $cmd $i dev $IFACE -done - -for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do - echo ip route $cmd default via $i -done diff --git a/tests/executors/static b/tests/executors/static new file mode 120000 index 0000000..1322f47 --- /dev/null +++ b/tests/executors/static @@ -0,0 +1 @@ +mock-executor \ No newline at end of file