#!/sbin/sh
# *****************************************************************************
#   (C) Copyright 2004-2008 Hewlett-Packard Development Company, L.P.
#   HPVM: $Id: hpvmguestlib 8227 2008-11-04 20:45:28Z spider $ - HP CONFIDENTIAL
# *****************************************************************************
# @(#) $Id: hpvmguestlib 8227 2008-11-04 20:45:28Z spider $
#
# hpvmguestlib:  startup for VMGuestLib
# *****************************************************************************

# Exit code setup as per rc
# Allowed exit values:
#       0 = success; causes "OK" to show up in checklist.
#       1 = failure; causes "FAIL" to show up in checklist.
#       2 = skip; causes "N/A" to show up in the checklist.
#           Use this value if execution of this script is overridden
#           by the use of a control variable, or if this script is not
#           appropriate to execute for some other reason.
OK=0
FAIL=1
SKIP=2

exitval=$SKIP

case $1 in
    start_msg)
	echo "Validating HP Virtual Machine Configuration"
    ;;

    stop_msg)
    ;;

    stop)
    ;;

    start)
	# Determine whether this is a VM or not.
	is_vm=`/usr/bin/getconf MACHINE_MODEL | /usr/bin/grep -c \
	    "Integrity Virtual Machine"`

	if [[ $is_vm -gt 0 ]]
	then
	    #  If this is a VM, check that the guest bundle is installed.  If
	    #  not, complain to rc.log and return an error to rc.log.
	    if [[ ! -x /sbin/init.d/hpvmguest ]]; then
			echo "ERROR: The HPVM-Guest software bundle is not installed on this VM."
			echo "  Overall system performance and stability may not be optimal."
			exitval=$FAIL
		else
			exitval=$OK
	    fi
	fi

    ;;
esac

exit $exitval
