VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/solaris/vnicinit_solaris.sh@ 5936

Last change on this file since 5936 was 5936, checked in by vboxsync, 17 years ago

Sol: Added hostif setup,term scripts to installer. Added copyright notices to the scripts.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Revision Id
File size: 1.8 KB
Line 
1#!/bin/bash
2# innotek VirtualBox
3# Copyright (C) 2007 innotek GmbH
4#
5# VirtualBox VNIC setup script for Solaris hosts with Crossbow.
6#
7
8if [ -z "$1" ]; then
9 echo "Missing MAC address."
10 echo
11 echo "Usage: $0 macaddress [vnicname]"
12 echo " A new VNIC is created if no vnicname is provided."
13 exit 1
14fi
15
16# Try obtain a physical NIC that is currently active
17phys_nic=`/usr/sbin/dladm show-dev | /usr/bin/awk 'NF==7 && $3=="up" { print $1 }'`
18if [ -z "$phys_nic" ]; then
19 # Failed to get a currently active NIC, get the first available NIC.
20 phys_nic=`/usr/sbin/dladm show-link | /usr/bin/nawk '/legacy/ {next} {print $1; exit}'`
21 if [ -z "$phys_nic" ]; then
22 # Failed to get any NICs!
23 echo "Failed to get a physical NIC to bind to."
24 exit 1
25 fi
26fi
27vnic_id=0
28vnic_name=""
29mac=$1
30
31# Create the VNIC if required
32if [ -z "$2" ]; then
33 # To use a specific physical NIC, replace $phys_nic with the name of the NIC.
34 vnic_id=`/usr/lib/vna $phys_nic $mac`
35 if [ $? != 0 ]; then
36 exit 1
37 fi
38 vnic_name=vnic${vnic_id}
39else
40 vnic_name=$2
41 vnic_id=${vnic_name##*[a-z]}
42fi
43
44if [ ${vnic_id} -lt 10 ]; then
45 host_ip="192.168.1.10${vnic_id}"
46 guest_ip="192.168.1.20${vnic_id}"
47elif [ ${vnic_id} -lt 256 ]; then
48 host_ip="192.168.1.${vnic_id}"
49 guest_ip="192.168.2.${vnic_id}"
50elif [ ${vnic_id} -gt 899 ]; then
51 let "temp_id = $vnic_id % 900"
52 host_ip="192.168.1.10${temp_id}"
53 guest_ip="192.168.1.20${temp_id}"
54else
55 # VNIC ID is probably off the scale!
56 host_ip="192.168.1.10"
57 guest_ip="192.168.1.20"
58fi
59
60netmask="255.255.255.0"
61
62if [ -z "$2" ]; then
63 /sbin/ifconfig $vnic_name plumb
64 /sbin/ifconfig $vnic_name $host_ip destination $guest_ip netmask $netmask up
65#else
66# Do existing VNIC configuration here if needed...
67fi
68
69echo "$vnic_name"
70exit $?
71
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette