#! /usr/bin/sh
#
# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"@(#)preremove	1.2	07/02/27 SMI"
#

PATH="/usr/bin:/usr/sbin:${PATH}"
export PATH

SERVICE="svc:/system/iscsitgt:default"

#
# Exit if not removing from the running system
#
[ "${PKG_INSTALL_ROOT:-/}" = "/" ] || exit 0

#
# Confirm service is installed, otherwise exit.
#
/usr/bin/svcprop -q ${SERVICE} || exit 0

#
# Check to see if the service is enabled and if so disable it.
#

SVCPROP=`svcprop -c -p general/enabled ${SERVICE}`

if [ "${SVCPROP}" = "true" ]; then
    svcadm disable ${SERVICE}
    if [ $? -ne 0 ]; then
            echo "\n$0 Disabling of ${SERVICE} failed!\n" >&2
            exit 1
    fi
fi

exit 0
