From 4c42c6bde357423f0704a6e5b1ea70081944a1bb Mon Sep 17 00:00:00 2001
From: Stig Thormodsrud <stig@vyatta.com>
Date: Mon, 14 Apr 2008 15:09:01 -0700
Subject: Fix 3148: can't delete bridge interface

---
 templates/interfaces/bridge/node.def | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'templates/interfaces/bridge/node.def')

diff --git a/templates/interfaces/bridge/node.def b/templates/interfaces/bridge/node.def
index ff643980..6af845f3 100644
--- a/templates/interfaces/bridge/node.def
+++ b/templates/interfaces/bridge/node.def
@@ -1,7 +1,16 @@
 tag:
 type: txt
 help: Configure a bridge interface
+
 syntax:expression: $VAR(@) in "br0", "br1", "br2", "br3", "br4", "br5", "br6", "br7", "br8", "br9" ; "Must be (br0 - br9)"
-create:expression: "sudo brctl addbr $VAR(@)"
-delete:expression: "sudo brctl delbr $VAR(@)"
+
+create: sudo brctl addbr $VAR(@)
+
+delete: if [ -n "`/usr/sbin/brctl show | grep $VAR(@) | grep eth`" ]; then
+	   echo "Interfaces are still assigned to bridge $VAR(@)";
+           exit 1;           
+        fi;
+        sudo ip link set $VAR(@) down;
+        sudo brctl delbr $VAR(@);
+
 comp_help: "Enter bridge interface name (br0 - br9)"
-- 
cgit v1.2.3

