#!/bin/sh
#
#       This script checks for the revision of the patch 
#       installed and takes the necessary action to back out changes
#	made to the ldap.client script
#
#

PATID=108993
NOUNDO_REV=14
rmv_all=1

INFO="$PKG_INSTALL_ROOT/var/sadm/pkg/SUNWcsr/pkginfo"
pids=`egrep '^PATCHLIST' $INFO | nawk -F= '{print $2}'`

undo_ldap_client() {

fname=ldap.client

cat<<STOP  > /tmp/$fname.$$ 
#!/sbin/sh
#
# Copyright (c) 1999 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident	"@(#)ldap.client	1.1	99/07/07 SMI"

case "\$1" in
start)
	[ -f /var/ldap/ldap_client_file -a \\
	    -f /usr/lib/ldap/ldap_cachemgr ] || exit 0
	/usr/lib/ldap/ldap_cachemgr &
	;;

stop)
	[ -f /usr/lib/ldap/ldap_cachemgr ] && /usr/lib/ldap/ldap_cachemgr -K
	;;

*)
	echo "Usage: \$0 { start | stop }"
	exit 1
	;;
esac
exit 0
STOP

cp /tmp/$fname.$$ $PKG_INSTALL_ROOT/etc/init.d/$fname
rm /tmp/$fname.$$

return 0
}


for i in `echo $pids`; do
	echo $i | egrep -s $PATID || continue
	rev=`expr //$i : '.*-\(.*\)'`
	#No undo edits for rev-14 or higher
	[ $rev -ge $NOUNDO_REV ] && exit
done

[ $rmv_all ] && undo_ldap_client

exit 0
