#############################################################################
# Copyright (C)2004-2005, Sun Microsystems Inc. All rights reserved.
# Use is subject to license terms.
#
# Name: disable
# Description: disable script for SUNWccinv pkg. This script is required
# of any package which conforms to the Client Framework and is a cron-based
# agent.

# pragma ident	"$Id: disable.sh,v 1.2.2.3 2005/05/11 16:06:49 jr150870 Exp $"
##############################################################################

################################################################################
#  Function of the disable script 
#  1.  Remove the executable entry from the crontab
#  2.  Remove the /etc/init.d and /etc/rcX.d entries.
#  3.  Leave the edited binary alone. It will be reconstructed on enable.
#################################################################################


INV_AGENT_COLLECTOR=/usr/lib/cc-cfw/platform/invagent/bin/cc-invagent

user="root"

fw_pkg="SUNWccfw"
fw_destroy_crontab="/usr/lib/cc-cfw/framework/lib/destroy_crontab_entry"

destroycronentry()
{
   
    ###
    ##  Check for the presence of the Configuration Framework Package
    ###

    pkginfo $fw_pkg > /dev/null
    if [ $? -ne 0 ] ; then
        $log "disable ERROR : The Framework package $fw_pkg is not available."
        $log "disable ERROR : Please install $fw_pkg and retry "
        exit 1
    fi

    ###
    ##  Check for the presence of the registration function of the Configuration Framework Package
    ###

    if [ ! -f  $fw_destroy_crontab ] ; then
        $log "disable ERROR : Disabling capability not provided by the Configuration Package framework $fw_pkg ."
        exit 1
    fi

    ###
    ## Invoking the destroy entry function with the executable script
    ###
    # this needs to be as unique as possible to avoid deleting something other than our target:
    command=cc-invagent
    `/usr/lib/cc-cfw/framework/lib/get_interface DESTROY_CRONTAB_ENTRY`  "$user" "$command" platform invagent

}


removeInitdEntry()
{
    remove=`/usr/lib/cc-cfw/framework/lib/get_interface DESTROY_INITD_ENTRY`
    startOrderFile="/usr/lib/cc-cfw/platform/invagent/etc/runlevel"
    ctrlScript="/usr/lib/cc-cfw/platform/invagent/etc/cc-invagent"
    
    $remove $ctrlScript $startOrderFile 
}

######### Main function #########

destroycronentry
removeInitdEntry
exit 0

