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