summaryrefslogtreecommitdiff
path: root/net-proxy/haproxy/files/haproxy.initd-r2
diff options
context:
space:
mode:
Diffstat (limited to 'net-proxy/haproxy/files/haproxy.initd-r2')
-rw-r--r--net-proxy/haproxy/files/haproxy.initd-r247
1 files changed, 47 insertions, 0 deletions
diff --git a/net-proxy/haproxy/files/haproxy.initd-r2 b/net-proxy/haproxy/files/haproxy.initd-r2
new file mode 100644
index 000000000000..c25c71e09268
--- /dev/null
+++ b/net-proxy/haproxy/files/haproxy.initd-r2
@@ -0,0 +1,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 $?
+}