grml-vnet: add help message on missing device name
[grml-network.git] / sbin / grml-vnet
index 109cc6f..82aca72 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
-# Filename:      grml-addtun
-# Purpose:       Program to create tun/tap devices and add them to a bridge
+# Filename:      grml-vnet
+# Purpose:       program to create tun/tap devices and add them to a bridge
 # Authors:       Michael Gebetsroither <gebi@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
@@ -93,6 +93,12 @@ while getopts "du:g:b:ah" opt; do
 done
 shift $(($OPTIND - 1))
 
+if [[ $# < 1 ]]; then
+    echo "Error: Please give at least one device" >&2
+    printUsage
+    exit 1
+fi
+
 if [[ $OPT_DEL_ == 'false' ]]; then
     if [[ $OPT_BRIDGE_ != '' && $OPT_AUTO_ == 'true' ]]; then
         brctl showmacs "$OPT_BRIDGE_" &>/dev/null || brctl addbr "$OPT_BRIDGE_"
@@ -104,6 +110,7 @@ else
     if [[ $OPT_BRIDGE_ != '' && $OPT_AUTO_ == 'true' ]]; then
         tmp_="`brctl showmacs "$OPT_BRIDGE_" |wc -l`"
         if (( $tmp_ == 1 )); then
+            ip link set down dev "$OPT_BRIDGE_"
             brctl delbr "$OPT_BRIDGE_"
         else
             die "E: bridge $OPT_BRIDGE_ not empty, not removing"