]> git.pld-linux.org Git - packages/Zope.git/blobdiff - Zope.init
- spaces -> tabs
[packages/Zope.git] / Zope.init
index 1443d58917813498c7c9c587f3342a1287ef6a17..3e611ae4d8c09939a650a59b12907003f67d4dc6 100644 (file)
--- a/Zope.init
+++ b/Zope.init
@@ -1,11 +1,14 @@
 #!/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
@@ -23,53 +26,111 @@ else
        exit 0
 fi
 
-CLIENT_HOME=/var/lib/zope
+# 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
+}
 
-RETVAL=0
+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
+}
 
 # See how we were called.
 case "$1" in
   start)
-       if [ -f /var/lock/subsys/zope ]; then
-               msg_already_running Zope
-       else    
-               msg_starting Zope
-               busy
-               daemon zope-zserver
-               RETVAL=$?;
-               sleep 5
-               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/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
-               kill `cat ${CLIENT_HOME}/Z2.pid`
-               sleep 1
-               deltext
-               ok
-               rm -f /var/lock/subsys/zope >/dev/null 2>&1
-       else
-               msg_not_running Zope
-               exit 1
-       fi
+               msg_stopping "Zope"
+               started
+               stop_instances
+               RETVAL=$?
+               if [ "$RETVAL" = 0 ] ; then
+                       msg_stopping "Zope"
+                       ok
+               else
+                       msg_stopping "Zope"
+                       fail
+               fi
+               rm -f /var/lock/subsys/zope >/dev/null 2>&1
+        else
+               msg_not_running "Zope"
+                exit 1
+        fi
        ;;
   status)
-       if ps -p `cat ${CLIENT_HOME}/Z2.pid | awk '{print $2}'` >/dev/null; then
-               RETVAL=$?
-               nls "Zope (pid %s) is running" "`cat ${CLIENT_HOME}/Z2.pid`"
-       else     
-               msg_not_running Zope
-               RETVAL=1
-       fi
+       stat_instances
        ;;
-  restart|reload)
+  restart|force-reload)
        $0 stop
        $0 start
+       exit $?
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|reload|status}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|force-reload|status}"
+       exit 3
        ;;
 esac
 
This page took 0.074602 seconds and 4 git commands to generate.