複数起動するシリーズの第2弾。 セッション保存用のmemcachedを別途起動する的なシナリオです。 あとでちゃんと書こう。。。
#!/bin/bash
#
# Init file for memcached
#
# Written by Dag Wieërs
#
# chkconfig: - 80 12
# description: Distributed memory caching daemon
#
# processname: memcached_session
# config: /etc/sysconfig/memcached_session
# config: /etc/memcached_session.conf
source /etc/rc.d/init.d/functions
### Default variables
PORT="11212"
USER="nobody"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
SYSCONFIG="/etc/sysconfig/memcached_session"
MEMCACHED="/usr/bin/memcached"
MEMCACHED_SESSION="/usr/bin/memcached_session"
### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
RETVAL=0
prog="memcached_session"
desc="Distributed memory caching"
start() {
echo "searching $prog"
if [ -e $MEMCACHED_SESSION ]
then
echo "$prog exist"
else
ln -s $MEMCACHED $MEMCACHED_SESSION
fi
echo -n $"Starting $desc ($prog): "
daemon $prog -d -p $PORT -u $USER -c $MAXCONN -m $CACHESIZE $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}
stop() {
echo -n $"Shutting down $desc ($prog): "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $desc ($prog): "
killproc $prog -HUP
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
RETVAL=$?
;;
reload)
reload
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac
exit $RETVAL