#!/bin/bash
#
#	/etc/rc.d/init.d/vsftpd-standalone
#
# Starts the vsftp daemon in standalone mode
#
# chkconfig: - 56 54
# description:  A Very Secure Ftp Daemon - Starts up in its non-default 
# standalone mode.
# processname: vsftpd
# Source function library.
. /etc/init.d/functions

test -x /usr/sbin/vsftpd || exit 0

RETVAL=0
prog="vsftpd"

start() {
	# Check if pxe is already running
	if [ ! -f /var/lock/subsys/vsftpd ]; then
	    echo -n $"Starting $prog: "
	    /usr/sbin/vsftpd &
            [ -n "`pidofproc /usr/sbin/vsftpd`" ] && success
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/vsftpd-standalone
	    echo
	fi
}

stop() {
	echo -n $"Stopping $prog: "
	killproc /usr/sbin/vsftpd
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/vsftpd-standalone
	echo
}

#
#	See how we were called.
#
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  reload|restart)
	stop
	start
	RETVAL=$?
	;;
  condrestart)
	if [ -f /var/lock/subsys/vsftpd-standalone ]; then
	    stop
	    start
	fi
	;;
  status)
	status /usr/sbin/vsftpd
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"
	exit 1
esac

exit $RETVAL
