#!/bin/sh

# chkconfig: 345 15 85
# description: Startup and shutdown script for Jabber open source server.

JABBER_DIR=/opt/jabberd
export JABBER_DIR

case $1 in
'start' )
su - jabber -c $JABBER_DIR/jud/users-agent &
su - jabber -c "ps ux" | awk '/users-agent/ && !/awk/ {print $2}' > $JABBER_DIR/pid/jud.pid
;;
'stop' )
kill `cat $JABBER_DIR/pid/jud.pid`
rm -rf $JABBER_DIR/pid/jud.pid
;;
*)
echo "usage: `basename $0` {start|stop}"
esac 

