From patchwork Fri May 12 14:13:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 761672 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wPX6x5Qs4z9s4q for ; Sat, 13 May 2017 00:15:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758167AbdELOOq (ORCPT ); Fri, 12 May 2017 10:14:46 -0400 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:39018 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756411AbdELOOp (ORCPT ); Fri, 12 May 2017 10:14:45 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id 9BKAdkL6wCQzG9BKAd1QTx; Fri, 12 May 2017 07:13:43 -0700 x-originating-ip: 107.180.71.197 Received: from haiyangz by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1d9BKA-0004yl-RO; Fri, 12 May 2017 07:13:42 -0700 From: Haiyang Zhang To: davem@davemloft.net, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, kys@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next] tools: hv: Add clean up for included files in Ubuntu net config Date: Fri, 12 May 2017 07:13:33 -0700 Message-Id: <1494598413-19106-1-git-send-email-haiyangz@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 Reply-To: haiyangz@microsoft.com X-CMAE-Envelope: MS4wfA4jt9UCQapxkoXAQloO4YsOFTS/1RjEWe9lmdsvHWbAI+qNAzk5TJ8lv/kABbzb+rG2WxWCAeMQnf/X+KLaKj/rf0Aymb92gw0Qd6opbnoFBwrrVDL0 sZbPkTvTcvPR/ojY1OrwcUnlN+NmYgRk9xL1eBVvu8wO6t3vMCKjiaMJFgIao+bNyf1uUn8xh8Te6P/+JOSQlTYg7NP/OWAKfFMCd9iH2jbLhvkGvBrN7Flg yn8DYI9cTjr4HCG7L+iUPgsedJKNuBjM6Otw1GnEXaIoZTOmEcFp2jtGCpDW5AatCWQ05xqXvjaxktDaox0oj5AM31nx/bnQ+Q/XoZL1tac/e6hnzGyib0ZR vEBcawAt6+rJX7oL5jFxg/1moHohjQ== Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Haiyang Zhang 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 --- tools/hv/bondvf.sh | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/tools/hv/bondvf.sh b/tools/hv/bondvf.sh index d85968c..1f42604 100755 --- a/tools/hv/bondvf.sh +++ b/tools/hv/bondvf.sh @@ -102,15 +102,29 @@ 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)' + 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 }