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 (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26
27. /lib/svc/share/smf_include.sh
28
29#
30# In a shared-IP zone we need this service to be up, but all of the work
31# it tries to do is irrelevant (and will actually lead to the service
32# failing if we try to do it), so just bail out.
33# In the global zone and exclusive-IP zones we proceed.
34#
35smf_configure_ip || exit $SMF_EXIT_OK
36
37if [ -f /etc/hostname.lo0 ] || [ -f /etc/hostname6.lo0 ]; then
38	echo "found /etc/hostname.lo0 or /etc/hostname6.lo0; "\
39		    "using ifconfig to create lo0" > /dev/msglog
40	# IPv4 loopback
41	/sbin/ifconfig lo0 plumb 127.0.0.1 up
42
43	# IPv6 loopback
44	/sbin/ifconfig lo0 inet6 plumb ::1 up
45
46	# Trusted Extensions shares the loopback interface with all zones
47	if (smf_is_system_labeled); then
48		if smf_is_globalzone; then
49			/sbin/ifconfig lo0 all-zones
50			/sbin/ifconfig lo0 inet6 all-zones
51		fi
52	fi
53else
54	state=`/sbin/ipadm show-if -p -o state lo0 2>/dev/null`
55	if [ $? -eq 0 -a "$state" = "disabled" ]; then
56		/sbin/ipadm enable-if -t lo0
57	else
58		# IPv4 loopback
59		/sbin/ipadm create-addr -t -T static -a 127.0.0.1/8 lo0/v4
60
61		# IPv6 loopback
62		/sbin/ipadm create-addr -t -T static -a ::1/128 lo0/v6
63	fi
64
65	# Trusted Extensions shares the loopback interface with all zones
66	if (smf_is_system_labeled); then
67		if smf_is_globalzone; then
68			/sbin/ipadm set-addrprop -t -p zone=all-zones lo0/v4
69			/sbin/ipadm set-addrprop -t -p zone=all-zones lo0/v6
70		fi
71	fi
72fi
73
74