xref: /titanic_51/usr/src/cmd/cmd-inet/etc/init.d/ncakmod (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
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, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23#
24# Copyright 1999-2002 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27#ident	"%Z%%M%	%I%	%E% SMI"
28
29# Default config values used by script
30nca=drv/nca
31ncakmodconf=/etc/nca/ncakmod.conf
32ncaifconf=/etc/nca/nca.if
33tempdir=/tmp
34default_miss_door=/var/run/nca_httpd_1.door
35
36# Function used to parse the interface names from /etc/hostname.* entries
37readifconf()
38{
39	while read i; do
40		case "$i" in
41		'#'* | '')	# Ignore comments, empty lines
42				continue ;;
43		'*')		configinterfaces="`echo /etc/hostname.*[0-9] \
44				   2>/dev/null`"
45				checkforvirt=false
46				break ;;
47		esac
48		configinterfaces="$configinterfaces $i"
49	done
50}
51
52case "$1" in
53'start')
54
55	if [ ! -f $ncakmodconf ]; then
56		# If configuration file is missing, just exit
57		exit 0
58	fi
59
60	. $ncakmodconf
61
62	# Default is "disabled" so we want to exit
63	[ "x$status" != "xenabled" ] && exit 0
64
65	if [ -f "$ncaifconf" ]; then
66		readifconf < $ncaifconf
67		configinterfaces="`echo $configinterfaces | \
68			/bin/sed 's/.etc.hostname.//g'`"
69		for i in $configinterfaces; do
70			findinterface="`echo $i | /bin/grep '[0-9][0-9]*'`"
71			if [ $? -ne 0 ]; then
72				# Need to expand interface (ie. iprb)
73				interface="`echo /etc/hostname.$i*[0-9] \
74					2>/dev/null | /bin/sed \
75					's/.etc.hostname.//g'`"
76				interfaces="$interfaces $interface"
77			else
78				interfaces="$interfaces $i"
79			fi
80		done
81
82		# If we don't have any interfaces configured, exit
83		[ -z "$interfaces" ] && exit 0
84
85		# Prevent multiple instances of ncaconfd
86		if /bin/pgrep ncaconfd > /dev/null 2>&1; then
87			echo "$0: ncaconfd is already running"
88			exit 1
89		fi
90
91		/usr/sbin/modload -p $nca
92
93		# Insert NCA into the stream of all the interfaces configured.
94		interfaces="`echo $interfaces | /bin/tr ' ' '\012' | \
95		    /bin/grep -v :`"
96		if [ "x$nca_active" != xenabled ]; then
97			/usr/lib/inet/ncaconfd -l $interfaces
98		else
99			/usr/lib/inet/ncaconfd -al $interfaces
100		fi
101
102		if [ "$httpd_door_path" != "$default_miss_door" ]; then
103			# Set the default HTTPD door in NCA via ndd
104			/usr/sbin/ndd -set /dev/nca httpd_door_path \
105			    $httpd_door_path
106		fi
107	fi
108	;;
109
110'stop')
111	# Need to reboot the system to stop
112	echo "System reset is required to stop NCA functionality"
113	;;
114
115*)
116
117	echo "Usage: $0 { start | stop }"
118	exit 1
119	;;
120esac
121exit 0
122