#!/bin/bash ############################################## # Add VMWare Network Bridged devices hot # # Revisions # J.Gargano - 2009-07-08 - 1.1 # ############################################# echo "Locating Existing Devices" for dev in $(ls /dev/vmnet*); do echo " Found $dev" done echo printf "Please enter a device number that does not exist in this list: " read num # Check if it exists if [ -e /dev/vmnet$num ];then echo "/dev/vmnet$num exists! Exiting." exit 1 fi # Select an interface echo echo "Locating interfaces to bridge" for int in $(ifconfig |grep "^[a-z,A-Z]" |cut -d' ' -f1); do echo $int done printf "Please enter a interface: " read interface # Check if it exists ifconfig $interface >/dev/null 2>&1 ret=$? if [ $ret != 0 ];then if [ "$1" != "-d" ]; then echo "Can't find interface. Exiting!" exit 1 else echo "Use dummy device: $interface" dummy="Dummy " fi fi # Create device echo "Creating device /dev/vmnet$num" mknod --mode=600 /dev/vmnet$num c 119 $num # Add to vmware netmap configuration # open netmap.conf and get next number in list let nextnetnum=$(cat /etc/vmware/netmap.conf | tail -1 | cut -d'.' -f1 | sed -e s/network//)+1 echo "Adding network$nextnetnum to /etc/vmware/netmap.conf" echo "network$nextnetnum.name = \"${dummy}Bridged to $interface\"">> /etc/vmware/netmap.conf echo "network$nextnetnum.device = \"vmnet$num\"">> /etc/vmware/netmap.conf # Add to vmware locations configuration echo "answer VNET_${num}_NAME ${dummy}Bridged to $interface" >> /etc/vmware/locations echo "answer VNET_${num}_INTERFACE $interface" >> /etc/vmware/locations echo "remove_file /dev/vmnet$num" >> /etc/vmware/locations echo "file /dev/vmnet$num" >> /etc/vmware/locations # Start Service `which vmnet-bridge` -d /var/run/vmnet-bridge-$num.pid -n $num -i $interface