#!/bin/sh
# Start the tcpsvd daemon
TCPSVD_NAME="tcpsvd-ftpd"
TCPSVD_COMMAND="/usr/bin/tcpsvd -vE 0.0.0.0 21 ftpd -w -vv /"

start() {
	#do not start server if ftp disabled flag exists
	if [ -f /ross/etc/ftpServerDisabled ] ; then
		echo "FTP Server disabled. Exiting"
		exit 0
	fi
	echo -n "Starting $TCPSVD_NAME: "
	if pgrep -f "$COMMAND" > /dev/null 2>&1; then
		echo "$NAME is already running"
		return 0
	fi
	$TCPSVD_COMMAND &
	echo "OK"
}	

stop() {
	echo -n "Stopping $TCPSVD_NAME: "
	if pgrep -f "$TCPSVD_COMMAND" > /dev/null 2>&1; then
		/usr/bin/pkill -f "$TCPSVD_COMMAND"
		echo "OK"
	else
		echo "$TCPSVD_NAME is not running"
	fi
}

restart() {
	stop
	sleep 1
	start
}	

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