#!/bin/sh
#
# Startup script for Zope server.
#
# $FreeBSD: ports/www/zope3/files/zope3.sh.in,v 1.1 2006/01/23 21:11:16 pav Exp $
#

# PROVIDE: zope3
# REQUIRE: DAEMON

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

. %%RC_SUBR%%

name="zope3"
rcvar=`set_rcvar`

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

zope3_start () {
    echo "Starting Zope 3:"
    zope3ctl "start"
}

zope3_stop () {
    echo "Stopping Zope 3:"
    zope3ctl "stop"
}

zope3_restart () {
    echo "Restarting Zope 3:"
    zope3ctl "restart"
}

  start_cmd="zope3_start"
   stop_cmd="zope3_stop"
restart_cmd="zope3_restart"

load_rc_config $name

: ${zope3_enable="NO"}
: ${zope3_instances=""}

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

run_rc_command "${cmd}"
