#!/sbin/sh -
# %W% %G% %U% - %Q%
#ident "%Z%unixvm:%M% %I%"

# Copyright (c) 2000 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/awk '{ print $1 }'`
}

vxlicense -t vvr >/dev/null 2>&1
if [ $? != 0 ]
then
	vxlicense -t srvm >/dev/null 2>&1
	if [ $? != 0 ]
	then
		exit 1
	fi
fi


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

case "$1" in
'start'|'')
	#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')
	pid=`ps -ef|grep /usr/sbin/host_infod|grep -v grep|awk '{print $2}'`
	[ "$pid" != "" ] && kill -9 $pid
        ;;
*)
        echo "Usage: /usr/sbin/host_infod"
        ;;
esac
