#!/bin/sh
# 
# ot-xmlmesh startup script
# chkconfig: 345 80 10
# description: Obtools xmlmesh server: ot-xmlmesh 

### BEGIN INIT INFO
# Provides: ot-xmlmesh
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Description: Obtools xmlmesh server: ot-xmlmesh
### END INIT INFO

# Source function library
. /etc/rc.d/init.d/functions

exec=/usr/sbin/ot-xmlmesh
prog=ot-xmlmesh
config=/etc/obtools/xmlmesh.cfg.xml

pidfile=/var/run/ot-xmlmesh.pid
lockfile=/var/lock/subsys/$prog

start() {
  [ -x $exec ] || exit 5
  [ -f $config ] || exit 6
  echo -n $"Starting Obtools xmlmesh server: ot-xmlmesh"
  daemon $exec
  retval=$?
  echo
  [ $retval -eq 0 ] && touch $lockfile
  return $retval
}

stop() {
  echo -n $"Stopping Obtools xmlmesh server: ot-xmlmesh"
  killproc -p $pidfile  ot-xmlmesh
  retval=$?
  echo
  [ $retval -eq 0 ] && rm -f $lockfile
  return $retval
}

restart() {
  stop
  start
}
reload() {
  retval=0
  return 
}
force_reload() {
  restart
}

rh_status() {
  status -p $pidfile $prog
}

rh_status_q() {
  rh_status > /dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
        exit 2
esac
exit $?

