xref: /titanic_41/usr/src/cmd/svc/milestone/net-nwam (revision c0889d7a91fa87e1cb7ef4457629b0cb51d47b50)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26
27#ident	"%Z%%M%	%I%	%E% SMI"
28
29. /lib/svc/share/smf_include.sh
30. /lib/svc/share/net_include.sh
31
32#
33# In a shared-IP zone we need this service to be up, but all of the work
34# it tries to do is irrelevant (and will actually lead to the service
35# failing if we try to do it), so just bail out.
36# In the global zone and exclusive-IP zones we proceed.
37#
38smf_configure_ip || exit $SMF_EXIT_OK
39
40case "$1" in
41'refresh')
42	/usr/bin/pkill -HUP -z `smf_zonename` nwamd
43	;;
44
45'start')
46	if smf_is_globalzone; then
47		net_reconfigure || exit $SMF_EXIT_ERR_CONFIG
48
49		#
50		# Upgrade handling. The upgrade file consists of a series
51		# of dladm(1M) commands. Note that after we are done, we
52		# cannot rename the upgrade script file as the file system
53		# is still read-only at this point. Defer this to the
54		# manifest-import service.
55		#
56		upgrade_script=/var/svc/profile/upgrade_datalink
57		if [ -f "${upgrade_script}" ]; then
58			. "${upgrade_script}"
59		fi
60
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