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

extra_commands="checkconfig"
extra_started_commands="reload"

command="/usr/bin/haproxy"
pidfile="/var/run/${SVCNAME}.pid"

if [ -z "${CONFFILE}" -a -d "/etc/haproxy" -a -f "/etc/haproxy/${SVCNAME}.cfg" ]; then
	CONFFILE=/etc/haproxy/${SVCNAME}.cfg
else
	CONFFILE=/etc/${SVCNAME}.cfg
fi

command_args="-D -p ${pidfile} -f ${CONFFILE}"

depend() {
	need net
	use dns logger
}

checkconfig() {
	if [ ! -f "${CONFFILE}" ]; then
		eerror "${CONFFILE} does not exist!"
		return 1
	fi

	ebegin "Checking ${CONFFILE}"
	$command -q -c -f "${CONFFILE}"
	eend $?
}

stop_pre() {
	if [ "${RC_CMD}" = "restart" ]; then
		checkconfig || return 1
	fi
}

reload() {
	ebegin "Reloading ${SVCNAME}"
	checkconfig || { eerror "Reloading failed, please fix your ${CONFFILE} first"; return 1; }
	$command -D -p "${pidfile}" -f "${CONFFILE}" -sf $(cat "${pidfile}")
	eend $?
}