#!/bin/sh

# openerp-server	OpenERP server
#
# chkconfig: - 81 87
# description: OpenERP Server
# processname: openerp-server
# config: /etc/openerp-server.cfg
# pidfile: /var/run/openerp-server.pid

### BEGIN INIT INFO
# Provides:             openerp-server
# Required-Start:       $syslog
# Required-Stop:        $syslog
# Should-Start:         $network
# Should-Stop:          $network
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    OpenERP Server
# Description:          OpenERP is a complete ERP and CRM software.
### END INIT INFO


WITHOUT_RC_COMPAT=1

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

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/openerp-server
NAME=openerp-server
DESC=openerp-server

CONFIGFILE="/etc/openerp-server.cfg"
PIDFILE=/var/run/$NAME.pid
LOCKFILE=/var/lock/subsys/openerp-server

# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c $CONFIGFILE"

start()
{
	start_daemon --make-pidfile --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- $DAEMON $DAEMON_OPTS
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- python
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	status)
		status --pidfile "$PIDFILE" -- $DAEMON
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL


