#!/bin/sh
# /etc/init.d/zeocluster
# Startup script for Zope with ZEOCluster
#
# adapted for Ubuntu paths, Plone 3.0 version and LSB functions
#
# description: Zope, a web application server
# this works as is for a default universal plone linux install
#
# config: /usr/local/plone/zeocluster/buildout.cfg

# LSB Source function library
. /lib/lsb/init-functions

RETVAL=0

# this is for the default install path for Plone-3.0-buildout
clusterpath="/usr/local/Plone/zeocluster"

prog="plone"

start() {
    log_begin_msg "Starting $prog zeo server..."
    ${clusterpath}/bin/plonectl start
    return $?
}

stop() {
    log_begin_msg "Stopping $prog zeo server..."
    ${clusterpath}/bin/plonectl stop
    return $?
}

restart() {
   stop
   start
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    echo `${clusterpath}/bin/plonectl status`
    ;;
  restart)
    restart
    ;;
  condrestart)
    [ -e /var/lock/$prog ] && restart
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|condrestart}"
    RETVAL=2
esac

exit $RETVAL
