-
Notifications
You must be signed in to change notification settings - Fork 11
/
configure_network.sh
102 lines (94 loc) · 3.56 KB
/
configure_network.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Simple script to configure the network adapter according to th values of the nvramrc variable network-boot-arguments
#
# History
# 07.11.2009 v1.0.0 /bs
# initial release for the Extended MilaX WANBOOT image v1.0.0
# 09.11.2009 v1.0.1 /bs
# new version for the Extended MilaX WANBOOT image v1.0.1:
# added code to plumb the network adapter
# added code to handle multiple net aliasse
#
# Links:
# Description and Download links for the Extended MilaX WANBOOT image:
# http://wikis.sun.com/display/BigAdmin/Converting+the+MilaX+Live+CD+for+SPARC+to+a+WANBOOT+image#ConvertingtheMilaXLiveCDforSPARCtoaWANBOOTimage-MilaXWANBOOTimages
#
# Author
# Bernd.Schemmer@gmx.de
# http://www.bnsmb.de
#
#
PATH=/usr/sbin/:/sbin:/usr/bin:/bin:${PATH}
export PATH
# get the contents of the nvramrc variable network-boot-arguments
#
eval ` eeprom network-boot-arguments | cut -f2- -d "=" | tr -s ",-" ";_" `
# result variables of the eval command:
#
# client_id=0AE1E784
# file=http://10.224.164.136/cgi_bin/wanboot_cgi
# host_ip=10.225.231.132.
# hostname=rtdev01t1
# router_ip=10.225.231.254
# subnet_mask=255.255.255.128
NETDEV=""
NETWORK_DEVICE=`prtconf -vpPD | grep " net:" | tr -s " " | cut -f3 -d " " | tr -d "'" `
[ "${NETWORK_DEVICE}"x != ""x ] && NETDEV=` ls -l /dev | grep ${NETWORK_DEVICE}: | tr -s " " | cut -f9 -d " " `
NETWORK_CONFIGURED=1
if [ "${NETDEV}"x != ""x ] ; then
ifconfig "${NETDEV}" plumb
CUR_IP=`ifconfig "${NETDEV}" | grep inet | cut -f2 -d " " `
if [ "${CUR_IP}"x != "0.0.0.0"x ] ;then
echo "Network adapter "${NETDEV}" already configured:"
ifconfig "${NETDEV}"
echo "Nothing to do here"
NETWORK_CONFIGURED=0
fi
if [ "${NETWORK_CONFIGURED}" = 1 ] ; then
if [ "${NETDEV}"x != ""x -a "${host_ip}"x != ""x -a "$ {router_ip}"x != ""x -a "${subnet_mask}" != ""x ] ; then
echo "Configuring the network ..."
set -x
ifconfig ${NETDEV} plumb ${host_ip} netmask ${subnet_mask} broadcast + up
route add default ${router_ip}
set +x
else
echo "Network configuration is incomplete -- can not configure the network."
fi
fi
fi
if [ "${hostname}"x != ""x ] ; then
echo "Configuring the nodename ..."
uname -S "${hostname}"
echo "${hostname}">/etc/nodename..
grep "${hostname}" /etc/hosts >/dev/null
if [ $? -ne 0 ] ; then
if [ "${host_ip}"x != ""x ] ; then
echo ${host_ip} ${hostname} >>/etc/hosts
fi
else
echo "/etc/hosts already configured."
fi
else
echo "Nodename not found in the nvram -- can not configure the nodename"
fi