#! /sbin/sh
##############################################################################
# Product: VMAGENT
# Fileset: VMAGENT-LIB
# preinstall
# $Id: VMAGENT-LIB.preinstall 7737 2008-05-01 18:19:59Z brett $
##############################################################################
#
# (c) Copyright 2005-2006 Hewlett-Packard Company
#
##############################################################################

##############################################################################
# SD control utilities
#
# The global variables SUCCESS, FAILURE, WARNING, EXCLUDE, PATH, ROOT,
# SW_CTL_SCRIPT_NAME, _pf, PRODUCT, and FILESET are all set by control_utils.
##############################################################################

typeset -r UTILS="/usr/lbin/sw/control_utils"
if [[ ! -f ${UTILS} ]]; then
    echo "ERROR:   Cannot find ${UTILS}"
    exit 1
fi
. ${UTILS}

##############################################################################
# Anticipated success
##############################################################################

exitval=${SUCCESS}

##############################################################################
# Local common variables
##############################################################################

typeset -r LOCALVARS=${SW_CONTROL_DIRECTORY}/common_variables
if [[ ! -f ${LOCALVARS} ]]; then
    msg "ERROR:   Cannot find ${LOCALVARS}"
    exit 1
fi
. ${LOCALVARS}

##############################################################################
# Ensure that old agents are reset
# prior to the installation of this fileset, otherwise print a warning:
# note that because agent and lib install differently, we must check both
##############################################################################

if [ -x /opt/hpvm/bin/vm_fssagt ]
then
    if [ -f /opt/hpvm/lib/hpux64/libhpvmfssclnt.so ]
    then
        /opt/hpvm/bin/vm_fssagt -s
        retval=$?
        if [[ ${retval} -ne 0 ]]; then
            msg warning "Cannot shutdown vm_fssagt."
            exitval=${WARNING}
        fi
    fi
fi

##############################################################################
# Exit status
##############################################################################

exit ${exitval}
