#
#       Copyright (c) 1999 Sun Microsystems, Inc.
#               All Rights Reserved
#
# @(#)preremove	3.12 99/10/27 Sun Microsystems, Inc.
#

if [ -f ${PKG_INSTALL_ROOT}/kernel/drv/screen ]
then
	echo "## Removing screen driver ##"
	rem_drv -b "${PKG_INSTALL_ROOT}" screen
fi

if [ -f ${PKG_INSTALL_ROOT}/usr/kernel/drv/screen_skip ]
then
	echo "## Removing screen_skip driver ##"
	rem_drv -b "${PKG_INSTALL_ROOT}" screen_skip
fi

# force reconfigure on next boot
touch ${PKG_INSTALL_ROOT}/reconfigure

# Remove our TCP service descriptions from /etc/services.
services=${PKG_INSTALL_ROOT}/etc/inet/services
if grep "^ss_" $services 1>/dev/null 2>&1
then
	cp $services $services.back
	grep -v "^ss_" $services > $services.nosunscreen
	rm $services
	cp $services.nosunscreen $services
	rm $services.back
fi

# Remove our file format descriptions from /etc/magic.
magic=${PKG_INSTALL_ROOT}/etc/magic
if grep 'Begin SunScreen files' $magic >/dev/null 2>&1
then
	sed '/Begin SunScreen files/,/End SunScreen files/d
	     /SunScreenConfigurationBackup/d' $magic > $magic.new
	cp $magic.new $magic
	rm $magic.new
fi

# Remove the .active directory; a subsequent re-install will have to
# re-activate in order to use a previously existing configuration; compiled
# configurations are not "portable" across different software versions.
if [ -d /etc/opt/SUNWicg/SunScreen/.active ]
then echo "## Removing active configuration ##"
     rm -r /etc/opt/SUNWicg/SunScreen/.active
fi

if [ -f /opt/SUNWicg/SunScreen/lib/cleanupatm ]; then
/opt/SUNWicg/SunScreen/lib/cleanupatm -f >/dev/null 2>&1
fi

echo "## Done ##"
