rendered paste body#!/usr/local/bin/bash
#*****************************************************
# #
# $comment: Solaris 10 HAProxy SMF Method script #
# $date: 21/11/06 : 12:50:32 #
# $author: cusgac #
# $rev: 0.01 #
# #
#*****************************************************
# File locations
PIDFILE=/var/run/haproxy.pid
HAPROXY=/usr/local/haproxy/bin
CONFIGFILE=/usr/local/haproxy/conf/haproxy.cfg
CONFIGDIR=/usr/local/haproxy/conf
case $1 in
'start')
echo "Starting HAProxy"
if [ -e $CONFIGFILE ]; then
$HAPROXY/haproxy -c -f $CONFIGDIR/haproxy.cfg
if [ $? -eq 0 ]; then
$HAPROXY/haproxy -D -f $CONFIGDIR/haproxy.cfg
else
echo "Could not validate $CONFIGFILE"
exit $SMF_EXIT_ERR_CONFIG
fi
else
echo "$CONFIGFILE not found!"
exit $SMF_EXIT_ERR_CONFIG
fi
;;
'restart')
echo "Restarting HAProxy"
if [ -e $CONFIGFILE ]; then
$HAPROXY/haproxy -c -f $CONFIGDIR/haproxy.cfg
if [ $? != 0 ]; then
echo "Could not validate $CONFIGFILE"
exit $SMF_EXIT_ERR_CONFIG
fi
else
echo "$CONFIGFILE not found!"
exit $SMF_EXIT_ERR_CONFIG
fi
if [ -e $PIDFILE ]; then
kill `cat $PIDFILE`
else
echo "$PIDFILE not found!"
exit $SMF_EXIT_ERR_PIDFILE
fi
$HAPROXY/haproxy -D -f $CONFIGFILE
;;
'stop')
echo "Stopping HAProxy"
if [ -e $PIDFILE ]; then
kill `cat $PIDFILE`
else
echo "$PIDFILE not found!"
fi
;;
'refresh')
echo "Rereading config file"
if [ ! -e $CONFIGFILE ]; then
echo "$CONFIGFILE does not exist!"
exit $SMF_EXIT_ERR_CONFIG
fi
if [ ! -e $PIDFILE ]; then
echo "$PIDFILE does not exist!"
else
$HAPROXY/haproxy -p $PIDFILE -sf `cat $PIDFILE`
fi
;;
esac