summaryrefslogtreecommitdiff
blob: 312357c8cc314c35bec97c3f6f5a40017b027976 (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
#!/sbin/runscript
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-ftp/pure-ftpd/files/pure-ftpd.rc7,v 1.6 2010/07/18 13:04:34 polynomial-c Exp $

ftpd_pidfile="/var/run/pure-ftpd.pid"
script_pidfile="/var/run/pure-uploadscript.pid"

depend() {
	need net
}

checkconfig() {
	if [ -z "$IS_CONFIGURED" ] ; then
		eerror "You need to setup /etc/conf.d/pure-ftpd first!"
		return 1
	fi
}

start() {
	checkconfig || return 1
	UPSCRIPT=""
	OKNODO=""
	if [ -n "$UPLOADSCRIPT" ] ; then
		UPSCRIPT="--uploadscript"
		OKNODO="--oknodo"
	fi
	ebegin "Starting Pure-FTPd"
	start-stop-daemon --start --quiet --pidfile ${ftpd_pidfile} $OKNODO --exec /usr/sbin/pure-ftpd -- --pidfile ${ftpd_pidfile} $SERVER $MAX_CONN $MAX_CONN_IP $DAEMON $DISK_FULL $USE_NAT $AUTH $LOG $TIMEOUT $CHARCONV $MISC_OTHER $UPSCRIPT
	result=$?
	if [ $result -ne 0 ] ; then
		eend 1 "Could not launch Pure-FTPd"
	else
		eend $result
		if [ -n "$UPLOADSCRIPT" ] ; then
			ebegin "Starting Pure-FTPd upload script"
			start-stop-daemon --start --quiet --make-pidfile --pidfile ${script_pidfile} --exec /usr/sbin/pure-uploadscript --background -- -r $UPLOADSCRIPT
			eend $?
		fi
	fi
}

stop() {
	ebegin "Stopping Pure-FTPd"
	start-stop-daemon --stop --retry 20 --quiet --pidfile ${ftpd_pidfile}
	eend $?
	if [ -n "$UPLOADSCRIPT" ] ; then
		ebegin "Stopping Pure-FTPd upload script"
		start-stop-daemon --stop --retry 20 --quiet --pidfile ${script_pidfile}
		eend $?
	fi
}