vnicinit_solaris.sh revision 332d68e9666b04a5aa788a586d9f4c6b1f19c700
# Sun VirtualBox
# VirtualBox VNIC setup script for Solaris hosts with Crossbow.
#
# Copyright (C) 2007-2009 Sun Microsystems, Inc.
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
# Clara, CA 95054 USA or visit http://www.sun.com if you need
# additional information or have any questions.
#
if [ -z "$1" ]; then
echo "Missing MAC address."
echo
echo "Usage: $0 macaddress [vnicname]"
echo " A new VNIC is created if no vnicname is provided."
exit 1
fi
mac=$1
# Create the VNIC if required
if [ -z "$2" ]; then
# snv <= 82 is to handled differently (dladm format changes at 83+)
# Try obtain one that's currently active (82 dladm show-link doesn't indicate status; just use show-dev atm)
eval $phys_field
else
phys_field=`/usr/sbin/dladm show-link -p -o link,state | /usr/bin/awk 'BEGIN{FS=":"} /up/ {print $1}'`
eval $phys_field
fi
if [ -z "$phys_nic" ]; then
# Failed to get a currently active NIC, get the first available link.
phys_field=`/usr/sbin/dladm show-link -p | /usr/bin/awk 'NF==5 && $2=="CLASS=\"phys\"" { print $1 }'`
eval $phys_field
else
phys_field=`/usr/sbin/dladm show-link -p -o link,class | /usr/bin/awk 'BEGIN{FS=":"} /up/ {print $1}'`
eval $phys_field
fi
if [ -z "$phys_nic" ]; then
# Failed to get any NICs!
echo "Failed to get a physical NIC to bind to."
exit 1
fi
fi
# To use a specific physical NIC, replace $phys_nic with the name of the NIC.
if [ $? != 0 ]; then
echo "vna failed to bind VNIC."
exit 1
fi
case "$vnic_name" in
;;
*)
vnic_name="vnic$vnic_name"
;;
esac
else
vnic_name=$2
fi
host_ip="192.168.1.10${vnic_id}"
guest_ip="192.168.1.20${vnic_id}"
host_ip="192.168.1.${vnic_id}"
guest_ip="192.168.2.${vnic_id}"
let "temp_id = $vnic_id % 900"
host_ip="192.168.1.10${temp_id}"
guest_ip="192.168.1.20${temp_id}"
else
# VNIC ID is probably off the scale!
host_ip="192.168.1.10"
guest_ip="192.168.1.20"
fi
netmask="255.255.255.0"
if [ -z "$2" ]; then
#else
# Do existing VNIC configuration here if needed...
fi
echo "$vnic_name"
exit 0