#!/bin/sh
#
# Startup script for BBFTPD, the BBFTP daemon
#
# description: 
# processname: bbftpd
# pidfile: /var/run/bbftpd.pid


PROG=bbftpd
PID=/var/run/$PROG.pid

case "$1" in 
  start)
	echo -n "Starting $PROG: "
	if test "x" != "x"; then
	   export X509_USER_CERT=
	   export X509_USER_KEY=
	   export X509_CERT_DIR=
	   export GRIDMAP=
	fi
        if [ -x /usr/bin/$PROG ];then
           /usr/bin/$PROG -b && echo "$PROG started."
        else
           echo "$PROG not found."
        fi
	;;

  stop)
	echo -n "Shutting down $PROG: "
        if [ -f $PID ];then
           kill `cat $PID` && echo "$PROG stopped."
           rm -f $PID
        else
           echo "$PROG already stopped."
        fi
        ;;

  reload|restart)
        $0 stop
        sleep 1
        $0 start
        ;;

  status)
        if [ -f ${PID} ];then
           echo "${PROG} is running (process `cat ${PID}`)."
        else
           echo "$PROG is not running."
        fi
        ;;

  *)
        echo "Usage: $0 {start|stop|restart|reload|status}"
        exit 1
	;;
esac

# The End.
exit 0

