##### preremove  : Copyright (c) 1999 by "WahleeWhirl Corporation"
#####
##### preremove  : Package Removal Script For
#####              Washington University ftpd (wu-ftpd-2.6.0)
##### Author     : Auteria "Wally" Winzer Jr.
##### Date & Time: Sat Oct 23 23:22:47 PDT 1999

########################################
# Set script variables and export them #
########################################
RC1_FTPD=/etc/init.d/academ; export RC1_FTPD
RC2_FTPD=/etc/init.d/academ-ftpd; export RC2_FTPD
RC3_FTPD=/etc/init.d/wu-ftpd; export RC3_FTPD
RC4_FTPD=/etc/init.d/wuftpd; export RC3_FTPD
RC5_FTPD=/etc/init.d/ftpd; export RC4_FTPD
RC6_FTPD=/etc/init.d/in.ftpd; export RC5_FTPD
RC7_FTPD=/etc/init.d/ftp; export RC4_FTPD
ECHO=/usr/bin/echo; export ECHO
PS="/usr/bin/ps -ef"; export PS
GREP=/usr/bin/grep; export GREP
GSTRING=grep; export GSTRING
FTP_STRING="in.ftpd"; export FTP_STRING
AWK=/usr/bin/awk; export AWK
KILL=/usr/bin/kill; export KILL
PAUSE="/usr/bin/sleep 2"; export PAUSE

##########################
# Start preremove script #
##########################
PID=`$PS | $GREP -v $GSTRING | $GREP "$FTP_STRING" | $AWK '{print $2}'`; export PID
if [ ! -z "$PID" ]; then
	$ECHO "wu-ftpd is running as a daemon.  Current PID = \"$PID\"."
	$PAUSE
	$ECHO "Checking Best Method Of Stopping wu-ftpd..."
	$PAUSE
	if [ -x "$RC1_FTPD" ]; then
		$ECHO "Using rc script \"$RC1_FTPD\" to stop wu-ftpd..."
		$RC1_FTPD stop
		$PAUSE
	elif [ -x "$RC2_FTPD" ]; then
		$ECHO "Using rc script \"$RC2_FTPD\" to stop wu-ftpd..."
		$RC2_FTPD stop
		$PAUSE
	elif [ -x "$RC3_FTPD" ]; then
		$ECHO "Using rc script \"$RC3_FTPD\" to stop wu-ftpd..."
		$RC3_FTPD stop
		$PAUSE
	elif [ -x "$RC4_FTPD" ]; then
		$ECHO "Using rc script \"$RC4_FTPD\" to stop wu-ftpd..."
		$RC4_FTPD stop
		$PAUSE
	elif [ -x "$RC5_FTPD" ]; then
		$ECHO "Using rc script \"$RC5_FTPD\" to stop wu-ftpd..."
		$RC5_FTPD stop
		$PAUSE
	elif [ -x "$RC6_FTPD" ]; then
		$ECHO "Using rc script \"$RC6_FTPD\" to stop wu-ftpd..."
		$RC6_FTPD stop
		$PAUSE
	elif [ -x "$RC7_FTPD" ]; then
		$ECHO "Using rc script \"$RC7_FTPD\" to stop wu-ftpd..."
		$RC7_FTPD stop
		$PAUSE
	else
		$ECHO "Sending SIGKILL to wu-ftpd.  PID = \"$PID\":\c"
		$KILL $PID && $ECHO " in.ftpd\c" && $ECHO " done."
		$ECHO "wu-ftpd v2.6.0 has been stopped successfully."
		$PAUSE
		$ECHO "Continuing with the package removal of \"WUFtpd260\"."
	fi
fi
if [ -z "$PID" ]; then
	$ECHO "wu-ftpd is running through inetd, not as a daemon."
	$PAUSE
	$ECHO "Continuing with the package removal of \"WUFtpd260\"."
fi
$PAUSE
$ECHO ""
