10Sstevel@tonic-gate#!/sbin/sh 20Sstevel@tonic-gate# 30Sstevel@tonic-gate# CDDL HEADER START 40Sstevel@tonic-gate# 50Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*1573Sdp# Common Development and Distribution License (the "License"). 7*1573Sdp# You may not use this file except in compliance with the License. 80Sstevel@tonic-gate# 90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate# See the License for the specific language governing permissions 120Sstevel@tonic-gate# and limitations under the License. 130Sstevel@tonic-gate# 140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate# 200Sstevel@tonic-gate# CDDL HEADER END 210Sstevel@tonic-gate# 220Sstevel@tonic-gate# 230Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. 240Sstevel@tonic-gate# All rights reserved. 250Sstevel@tonic-gate# 260Sstevel@tonic-gate# 27*1573Sdp# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 280Sstevel@tonic-gate# Use is subject to license terms. 290Sstevel@tonic-gate# 300Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate. /lib/svc/share/smf_include.sh 330Sstevel@tonic-gate. /lib/svc/share/net_include.sh 340Sstevel@tonic-gate 350Sstevel@tonic-gate# Make sure that the libraries essential to this stage of booting can be found. 360Sstevel@tonic-gateLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH 370Sstevel@tonic-gate 380Sstevel@tonic-gate# 390Sstevel@tonic-gate# If DHCP was used on a primary interface then set the hostname 400Sstevel@tonic-gate# that was returned. If no hostname was returned, set the name 410Sstevel@tonic-gate# to be "unknown". The hostname must be set to something, because 420Sstevel@tonic-gate# tooltalk will hang unless the name can be locally resolved. 430Sstevel@tonic-gate# Sendmail also requires the name to be resolvable locally. 440Sstevel@tonic-gate# Later, in inetsvc, we create a name "unknown" and create a entry 450Sstevel@tonic-gate# in the local /etc/inet/hosts file pairing "unknown" with the IP 460Sstevel@tonic-gate# address assigned by DHCP. The use of bootparams as a fallback 470Sstevel@tonic-gate# for all non-DHCP cases provides compatibility with the 480Sstevel@tonic-gate# behavior of the system before netstrategy was introduced. 490Sstevel@tonic-gate# 500Sstevel@tonic-gate# For non-global zones, fall back to the `uname -n` value provided by the 510Sstevel@tonic-gate# kernel if /etc/nodename does not exist, as is expected on an initial boot. 520Sstevel@tonic-gate# 530Sstevel@tonic-gate 540Sstevel@tonic-gatesmf_netstrategy 550Sstevel@tonic-gate 560Sstevel@tonic-gatecase "$_INIT_NET_STRATEGY" in 570Sstevel@tonic-gate "dhcp") hostname=`/sbin/dhcpinfo Hostname` ;; 580Sstevel@tonic-gate "rarp") hostname=`/sbin/hostconfig -h -p bootparams` 590Sstevel@tonic-gate trap 'intr=1' 2 3 600Sstevel@tonic-gate while [ -z "$hostname" -a ! -f /etc/.UNCONFIGURED -a \ 610Sstevel@tonic-gate -z "$intr" ]; do 620Sstevel@tonic-gate echo "re-trying host configuration..." 630Sstevel@tonic-gate # Restrict this to IPv4 interfaces. 640Sstevel@tonic-gate /sbin/ifconfig -adD4 auto-revarp up 650Sstevel@tonic-gate hostname=`/sbin/hostconfig -h -p bootparams` 660Sstevel@tonic-gate done 670Sstevel@tonic-gate trap 2 3 ;; 680Sstevel@tonic-gate "none") hostname="`shcat /etc/nodename 2>/dev/null`" 690Sstevel@tonic-gate if [ -z "$hostname" ]; then 70*1573Sdp if smf_is_globalzone; then 710Sstevel@tonic-gate hostname=`/sbin/hostconfig -h -p bootparams` 720Sstevel@tonic-gate else 730Sstevel@tonic-gate hostname=`/sbin/uname -n` 740Sstevel@tonic-gate fi 750Sstevel@tonic-gate fi ;; 760Sstevel@tonic-gateesac 770Sstevel@tonic-gate 780Sstevel@tonic-gate# 790Sstevel@tonic-gate# If the netstrategy was unsuccessful and we haven't got a locally configured 800Sstevel@tonic-gate# name, default to "unknown" 810Sstevel@tonic-gate# 820Sstevel@tonic-gateif [ -z "$hostname" ]; then 830Sstevel@tonic-gate hostname="`shcat /etc/nodename 2>/dev/null`" 840Sstevel@tonic-gate if [ -z "$hostname" ]; then 850Sstevel@tonic-gate hostname="unknown" 860Sstevel@tonic-gate fi 870Sstevel@tonic-gatefi 880Sstevel@tonic-gate 890Sstevel@tonic-gate/sbin/uname -S $hostname 900Sstevel@tonic-gate 910Sstevel@tonic-gateecho "Hostname: `/sbin/uname -n`" > /dev/msglog 920Sstevel@tonic-gate 930Sstevel@tonic-gate# Reset the library path now that we are past the critical stage 940Sstevel@tonic-gateunset LD_LIBRARY_PATH 95*1573Sdp 96*1573Sdpexit $SMF_EXIT_OK 97