#!/sbin/runscript # Copyright 2003-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 # $Header: /var/cvsroot/gentoo-x86/net-ftp/vsftpd/files/vsftpd.init,v 1.5 2007/04/10 13:00:55 uberlord Exp $ VSFTPD_NAME=${SVCNAME##*.} if [ -n "${VSFTPD_NAME}" -a "${SVCNAME}" != "vsftpd" ]; then VSFTPD_PID="/var/run/vsftpd.${VSFTPD_NAME}.pid" VSFTPD_CONF_DEFAULT="/etc/vsftpd/${VSFTPD_NAME}.conf" else VSFTPD_PID="/var/run/vsftpd.pid" VSFTPD_CONF_DEFAULT="/etc/vsftpd/vsftpd.conf" fi VSFTPD_CONF=${VSFTPD_CONF:-${VSFTPD_CONF_DEFAULT}} depend() { need net use dns logger } checkconfig() { if [ ! -e ${VSFTPD_CONF} ] ; then eerror "Please setup ${VSFTPD_CONF} before starting vsftpd" eerror "There are sample configurations in /usr/share/doc/vsftpd" return 1 fi if egrep -iq "^ *background *= *yes" "${VSFTPD_CONF}" ; then eerror "${VSFTPD_CONF} must not set background=YES" return 1 fi local has_ip=false has_ipv6=false ip_error=true egrep -iq "^ *listen *= *yes" "${VSFTPD_CONF}" && has_ip=true egrep -iq "^ *listen_ipv6 *= *yes" "${VSFTPD_CONF}" && has_ipv6=true if ${has_ip} && ! ${has_ipv6} ; then ip_error=false elif ! ${has_ip} && ${has_ipv6} ; then ip_error=false fi if ${ip_error} ; then eerror "${VSFTPD_CONF} must contain listen=YES or listen_ipv6=YES" eerror "but not both" return 1 fi } start() { checkconfig || return 1 ebegin "Starting ${SVCNAME}" start-stop-daemon --start --exec /usr/sbin/vsftpd \ --background --make-pidfile --pidfile "${VSFTPD_PID}" \ -- "${VSFTPD_CONF}" eend $? } stop() { ebegin "Stopping ${SVCNAME}" start-stop-daemon --stop --exec /usr/sbin/vsftpd \ --pidfile "${VSFTPD_PID}" eend $? } # vim: ts=4