net-svc revision 6927f468b0af7710df000f6b16f6ee413e1e3007
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem# CDDL HEADER START
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic# The contents of this file are subject to the terms of the
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic# Common Development and Distribution License (the "License").
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic# You may not use this file except in compliance with the License.
4da61833a1cbbca94094f9653fd970582b97a72etrawick# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4da61833a1cbbca94094f9653fd970582b97a72etrawick# See the License for the specific language governing permissions
4da61833a1cbbca94094f9653fd970582b97a72etrawick# and limitations under the License.
4789804be088bcd86ae637a29cdb7fda25169521jailletc# When distributing Covered Code, include this CDDL HEADER in each
4789804be088bcd86ae637a29cdb7fda25169521jailletc# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4789804be088bcd86ae637a29cdb7fda25169521jailletc# If applicable, add the following below this CDDL HEADER, with the
e50c3026198fd496f183cda4c32a202925476778covener# fields enclosed by brackets "[]" replaced with your own identifying
e50c3026198fd496f183cda4c32a202925476778covener# information: Portions Copyright [yyyy] [name of copyright owner]
5b88c8507d5ef6d0c4cfbc78230294968175b638minfrin# CDDL HEADER END
6c3b9cebb551140fbb25d58bae08b539b3802133ylavic# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
6c3b9cebb551140fbb25d58bae08b539b3802133ylavic# Use is subject to license terms.
4f29b65ab4b547ad5dbe506e2d0ff5d12ead9247ylavic#ident "%Z%%M% %I% %E% SMI"
0a0df13b7f1f4f1a74fe295253d89ca3911b301aylavic# This is third phase of TCP/IP startup/configuration. This script
0a0df13b7f1f4f1a74fe295253d89ca3911b301aylavic# runs after the NIS/NIS+ startup script. We run things here that may
69301145375a889e7e37caf7cc7321ac0f91801erpluem# depend on NIS/NIS+ maps.
d58a848a016d401b965111e50ef829e1641f7834minfrin # In a zone we need this service to be up, but all of the work
d58a848a016d401b965111e50ef829e1641f7834minfrin # it tries to do is irrelevant (and will actually lead to the service
2e6f4d654c96c98b761fb012fd25c5d5b1558c44sf # failing if we try to do it), so just bail out.
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavic ;; # Fall through -- rest of script is the initialization code
e8bd80a4bb88199d2f9a24a50345688e52d9c116ylavic echo "Usage: $0 { start | stop }"
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic# If boot variables are not set, set variables we use
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic[ -z "$_INIT_UTS_NODENAME" ] && _INIT_UTS_NODENAME=`/usr/bin/uname -n`
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener# Wait up to 5 seconds for ypbind to obtain a binding.
44ff304057225e944e220e981d434a046d14cf06covener for i in 1 2 3 4 5; do
032982212dbcc7c3cce95bf89c503bb56e185ac7kbrand# This function takes two file names and the file mode as input. The two
caad2986f81ab263f7af41467dd622dc9add17f3ylavic# files are compared for differences (using cmp(1)) and if different, the
caad2986f81ab263f7af41467dd622dc9add17f3ylavic# second file is over written with the first. A chmod is done with the file
caad2986f81ab263f7af41467dd622dc9add17f3ylavic# mode passed in. If the files are equal, the first file passed
caad2986f81ab263f7af41467dd622dc9add17f3ylavic# in (the /tmp file) is deleted.
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem if [ $? -eq 1 ]; then
1e2d421a36999d292042a5539971070d54aa6c63ylavic # The umask during boot is configurable, which requires
09c87c777bed1655621bb20e1c46cb6b1a63279dcovener# update_nss
6502b7b32f980cc2093bb3ebce37e5e4dc68fba4ylavic# This routine takes as a parameter, the name of the respective policy
6502b7b32f980cc2093bb3ebce37e5e4dc68fba4ylavic# to change in the nsswitch.conf (hosts or ipnodes) to update with dns.
e6b4bd1113567627ab6bb6c6a7105e1e01a7d889jailletc # Add dns to the nsswitch file, if it isn't already there.
e466c40e1801982602ee0200c9e8b61cc148742djailletc n = split($0, a);
e466c40e1801982602ee0200c9e8b61cc148742djailletc newl = a[1];
457468b82e59d01eba00dd9d0817309c8f5e414ejim if ($0 !~ /dns/) {
457468b82e59d01eba00dd9d0817309c8f5e414ejim printf("#%s # Commented out by DHCP\n", $0);
457468b82e59d01eba00dd9d0817309c8f5e414ejim updated = 0;
04983e3bd1754764eec7d6bb772fe3b0bf391771jorton for (i = 2; i <= n; i++) {
04983e3bd1754764eec7d6bb772fe3b0bf391771jorton if (updated == 0 && index(a[i], "[") == 1) {
15890c9306ba98f6fc243e15a3c4778ddc7d773erpluem newl = newl" dns";
49dacedb6c387b786b7911082ff35121a45f414bcovener newl = newl" "a[i];
cfd9415521847b2f9394fad04fb701cfb955f503rjung if (updated == 0) {
cfd9415521847b2f9394fad04fb701cfb955f503rjung newl = newl" dns";
28c31fb73c1264bd1d0ff932573677030b024c7dwrowe if (updated != 0)
28c31fb73c1264bd1d0ff932573677030b024c7dwrowe newl = newl" # Added by DHCP";
8491e0600f69b0405e156ea8a419653c065c645bcovener printf("%s\n", newl);
63b9f1f5880391261705f696d7d65507bbe9ace3covener printf("%s\n", $0);
63b9f1f5880391261705f696d7d65507bbe9ace3covener } $1 !~ /^'${policy}':/ { printf("%s\n", $0); }' /etc/nsswitch.conf \
49dacedb6c387b786b7911082ff35121a45f414bcovener mv_file /tmp/nsswitch.conf.$$ /etc/nsswitch.conf 644
3c990331fc6702119e4f5b8ba9eae3021aea5265jim# update_files
3c990331fc6702119e4f5b8ba9eae3021aea5265jim# This routine takes as a parameter, the name of the respective file
fc42512879dd0504532f52fe5d0d0383dda96a1eniq# (hosts or ipnodes) to update with the new host name and IP address.
da0442c0440caef34706e2c2f3af05cb65921cc0jailletc /usr/bin/sed -e '/# Added by DHCP$/d' /etc/inet/${filename} \
15890c9306ba98f6fc243e15a3c4778ddc7d773erpluem if [ $# -gt 0 ]; then
65967d05f839dbf27cf91d91fa79585eeae19660minfrin # IP address is missing from the respective file. Now check
8152945ae46857b170cb227e79bb799f4fc7710dminfrin # to see if the hostname is present with a different IP.
8152945ae46857b170cb227e79bb799f4fc7710dminfrin set -- `/usr/bin/grep -s -v '^#' /tmp/${filename}_clear.$$ | \
75f5c2db254c0167a0e396254460de09b775d203trawick if [ $# -gt 0 ]; then
2e15620d724fb8e3a5be183b917359a2fd6e9468covener mv_file /tmp/${filename}.$$ /etc/inet/${filename} 444
1b988c41ee505962781d110a3e4c2c90f1ea0aa4covener# We now need to reset the netmask and broadcast address for our network
b8efdc95bec9cf089aa1be0bfd07d46aa1137a7acovener# interfaces. Since this may result in a name service lookup, we want to
b8efdc95bec9cf089aa1be0bfd07d46aa1137a7acovener# now wait for NIS to come up if we previously started it.
f06e7c4b1bce6b6491e5de0b7998d3f5696b293dchrisd[ -z "$domain" ] || [ ! -d /var/yp/binding/$domain ] || wait_nis || \
179565be4043d7e5f9161aa75271fa0a001866d9covener echo "WARNING: Timed out waiting for NIS to come up" >& 2
111436a32ba1254291e4883292fb116d15fe8f64covener# Re-set the netmask and broadcast addr for all IP interfaces. This ifconfig
fce4949fb0b309a5744afcd503c6ed2d35621ee2covener# is run here, after waiting for name services, so that "netmask +" will find
fce4949fb0b309a5744afcd503c6ed2d35621ee2covener# the netmask if it lives in a NIS map. The 'D' in -auD tells ifconfig NOT to
fce4949fb0b309a5744afcd503c6ed2d35621ee2covener# mess with the interface if it is under DHCP control
7b7430e701e9a31ce809da7c220bb8dfcf68c86etrawick# Uncomment these lines to print complete network interface configuration
ccc20788c1e5fc973f36df634399c89acb70deaejerenkrantz# echo "network interface configuration:"
993d1261a278d7322bccef219101220b7b4fb8c5jkaluzaif [ -n "$dnsservers" ]; then
ba050a6f942b9fa0e81ed73437588005c569655ccovener # Go through /etc/resolv.conf and replace any existing
ba050a6f942b9fa0e81ed73437588005c569655ccovener # domain or nameserver entries with new ones derived
ba050a6f942b9fa0e81ed73437588005c569655ccovener # from DHCP. Note that it is important to preserve
ba050a6f942b9fa0e81ed73437588005c569655ccovener # order of domain entries vs. search entries; the search
135ddda3a989215d2bedbcf1529bfb269c3eda23niq # entries are reserved for administrator customization
135ddda3a989215d2bedbcf1529bfb269c3eda23niq # and if placed after the domain entry will override it.
9b0076ddd1103e5fa9c1f9bafde4b06ce244fbaecovener /usr/bin/nawk </etc/resolv.conf >/tmp/resolv.conf.$$ '
9b0076ddd1103e5fa9c1f9bafde4b06ce244fbaecovener function writedomain() {
9b0076ddd1103e5fa9c1f9bafde4b06ce244fbaecovener if (updated == 0) {
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza # Use only first domain, not a search list
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza split(ENVIRON["dnsdomain"], d)
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza if(length(d[1]) != 0)
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza printf("domain %s\n", d[1])
77ca16c5676da23155311e13cee61e7eaba9fa3ejailletc $1 == "domain" { writedomain(); next }
77ca16c5676da23155311e13cee61e7eaba9fa3ejailletc $1 != "nameserver" { print $0 }
77ca16c5676da23155311e13cee61e7eaba9fa3ejailletc writedomain()
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick n = split(ENVIRON["dnsservers"], s)
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick for (i = 1; i <= n; ++i)
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick printf("nameserver %s\n", s[i])
85eacfc96a04547ef25aabbc06440039715084c2jorton # Add dns to the nsswitch file, if it isn't already there.
cb666b29f81df1d11d65002250153353568021fccovenerelif /usr/bin/grep '# Added by DHCP$' /etc/nsswitch.conf >/dev/null 2>&1; then
cb666b29f81df1d11d65002250153353568021fccovener # If we added DNS to the hosts and ipnodes policy in the nsswitch,
6a80c3c6f4b8ea7ba5e89402b8b779b09ce020e0covener # remove it.
6a80c3c6f4b8ea7ba5e89402b8b779b09ce020e0covener -e '/# Added by DHCP$/d' \
75a230a728338d84dcfe81edd375352f34de22d0covener -e 's/^\(#hosts:\)\(.*[^#]\)\(#.*\)$/hosts: \2/' \
75a230a728338d84dcfe81edd375352f34de22d0covener -e 's/^\(#ipnodes:\)\(.*[^#]\)\(#.*\)$/ipnodes: \2/' \
1f50dc34ae069adeed20b2986e5ffdefa5c410e0covener mv_file /tmp/nsswitch.conf.$$ /etc/nsswitch.conf 644
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin # We're not using a dhcp strategy, so host entries added by
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin # DHCP should be removed from /etc/inet/hosts and /etc/inet/ipnodes.
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin if /usr/bin/grep '# Added by DHCP$' /etc/inet/hosts >/dev/null 2>&1;
63921358ef93fcb41bc71d9894221ba3d7fbb87bminfrin if /usr/bin/grep '# Added by DHCP$' /etc/inet/ipnodes >/dev/null 2>&1;
5c43d2fb853f84497b5ece2d414ef9484aa87e5fsf# Load the IPQoS configuration.
05a5a9c3e16f21566e1b61f4bd68025ce1b741ccjoes# This is backgrounded so that any remote hostname lookups it performs
05a5a9c3e16f21566e1b61f4bd68025ce1b741ccjoes# don't unduely delay startup. Any messages go via syslog.
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niqif [ -f /usr/sbin/ipqosconf -a -f /etc/inet/ipqosinit.conf ]; then
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq# Add a static route for multicast packets out our default interface.
413ee814748f37be168ff12407fa6dba0ceeabe6trawick# The default interface is the interface that corresponds to the node name.
c12917da693bae4028a1d5a5e8224bceed8c739dsf# Run in background subshell to avoid waiting for name service.
eafcc0ebf263d0ba69855b6e10958c4c1a2361bdsf mcastif=`/sbin/dhcpinfo Yiaddr` || mcastif=$_INIT_UTS_NODENAME