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

# PROVIDE: zeo3
# REQUIRE: DAEMON

# Define these zeo3_* variables in one of these files:
#       /etc/rc.conf
#       /etc/rc.conf.local
#       /etc/rc.conf.d/zeo3
#
# zeo3_enable : bool
#   Enable Zeo ("YES") or not ("NO", the default).
#
# zeo3_instances : list
#   List of dirs with Zeo's instances ("" by default).
#

. /etc/rc.subr

name="zeo3"
rcvar=`set_rcvar`

zeo3ctl () {
    for instance in $zeo3_instances; do
	if [ -d ${instance} ]; then
	    echo -n "  Zeo instance ${instance} -> "
	    ${instance}/bin/zeoctl "$1"
	fi
    done
}

zeo3_start () {
    echo "Starting Zeo 3:"
    zeo3ctl "start"
}

zeo3_stop () {
    echo "Stopping Zeo 3:"
    zeo3ctl "stop"
}

zeo3_restart () {
    echo "Restarting Zeo 3:"
    zeo3ctl "restart"
}

  start_cmd="zeo3_start"
   stop_cmd="zeo3_stop"
restart_cmd="zeo3_restart"

load_rc_config $name

: ${zeo3_enable="NO"}
: ${zeo3_instances=""}

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

run_rc_command "${cmd}"
