xref: /titanic_44/usr/src/cmd/svc/milestone/net-nwam (revision a4aeef46cda1835da2b19f8f62b4526de6521e6c)
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. /lib/svc/share/net_include.sh
29
30#
31# In a shared-IP zone we need this service to be up, but all of the work
32# it tries to do is irrelevant (and will actually lead to the service
33# failing if we try to do it), so just bail out.
34# In the global zone and exclusive-IP zones we proceed.
35#
36smf_configure_ip || exit $SMF_EXIT_OK
37
38case "$1" in
39'refresh')
40	/usr/bin/pkill -HUP -z `smf_zonename` nwamd
41	;;
42
43'start')
44	if smf_is_globalzone; then
45		net_reconfigure || exit $SMF_EXIT_ERR_CONFIG
46
47		# Update PVID on interfaces configured with VLAN 1
48		update_pvid
49
50		#
51		# Upgrade handling. The upgrade file consists of a series
52		# of dladm(1M) commands. Note that after we are done, we
53		# cannot rename the upgrade script file as the file system
54		# is still read-only at this point. Defer this to the
55		# manifest-import service.
56		#
57		upgrade_script=/var/svc/profile/upgrade_datalink
58		if [ -f "${upgrade_script}" ]; then
59			. "${upgrade_script}"
60		fi
61
62		# Bring up simnet instances
63		/sbin/dladm up-simnet
64		# Initialize security objects.
65		/sbin/dladm init-secobj
66
67		# Bring up VNICs, VLANs and flows
68		/sbin/dladm up-vnic
69		/sbin/dladm up-vlan
70		/sbin/flowadm init-flow
71	fi
72	# start nwamd in foreground; it will daemonize itself
73	if /lib/inet/nwamd ; then
74		exit $SMF_EXIT_OK
75	else
76		exit $SMF_EXIT_ERR_FATAL
77	fi
78	;;
79
80'stop')
81	/usr/bin/pkill -z `smf_zonename` nwamd
82	;;
83
84'-u')
85	# After we run this part of the script upon the next reboot
86	# network/physical:default will be enabled and
87	# network/physical:nwam will be disabled.
88	# There are various other parts of the system (nscd, nfs) that
89	# depend on continuing to have a working network.  For this
90	# reason we don't change the network configuration immediately.
91
92	SVCADM=/usr/sbin/svcadm
93	SVCCFG=/usr/sbin/svccfg
94	net_phys=svc:/network/physical:default
95	net_nwam=svc:/network/physical:nwam
96
97	# Disable network/physical temporarily and make sure that will
98	# be enabled on reboot.
99	$SVCADM disable -st $net_phys
100	$SVCCFG -s $net_phys setprop general/enabled=true
101
102	# If nwam is online then make sure that it's temporarily enabled.
103	nwam_online=`/usr/bin/svcprop -t -p restarter/state $net_nwam`
104	if [ $? -eq 0 ]; then
105		set -- $nwam_online
106		[ $3 = "online" ] && $SVCADM enable -st $net_nwam
107	fi
108
109	# Set nwam so that it won't be enabled upon reboot.
110	$SVCCFG -s $net_nwam setprop general/enabled=false
111	exit 0
112	;;
113
114'-c')
115	# Nothing to do for sysidtool
116	exit 0
117	;;
118
119*)
120	echo "Usage: $0 { start | stop | refresh }"
121	exit $SMF_EXIT_ERR_FATAL
122	;;
123esac
124exit $SMF_EXIT_OK
125