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