#! /bin/sh # # chkconfig: 345 55 45 # description: memcached compatible key value db. # processname: memcached # config: /etc/flared # pidfile: /var/lib/flare/flare.pid ### BEGIN INIT INFO # Provides: memcached # Required-Start: $network # Required-Stop: $network # Default-Start: 3 4 5 # Short-Description: memcached compatible key value db. # Description: memcached compatible key value db. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions RUN_INDEX=yes RUN_NODE=yes DAEMON_INDEX=/usr/bin/flarei DAEMON_NODE=/usr/bin/flared DAEMON_USER=flare DESC=flare DESC_INDEX=`basename $DAEMON_INDEX` DESC_NODE=`basename $DAEMON_NODE` NAME=flare NAME_INDEX=$DESC_INDEX NAME_NODE=$DESC_NODE CONF_INDEX=/etc/flare/flarei.conf CONF_NODE=/etc/flare/flared.conf DATA_INDEX=/var/lib/flare DATA_NODE=/var/lib/flare LOCK_FILE=/var/lock/subsys/flare test -x $DAEMON_INDEX || exit 0 test -x $DAEMON_NODE || exit 0 if [ -f /etc/sysconfig/flare ] ; then . /etc/sysconfig/flare fi start(){ echo "Starting $DESC: " start_index sleep 1 start_node echo "" } start_index() { if [ $RUN_INDEX = "yes" ]; then echo -n "Starting $DESC_INDEX: " daemon --user $DAEMON_USER --pidfile $DATA_INDEX/$NAME_INDEX.pid $DAEMON_INDEX -f $CONF_INDEX --daemonize RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $LOCK_FILE-index else echo "$DESC_INDEX disabled (skip starting)." fi } start_node() { if [ $RUN_NODE = "yes" ]; then echo -n "Starting $DESC_NODE: " daemon --user $DAEMON_USER --pidfile $DATA_NODE/$NAME_NODE.pid $DAEMON_NODE -f $CONF_NODE --daemonize RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $LOCK_FILE-node else echo "$DESC_NODE disabled (skip starting)." fi } stop() { echo "Stopping $DESC: " stop_node stop_index } stop_index() { if [ $RUN_INDEX = "yes" ]; then echo -n "Stopping $DESC_INDEX: " killproc -p $DATA_INDEX/$NAME_INDEX.pid $DAEMON_INDEX RETVAL=$? echo if [ $RETVAL -eq 0 ] ; then rm -f $DATA_INDEX/$NAME_INDEX.pid rm -f $LOCK_FILE-index fi else echo "$DESC_INDEX disabled (skip stopping)." fi } stop_node() { if [ $RUN_NODE = "yes" ]; then echo -n "Stopping $DESC_NODE: " killproc -p $DATA_NODE/$NAME_NODE.pid $DAEMON_NODE RETVAL=$? echo if [ $RETVAL -eq 0 ] ; then rm -f $DATA_NODE/$NAME_NODE.pid rm -f $LOCK_FILE-node fi gprintf "waiting 10 seconds so that flarei can detect the flared state...\n" sleep 10 else echo "$DESC_NODE disabled (skip stopping)." fi } reload() { echo "Reloading $DESC: " reload_index reload_node } reload_index() { if [ $RUN_INDEX = "yes" ]; then echo -n "Reloading $DESC_INDEX: " killproc -p $DATA_INDEX/$NAME_INDEX.pid $DAEMON_INDEX -HUP RETVAL=$? echo else echo "$DESC_INDEX disabled (skip reloading)." fi } reload_node() { if [ $RUN_NODE = "yes" ]; then echo -n "Reloading $DESC_NODE: " killproc -p $DATA_NODE/$NAME_NODE.pid $DAEMON_NODE -HUP RETVAL=$? echo else echo "$DESC_NODE disabled (skip reloading)." fi } restart() { stop start } restart_index() { if [ $RUN_INDEX = "yes" ]; then stop_index start_index else echo "$DESC_INDEX disabled (skip restarting)." fi } restart_node() { if [ $RUN_NODE = "yes" ]; then stop_node start_node else echo "$DESC_NODE disabled (skip restarting)." fi } case "$1" in start) start ;; start-index) start_index ;; start-node) start_node ;; stop) stop ;; stop-index) stop_index ;; stop-node) stop_node ;; reload) reload ;; reload-index) reload-index ;; reload-node) reload-node ;; restart) restart ;; restart-index) restart_index ;; restart-node) restart_node ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|start-index|start-node|stop|stop-index|stop-node|restart|restart-index|restart-node|reload|reload-index|reload-node}" >&2 exit 1 ;; esac exit 0