summaryrefslogtreecommitdiff
blob: be28d958a0275ed7429b3b87a6d50af467fb8ccd (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
63
64
#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

description="Gatling high performance web server init script"
opts="reload"

depend() { 
	need net
}

checkconfig() {
	# Verify UID is valid for running process.
	if [[ ! $(id ${GATLING_UID} 2>/dev/null) ]]; then
		ewarn "User ${GATLING_UID} not found!"
		return 1
	fi

	# Set gatling run opts
	if yesno ${VHOST};then VHOST=-v;else VHOST=-V;fi
	if yesno ${SSL};then SSL=-e;else SSL=-E;fi
	if yesno ${DIR_INDEXING};then DIR_INDEXING=-d;else DIR_INDEXING=-D;fi
	if yesno ${FTP}; then FTP=-f;else FTP=-F;fi
	if yesno ${FTP_AUTH}; then FTP_AUTH=-l;else unset FTP_AUTH;fi
	if yesno ${FTP_UP};then unset FTP_UP;else FTP_UP=-U;fi
	yesno ${TRANS_PROXY} && TRANS_PROXY=-t 
}

start() {
	checkconfig || return 1

	ebegin "Starting gatling"
	start-stop-daemon --start --quiet --background --make-pidfile --pidfile ${PID} \
--name gatling --exec /usr/bin/gatling -- -T ${HTTP_TIMEOUT} -i ${IP} -p ${PORT} -P ${PREFETCH} \
${VHOST} -c ${ROOTDIR} ${DIR_INDEXING} ${TRANS_PROXY} -u ${GATLING_UID} ${FTP} -T ${FTP_TIMEOUT} \
${FTP_AUTH} ${FTP_UPLOADS} 
	eend $?
}

stop() {
	ebegin "Stopping gatling"
	start-stop-daemon --quiet --stop --pidfile ${PID} 
	eend $?
}

reload() {
        if ! service_started "${SVCNAME}" ; then
                eerror "${SVCNAME} isn't running"
                return 1
        fi

	checkconfig || return 1

	ebegin "Sending gatling the HUP signal"
	start-stop-daemon --quiet --signal HUP --pidfile ${PID}

	ebegin "Restarting gatling server"
        start-stop-daemon --start --quiet --background --make-pidfile --pidfile ${PID} \
--name gatling --exec /usr/bin/gatling -- -T ${HTTP_TIMEOUT} -i ${IP} -p ${PORT} -P ${PREFETCH} \
${VHOST} -c ${ROOTDIR} ${DIR_INDEXING} ${TRANS_PROXY} -u ${GATLING_UID} ${FTP} -T ${FTP_TIMEOUT} \
${FTP_AUTH} ${FTP_UPLOADS}
        eend $?
}