#!/bin/sh
#
# Startup script for Zope server.
#
# $FreeBSD: ports/www/zope28/files/zope28.sh.in,v 1.2 2006/01/05 23:39:09 pav Exp $
#

# PROVIDE: zope28
# REQUIRE: DAEMON

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

. /etc/rc.subr

name="zope28"
rcvar=`set_rcvar`

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

zope28_start () {
    echo "Starting Zope 2.8:"
    zope28ctl "start"
}

zope28_stop () {
    echo "Stopping Zope 2.8:"
    zope28ctl "stop"
}

zope28_restart () {
    echo "Restarting Zope 2.8:"
    zope28ctl "restart"
}

  start_cmd="zope28_start"
   stop_cmd="zope28_stop"
restart_cmd="zope28_restart"

load_rc_config $name

: ${zope28_enable="NO"}
: ${zope28_instances=""}

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

run_rc_command "${cmd}"
