#!/bin/ksh -p
#
# ident "@(#)utpkg-utdsr-ctl.ksh	1.2 09/09/17 SMI"
#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

set -u

function disable {    
    
#
# For Linux only.  We need to remove the links to init.d files using chkconfig.
#
    typeset OS=`uname -s`
    if [ $OS = "Linux" ]; then
	typeset INITFILE="utds"
	chkconfig --del $INITFILE > /dev/null
    #
    # On SuSE/JDS, chkconfig (based on insserv) does not remove Kill links in
    # lower runlevels.  They must be removed manually.
    #
	if [ -f /etc/SuSE-release ]; then
	# we are installing on either SuSE or JDS
	    typeset ETCINIT=/etc/rc.d
	    rm -f $ETCINIT/rc4.d/K??$INITFILE
	    rm -f $ETCINIT/rc3.d/K??$INITFILE
	    rm -f $ETCINIT/rc2.d/K??$INITFILE
	    rm -f $ETCINIT/rc1.d/K??$INITFILE
	fi
    fi
    
#
# Cleaning all generated files.
#
    rm -f /var/opt/SUNWut/srds/log/*
    rm -f /var/opt/SUNWut/srds/replog/*
    rm -f /var/opt/SUNWut/srds/admin/*
    rm -rf /var/opt/SUNWut/srds/dbm.ut
    rm -rf /etc/opt/SUNWut/srds/current/*
    
    return 0
    
    
}

function enable {

    return 0
}


########################################################################
# Local Variables
# They must defined here to resolve some of the parameter resolution
# problem
########################################################################
local_variables() {
    return
}


########################################################################
#
# Configurable parameter
#
########################################################################
# NONE


########################################################################
#
# Variables used in the shared script utctl-shlib
#
########################################################################
DESCR="Uninstalls rc scripts. Removes generated files."


########################################################################
#
# Execution starts here
#
PROGPATH=`dirname $0`
. $PROGPATH/utctl-shlib
