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