* add entry to /etc/vmware/locations
authormitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Sat, 26 Jun 2010 00:47:00 +0000 (00:47 +0000)
committermitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Sat, 26 Jun 2010 00:47:00 +0000 (00:47 +0000)
 * accept dummy (non exist) device
 * more information

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

vmware/hotaddbridge

index 59da5ee..8a7d4cf 100755 (executable)
@@ -16,7 +16,7 @@ echo
 printf "Please enter a device number that does not exist in this list: "
 read num
 # Check if it exists
-if [ -f /dev/vmnet$num ];then
+if [ -e /dev/vmnet$num ];then
     echo "/dev/vmnet$num exists! Exiting."
     exit 1
 fi
@@ -36,14 +36,19 @@ read interface
 ifconfig $interface >/dev/null 2>&1
 ret=$?
 if [ $ret != 0 ];then
-    echo "Can't find interface. Exiting!"
-    exit 1
+    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 /dev/vmnet$num c 119 $num
+mknod --mode=600 /dev/vmnet$num c 119 $num
 
 # Add to vmware netmap configuration
 # open netmap.conf and get next number in list
@@ -51,9 +56,14 @@ let nextnetnum=$(cat /etc/vmware/netmap.conf | tail -1 | cut -d'.' -f1 | sed -e
 
 echo "Adding network$nextnetnum to /etc/vmware/netmap.conf"
 
-echo "network$nextnetnum.name=\"$interface\"">> /etc/vmware/netmap.conf
-echo "network$nextnetnum.device=\"vmnet$num\"">> /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
-vmnet-bridge -d /var/run/vmnet-bridge-$num.pid -n $num -i $interface
+`which vmnet-bridge` -d /var/run/vmnet-bridge-$num.pid -n $num -i $interface