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