#! /bin/sh
#
# ftpd        This starts and stops ftpd.
#
# chkconfig: 345 50 50
# description: Wu-ftpd is one of the most widely \
# used daemons on the Internet. \
#
# processname: /usr/sbin/in.ftpd
# config: /etc/sysconfig/network
# config: /etc/ftpaccess
# pidfile: /var/run/ftpd.pid

PATH=/sbin:/bin:/usr/bin:/usr/sbin

# Source function library.
. /etc/init.d/functions

# Get config.
test -f /etc/sysconfig/network && . /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "yes" ] || exit 0

[ -f /usr/sbin/in.ftpd ] || exit 1
[ -f /etc/ftpaccess ] || exit 1

RETVAL=0

start(){
    echo -n "Starting ftpd: "
    daemon in.ftpd -l -a -S
    RETVAL=$?
    echo
    touch /var/lock/subsys/ftpd
    return $RETVAL
}

stop(){
    echo -n "Stopping ftpd: "
    killproc in.ftpd
    RETVAL=$?
    echo
    rm -f /var/lock/subsys/ftpd
    return $RETVAL

}

reload(){
    echo -n "Reloading ftpd: "
    killproc in.ftpd -USR2
    RETVAL=$?
    echo
    return $RETVAL
}

restart(){
    stop
    start
}

condrestart(){
    [ -e /var/lock/subsys/ftpd ] && restart
    return 0
}


# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status in.ftpd
        ;;
    restart)
        restart
        ;;
    reload)
        reload
        ;;
    condrestart)
        condrestart
        ;;
    *)
        echo "Usage: ftpd {start|stop|status|restart|condrestart|reload}"
        RETVAL=1
esac

exit $RETVAL
