net-netmask revision 11767:8f30d0e611c6
11573Srgrimes#!/sbin/sh
21573Srgrimes#
31573Srgrimes# CDDL HEADER START
41573Srgrimes#
51573Srgrimes# The contents of this file are subject to the terms of the
61573Srgrimes# Common Development and Distribution License (the "License").
71573Srgrimes# You may not use this file except in compliance with the License.
81573Srgrimes#
91573Srgrimes# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
101573Srgrimes# or http://www.opensolaris.org/os/licensing.
111573Srgrimes# See the License for the specific language governing permissions
121573Srgrimes# and limitations under the License.
131573Srgrimes#
141573Srgrimes# When distributing Covered Code, include this CDDL HEADER in each
151573Srgrimes# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
161573Srgrimes# If applicable, add the following below this CDDL HEADER, with the
171573Srgrimes# fields enclosed by brackets "[]" replaced with your own identifying
181573Srgrimes# information: Portions Copyright [yyyy] [name of copyright owner]
191573Srgrimes#
201573Srgrimes# CDDL HEADER END
211573Srgrimes#
221573Srgrimes#
231573Srgrimes# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
241573Srgrimes# Use is subject to license terms.
251573Srgrimes#
261573Srgrimes
271573Srgrimes#
281573Srgrimes# Reset netmask and broadcast address whenever new information is
2950476Speter# availabe from NIS.
301573Srgrimes#
31227416Sdougb
321573Srgrimes. /lib/svc/share/smf_include.sh
3379531Sru
341573Srgrimes#
351573Srgrimes# In a shared-IP zone we need this service to be up, but all of the
361573Srgrimes# work it tries to do is irrelevant (and will actually lead to the
3759460Sphantom# service failing if we try to do it), so just bail out. 
3859460Sphantom# In the global zone and exclusive-IP zones we proceed.
391573Srgrimes#
4084306Srusmf_configure_ip || exit $SMF_EXIT_OK
41208914Suqs
42208914Suqs#
43208914Suqs# wait_nis
44208914Suqs# Wait up to 5 seconds for ypbind to obtain a binding.
451573Srgrimes#
461573Srgrimeswait_nis ()
471573Srgrimes{
48100144Skeramida	for i in 1 2 3 4 5; do
49100144Skeramida		server=`/usr/bin/ypwhich 2>/dev/null`
50108028Sru		[ $? -eq 0 -a -n "$server" ] && return 0 || sleep 1
511573Srgrimes	done
521573Srgrimes	return 1
531573Srgrimes}
541573Srgrimes
551573Srgrimes#
56108087Sru# Reset the netmask and broadcast address for our network interfaces.
571573Srgrimes# Since this may result in a name service lookup, we want to now wait
581573Srgrimes# for NIS to come up if we previously started it.
591573Srgrimes#
601573Srgrimesdomain=`/usr/bin/domainname 2>/dev/null`
611573Srgrimes
621573Srgrimes[ -z "$domain" ] || [ ! -d /var/yp/binding/$domain ] || wait_nis || \
631573Srgrimes    echo "WARNING: Timed out waiting for NIS to come up" >& 2
641573Srgrimes
651573Srgrimes#
661573Srgrimes# Re-set the netmask and broadcast addr for all IP interfaces.  This
671573Srgrimes# ifconfig is run here, after waiting for name services, so that
681573Srgrimes# "netmask +" will find the netmask if it lives in a NIS map. The 'D'
691573Srgrimes# in -auD tells ifconfig NOT to mess with the interface if it is
701573Srgrimes# under DHCP control
711573Srgrimes#
721573Srgrimes/usr/sbin/ifconfig -auD4 netmask + broadcast +
731573Srgrimes
741573Srgrimes# Uncomment these lines to print complete network interface configuration
751573Srgrimes# echo "network interface configuration:"
761573Srgrimes# /usr/sbin/ifconfig -a
771573Srgrimes