Merge branch 'master' of /home/git/Development/dotfiles

This commit is contained in:
sonny 2018-05-11 16:17:13 +02:00
commit 069c51574b
3 changed files with 73 additions and 0 deletions

24
scripts/generate-tap Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
# Generate a numbered tap device name
TAP="tap0"
COUNT=0
while [[ true ]]; do
FOUND=false
for INT in $(ls /sys/class/net); do
if [[ $INT == $TAP ]]; then
((COUNT++))
TAP="tap$COUNT"
FOUND=true
continue
fi
done
if [[ !$FOUND ]]; then
break
fi
done

22
scripts/qemu-custom-ifdown Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
# This script removes the specified interface if it exists
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 == $1 ]]; then
/sbin/ip link delete dev $1 type tap
DELETED=true
break
fi
done
if [[ !$DELETED ]]; then
echo "Interface $1 not found, nothing to delete"
exit 1
fi

27
scripts/qemu-custom-ifup Executable file
View file

@ -0,0 +1,27 @@
#!/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