blob: 942d959c8a535829404395883119b1f254f9b84b [file] [log] [blame]
willy tarreau982249e2005-12-18 00:57:06 +01001#!/bin/sh
2#
3# chkconfig: - 85 15
4# description: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited \
5# for high availability environments.
6# processname: haproxy
7# config: /etc/haproxy/haproxy.cfg
8# pidfile: /var/run/haproxy.pid
9
10# Script Author: Simon Matter <simon.matter@invoca.ch>
11# Version: 2004060600
12
13# Source function library.
14if [ -f /etc/init.d/functions ]; then
15 . /etc/init.d/functions
16elif [ -f /etc/rc.d/init.d/functions ] ; then
17 . /etc/rc.d/init.d/functions
18else
19 exit 0
20fi
21
22# Source networking configuration.
23. /etc/sysconfig/network
24
25# Check that networking is up.
26[ ${NETWORKING} = "no" ] && exit 0
27
28# This is our service name
29BASENAME=`basename $0`
30if [ -L $0 ]; then
31 BASENAME=`find $0 -name $BASENAME -printf %l`
32 BASENAME=`basename $BASENAME`
33fi
34
35[ -f /etc/$BASENAME/$BASENAME.cfg ] || exit 1
36
37RETVAL=0
38
39start() {
40 /usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg
41 if [ $? -ne 0 ]; then
42 echo "Errors found in configuration file, check it with '$BASENAME check'."
43 return 1
44 fi
45
46 echo -n "Starting $BASENAME: "
47 daemon /usr/sbin/$BASENAME -D -f /etc/$BASENAME/$BASENAME.cfg -p /var/run/$BASENAME.pid
48 RETVAL=$?
49 echo
50 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
51 return $RETVAL
52}
53
54stop() {
55 echo -n "Shutting down $BASENAME: "
56 killproc $BASENAME -USR1
57 RETVAL=$?
58 echo
59 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASENAME
60 [ $RETVAL -eq 0 ] && rm -f /var/run/$BASENAME.pid
61 return $RETVAL
62}
63
64restart() {
65 /usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg
66 if [ $? -ne 0 ]; then
67 echo "Errors found in configuration file, check it with '$BASENAME check'."
68 return 1
69 fi
70 stop
71 start
72}
73
Willy Tarreau3909a2a2009-05-01 15:49:56 +020074reload() {
75 /usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg
76 if [ $? -ne 0 ]; then
77 echo "Errors found in configuration file, check it with '$BASENAME check'."
78 return 1
79 fi
80 /usr/sbin/$BASENAME -D -f /etc/$BASENAME/$BASENAME.cfg -p /var/run/$BASENAME.pid -sf $(cat /var/run/$BASENAME.pid)
81}
82
willy tarreau982249e2005-12-18 00:57:06 +010083check() {
84 /usr/sbin/$BASENAME -c -q -V -f /etc/$BASENAME/$BASENAME.cfg
85}
86
87rhstatus() {
88 status $BASENAME
89}
90
91condrestart() {
92 [ -e /var/lock/subsys/$BASENAME ] && restart || :
93}
94
95# See how we were called.
96case "$1" in
97 start)
98 start
99 ;;
100 stop)
101 stop
102 ;;
103 restart)
104 restart
105 ;;
106 reload)
Willy Tarreau3909a2a2009-05-01 15:49:56 +0200107 reload
willy tarreau982249e2005-12-18 00:57:06 +0100108 ;;
109 condrestart)
110 condrestart
111 ;;
112 status)
113 rhstatus
114 ;;
115 check)
116 check
117 ;;
118 *)
119 echo $"Usage: $BASENAME {start|stop|restart|reload|condrestart|status|check}"
Willy Tarreau98edd772007-12-02 14:02:52 +0100120 exit 1
willy tarreau982249e2005-12-18 00:57:06 +0100121esac
122
Willy Tarreau98edd772007-12-02 14:02:52 +0100123exit $?