#!/bin/sh
+# zope
#
-# zope Start/Stop the Zope web-application server.
+# chkconfig: 345 90 10
+# description: Starts and stops the Zope instances
+# processname: z2.py
+# config: /etc/sysconfig/zope
#
-# chkconfig: 2345 72 72
-# description: zope is a web server specifically for handling \
-# HTTP requests to the Zope web-application service.
# probe: true
+#
+
# Source function library.
. /etc/rc.d/init.d/functions
exit 0
fi
-CLIENT_HOME=/var/lib/zope
-PIDFILE=${CLIENT_HOME}/Z2.pid
+# Zope settings.
+INSTANCES="main"
+[ -f /etc/sysconfig/zope ] && . /etc/sysconfig/zope
+
+
+start_instances()
+{
+ RETVAL=1
+ for INSTANCE_NAME in $INSTANCES
+ do
+ INSTANCE_HOME="/var/lib/zope/$INSTANCE_NAME"
+
+ if [ -f /var/lock/subsys/"zope-$INSTANCE_NAME" ]; then
+ msg_already_running "Zope instance $INSTANCE_NAME"
+ continue
+ fi
+
+ run_cmd "Starting Zope instance $INSTANCE_NAME" "$INSTANCE_HOME"/bin/zopectl start
+ RET=$?
+ if [ $RET -eq 0 ]; then
+ touch /var/lock/subsys/"zope-$INSTANCE_NAME"
+ RETVAL=0
+ fi
+ done
+ return $RETVAL
+}
+
+stop_instances()
+{
+ RETVAL=1
+ for INSTANCE_NAME in $INSTANCES
+ do
+ INSTANCE_HOME="/var/lib/zope/$INSTANCE_NAME"
+
+ if [ ! -f /var/lock/subsys/"zope-$INSTANCE_NAME" ]; then
+ msg_not_running "Zope instance $INSTANCE_NAME"
+ continue
+ fi
+
+ run_cmd "Stopping Zope instance $INSTANCE_NAME" "$INSTANCE_HOME"/bin/zopectl stop
+ RET=$?
+ if [ $RET -eq 0 ]; then
+ RETVAL=0
+ fi
+ rm -f /var/lock/subsys/"zope-$INSTANCE_NAME"
+ done
+ return $RETVAL
+}
+
+stat_instances()
+{
+ for INSTANCE_NAME in $INSTANCES
+ do
+ INSTANCE_HOME=/var/lib/zope/$INSTANCE_NAME
+ PIDFILE=$INSTANCE_HOME/var/Z2.pid
+ $INSTANCE_HOME/bin/zopectl status
+ done
+}
-RETVAL=0
# See how we were called.
case "$1" in
start)
- if [ ! -f /var/lock/subsys/zope ]; then
- msg_starting Zope
- daemon zope-zserver
- RETVAL=$?;
- sleep 5
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zope
- else
- msg_already_running Zope
- fi
+ msg_starting "Zope"
+ started
+ start_instances
+ RETVAL=$?
+ if [ "$RETVAL" = 0 ] ; then
+ msg_starting "Zope"
+ ok
+ touch /var/lock/subsys/zope
+ else
+ msg_starting "Zope"
+ fail
+ fi
;;
stop)
if [ -f /var/lock/subsys/zope ]; then
- msg_stopping Zope
- busy
- kill `cat ${CLIENT_HOME}/Z2.pid`
- RET=$?
- sleep 1
- [ $RET -eq 0 ] && ok || died
- rm -f /var/lock/subsys/zope ${CLIENT_HOME}/Z2.pid >/dev/null 2>&1
- else
- msg_not_running Zope
- fi
- ;;
- status)
- if [ -f $PIDFILE ]; then
- if ps -p `cat $PIDFILE` >/dev/null; then
- RETVAL=$?
- nls "%s (pid %s) is running..." Zope "`cat $PIDFILE`"
- else
- nls "%s dead but pid file exists" Zope
- RETVAL=1
- fi
- else
- if [ -f /var/lock/subsys/zope ]; then
- nls "%s dead but subsys locked" Zope
- RETVAL=2
+ msg_stopping "Zope"
+ started
+ stop_instances
+ RETVAL=$?
+ if [ "$RETVAL" = 0 ] ; then
+ msg_stopping "Zope"
+ ok
else
- nls "%s is stopped" Zope
- RETVAL=3
+ msg_stopping "Zope"
+ fail
fi
- fi
+ rm -f /var/lock/subsys/zope >/dev/null 2>&1
+ else
+ msg_not_running "Zope"
+ exit 1
+ fi
+ ;;
+ status)
+ stat_instances
;;
restart|force-reload)
$0 stop