source: lab.git/TipAndDoc/vmware/hotaddbridge @ 8333ea0

trunk
Last change on this file since 8333ea0 was 8333ea0, checked in by mitty <mitty@…>, 13 years ago

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@92 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

  • Property mode set to 100755
File size: 1.8 KB
Line 
1#!/bin/bash
2##############################################
3# Add VMWare Network Bridged devices hot
4#
5# Revisions
6# J.Gargano - 2009-07-08 - 1.1
7#
8#############################################
9
10echo "Locating Existing Devices"
11for dev in $(ls /dev/vmnet*);
12do
13    echo " Found $dev"
14done
15echo
16printf "Please enter a device number that does not exist in this list: "
17read num
18# Check if it exists
19if [ -e /dev/vmnet$num ];then
20    echo "/dev/vmnet$num exists! Exiting."
21    exit 1
22fi
23
24
25# Select an interface
26echo
27echo "Locating interfaces to bridge"
28for int in $(ifconfig |grep "^[a-z,A-Z]" |cut -d' ' -f1);
29do
30    echo $int
31done
32printf "Please enter a interface: "
33read interface
34
35# Check if it exists
36ifconfig $interface >/dev/null 2>&1
37ret=$?
38if [ $ret != 0 ];then
39    if [ "$1" != "-d" ]; then
40        echo "Can't find interface. Exiting!"
41        exit 1
42    else
43        echo "Use dummy device: $interface"
44        dummy="Dummy "
45    fi
46fi
47
48
49# Create device
50echo "Creating device /dev/vmnet$num"
51mknod --mode=600 /dev/vmnet$num c 119 $num
52
53# Add to vmware netmap configuration
54# open netmap.conf and get next number in list
55let nextnetnum=$(cat /etc/vmware/netmap.conf | tail -1 | cut -d'.' -f1 | sed -e s/network//)+1
56
57echo "Adding network$nextnetnum to /etc/vmware/netmap.conf"
58
59echo "network$nextnetnum.name = \"${dummy}Bridged to $interface\"">> /etc/vmware/netmap.conf
60echo "network$nextnetnum.device = \"vmnet$num\"">> /etc/vmware/netmap.conf
61
62# Add to vmware locations configuration
63echo "answer VNET_${num}_NAME ${dummy}Bridged to $interface" >> /etc/vmware/locations
64echo "answer VNET_${num}_INTERFACE $interface" >> /etc/vmware/locations
65echo "remove_file /dev/vmnet$num" >> /etc/vmware/locations
66echo "file /dev/vmnet$num" >> /etc/vmware/locations
67
68# Start Service
69`which vmnet-bridge` -d /var/run/vmnet-bridge-$num.pid -n $num -i $interface
Note: See TracBrowser for help on using the repository browser.