#!/bin/sh
# $Id: proftpd.init,v 1.2 2002/06/10 15:35:47 dude Exp $
#
# proftpd       This shell script takes care of starting and stopping
#               proftpd.
#
# chkconfig: - 80 30
# description: ProFTPD is an enhanced FTP server with a focus towards \
#              simplicity, security, and ease of configuration. \
#              It features a very Apache-like configuration syntax, \
#              and a highly customizable server infrastructure, \
#              including support for multiple 'virtual' FTP servers, \
#              anonymous FTP, and permission-based directory visibility.
# processname: proftpd
# config: /etc/proftp.conf
# pidfile: /var/run/proftpd.pid

# Source function library.
. /usr/local/etc/rc.d/functions

[ -x /usr/local/sbin/proftpd ] || exit 0

RETVAL=0

FTPSHUT=/usr/local/sbin/ftpshut
LOCK_FILE=/var/spool/lock/proftpd

start() {
        echo -n "Starting proftpd: "
        daemon /usr/local/sbin/proftpd
        RETVAL=$?
        if [ $RETVAL -eq 0 ] && touch $LOCK_FILE
	then
		echo -e "\t\t[ OK ]";
	else
		echo -e "\t\t[ FAILED ]";
	fi
        return $RETVAL
}

stop() {
        echo -n "Shutting down proftpd: "
        killall proftpd 2> /dev/null
        RETVAL=$?
        if [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
	then
		echo -e "\t\t[ OK ]";
	else
		echo -e "\t\t[ FAILED ]";
	fi
        return $RETVAL
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status proftpd
        RETVAL=$?
        ;;
  restart)
        stop
        start
        RETVAL=$?
        ;;
  condrestart)
        if [ -f $LOCK_FILE ]; then
          stop
          start
          RETVAL=$?
        fi
        ;;
  reload)
        echo -n "Re-reading proftpd configuration: "
        killall -HUP proftpd 2> /dev/null
        RETVAL=$?
	if [ $RETVAL = 0 ]
	then
		echo -e "\t[ OK ]";
	else
		echo -e "\t[ FAILED ]";
	fi
        ;;
  *)
        echo "Usage: proftpd {start|stop|restart|reload|condrestart|status}"
        exit 1
esac

exit $RETVAL
