#!/bin/sh # # mysqlproxy init file for MySQL-Proxy # /etc/init.d/mysqlproxy: This script starts and stops the mysql-proxy daemon # # chkconfig: - 50 50 # description: The MySQL Proxy daemon init script # # processname: mysql-proxy # config: /etc/mysql-proxy/mysql-proxy.conf # Source function library. . /etc/rc.d/init.d/functions PROXY_PATH=/opt/mysql-proxy LUA_PATH=$PROXY_PATH/share/mysql-proxy/?.lua prog="mysql-proxy" # Source networking configuration . /etc/sysconfig/network # Check that networking is up [ ${NETWORKING} = "no" ] && exit 0 # Set default mysql-proxy configuration. declare -x PROXY_OPTIONS="" # Parse mysql-proxy configuration file if [ -f /etc/mysql-proxy/mysql-proxy.conf ] ; then exec 3<&0 exec < /etc/mysql-proxy/mysql-proxy.conf while read opt do # remove comments, tabs, and spaces opt=`echo $opt | sed "s/\#.*//;s/\t//g;s/ //g"` if [ -n "$opt" ] then PROXY_OPTIONS=$PROXY_OPTIONS" --$opt" fi done fi # Set a successful return value by default RETVAL=0 # See how we were called. case "$1" in start) # Start daemon. echo -n $"Starting $prog: " daemon $NICELEVEL $PROXY_PATH/sbin/mysql-proxy $PROXY_OPTIONS RETVAL=$? echo if [ $RETVAL = 0 ]; then touch /var/lock/subsys/mysql-proxy fi ;; stop) # Stop daemons. echo -n $"Stopping $prog: " killproc $prog RETVAL=$? echo if [ $RETVAL = 0 ]; then rm -f /var/lock/subsys/mysql-proxy rm -f $PROXY_PID fi ;; restart) $0 stop $2 sleep 3 $0 start $2 ;; status) status mysql-proxy RETVAL=$? ;; condrestart) [ -e /var/lock/subsys/mysql-proxy ] && restart || : *) echo "Usage: $0 {start|stop|restart|condrestart|status }" RETVAL=1 ;; esac exit $RETVAL