8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / cmd-inet / etc / init.d / ncakmod
blobe29d31453d32f0ea3f0d15320f649eeab827732b
1 #!/sbin/sh
3 # CDDL HEADER START
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.
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.
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]
21 # CDDL HEADER END
24 # Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
27 #ident "%Z%%M% %I% %E% SMI"
29 # Default config values used by script
30 nca=drv/nca
31 ncakmodconf=/etc/nca/ncakmod.conf
32 ncaifconf=/etc/nca/nca.if
33 tempdir=/tmp
34 default_miss_door=/var/run/nca_httpd_1.door
36 # Function used to parse the interface names from /etc/hostname.* entries
37 readifconf()
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
52 case "$1" in
53 'start')
55 if [ ! -f $ncakmodconf ]; then
56 # If configuration file is missing, just exit
57 exit 0
60 . $ncakmodconf
62 # Default is "disabled" so we want to exit
63 [ "x$status" != "xenabled" ] && exit 0
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"
80 done
82 # If we don't have any interfaces configured, exit
83 [ -z "$interfaces" ] && exit 0
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
91 /usr/sbin/modload -p $nca
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
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
110 'stop')
111 # Need to reboot the system to stop
112 echo "System reset is required to stop NCA functionality"
117 echo "Usage: $0 { start | stop }"
118 exit 1
120 esac
121 exit 0