#!/bin/sh
. /usr/lib/linuxconf/install/rpm-identdist.sh

echo "#### /usr/lib/linuxconf/install/rpm-preuninst.sh" >>/tmp/linuxconf-rpmuninstall.log
date >>/tmp/linuxconf-rpmuninstall.log

log(){
	echo $* >>/tmp/linuxconf-rpmuninstall.log
	$*
}

log rm -f $OLDINSTALL
log rm -f $GRABNOTICE

if [ "$1" = 0 ] ; then
# Restore Original /etc/rc.d/rc.sysinit
	if [ ! `grep $PATHRCINIT /usr/lib/linuxconf/uninstall/options` ] ; then
		if [ -f $PATHRCINIT.beforelinuxconf ] ; then
			log rm -f $PATHRCINIT
			log mv $PATHRCINIT.beforelinuxconf $PATHRCINIT
		elif [ -f /usr/lib/linuxconf/uninstall/$RCINIT.beforelinuxconf ] ; then
			log rm -f $PATHRCINIT
			log mv /usr/lib/linuxconf/uninstall/$RCINIT.beforelinuxconf $PATHRCINIT	
		fi
	fi

# Restore Original /etc/rc.d/rc file
	if [ ! `grep $PATHRC /usr/lib/linuxconf/uninstall/options` ] ; then
		if [ -f $PATHRC.beforelinuxconf ] ; then
			log rm -f $PATHRC
			log mv $PATHRC.beforelinuxconf $PATHRC
		elif [ -f /usr/lib/linuxconf/uninstall/rc.beforelinuxconf ] ; then
			log rm -f $PATHRC
			log mv /usr/lib/linuxconf/uninstall/rc.beforelinuxconf $PATHRC
		fi
	fi

# Backup /etc/conf.linuxconf
	if [ -f /etc/conf.linuxconf ] ; then
		log mv /etc/conf.linuxconf /etc/conf.linuxconf-installed
	fi

# Remove /etc/quota.conf
	if [ -f /etc/quota.conf ] ; then
		log rm -f /etc/quota.conf
	fi

# Delete files that may still exist - I hate errors!
	log rm -Rf /usr/lib/linuxconf/uninstall/* 

elif [ "$1" = 1 ] ; then

  	# Someday, we will probably need to do something during an upgrade.
  	# I'm pretty sure Jacques has more features than the subnetted
  	# reverse lookup to add :-)
	true
fi

