mdserver-web/plugins/haproxy/init.d/haproxy.tpl

119 lines
2.6 KiB
Smarty
Raw Normal View History

2022-08-28 11:02:37 -04: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
2022-08-29 00:08:02 -04:00
echo ".."
2022-08-28 11:02:37 -04:00
fi
# Source networking configuration.
2022-08-29 00:08:02 -04:00
if [ -f /etc/sysconfig/network ];then
. /etc/sysconfig/network
fi
2022-08-28 11:02:37 -04:00
# Check that networking is up.
2022-08-29 00:08:02 -04:00
# [ ${NETWORKING} = "no" ] && exit 0
2022-08-28 10:50:17 -04:00
2022-08-28 11:02:37 -04:00
HAPROXYDIR={$SERVER_PATH}/haproxy
BASENAME=haproxy
# This is our service name
#BASENAME=`basename $0`
#if [ -L $0 ]; then
# BASENAME=`find $0 -name $BASENAME -printf %l`
# BASENAME=`basename $BASENAME`
#fi
2022-08-28 11:26:02 -04:00
[ -f $HAPROXYDIR/etc/$BASENAME.conf ] || exit 1
2022-08-28 11:02:37 -04:00
RETVAL=0
start() {
2022-08-28 11:26:02 -04:00
$HAPROXYDIR/sbin/$BASENAME -c -q -f $HAPROXYDIR/etc/$BASENAME.conf
2022-08-28 10:50:17 -04:00
2022-08-29 00:08:02 -04:00
2022-08-28 11:02:37 -04:00
if [ $? -ne 0 ]; then
echo "Errors found in configuration file, check it with '$BASENAME check'."
return 1
2022-08-28 10:50:17 -04:00
fi
2022-08-28 11:02:37 -04:00
echo -n "Starting $BASENAME: "
2022-08-29 00:08:02 -04:00
daemon $HAPROXYDIR/sbin/$BASENAME -D -f $HAPROXYDIR/etc/$BASENAME.conf
2022-08-28 11:02:37 -04:00
RETVAL=$?
2022-08-29 00:08:02 -04:00
# echo
# [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
2022-08-28 11:02:37 -04:00
return $RETVAL
2022-08-28 10:50:17 -04:00
}
2022-08-28 11:02:37 -04:00
stop() {
echo -n "Shutting down $BASENAME: "
killproc $BASENAME -USR1
2022-08-28 10:50:17 -04:00
2022-08-28 11:02:37 -04:00
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASENAME
[ $RETVAL -eq 0 ] && rm -f /var/run/$BASENAME.pid
return $RETVAL
2022-08-28 10:50:17 -04:00
}
2022-08-28 11:02:37 -04:00
restart() {
2022-08-28 11:26:02 -04:00
$HAPROXYDIR/sbin/$BASENAME -c -q -f $HAPROXYDIR/etc/$BASENAME.conf
2022-08-28 11:02:37 -04:00
if [ $? -ne 0 ]; then
echo "Errors found in configuration file, check it with '$BASENAME check'."
return 1
fi
stop
start
2022-08-28 10:50:17 -04:00
}
2022-08-28 11:02:37 -04:00
reload() {
2022-08-28 11:26:02 -04:00
$HAPROXYDIR/sbin/$BASENAME -c -q -f $HAPROXYDIR/etc/$BASENAME.conf
2022-08-28 11:02:37 -04:00
if [ $? -ne 0 ]; then
echo "Errors found in configuration file, check it with '$BASENAME check'."
return 1
fi
2022-08-29 00:08:02 -04:00
$HAPROXYDIR/sbin/$BASENAME -D -f $HAPROXYDIR/$BASENAME.conf -p /var/run/$BASENAME.pid -sf $(cat /var/run/$BASENAME.pid)
2022-08-28 11:02:37 -04:00
}
check() {
2022-08-28 11:26:02 -04:00
$HAPROXYDIR/sbin/$BASENAME -c -q -V -f $HAPROXYDIR/etc/$BASENAME.conf
2022-08-28 11:02:37 -04:00
}
rhstatus() {
status $BASENAME
}
condrestart() {
[ -e /var/lock/subsys/$BASENAME ] && restart || :
}
2022-08-28 10:50:17 -04:00
# See how we were called.
case "$1" in
2022-08-28 11:02:37 -04:00
start) start ;;
stop) stop ;;
restart) restart;;
reload) reload;;
condrestart) condrestart ;;
status) rhstatus ;;
check) check ;;
*)
echo $"Usage: $BASENAME {start|stop|restart|reload|condrestart|status|check}"
exit 1
2022-08-28 10:50:17 -04:00
esac
2022-08-28 11:02:37 -04:00
2022-08-28 10:50:17 -04:00
exit $?