#!/bin/sh
#
# preremove script for Cisco Network Registrar (nwreg2)
#
# Copyright (C) 2002-2007 by Cisco Systems, Inc.  This program contains
# proprietary and confidential information.  All rights reserved except as
# may be permitted by prior written consent.
#
# for debug only
# set -x


RC_FILE=/etc/init.d/nwreglocal
if [ -f $RC_FILE ]; then
    ROOTDIR=`/bin/grep INSTALLPATH= $RC_FILE | /bin/sed -e '/INSTALLPATH=/s///'`
    RC_FILE=nwreglocal
    product_name="Network Registrar Local Server Agent"

    TCLSH=$ROOTDIR/bin/uninstall/tclsh8.4

    # Add the local directory to the library search path for TCL script
    # execution
    if [ "$LD_LIBRARY_PATH"x = "x" ]; then
	LD_LIBRARY_PATH=$ROOTDIR/bin/uninstall:$ROOTDIR/lib:$ROOTDIR
    else
	LD_LIBRARY_PATH=$ROOTDIR/bin/uninstall:$ROOTDIR/lib:$ROOTDIR:$LD_LIBRARY_PATH
    fi

    export LD_LIBRARY_PATH

    TCL_LIBRARY=$ROOTDIR/bin/uninstall

    export product_name
    export ROOTDIR
    export RC_FILE
    export TCL_LIBRARY

    # Execute the Tcl script which is responsible for removing the installed
    # files.
    $TCLSH $ROOTDIR/conf/cnrremove.tcl
fi

RC_FILE=/etc/init.d/nwregregion
if [ -f $RC_FILE ]; then
    ROOTDIR=`/bin/grep INSTALLPATH= $RC_FILE | /bin/sed -e '/INSTALLPATH=/s///'`
    RC_FILE=nwregregion
    product_name="Network Registrar Regional Server Agent"

    TCLSH=$ROOTDIR/bin/uninstall/tclsh8.4

    # Add the local directory to the library search path for TCL script
    # execution
    if [ "$LD_LIBRARY_PATH"x = "x" ]; then
	LD_LIBRARY_PATH=$ROOTDIR/bin/uninstall:$ROOTDIR/lib:$ROOTDIR
    else
	LD_LIBRARY_PATH=$ROOTDIR/bin/uninstall:$ROOTDIR/lib:$ROOTDIR:$LD_LIBRARY_PATH
    fi

    export LD_LIBRARY_PATH

    TCL_LIBRARY=$ROOTDIR/bin/uninstall

    export product_name
    export ROOTDIR
    export RC_FILE
    export TCL_LIBRARY

    # Execute the Tcl script which is responsible for removing the installed
    # files.
    $TCLSH $ROOTDIR/conf/cnrremove.tcl
fi

exit 0
