2 # Filename: grml-addtun
3 # Purpose: Program to create tun/tap devices and add them to a bridge
4 # Authors: Michael Gebetsroither <gebi@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 ################################################################################
8 # grml-addtun [OPTIONS] <tun0> <tun1> ...
18 while getopts "du:g:b:h" opt; do
21 u) OPT_USER_="$OPTARG" ;;
22 g) OPT_GROUP_="$OPTARG" ;;
23 b) OPT_BRIDGE_="$OPTARG" ;;
24 h) printUsage; exit 0 ;;
25 ?) printUsage; exit 1 ;;
28 shift $(($OPTIND - 1))
31 function fromCmdline()
36 while (( $# != 0 )); do
48 if [[ $OPT_USER_ != '' ]]; then args_="$args_ -u $OPT_USER_"; fi
49 if [[ $OPT_GROUP_ != '' ]]; then args_="$args_ -u $OPT_GROUP_"; fi
51 if [[ $OPT_BRIDGE_ != '' ]]; then
52 brctl addif "$OPT_BRIDGE_" "$1"
58 if [[ $OPT_BRIDGE_ != '' ]]; then
59 brctl delif "$OPT_BRIDGE_" "$1"
64 if [[ $OPT_DEL_ == 'false' ]]; then
65 fromCmdline "createTun" "$@"
67 fromCmdline "trashTun" "$@"