blob: 4de71ee1602662de6c36d607be19dd08fce7d7be [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
74check() {
75 /usr/sbin/$BASENAME -c -q -V -f /etc/$BASENAME/$BASENAME.cfg
76}
77
78rhstatus() {
79 status $BASENAME
80}
81
82condrestart() {
83 [ -e /var/lock/subsys/$BASENAME ] && restart || :
84}
85
86# See how we were called.
87case "$1" in
88 start)
89 start
90 ;;
91 stop)
92 stop
93 ;;
94 restart)
95 restart
96 ;;
97 reload)
98 restart
99 ;;
100 condrestart)
101 condrestart
102 ;;
103 status)
104 rhstatus
105 ;;
106 check)
107 check
108 ;;
109 *)
110 echo $"Usage: $BASENAME {start|stop|restart|reload|condrestart|status|check}"
Willy Tarreau98edd772007-12-02 14:02:52 +0100111 exit 1
willy tarreau982249e2005-12-18 00:57:06 +0100112esac
113
Willy Tarreau98edd772007-12-02 14:02:52 +0100114exit $?