#!/bin/sh # # MySQL-Proxy Crontab v0.0.1 # [ proxychk.cron ] # # - Clint Alexander # # Every 5 min.: */5 * * * * /opt/mysql-proxy/sbin/proxychk.cron # # Define default values PROXYCFG="/etc/mysql-proxy/mysql-proxy.conf" PROXYCMD="/opt/mysql-proxy/sbin/mysql-proxy" PROXYPID="/var/run/mysql-proxy.pid" # Get options from config file if [ -f $PROXYCFG] ; then exec 3<&0 exec < $PROXYCFG while read line do # remove comments and remove tabs and spaces line=`echo $line | sed "s/\#.*//;s/\t//g;s/ //g"` optName=`echo $line | cut -d"=" -f1` optValue=`echo $option | cut -d"=" -f2` # if pid-file is defined, reset our default setting if [ "$optName" == "pid-file" ]; then PROXYPID=$optValue fi done fi if test -r $PROXYPID; then currpid=`cat $PROXYPID` if `kill -CHLD $currpid > /dev/null 2>&1`; then # no problems found, exiting exit 0; fi echo "" echo "MySQL-Proxy Notice on `hostname`:" echo "" echo " Found a stale pid file ($PROXYPID)." echo " -> Removing." echo "" rm -f $PROXYPID else echo "" echo "MySQL-Proxy Notice on `hostname`:" echo "" echo " Pid file not found ($PROXYPID)." echo "" fi echo " Restarting Mysql-Proxy service on `hostname`" echo "" /etc/init.d/mysqlproxy start echo " $0 exiting on `date`" echo ""