#!/bin/sh # # chkconfig: 345 90 10 # description: Linux Kernel Live Usage Monitor # source function library . /etc/rc.d/init.d/functions prog=klive PYTHON=/usr/bin/python TWISTD=/usr/bin/twistd WORKDIR=/var/lib/klive PID=$WORKDIR/twistd.pid case "$1" in start) ps x | grep -q "[t]wistd -oy klive.tac" if [ $? -ne 1 ]; then gprintf "$prog: already running" echo exit 1 fi if [ -x $PYTHON -a -x $TWISTD ]; then cd $WORKDIR gprintf "Starting %s:" "$prog" $PYTHON $TWISTD -oy klive.tac touch /var/lock/subsys/$prog && success echo RETVAL=0 else failure echo RETVAL=1 fi ;; stop) gprintf "Stopping %s:" "$prog" if [ -r $PID ] ; then kill `cat $PID` && success || failure rm -f /var/lock/subsys/$prog echo RETVAL=0 else failure echo RETVAL=1 fi ;; restart) stop sleep 1 start RETVAL=0 ;; reload) restart ;; status) status $prog ;; *) gprintf "Usage: %s {start|stop|restart|reload|status}\n" "$0" RETVAL=1 esac exit $RETVAL