#!/bin/ksh
#
# mvdeinstall version 1.1 - 12/11/95 (jlc)
#
# configuration script to remove MarkVision & Lexmark MarkNet adaptors to
# NetView/6000 for AIX version 3 or 4
#
(
ErrCode=0

if [ `whoami` != "root" ]
then
	print "This configuration script must be run by root."
	exit 1
fi


cd "/usr/lpp/mv4nv"
if [ $? -ne 0 ]
then
	print "ERROR:1 Could not change to working directory /usr/lpp/mv4nv."
	exit 1
fi

/usr/OV/bin/removetrap -l MarkNet_IRC
if [ $? -ne 0 ]
then
	print "ERROR:11 could not remove IR Cleared from trapd configuration."
	ErrCode=1
fi
/usr/OV/bin/removetrap -l MarkNet_IRR
if [ $? -ne 0 ]
then
	print "ERROR:12 could not remove IR Received from trapd configuration."
	ErrCode=1
fi

# make sure Netview is not running
/usr/OV/bin/nv6000_smit stopdaemons 
# alternate command: /usr/OV/bin/ovstop -v
if [ $? -ne 0 ]
then
	print ""
	print "ERROR:2 could not stop Netview daemons."
	exit 1
fi



#  remove "...641.1:Lexmark:Lexmark MarkNet" to oid_to_type
#  ALT: mv /usr/OV/conf/oid_to_type.mvbak /usr/OV/conf/oid_to_type 
#       if [ -f /usr/OV/conf/oid_to_type.mvbak ]
#	print "WARNING:22 oid_to_type.mvbak not found."

mv /usr/OV/conf/oid_to_type /usr/OV/conf/oid_to_type.mv
if [ $? -eq 0 ]
then
	grep -v "Lexmark_MarkNet" /usr/OV/conf/oid_to_type.mv > /usr/OV/conf/oid_to_type
	if [ $? -ne 0 ]
	then
		print "ERROR:21 could not restore oid_to_type."
		ErrCode=1
	fi
else
	print "WARNING:22 could not move oid_to_type."
	ErrCode=1
fi


#  remove "...641.1:device:printer" to oid_to_sym
#  ALT: /usr/OV/conf/C/oid_to_sym.mvbak /usr/OV/conf/C/oid_to_sym 
#       if [ -f /usr/OV/conf/C/oid_to_sym.mvbak ]
#	print "WARNING:32 oid_to_sym.mvbak not found."
mv /usr/OV/conf/C/oid_to_sym /usr/OV/conf/C/oid_to_sym.mv
if [ $? -eq 0 ]
then
	grep -v "Lexmark_MarkNet" /usr/OV/conf/C/oid_to_sym.mv > /usr/OV/conf/C/oid_to_sym
	if [ $? -ne 0 ]
	then
		print "ERROR:31 could not restore oid_to_sym."
		ErrCode=1
	fi
else
	print "WARNING:32 could not move oid_to_sym."
	ErrCode=1
fi


#  remove tool and action item "MarkVision"
rm /usr/OV/registration/C/markvision
if [ $? -ne 0 ]
then
	print "ERROR:41 could not remove markvision tool."
	ErrCode=1
fi

#  remove vendor "lexmark" and snmp agent "Lexmark MarkNet" from fields
rm /usr/OV/fields/C/lexmark_fields
if [ $? -ne 0 ]
then
	print "ERROR:51 could not remove 'lexmark.fields'."
	ErrCode=1
fi

#  remove  markvision toolbar image
rm /usr/OV/icons/gifs/mv2.gif
if [ $? -ne 0 ]
then
	print "ERROR:51 could not remove icon 'mv2.gif'."
	ErrCode=1
fi
rm /usr/OV/icons/drag-bitmaps/mvx.xbm.?
if [ $? -ne 0 ]
then
	print "ERROR:51 could not remove drag-bitmap 'mvx.xbm'."
	ErrCode=1
fi


# restart all daemons
/etc/netnmrc

/usr/OV/bin/ovw -fields
if [ $? -ne 0 ]
then
	print "ERROR:61 ovw failed to reload fields."
	ErrCode=1
fi

print ""
if [ $ErrCode -eq 0 ]
then
rm -rf "/usr/lpp/mv4nv/bak"
print "mvdeinstall completed successfully."
exit 0
else
print "WARNING: mvdeinstall did not complete all removals. "
print "         see warnings above for details."
exit 1
fi
)  2>&1 | tee /usr/lpp/mv4nv/mvdeinstall.log
