tap - vx32 - Local 9vx git repository for patches.
 (HTM) git clone git://r-36.net/vx32
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       tap (736B)
       ---
            1 #!/bin/sh
            2 # tap: set up/down a tap device
            3 
            4 fatal() { echo $* 1>&2; exit 1; }
            5 usage="usage: tap cmd [args]"
            6 
            7 cmd=$1
            8 shift || fatal $usage
            9 user=`whoami`
           10 
           11 # Create the tap device with tunctl
           12 iface=`sudo tunctl -b -u $user`
           13 # or openvpn
           14 #iface=tap0
           15 #sudo openvpn --mktun --dev $iface --user $user
           16 
           17 # Bring the tap device up
           18 sudo /sbin/ifconfig $iface 0.0.0.0 up
           19 
           20 # Add it to the bridge
           21 sudo /usr/sbin/brctl addif br0 $iface
           22 
           23 # Launch 9vx (use -F to not fork)
           24 $cmd "$@" -F "ether0=type=tap dev=$iface"
           25 
           26 # Bring the tap device down and disconnect from br0
           27 sudo /sbin/ifconfig $iface down
           28 sudo /usr/sbin/brctl delif br0 $iface
           29 
           30 # Remove the tap device with tunctl
           31 sudo tunctl -d $iface &> /dev/null
           32 # or openvpn
           33 #sudo openvpn --rmtun --dev $1