projects
/
grml-network.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6d0d35b
)
grml-addtun: added -a for automatic bridge handling
author
Michael Gebetsroither
<michael.geb@gmx.at>
Thu, 4 Oct 2007 11:08:51 +0000
(13:08 +0200)
committer
Michael Gebetsroither
<michael.geb@gmx.at>
Thu, 4 Oct 2007 11:08:51 +0000
(13:08 +0200)
sbin/grml-addtun
patch
|
blob
|
history
diff --git
a/sbin/grml-addtun
b/sbin/grml-addtun
index
3b6d5b9
..
ac7d6a4
100755
(executable)
--- a/
sbin/grml-addtun
+++ b/
sbin/grml-addtun
@@
-14,6
+14,7
@@
OPT_DEL_='false'
OPT_USER_=''
OPT_GROUP_=''
OPT_BRIDGE_=''
OPT_USER_=''
OPT_GROUP_=''
OPT_BRIDGE_=''
+OPT_AUTO_='false'
function printUsage()
function printUsage()
@@
-28,7
+29,8
@@
OPTIONS:
-u <user> this user should be able to use the tun device
-g <group> this group should be able to use the tun device
-b <bridge> if given, all tun/tap devices are added/removed from the bridge
-u <user> this user should be able to use the tun device
-g <group> this group should be able to use the tun device
-b <bridge> if given, all tun/tap devices are added/removed from the bridge
- bridge is created if not allready existent
+ -a enable auto mode, eg. create the bridge if not allready existing and
+ delete it when empty after removing given tun devices
-h this help
EOT
}
-h this help
EOT
}
@@
-76,12
+78,13
@@
function die()
# MAIN
##
# MAIN
##
-while getopts "du:g:b:h" opt; do
+while getopts "du:g:b:
a
h" opt; do
case "$opt" in
d) OPT_DEL_='true' ;;
u) OPT_USER_="$OPTARG" ;;
g) OPT_GROUP_="$OPTARG" ;;
b) OPT_BRIDGE_="$OPTARG" ;;
case "$opt" in
d) OPT_DEL_='true' ;;
u) OPT_USER_="$OPTARG" ;;
g) OPT_GROUP_="$OPTARG" ;;
b) OPT_BRIDGE_="$OPTARG" ;;
+ a) OPT_AUTO_='true' ;;
h) printUsage; exit 0 ;;
?) printUsage; exit 1 ;;
esac
h) printUsage; exit 0 ;;
?) printUsage; exit 1 ;;
esac
@@
-89,13
+92,13
@@
done
shift $(($OPTIND - 1))
if [[ $OPT_DEL_ == 'false' ]]; then
shift $(($OPTIND - 1))
if [[ $OPT_DEL_ == 'false' ]]; then
- if [[ $OPT_BRIDGE_ != '' ]]; then
+ if [[ $OPT_BRIDGE_ != ''
&& $OPT_AUTO_ == 'true'
]]; then
brctl showmacs "$OPT_BRIDGE_" &>/dev/null || brctl addbr "$OPT_BRIDGE_"
fi
fromCmdline "createTun" "$@"
else
fromCmdline "trashTun" "$@"
brctl showmacs "$OPT_BRIDGE_" &>/dev/null || brctl addbr "$OPT_BRIDGE_"
fi
fromCmdline "createTun" "$@"
else
fromCmdline "trashTun" "$@"
- if [[ $OPT_BRIDGE_ != '' ]]; then
+ if [[ $OPT_BRIDGE_ != ''
&& $OPT_AUTO_ == 'true'
]]; then
tmp_="`brctl showmacs "$OPT_BRIDGE_" |wc -l`"
if (( $tmp_ == 1 )); then
brctl delbr "$OPT_BRIDGE_"
tmp_="`brctl showmacs "$OPT_BRIDGE_" |wc -l`"
if (( $tmp_ == 1 )); then
brctl delbr "$OPT_BRIDGE_"