Skip to content

Commit

Permalink
tools: hv: Add clean up function for Ubuntu config
Browse files Browse the repository at this point in the history
This patch adds a function to clean up duplicate config info
on Ubuntu.

Signed-off-by: Haiyang Zhang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
haiyangz authored and davem330 committed Mar 7, 2017
1 parent df789fe commit 1a4691b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tools/hv/bondvf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1a4691b

Please sign in to comment.