xref: /titanic_53/usr/src/cmd/svc/milestone/net-nwam (revision f0fb1b003bde1f700fa30fac4f02ec87a65271d8)
1d71dbb73Sjbeck#!/sbin/sh
2d71dbb73Sjbeck#
3d71dbb73Sjbeck# CDDL HEADER START
4d71dbb73Sjbeck#
5d71dbb73Sjbeck# The contents of this file are subject to the terms of the
6d71dbb73Sjbeck# Common Development and Distribution License (the "License").
7d71dbb73Sjbeck# You may not use this file except in compliance with the License.
8d71dbb73Sjbeck#
9d71dbb73Sjbeck# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d71dbb73Sjbeck# or http://www.opensolaris.org/os/licensing.
11d71dbb73Sjbeck# See the License for the specific language governing permissions
12d71dbb73Sjbeck# and limitations under the License.
13d71dbb73Sjbeck#
14d71dbb73Sjbeck# When distributing Covered Code, include this CDDL HEADER in each
15d71dbb73Sjbeck# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16d71dbb73Sjbeck# If applicable, add the following below this CDDL HEADER, with the
17d71dbb73Sjbeck# fields enclosed by brackets "[]" replaced with your own identifying
18d71dbb73Sjbeck# information: Portions Copyright [yyyy] [name of copyright owner]
19d71dbb73Sjbeck#
20d71dbb73Sjbeck# CDDL HEADER END
21d71dbb73Sjbeck#
22d71dbb73Sjbeck#
23*f0fb1b00SRenee Danson Sommerfeld# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24d71dbb73Sjbeck# Use is subject to license terms.
25d71dbb73Sjbeck#
26d71dbb73Sjbeck
27d71dbb73Sjbeck. /lib/svc/share/smf_include.sh
28d62bc4baSyz147064. /lib/svc/share/net_include.sh
29d71dbb73Sjbeck
30d71dbb73Sjbeck#
31d71dbb73Sjbeck# In a shared-IP zone we need this service to be up, but all of the work
32d71dbb73Sjbeck# it tries to do is irrelevant (and will actually lead to the service
33d71dbb73Sjbeck# failing if we try to do it), so just bail out.
34d71dbb73Sjbeck# In the global zone and exclusive-IP zones we proceed.
35d71dbb73Sjbeck#
36d71dbb73Sjbecksmf_configure_ip || exit $SMF_EXIT_OK
37d71dbb73Sjbeck
38d71dbb73Sjbeckcase "$1" in
39d71dbb73Sjbeck'refresh')
40d71dbb73Sjbeck	/usr/bin/pkill -HUP -z `smf_zonename` nwamd
41d71dbb73Sjbeck	;;
42d71dbb73Sjbeck
43d71dbb73Sjbeck'start')
44d71dbb73Sjbeck	if smf_is_globalzone; then
45d62bc4baSyz147064		net_reconfigure || exit $SMF_EXIT_ERR_CONFIG
46d62bc4baSyz147064
474eaa4710SRishi Srivatsavai		# Update PVID on interfaces configured with VLAN 1
484eaa4710SRishi Srivatsavai		update_pvid
494eaa4710SRishi Srivatsavai
50d62bc4baSyz147064		#
51d62bc4baSyz147064		# Upgrade handling. The upgrade file consists of a series
52d62bc4baSyz147064		# of dladm(1M) commands. Note that after we are done, we
53d62bc4baSyz147064		# cannot rename the upgrade script file as the file system
54d62bc4baSyz147064		# is still read-only at this point. Defer this to the
55d62bc4baSyz147064		# manifest-import service.
56d62bc4baSyz147064		#
57d62bc4baSyz147064		upgrade_script=/var/svc/profile/upgrade_datalink
58d62bc4baSyz147064		if [ -f "${upgrade_script}" ]; then
59d62bc4baSyz147064			. "${upgrade_script}"
60d62bc4baSyz147064		fi
61d62bc4baSyz147064
62b509e89bSRishi Srivatsavai		# Bring up simnet instances
63b509e89bSRishi Srivatsavai		/sbin/dladm up-simnet
64d71dbb73Sjbeck		# Initialize security objects.
65d71dbb73Sjbeck		/sbin/dladm init-secobj
66*f0fb1b00SRenee Danson Sommerfeld
67*f0fb1b00SRenee Danson Sommerfeld		# Bring up VNICs, VLANs and flows
68*f0fb1b00SRenee Danson Sommerfeld		/sbin/dladm up-vnic
69*f0fb1b00SRenee Danson Sommerfeld		/sbin/dladm up-vlan
70*f0fb1b00SRenee Danson Sommerfeld		/sbin/flowadm init-flow
71d71dbb73Sjbeck	fi
72d71dbb73Sjbeck	# start nwamd in foreground; it will daemonize itself
73d71dbb73Sjbeck	if /lib/inet/nwamd ; then
74d71dbb73Sjbeck		exit $SMF_EXIT_OK
75d71dbb73Sjbeck	else
76d71dbb73Sjbeck		exit $SMF_EXIT_ERR_FATAL
77d71dbb73Sjbeck	fi
78d71dbb73Sjbeck	;;
79d71dbb73Sjbeck
80d71dbb73Sjbeck'stop')
81d71dbb73Sjbeck	/usr/bin/pkill -z `smf_zonename` nwamd
82d71dbb73Sjbeck	;;
83d71dbb73Sjbeck
84afc7d545Smh138676'-u')
85afc7d545Smh138676	# After we run this part of the script upon the next reboot
86afc7d545Smh138676	# network/physical:default will be enabled and
87afc7d545Smh138676	# network/physical:nwam will be disabled.
88afc7d545Smh138676	# There are various other parts of the system (nscd, nfs) that
89afc7d545Smh138676	# depend on continuing to have a working network.  For this
90afc7d545Smh138676	# reason we don't change the network configuration immediately.
91afc7d545Smh138676
92afc7d545Smh138676	SVCADM=/usr/sbin/svcadm
93afc7d545Smh138676	SVCCFG=/usr/sbin/svccfg
94afc7d545Smh138676	net_phys=svc:/network/physical:default
95afc7d545Smh138676	net_nwam=svc:/network/physical:nwam
96afc7d545Smh138676
97afc7d545Smh138676	# Disable network/physical temporarily and make sure that will
98afc7d545Smh138676	# be enabled on reboot.
99afc7d545Smh138676	$SVCADM disable -st $net_phys
100afc7d545Smh138676	$SVCCFG -s $net_phys setprop general/enabled=true
101afc7d545Smh138676
102afc7d545Smh138676	# If nwam is online then make sure that it's temporarily enabled.
103afc7d545Smh138676	nwam_online=`/usr/bin/svcprop -t -p restarter/state $net_nwam`
104afc7d545Smh138676	if [ $? -eq 0 ]; then
105afc7d545Smh138676		set -- $nwam_online
106afc7d545Smh138676		[ $3 = "online" ] && $SVCADM enable -st $net_nwam
107afc7d545Smh138676	fi
108afc7d545Smh138676
109afc7d545Smh138676	# Set nwam so that it won't be enabled upon reboot.
110afc7d545Smh138676	$SVCCFG -s $net_nwam setprop general/enabled=false
111afc7d545Smh138676	exit 0
112afc7d545Smh138676	;;
113afc7d545Smh138676
114afc7d545Smh138676'-c')
115afc7d545Smh138676	# Nothing to do for sysidtool
116afc7d545Smh138676	exit 0
117afc7d545Smh138676	;;
118afc7d545Smh138676
119d71dbb73Sjbeck*)
120d71dbb73Sjbeck	echo "Usage: $0 { start | stop | refresh }"
121d71dbb73Sjbeck	exit $SMF_EXIT_ERR_FATAL
122d71dbb73Sjbeck	;;
123d71dbb73Sjbeckesac
124d71dbb73Sjbeckexit $SMF_EXIT_OK
125