#!/bin/sh
#############################################################################
# Copyright (C)2004-2005, Sun Microsystems Inc. All rights reserved.
# Use is subject to license terms.
#
# Name: disable
# Description: disable for SUNWcctpx pkg.
#
# pragma ident	"$Id: disable.sh,v 1.2.2.4 2005/04/08 20:21:52 rc5273 Exp $"
##############################################################################

################################################################################
#  Function of the disable script 
#  1.  Remove the executable entry from the /etc/init.d.
#  2.  Clean up the directories.
#################################################################################

#
# control logging method
#

log=echo
#log="logger -pdaemon.err"
 
tracefile="/var/tmp/cctclient.trace" 
runtimedir="/var/tmp/cc-transport"
initscript="/etc/init.d/cc-transport"

fw_pkg="SUNWccfw"

#
# Stop running instance, if $initscript exists
# then we've been enabled and possibly started.
#
if [ -x ${initscript} ] ; then
    ${initscript} stop
fi

#
# Cleanup all state in $runtimedir
#
if [ -d ${runtimedir} ] ; then
    /usr/bin/rm -rf ${runtimedir}
fi

#
# Delete the trace output file if it exists
#
if [ -f ${tracefile} ] ; then
    /usr/bin/rm -f ${tracefile}
fi

#
#  Check for the presence of the Configuration Framework Package
#
pkginfo $fw_pkg > /dev/null
if [ $? -ne 0 ] ; then
    $log "The required package $fw_pkg is not installed, please install it."
    exit 1
fi

#
# remove init and rcX.d entries
#
runlevel_file=/usr/lib/cc-cfw/platform/transport/runlevel
executable_script=/usr/lib/cc-cfw/platform/transport/cc-transport

$log Removing initd entry for $executable_script $runlevel_file
`/usr/lib/cc-cfw/framework/lib/get_interface DESTROY_INITD_ENTRY` $executable_script $runlevel_file

$log Setting the status to disabled for CC transport
`/usr/lib/cc-cfw/framework/lib/get_interface SET_COMPONENT_STATUS`  platform transport disabled

#
# exit with success status
#
exit 0
