27 lines
547 B
Bash
Executable file
27 lines
547 B
Bash
Executable file
#!/bin/bash
|
|
# This script adds an specified tap interface to first bridge
|
|
# found with the name containing br0
|
|
|
|
if [[ $EUID != 0 ]]; then
|
|
echo "This script needs sudo priveleges"
|
|
echo "Exiting..."
|
|
exit 1
|
|
fi
|
|
|
|
for INT in $(ls /sys/class/net); do
|
|
if [[ $INT == *"br0"* && -d /sys/class/net/$INT/bridge/. ]]; then
|
|
BRIDGE="$INT"
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [[ -z $BRIDGE ]]; then
|
|
echo 'No bridge INTerfaces seen'
|
|
exit 1
|
|
fi
|
|
|
|
/sbin/ip tuntap add dev $1 mode tap
|
|
/sbin/ip link set $1 up
|
|
|
|
/sbin/ip link set dev $1 master $BRIDGE
|
|
|