| 1 | #!/sbin/openrc-run |
| 2 | # Copyright 1999-2011 Gentoo Foundation |
| 3 | # Distributed under the terms of the GNU General Public License v2 |
| 4 | # $Header: /var/cvsroot/gentoo-x86/net-proxy/haproxy/files/haproxy.initd-r1,v 1.2 2011/12/04 10:32:32 swegener Exp $ |
| 5 | |
| 6 | extra_commands="checkconfig" |
| 7 | extra_started_commands="reload" |
| 8 | command=/usr/sbin/haproxy |
| 9 | |
| 10 | CONF=${HAPROXY_CONF:-/etc/haproxy/${SVCNAME}.cfg} |
| 11 | PIDFILE=/var/run/${SVCNAME}.pid |
| 12 | |
| 13 | depend() { |
| 14 | need net |
| 15 | after firewall |
| 16 | use dns logger |
| 17 | } |
| 18 | |
| 19 | checkconfig() { |
| 20 | if [ ! -f "${CONF}" ] && [ ! -d "${CONF}" ]; then |
| 21 | eerror "${CONF} does not exist!" |
| 22 | return 1 |
| 23 | fi |
| 24 | |
| 25 | ebegin "Checking ${CONF}" |
| 26 | $command -q -c -f "${CONF}" |
| 27 | eend $? |
| 28 | } |
| 29 | |
| 30 | start() { |
| 31 | ebegin "Starting ${SVCNAME}" |
| 32 | start-stop-daemon --pidfile "${PIDFILE}" --exec $command \ |
| 33 | --start -- -D -p "${PIDFILE}" -f "${CONF}" |
| 34 | eend $? |
| 35 | } |
| 36 | |
| 37 | stop() { |
| 38 | ebegin "Stopping ${SVCNAME}" |
| 39 | |
| 40 | if [ "${RC_CMD}" = "restart" ]; then |
| 41 | checkconfig || return 1 |
| 42 | fi |
| 43 | |
| 44 | start-stop-daemon --stop --pidfile "${PIDFILE}" |
| 45 | eend $? |
| 46 | } |
| 47 | |
| 48 | reload() { |
| 49 | ebegin "Reloading ${SVCNAME}" |
| 50 | checkconfig || { eerror "Reloading failed, please fix your ${CONF} first"; return 1; } |
| 51 | $command -D -p "${PIDFILE}" -f "${CONF}" -sf $(cat "${PIDFILE}") |
| 52 | eend $? |
| 53 | } |
| 54 | |