summaryrefslogtreecommitdiffstats
path: root/tools/hv
diff options
context:
space:
mode:
authorHaiyang Zhang2017-02-24 18:30:32 +0100
committerDavid S. Miller2017-03-07 02:10:40 +0100
commit1a4691b204e75a853ec74947bed0dd6966558d29 (patch)
treec638ea347973c8307fcf27d235da309069a906ac /tools/hv
parentipv6: Provide ipv6 version of "disable_policy" sysctl (diff)
downloadkernel-qcow2-linux-1a4691b204e75a853ec74947bed0dd6966558d29.tar.gz
kernel-qcow2-linux-1a4691b204e75a853ec74947bed0dd6966558d29.tar.xz
kernel-qcow2-linux-1a4691b204e75a853ec74947bed0dd6966558d29.zip
tools: hv: Add clean up function for Ubuntu config
This patch adds a function to clean up duplicate config info on Ubuntu. Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/hv')
-rwxr-xr-xtools/hv/bondvf.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/hv/bondvf.sh b/tools/hv/bondvf.sh
index 4aa5369ffa4e..d85968cb1bf2 100755
--- a/tools/hv/bondvf.sh
+++ b/tools/hv/bondvf.sh
@@ -101,9 +101,25 @@ function create_bond_cfg_redhat {
echo BONDING_OPTS=\"mode=active-backup miimon=100 primary=$2\" >>$fn
}
+function del_eth_cfg_ubuntu {
+ local fn=$cfgdir/interfaces
+ local tmpfl=$(mktemp)
+
+ local nic_start='^[ \t]*(auto|iface|mapping|allow-.*)[ \t]+'$1
+ local nic_end='^[ \t]*(auto|iface|mapping|allow-.*|source)'
+
+ awk "/$nic_end/{x=0} x{next} /$nic_start/{x=1;next} 1" $fn >$tmpfl
+
+ cp $tmpfl $fn
+
+ rm $tmpfl
+}
+
function create_eth_cfg_ubuntu {
local fn=$cfgdir/interfaces
+ del_eth_cfg_ubuntu $1
+
echo $'\n'auto $1 >>$fn
echo iface $1 inet manual >>$fn
echo bond-master $2 >>$fn
@@ -119,6 +135,8 @@ function create_eth_cfg_pri_ubuntu {
function create_bond_cfg_ubuntu {
local fn=$cfgdir/interfaces
+ del_eth_cfg_ubuntu $1
+
echo $'\n'auto $1 >>$fn
echo iface $1 inet dhcp >>$fn
echo bond-mode active-backup >>$fn