Virtual server monitor:Debian init.d file
From Revolution Linux OpenSource projects
For the backend to work in Debian, you will need to replace /etc/init.d/vsmon-backend with the following file :
#!/bin/sh
#---------------------------------------------------------------
# Project : VServerMonitor
# Module : initscripts
# File : vsmon-backend
# Version : $Id$
# Author : Guillaume Pratte
# Created On : Thu Aug 29 2006
#---------------------------------------------------------------
# chkconfig: 35 90 20
# description: VServerMonitor backend.
#---------------------------------------------------------------
# Source function library.
#. /etc/rc.d/init.d/functions
DESCRIPTION="VServerMonitor backend"
BASEDIR="/usr/lib/python2.4/site-packages/vsmon/backend"
MAIN="backend.py"
PROGNAME="vsmon-backend"
PID="/var/run/${PROGNAME}.pid"
PY="/usr/bin/python"
ret=1
case $1 in
start)
echo Starting $DESCRIPTION
pid_in_memory=`/usr/sbin/chcontext --ctx 1 ps auwwwwx | grep $MAIN | grep -v grep | awk '{print $2}'`
if [ -n "$pid_in_memory" ]; then
echo failure
echo
echo "Program is running.\n"
exit
fi
chcontext --ctx 1 $PY $BASEDIR/$MAIN &
pid_started=$!
sleep 1
pid_in_memory=`/usr/sbin/chcontext --ctx 1 ps auwwwwx | grep $MAIN | grep -v grep | awk '{print $2}'`
if [ "$pid_in_memory" = "$pid_started" ]; then
echo $pid_started > $PID
echo success
echo
else
echo failure
echo
fi
;;
stop)
echo "Stopping $DESCRIPTION: "
if [ -r $PID ]; then
/usr/sbin/chcontext --ctx 1 kill `cat $PID` > /dev/null 2>&1
ret=$?
fi
if [ $ret = 0 ]; then
echo "$DESCRIPTION shutdown ok"
rm -f $PID
else
echo "$DESCRIPTION shutdown failed"
fi
echo
;;
reload)
;;
restart)
$0 stop
$0 start
ret=$?
;;
*)
echo "Usage: $(basename $0) {start|stop|restart}"
exit 0
;;
esac
exit $ret
