#!/bin/sh
#
# jftpgw	This script handles the starting and stopping of the FTP
#		proxy.
#
# chkconfig: 2345 85 15
# description:	Jftpgw is a simple FTP proxy.
# processname:	jftpgw
# Script Author: Simon Matter <simix@datacomm.ch>
# V1.0.2

# Source function library.
if [ -f /etc/init.d/functions ]; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 0
fi

# Source networking configuration.
. /etc/sysconfig/network

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

# This is our service name
BASENAME=`basename $0`
if [ -L $0 ]; then
  BASENAME=`find $0 -name $BASENAME -printf %l`
  BASENAME=`basename $BASENAME`
fi

RETVAL=0

start() {
  echo -n "Starting $BASENAME: "
  daemon /usr/sbin/$BASENAME
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
  return $RETVAL
}

stop() {
  echo -n "Shutting down $BASENAME: "
  killproc $BASENAME
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASENAME
  return $RETVAL
}

reload() {
  echo -n "Reloading $BASENAME.conf file: "
  killproc $BASENAME -HUP
  RETVAL=$?
  echo
  return $RETVAL
}

restart() {
  stop
  start
}

rhstatus() {
  status $BASENAME
}

condrestart() {
  [ -e /var/lock/subsys/$BASENAME ] && restart || :
}

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

exit $RETVAL
