xref: /titanic_52/usr/src/cmd/svc/milestone/net-nwam (revision f9ead4a57883f3ef04ef20d83cc47987d98c0687)
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 2009 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	fi
67	# start nwamd in foreground; it will daemonize itself
68	if /lib/inet/nwamd ; then
69		exit $SMF_EXIT_OK
70	else
71		exit $SMF_EXIT_ERR_FATAL
72	fi
73	;;
74
75'stop')
76	/usr/bin/pkill -z `smf_zonename` nwamd
77	;;
78
79'-u')
80	# After we run this part of the script upon the next reboot
81	# network/physical:default will be enabled and
82	# network/physical:nwam will be disabled.
83	# There are various other parts of the system (nscd, nfs) that
84	# depend on continuing to have a working network.  For this
85	# reason we don't change the network configuration immediately.
86
87	SVCADM=/usr/sbin/svcadm
88	SVCCFG=/usr/sbin/svccfg
89	net_phys=svc:/network/physical:default
90	net_nwam=svc:/network/physical:nwam
91
92	# Disable network/physical temporarily and make sure that will
93	# be enabled on reboot.
94	$SVCADM disable -st $net_phys
95	$SVCCFG -s $net_phys setprop general/enabled=true
96
97	# If nwam is online then make sure that it's temporarily enabled.
98	nwam_online=`/usr/bin/svcprop -t -p restarter/state $net_nwam`
99	if [ $? -eq 0 ]; then
100		set -- $nwam_online
101		[ $3 = "online" ] && $SVCADM enable -st $net_nwam
102	fi
103
104	# Set nwam so that it won't be enabled upon reboot.
105	$SVCCFG -s $net_nwam setprop general/enabled=false
106	exit 0
107	;;
108
109'-c')
110	# Nothing to do for sysidtool
111	exit 0
112	;;
113
114*)
115	echo "Usage: $0 { start | stop | refresh }"
116	exit $SMF_EXIT_ERR_FATAL
117	;;
118esac
119exit $SMF_EXIT_OK
120