#############################################################################
# 
# Copyright (C)2004-2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# Name: enable
# Description: enable for SUNWccccfg pkg. This script is required
# of any package which conforms to the Client Framework and is a deamon
#
# pragma ident	"$Id: enable.sh,v 1.2.2.1 2005/03/12 01:13:45 sd148285 Exp $"
##############################################################################

################################################################################
#  Function of the enable 
#  1.  Create the right environment so that the executable can function correctly
#  2.  Make an entry into the /etc/init.d for the executable.
#################################################################################

fw_pkg="SUNWccfw"
fw_create_initd_function="/usr/lib/cc-cfw/framework/lib/create_initd_entry"
fw_set_component_status="/usr/lib/cc-cfw/framework/lib/set_component_status"

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

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

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

    if [ ! -f  $fw_create_initd_function ] ; then
        $log "enable ERROR : Enabling capability not provided by the Framework Package $fw_pkg ."
        exit 1
    fi

    ##  Send in the path to the executable and the runlevel
    runlevel_file=/usr/lib/cc-cfw/platform/ccragent/runlevel
    executable_script=/usr/lib/cc-cfw/platform/ccragent/cc-ccragent

    $log Creating the initd entry for ccragent
    `/usr/lib/cc-cfw/framework/lib/get_interface CREATE_INITD_ENTRY`  $executable_script $runlevel_file

    $log Setting the status to enabled for  ccragent
     `/usr/lib/cc-cfw/framework/lib/get_interface SET_COMPONENT_STATUS`  platform ccragent enabled


}

#######  Main processing logic #######

#
# control logging method
#
log=echo
#log="logger -pdaemon.err"

createinitdentry

exit 0

