2011-04-04

MySQL Proxy 起動スクリプト

  1. #!/bin/sh  
  2. #  
  3. # mysql-proxy This script starts and stops the mysql-proxy daemon  
  4. #  
  5. # chkconfig: - 78 30  
  6. # processname: mysql-proxy  
  7. # description: mysql-proxy is a proxy daemon to mysql  
  8.   
  9. # Source function library.  
  10. . /etc/rc.d/init.d/functions  
  11.   
  12. PROXY_PATH=/opt/mysql-proxy/sbin  
  13.   
  14. prog="mysql-proxy"  
  15.   
  16. # Source networking configuration.  
  17. . /etc/sysconfig/network  
  18.   
  19. # Check that networking is up.  
  20. [ ${NETWORKING} = "no" ] && exit 0  
  21.   
  22. # Set default mysql-proxy configuration.  
  23. PROXY_OPTIONS="--daemon"  
  24. PROXY_PID=/var/run/mysql-proxy.pid  
  25.   
  26. # Source mysql-proxy configuration.  
  27. if [ -f /etc/sysconfig/mysql-proxy ] ; then  
  28.         . /etc/sysconfig/mysql-proxy  
  29. fi  
  30.   
  31. PATH=$PATH:/usr/bin:/usr/local/bin:$PROXY_PATH  
  32.   
  33. # By default it's all good  
  34. RETVAL=0  
  35.   
  36. # See how we were called.  
  37. case "$1" in  
  38.   start)  
  39.         # Start daemon.  
  40.         echo -n $"Starting $prog: "  
  41.         daemon $NICELEVEL $PROXY_PATH/mysql-proxy $PROXY_OPTIONS --pid-file $PROXY_PID  
  42.         RETVAL=$?  
  43.         echo  
  44.         if [ $RETVAL = 0 ]; then  
  45.                 touch /var/lock/subsys/mysql-proxy  
  46.         fi  
  47.         ;;  
  48.   stop)  
  49.         # Stop daemons.  
  50.         echo -n $"Stopping $prog: "  
  51.         killproc $prog  
  52.         RETVAL=$?  
  53.         echo  
  54.         if [ $RETVAL = 0 ]; then  
  55.                 rm -f /var/lock/subsys/mysql-proxy  
  56.                 rm -f $PROXY_PID  
  57.         fi  
  58.         ;;  
  59.   restart)  
  60.         $0 stop  
  61.         sleep 3  
  62.         $0 start  
  63.         ;;  
  64.   condrestart)  
  65.        [ -e /var/lock/subsys/mysql-proxy ] && $0 restart  
  66.        ;;  
  67.   status)  
  68.         status mysql-proxy  
  69.         RETVAL=$?  
  70.         ;;  
  71.   *)  
  72.         echo "Usage: $0 {start|stop|restart|status|condrestart}"  
  73.         RETVAL=1  
  74.         ;;  
  75. esac  
  76.   
  77. exit $RETVAL  

0 件のコメント:

コメントを投稿