#!/bin/sh
#
# Startup script for Zope server.
#
# Based on:
# $FreeBSD: ports/www/zope29/files/zope29.sh.in,v 1.1 2006/01/28 10:07:29 pav Exp $
#

# PROVIDE: zope2_10
# REQUIRE: DAEMON

# Define these zope2_10_* variables in one of these files:
#       /etc/rc.conf
#       /etc/rc.conf.local
#       /etc/rc.conf.d/zope2_10
#
# zope2_10_enable : bool
#   Enable Zope ("YES") or not ("NO", the default).
#
# zope2_10_instances : list
#   List of dirs with Zope's instances ("" by default).
#

. /etc/rc.subr

name="zope2_10"
rcvar=`set_rcvar`

zope2_10ctl () {
    for instance in $zope2_10_instances; do
        if [ -d ${instance} ]; then
            echo -n "  Zope instance ${instance} -> "
            ${instance}/bin/plonectl "$1"
        fi
    done
}

zope2_10_start () {
    echo "Starting Zope 2.10:"
    zope2_10ctl "start"
}

zope2_10_stop () {
    echo "Stopping Zope 2.10:"
    zope2_10ctl "stop"
}

zope2_10_restart () {
    echo "Restarting Zope 2.10:"
    zope2_10ctl "restart"
}

  start_cmd="zope2_10_start"
   stop_cmd="zope2_10_stop"
restart_cmd="zope2_10_restart"

load_rc_config $name

: ${zope2_10_enable="NO"}
: ${zope2_10_instances=""}

cmd="$1"
[ $# -gt 0 ] && shift
[ -n  "$*" ] && zope2_10_instances="$*"

run_rc_command "${cmd}"

