30 lines
515 B
Text
30 lines
515 B
Text
|
#!/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
|