# vsftpd - FTP Daemon
#

description	"vsftpd daemon"
author		"Chuck Short <zulcss@ubuntu.com>"

start on runlevel [2345] or net-device-up IFACE!=lo
stop on runlevel [!2345]
respawn

pre-start script
	check_standalone_mode()
	{
		# Return 1 if vsftpd.conf doesn't have listen yes or listen_ipv6=yes
		CONFFILE="/etc/vsftpd.conf"

		if [ -e  "${CONFFILE}" ] && ! egrep -iq "^ *listen(_ipv6)? *= *yes" "${CONFFILE}"
		then
			echo "${CONFFILE}: listen disabled - service will not start"
			return 1
		fi 
	}
	[ -d /var/run/vsftpd ] || install -m 755 -o root -g root -d /var/run/vsftpd
	[ -d /var/run/vsftpd/empty ] || install -m 755 -o root -g root -d /var/run/vsftpd/empty
	check_standalone_mode || stop
end script

exec /usr/sbin/vsftpd

