Skip to content

mxm, IT's mad science

Sections
Personal tools
You are here: Home » Papers » Zope automatic startup script
Downloads
You can download mxm products here.

Due to it's technical and international nature, this section is in english.

Max M Has a blog too.

og er glad for mad

 

Zope automatic startup script

If you want to make Zope start automatically on a Linux machine, you need to put a startup script into '/etc/rc.d/init.d'. I remember finding this script somewhere on on the web. It is normally part of a .rpm file i think, but if you install from source you don't have it. So I put it up here. it probably needs som fixing to work in anything but redhat.
#!/bin/sh
# Startup script for Zope
#
# chkconfig: 345 80 20
# description: Zope, a web application server
#
# config: /etc/zope.conf

# Source function library.
. /etc/init.d/functions

RETVAL=0
zopectl="/home/zopeuser/instances/INSTANCE_HOME/bin/zopectl"
user="zopeuser"
prog="zope"

start() {
        output=`$zopectl -u $user start`
        # the return status of zopectl is not reliable, we need to parse
        # its output via substring match
        started=${output#*started}
	if [ "$started" == "$output" ]; then
            # failed
            action $"Starting $prog:  " /bin/false
            RETVAL=1
        else
            # success
            action $"Starting $prog:  " /bin/true
            touch /var/lock/subsys/$prog
            RETVAL=0
        fi
        return $RETVAL
}

stop() {
        output=`$zopectl -u $user stop`
        # the return status of zopectl is not reliable, we need to parse
        # its output via substring match
        stopped=${output#*stopped}
	if [ "$stopped" == "$output" ]; then
            # failed
            action $"Stopping $prog:  " /bin/false
            RETVAL=0
        else
            # success
            action $"Stopping $prog:  " /bin/true
            rm -f /var/lock/subsys/$prog
            RETVAL=1
        fi
        return $RETVAL
}

restart() {
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	$zopectl status
	;;
  restart)
	restart
	;;
  condrestart)
	[ -e /var/lock/subsys/$prog ] && restart
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart}"
	RETVAL=1
esac

exit $REVAL
 
Created by maxm
Last modified 2006-03-09 03:51 PM