net-netmask revision 6ba597c56d749c61b4f783157f63196d7b2445f0
d4ef65050feac78554addf6e16a06c6e2e0bd331Brian Wellington#!/sbin/sh
a6ca100924894cdd8e2b791d75a8cef32b1fba1fTinderbox User#
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# CDDL HEADER START
d4ef65050feac78554addf6e16a06c6e2e0bd331Brian Wellington#
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater# The contents of this file are subject to the terms of the
d4ef65050feac78554addf6e16a06c6e2e0bd331Brian Wellington# Common Development and Distribution License (the "License").
d4ef65050feac78554addf6e16a06c6e2e0bd331Brian Wellington# You may not use this file except in compliance with the License.
d4ef65050feac78554addf6e16a06c6e2e0bd331Brian Wellington#
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# or http://www.opensolaris.org/os/licensing.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# See the License for the specific language governing permissions
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# and limitations under the License.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews#
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# When distributing Covered Code, include this CDDL HEADER in each
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d4ef65050feac78554addf6e16a06c6e2e0bd331Brian Wellington# If applicable, add the following below this CDDL HEADER, with the
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User# fields enclosed by brackets "[]" replaced with your own identifying
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# information: Portions Copyright [yyyy] [name of copyright owner]
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt#
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# CDDL HEADER END
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt#
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt#
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
e939674d53a127ddeeaf4b41fd72933f0b493308Mark Andrews# Use is subject to license terms.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt#
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington#
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington# Reset netmask and broadcast address whenever new information is
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington# availabe from NIS.
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington#
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington. /lib/svc/share/smf_include.sh
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington#
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington# In a shared-IP zone we need this service to be up, but all of the
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington# work it tries to do is irrelevant (and will actually lead to the
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington# service failing if we try to do it), so just bail out.
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington# In the global zone and exclusive-IP zones we proceed.
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington#
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeinsmf_configure_ip || exit $SMF_EXIT_OK
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein#
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein# wait_nis
c1a883f2e04d94e99c433b1f6cfd0c0338f4ed85Mark Andrews# Wait up to 5 seconds for ypbind to obtain a binding.
3398334b3acda24b086957286288ca9852662b12Automatic Updater#
dde8659175c5798267fb0fdefd7576e4efe271b3Automatic Updaterwait_nis ()
f428e385a4f7a42196b53de8e134909e8c488258Automatic Updater{
207cee019eb5cbbe7c905f7c52f7b5d11f8c0305Automatic Updater for i in 1 2 3 4 5; do
99d8f5a70440ee8b63ab1745d713b96dde890546Tinderbox User server=`/usr/bin/ypwhich 2>/dev/null`
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User [ $? -eq 0 -a -n "$server" ] && return 0 || sleep 1
a6ca100924894cdd8e2b791d75a8cef32b1fba1fTinderbox User done
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein return 1
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein#
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein# Reset the netmask and broadcast address for our network interfaces.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein# Since this may result in a name service lookup, we want to now wait
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein# for NIS to come up if we previously started it.
f5d30e2864e048a42c4dc1134993ae7efdb5d6c3Mark Andrews#
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeindomain=`/usr/bin/domainname 2>/dev/null`
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein[ -z "$domain" ] || [ ! -d /var/yp/binding/$domain ] || wait_nis || \
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington echo "WARNING: Timed out waiting for NIS to come up" >& 2
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington#
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# Re-set the netmask and broadcast addr for all IP interfaces. This
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# ifconfig is run here, after waiting for name services, so that
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# "netmask +" will find the netmask if it lives in a NIS map. The 'D'
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# in -auD tells ifconfig NOT to mess with the interface if it is
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# under DHCP control
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt#
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt/usr/sbin/ifconfig -auD4 netmask + broadcast +
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt
e939674d53a127ddeeaf4b41fd72933f0b493308Mark Andrews# Uncomment these lines to print complete network interface configuration
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# echo "network interface configuration:"
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# /usr/sbin/ifconfig -a
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt