#!/sbin/sh -
# $Id: vxnm-host_infod.sh,v 1.9.45.2 2001/05/03 16:30:22 dtawri Exp $
#ident "$Source: /project/unixvm-cvs/src/sol/cmd/vxvm/init.d/vxnm-host_infod.sh,v $"

# Copyright (c) 2001 VERITAS Software Corporation.  ALL RIGHTS RESERVED.
# UNPUBLISHED -- RIGHTS RESERVED UNDER THE COPYRIGHT
# LAWS OF THE UNITED STATES.  USE OF A COPYRIGHT NOTICE
# IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
# OR DISCLOSURE.
# 
# THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND
# TRADE SECRETS OF VERITAS SOFTWARE.  USE, DISCLOSURE,
# OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
# EXPRESS WRITTEN PERMISSION OF VERITAS SOFTWARE.
# 
#               RESTRICTED RIGHTS LEGEND
# USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT IS
# SUBJECT TO RESTRICTIONS AS SET FORTH IN SUBPARAGRAPH
# (C) (1) (ii) OF THE RIGHTS IN TECHNICAL DATA AND
# COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013.
#               VERITAS SOFTWARE
# 1600 PLYMOUTH STREET, MOUNTAIN VIEW, CA 94043

#script used for spawning off the RPC server - only do it if there is
# and VVR license

#
# Need to force C locale setting so that
# english text is processed.
#
LANG=C
export LANG


findproc() {            # return pid of the named process(es)
        pid=`/usr/bin/ps -e -o pid,comm |
             /usr/bin/grep "$1" | /usr/bin/grep -v grep |
             /usr/bin/awk '{ print $1 }'`
}

if [ ! -d /usr/sbin ]
then                    # /usr not mounted
        echo "/usr not mounted"
        exit
fi

if [ ! -f /usr/sbin/host_infod ]
then
	exit 1
fi

case "$1" in
'start'|'')
	#Check if valid license exists.
	/usr/sbin/vxlicense -t vvr >/dev/null 2>&1
	if [ $? != 0 ]
	then
		/usr/sbin/vxlicense -t srvm >/dev/null 2>&1
		if [ $? != 0 ]
		then
			exit 1
		fi
	fi
	#Check if host_infod is already running.
	findproc host_infod;
	if [ "$pid" <> "" ]; then
		#echo "\tVVR : host_infod already running, with pid: $pid";
		exit 0
	fi
        /usr/sbin/host_infod &
        ;;
'stop')
	findproc host_infod;
	if [ "$pid" <> "" ]; then
		kill -9 $pid
		exit 0
	fi
        ;;
*)
        echo "Usage: /usr/sbin/host_infod"
        ;;
esac
