#!/bin/sh
#
# Copyright (c) 1993, by Sun Microsystems, Inc.
#
#ident	"$Header: /net/projects/S2.6/cvs/os_net/src_ws/usr/src/tadcmd/locations/init.d/nscd,v 1.1 1997/10/09 10:37:03 ang Exp $"
#
#LocINFO Name Service Cache
#

procexist() {
    pid=`/usr/bin/ps -e | /usr/bin/grep " ${1}$" |
	     /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
    if [ -z "$pid" ]
    then
	return 1
    fi
    return 0
}

#
# Start/stop nscd
#

case "$1" in

'start')
    cp -p $LOCDB/etc/nscd.conf /etc 2>/dev/null
    ${SH} /etc/init.d/nscd $1
    ;;

'stop')
    ${SH} /etc/init.d/nscd $1
    rm -f /etc/nscd.conf
    ;;

'create')
    cp -p /etc/nscd.conf $LOCDB/etc 2>/dev/null
    exit `procexist nscd && [ -f /etc/nscd.conf ]`
    ;;

*)
    echo "Usage: $0 { start | stop | create }" 1>&2
    ;;
esac

exit 0
