xref: /titanic_51/usr/src/cmd/svc/milestone/net-nwam (revision 24fe0b3bf671e123467ce1df0b67cadd3614c8e4)
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		#
48		# Upgrade handling. The upgrade file consists of a series
49		# of dladm(1M) commands. Note that after we are done, we
50		# cannot rename the upgrade script file as the file system
51		# is still read-only at this point. Defer this to the
52		# manifest-import service.
53		#
54		upgrade_script=/var/svc/profile/upgrade_datalink
55		if [ -f "${upgrade_script}" ]; then
56			. "${upgrade_script}"
57		fi
58
59		# Bring up simnet instances
60		/sbin/dladm up-simnet
61		# Initialize security objects.
62		/sbin/dladm init-secobj
63	fi
64	# start nwamd in foreground; it will daemonize itself
65	if /lib/inet/nwamd ; then
66		exit $SMF_EXIT_OK
67	else
68		exit $SMF_EXIT_ERR_FATAL
69	fi
70	;;
71
72'stop')
73	/usr/bin/pkill -z `smf_zonename` nwamd
74	;;
75
76'-u')
77	# After we run this part of the script upon the next reboot
78	# network/physical:default will be enabled and
79	# network/physical:nwam will be disabled.
80	# There are various other parts of the system (nscd, nfs) that
81	# depend on continuing to have a working network.  For this
82	# reason we don't change the network configuration immediately.
83
84	SVCADM=/usr/sbin/svcadm
85	SVCCFG=/usr/sbin/svccfg
86	net_phys=svc:/network/physical:default
87	net_nwam=svc:/network/physical:nwam
88
89	# Disable network/physical temporarily and make sure that will
90	# be enabled on reboot.
91	$SVCADM disable -st $net_phys
92	$SVCCFG -s $net_phys setprop general/enabled=true
93
94	# If nwam is online then make sure that it's temporarily enabled.
95	nwam_online=`/usr/bin/svcprop -t -p restarter/state $net_nwam`
96	if [ $? -eq 0 ]; then
97		set -- $nwam_online
98		[ $3 = "online" ] && $SVCADM enable -st $net_nwam
99	fi
100
101	# Set nwam so that it won't be enabled upon reboot.
102	$SVCCFG -s $net_nwam setprop general/enabled=false
103	exit 0
104	;;
105
106'-c')
107	# Nothing to do for sysidtool
108	exit 0
109	;;
110
111*)
112	echo "Usage: $0 { start | stop | refresh }"
113	exit $SMF_EXIT_ERR_FATAL
114	;;
115esac
116exit $SMF_EXIT_OK
117