#!/bin/sh
#
# $FreeBSD: ports/ftp/vsftpd/files/vsftpd.sh.in,v 1.7 2006/02/20 20:47:01 dougb Exp $
#

# PROVIDE: vsftpd
# REQUIRE: DAEMON

# Add the following line to /etc/rc.conf to enable `vsftpd':
#
# vsftpd_enable="YES"
# vsftpd_flags="/some/path/conf.file" # Not required
#

. "%%RC_SUBR%%"

name="vsftpd"
rcvar=`set_rcvar`

load_rc_config "$name"
: ${vsftpd_enable:="NO"}
: ${vsftpd_flags:=""}

command="%%PREFIX%%/libexec/$name"
required_files="%%PREFIX%%/etc/$name.conf"
start_precmd="vsftpd_check"

vsftpd_check()
{
	if grep -q "^ftp[ 	]" /etc/inetd.conf ${required_files}
	then
		err 1 "ftp is already activated in /etc/inetd.conf"
	fi
	if ! egrep -q -i -E "^listen.*=.*YES$" ${required_files}
	then
		err 1 "vsftpd script need "listen=YES" on config file"
	fi
	if ! egrep -q -i -E "^background.*=.*YES$" ${required_files}
	then
		err 1 "vsftpd script need "background=YES" on config file"
	fi
}

run_rc_command "$1"


syntax highlighted by Code2HTML, v. 0.9.1