1#!/sbin/sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License, Version 1.0 only 7# (the "License"). You may not use this file except in compliance 8# with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or http://www.opensolaris.org/os/licensing. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23# 24# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. 25# All rights reserved. 26# 27# 28# Copyright 2004 Sun Microsystems, Inc. All rights reserved. 29# Use is subject to license terms. 30# 31# ident "%Z%%M% %I% %E% SMI" 32 33. /lib/svc/share/smf_include.sh 34. /lib/svc/share/net_include.sh 35 36# Make sure that the libraries essential to this stage of booting can be found. 37LD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH 38 39# 40# If DHCP was used on a primary interface then set the hostname 41# that was returned. If no hostname was returned, set the name 42# to be "unknown". The hostname must be set to something, because 43# tooltalk will hang unless the name can be locally resolved. 44# Sendmail also requires the name to be resolvable locally. 45# Later, in inetsvc, we create a name "unknown" and create a entry 46# in the local /etc/inet/hosts file pairing "unknown" with the IP 47# address assigned by DHCP. The use of bootparams as a fallback 48# for all non-DHCP cases provides compatibility with the 49# behavior of the system before netstrategy was introduced. 50# 51# For non-global zones, fall back to the `uname -n` value provided by the 52# kernel if /etc/nodename does not exist, as is expected on an initial boot. 53# 54 55smf_netstrategy 56 57case "$_INIT_NET_STRATEGY" in 58 "dhcp") hostname=`/sbin/dhcpinfo Hostname` ;; 59 "rarp") hostname=`/sbin/hostconfig -h -p bootparams` 60 trap 'intr=1' 2 3 61 while [ -z "$hostname" -a ! -f /etc/.UNCONFIGURED -a \ 62 -z "$intr" ]; do 63 echo "re-trying host configuration..." 64 # Restrict this to IPv4 interfaces. 65 /sbin/ifconfig -adD4 auto-revarp up 66 hostname=`/sbin/hostconfig -h -p bootparams` 67 done 68 trap 2 3 ;; 69 "none") hostname="`shcat /etc/nodename 2>/dev/null`" 70 if [ -z "$hostname" ]; then 71 if [ "${_INIT_ZONENAME:=`/sbin/zonename`}" = "global" ] 72 then 73 hostname=`/sbin/hostconfig -h -p bootparams` 74 else 75 hostname=`/sbin/uname -n` 76 fi 77 fi ;; 78esac 79 80# 81# If the netstrategy was unsuccessful and we haven't got a locally configured 82# name, default to "unknown" 83# 84if [ -z "$hostname" ]; then 85 hostname="`shcat /etc/nodename 2>/dev/null`" 86 if [ -z "$hostname" ]; then 87 hostname="unknown" 88 fi 89fi 90 91/sbin/uname -S $hostname 92 93echo "Hostname: `/sbin/uname -n`" > /dev/msglog 94 95# Reset the library path now that we are past the critical stage 96unset LD_LIBRARY_PATH 97