#!/bin/sh
#
#       This script checks for the revision of the Kernel Update
#       installed and takes the necessary action
#
PATID=109134
NUNDO_REV=04

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

undo_wbeminit() {

fname=init.wbem
cat >/tmp/$fname.$$ <<\EOF
#!/sbin/sh
#
# Copyright (c) 1999 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident	"@(#)init.wbem.sh	1.52	99/10/18 SMI"

case "$1" in
'start')
	[ -d /var/sadm/wbem/log ] || /usr/bin/mkdir -pm 0700 /var/sadm/wbem/log
	umask 066; /usr/sadm/lib/wbem/cimomboot "$@" >/dev/msglog 2>&1 &
	echo $! >/var/sadm/wbem/log/cimbootserver.pid
	;;

'stop')
	for daemon in cimbootserver cimomserver space rmid; do
		pidfile=/var/sadm/wbem/log/$daemon.pid
		if [ -f $pidfile ]; then
			pid=`/usr/bin/cat $pidfile`
			[ "$pid" -gt 0 ] && kill $pid >/dev/null 2>&1
			rm -f $pidfile
		fi
	done
	;;

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


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

return 0

}

rev=0

for i in `echo $pids`; do
	echo $i | egrep -s $PATID || continue
	rev=`expr //$i : '.*-\(.*\)'`
done

#No undo edits for rev-04 or higher
[ $rev -ge $NUNDO_REV ] && exit

undo_wbeminit && exit

exit 0
