Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9aef88ec authored by Haiyang Zhang's avatar Haiyang Zhang Committed by David S. Miller
Browse files

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: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c519fe9a
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -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
	done

	rm $tmpfl
}