16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#!/sbin/sh
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# CDDL HEADER START
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# The contents of this file are subject to the terms of the
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Common Development and Distribution License, Version 1.0 only
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# (the "License"). You may not use this file except in compliance
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# with the License.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# or http://www.opensolaris.org/os/licensing.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# See the License for the specific language governing permissions
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# and limitations under the License.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# When distributing Covered Code, include this CDDL HEADER in each
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# If applicable, add the following below this CDDL HEADER, with the
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# fields enclosed by brackets "[]" replaced with your own identifying
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# CDDL HEADER END
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Use is subject to license terms.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#ident "%Z%%M% %I% %E% SMI"
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Default config values used by script
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncnca=drv/nca
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncncakmodconf=/etc/nca/ncakmod.conf
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncncaifconf=/etc/nca/nca.if
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsynctempdir=/tmp
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncdefault_miss_door=/var/run/nca_httpd_1.door
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Function used to parse the interface names from /etc/hostname.* entries
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncreadifconf()
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync{
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync while read i; do
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync case "$i" in
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync '#'* | '') # Ignore comments, empty lines
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync continue ;;
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync '*') configinterfaces="`echo /etc/hostname.*[0-9] \
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync 2>/dev/null`"
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync checkforvirt=false
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync break ;;
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync esac
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync configinterfaces="$configinterfaces $i"
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync done
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync}
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsynccase "$1" in
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync'start')
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync if [ ! -f $ncakmodconf ]; then
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync # If configuration file is missing, just exit
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync exit 0
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync fi
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync . $ncakmodconf
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync # Default is "disabled" so we want to exit
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync [ "x$status" != "xenabled" ] && exit 0
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync if [ -f "$ncaifconf" ]; then
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync readifconf < $ncaifconf
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync configinterfaces="`echo $configinterfaces | \
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync /bin/sed 's/.etc.hostname.//g'`"
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync for i in $configinterfaces; do
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync findinterface="`echo $i | /bin/grep '[0-9][0-9]*'`"
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync if [ $? -ne 0 ]; then
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync # Need to expand interface (ie. iprb)
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync interface="`echo /etc/hostname.$i*[0-9] \
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync 2>/dev/null | /bin/sed \
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync 's/.etc.hostname.//g'`"
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync interfaces="$interfaces $interface"
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync else
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync interfaces="$interfaces $i"
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync fi
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync done
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync # If we don't have any interfaces configured, exit
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync [ -z "$interfaces" ] && exit 0
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync # Prevent multiple instances of ncaconfd
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync if /bin/pgrep ncaconfd > /dev/null 2>&1; then
echo "$0: ncaconfd is already running"
exit 1
fi
/usr/sbin/modload -p $nca
# Insert NCA into the stream of all the interfaces configured.
interfaces="`echo $interfaces | /bin/tr ' ' '\012' | \
/bin/grep -v :`"
if [ "x$nca_active" != xenabled ]; then
/usr/lib/inet/ncaconfd -l $interfaces
else
/usr/lib/inet/ncaconfd -al $interfaces
fi
if [ "$httpd_door_path" != "$default_miss_door" ]; then
# Set the default HTTPD door in NCA via ndd
/usr/sbin/ndd -set /dev/nca httpd_door_path \
$httpd_door_path
fi
fi
;;
'stop')
# Need to reboot the system to stop
echo "System reset is required to stop NCA functionality"
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0