summaryrefslogtreecommitdiff
blob: c2027045ca2839a6236900c4e2cd39fe3c142d08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/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.2 2006/03/10 12:12:21 uberlord Exp $

VSFTPD_CONF="/etc/vsftpd/vsftpd.conf"
VSFTPD_NAME="${SVCNAME##*.}"
if [[ -n ${VSFTPD_NAME} && ${SVCNAME} != "vsftpd" ]]; then
    VSFTPD_PID="/var/run/vsftpd.${VSFTPD_NAME}.pid"
else
    VSFTPD_PID="/var/run/vsftpd.pid"
fi

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 vsftpd"
	start-stop-daemon --start --exec /usr/sbin/vsftpd \
		--background --make-pidfile --pidfile "${VSFTPD_PID}" \
		-- "${VSFTPD_CONF}"
	eend $?
}

stop() {
	ebegin "Stopping vsftpd"
	start-stop-daemon --stop --exec /usr/sbin/vsftpd \
		--pidfile "${VSFTPD_PID}"
	eend $?
}

# vim: ts=4