Skip to content

Commit 9aef88e

Browse files
haiyangzdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c519fe9 commit 9aef88e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

tools/hv/bondvf.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,30 @@ function create_bond_cfg_redhat {
102102
}
103103

104104
function del_eth_cfg_ubuntu {
105-
local fn=$cfgdir/interfaces
105+
local mainfn=$cfgdir/interfaces
106+
local fnlist=( $mainfn )
107+
108+
local dirlist=(`awk '/^[ \t]*source/{print $2}' $mainfn`)
109+
110+
local i
111+
for i in "${dirlist[@]}"
112+
do
113+
fnlist+=(`ls $i 2>/dev/null`)
114+
done
115+
106116
local tmpfl=$(mktemp)
107117

108118
local nic_start='^[ \t]*(auto|iface|mapping|allow-.*)[ \t]+'$1
109119
local nic_end='^[ \t]*(auto|iface|mapping|allow-.*|source)'
110120

111-
awk "/$nic_end/{x=0} x{next} /$nic_start/{x=1;next} 1" $fn >$tmpfl
121+
local fn
122+
for fn in "${fnlist[@]}"
123+
do
124+
awk "/$nic_end/{x=0} x{next} /$nic_start/{x=1;next} 1" \
125+
$fn >$tmpfl
112126

113-
cp $tmpfl $fn
127+
cp $tmpfl $fn
128+
done
114129

115130
rm $tmpfl
116131
}

0 commit comments

Comments
 (0)