2005-12-17 23:57:06 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# chkconfig: - 85 15
|
|
|
|
# description: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited \
|
|
|
|
# for high availability environments.
|
|
|
|
# processname: haproxy
|
|
|
|
# config: /etc/haproxy/haproxy.cfg
|
|
|
|
# pidfile: /var/run/haproxy.pid
|
|
|
|
|
|
|
|
# Script Author: Simon Matter <simon.matter@invoca.ch>
|
|
|
|
# Version: 2004060600
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
if [ -f /etc/init.d/functions ]; then
|
|
|
|
. /etc/init.d/functions
|
|
|
|
elif [ -f /etc/rc.d/init.d/functions ] ; then
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
else
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Source networking configuration.
|
|
|
|
. /etc/sysconfig/network
|
|
|
|
|
|
|
|
# Check that networking is up.
|
|
|
|
[ ${NETWORKING} = "no" ] && exit 0
|
|
|
|
|
|
|
|
# This is our service name
|
|
|
|
BASENAME=`basename $0`
|
|
|
|
if [ -L $0 ]; then
|
|
|
|
BASENAME=`find $0 -name $BASENAME -printf %l`
|
|
|
|
BASENAME=`basename $BASENAME`
|
|
|
|
fi
|
|
|
|
|
2015-02-23 15:28:37 +00:00
|
|
|
BIN=/usr/sbin/$BASENAME
|
|
|
|
|
2015-02-23 15:28:36 +00:00
|
|
|
CFG=/etc/$BASENAME/$BASENAME.cfg
|
|
|
|
[ -f $CFG ] || exit 1
|
2005-12-17 23:57:06 +00:00
|
|
|
|
2015-02-23 15:28:38 +00:00
|
|
|
PIDFILE=/var/run/$BASENAME.pid
|
2015-02-23 15:28:39 +00:00
|
|
|
LOCKFILE=/var/lock/subsys/$BASENAME
|
2015-02-23 15:28:38 +00:00
|
|
|
|
2005-12-17 23:57:06 +00:00
|
|
|
RETVAL=0
|
|
|
|
|
|
|
|
start() {
|
2015-02-23 15:28:40 +00:00
|
|
|
quiet_check
|
2005-12-17 23:57:06 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Errors found in configuration file, check it with '$BASENAME check'."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -n "Starting $BASENAME: "
|
2015-02-23 15:28:38 +00:00
|
|
|
daemon $BIN -D -f $CFG -p $PIDFILE
|
2005-12-17 23:57:06 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
2015-02-23 15:28:39 +00:00
|
|
|
[ $RETVAL -eq 0 ] && touch $LOCKFILE
|
2005-12-17 23:57:06 +00:00
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
echo -n "Shutting down $BASENAME: "
|
|
|
|
killproc $BASENAME -USR1
|
|
|
|
RETVAL=$?
|
|
|
|
echo
|
2015-02-23 15:28:39 +00:00
|
|
|
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
|
2015-02-23 15:28:38 +00:00
|
|
|
[ $RETVAL -eq 0 ] && rm -f $PIDFILE
|
2005-12-17 23:57:06 +00:00
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
2015-02-23 15:28:40 +00:00
|
|
|
quiet_check
|
2005-12-17 23:57:06 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Errors found in configuration file, check it with '$BASENAME check'."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
2009-05-01 13:49:56 +00:00
|
|
|
reload() {
|
2015-02-23 15:28:41 +00:00
|
|
|
if ! [ -s $PIDFILE ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2015-02-23 15:28:40 +00:00
|
|
|
quiet_check
|
2009-05-01 13:49:56 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Errors found in configuration file, check it with '$BASENAME check'."
|
|
|
|
return 1
|
|
|
|
fi
|
2015-02-23 15:28:38 +00:00
|
|
|
$BIN -D -f $CFG -p $PIDFILE -sf $(cat $PIDFILE)
|
2009-05-01 13:49:56 +00:00
|
|
|
}
|
|
|
|
|
2005-12-17 23:57:06 +00:00
|
|
|
check() {
|
2015-02-23 15:28:37 +00:00
|
|
|
$BIN -c -q -V -f $CFG
|
2005-12-17 23:57:06 +00:00
|
|
|
}
|
|
|
|
|
2015-02-23 15:28:40 +00:00
|
|
|
quiet_check()
|
|
|
|
$BIN -c -q -f $CFG
|
|
|
|
}
|
|
|
|
|
2005-12-17 23:57:06 +00:00
|
|
|
rhstatus() {
|
|
|
|
status $BASENAME
|
|
|
|
}
|
|
|
|
|
|
|
|
condrestart() {
|
2015-02-23 15:28:39 +00:00
|
|
|
[ -e $LOCKFILE ] && restart || :
|
2005-12-17 23:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
restart
|
|
|
|
;;
|
|
|
|
reload)
|
2009-05-01 13:49:56 +00:00
|
|
|
reload
|
2005-12-17 23:57:06 +00:00
|
|
|
;;
|
|
|
|
condrestart)
|
|
|
|
condrestart
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
rhstatus
|
|
|
|
;;
|
|
|
|
check)
|
|
|
|
check
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $BASENAME {start|stop|restart|reload|condrestart|status|check}"
|
2007-12-02 13:02:52 +00:00
|
|
|
exit 1
|
2005-12-17 23:57:06 +00:00
|
|
|
esac
|
|
|
|
|
2007-12-02 13:02:52 +00:00
|
|
|
exit $?
|