executors: static: bring down routes before addresses

This commit is contained in:
Ariadne Conill 2020-07-26 04:13:25 -06:00
parent 83440e3f88
commit 326e27cdb4

View file

@ -1,11 +1,5 @@
#!/bin/sh #!/bin/sh
case "$PHASE" in
up) cmd="add" ;;
down) cmd="del" ;;
*) exit 0 ;;
esac
addr_family() { addr_family() {
if [ "$1" != "${1#*[0-9].[0-9]}" ]; then if [ "$1" != "${1#*[0-9].[0-9]}" ]; then
echo "-4" echo "-4"
@ -16,14 +10,28 @@ addr_family() {
fi fi
} }
configure_addresses() {
for i in $(ifquery -p address -i $INTERFACES_FILE $IFACE); do for i in $(ifquery -p address -i $INTERFACES_FILE $IFACE); do
addrfam=$(addr_family $i) addrfam=$(addr_family $i)
${MOCK} ip $addrfam addr $1 $i dev $IFACE
${MOCK} ip $addrfam addr $cmd $i dev $IFACE
done done
}
configure_gateways() {
for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do
addrfam=$(addr_family $i) addrfam=$(addr_family $i)
${MOCK} ip $addrfam route $1 default via $i
${MOCK} ip $addrfam route $cmd default via $i
done done
}
case "$PHASE" in
up)
configure_addresses add
configure_gateways add
;;
down)
configure_gateways del
configure_addresses del
;;
*) exit 0 ;;
esac