diff options
author | Haiyang Zhang <haiyangz@microsoft.com> | 2017-05-12 22:14:11 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-05-16 18:52:45 +0300 |
commit | 9aef88ec85258ef958d0732c2622959f934882d2 (patch) | |
tree | 0cb36c635b6c5641f0b600133996d46b117f8ac8 /tools/hv | |
parent | c519fe9a4f0d1a1c559529c404589b8e346143f3 (diff) | |
download | linux-9aef88ec85258ef958d0732c2622959f934882d2.tar.xz |
tools: hv: Add clean up for included files in Ubuntu net config
The clean up function is updated to cover duplicate config info in
files included by "source" key word in Ubuntu network config.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/hv')
-rwxr-xr-x | tools/hv/bondvf.sh | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/tools/hv/bondvf.sh b/tools/hv/bondvf.sh index d85968cb1bf2..112deba8c4e9 100755 --- a/tools/hv/bondvf.sh +++ b/tools/hv/bondvf.sh @@ -102,15 +102,30 @@ function create_bond_cfg_redhat { } function del_eth_cfg_ubuntu { - local fn=$cfgdir/interfaces + local mainfn=$cfgdir/interfaces + local fnlist=( $mainfn ) + + local dirlist=(`awk '/^[ \t]*source/{print $2}' $mainfn`) + + local i + for i in "${dirlist[@]}" + do + fnlist+=(`ls $i 2>/dev/null`) + done + 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 + local fn + for fn in "${fnlist[@]}" + do + awk "/$nic_end/{x=0} x{next} /$nic_start/{x=1;next} 1" \ + $fn >$tmpfl - cp $tmpfl $fn + cp $tmpfl $fn + done rm $tmpfl } |