#!/sbin/runscript # Zope rc-script for Gentoo Linux # Copyright 2002-2003 by Jason Shoemaker # Distributed under the terms of the GNU General Public License, v2 or later. # $Header: /home/cvsroot/gentoo-x86/net-zope/zope/files/2.6.4/zope.initd,v 1.1 2004/03/14 12:32:15 lanius Exp $ PIDFILE=${INSTANCE_HOME}/var/Z2.pid depend() { need net } # Since zope doesn't delete its .pid file when done, we have to determine its # status. Zope can be shutdown from a browser...this bypasses init.d. # Need to export these conf.d variables so that (env) can use them # Check if the file exist. then send file to stdout. # Parameters: # $1 = /path/to/pid.file # Outputs: read_pid() { if [ -r "${1}" ] ; then cat ${1} fi } # Check if we have a living PID, if not delete the PID FILE # Parameters: # $1 = /path/to/pid.file # Returns: # 0 if alive pid file remains # 1 if dead pid file removed # 2 if no pid file found check_pid_status() { local RESULT=2 # assume no pid file will be found local PID=$(read_pid ${1}) if [ -n "${PID}" ] ; then ps --no-headers ${PID} > /dev/null 2>&1 if [ "${?}" -eq 0 ] ; then RESULT=0 else rm -f ${1} RESULT=1 fi fi return ${RESULT} } # Parameters: # None # Returns: # 0 true # 1 false is_zope_dead() { local RESULT= check_pid_status ${PIDFILE} RESULT=${?} if [ "${RESULT}" -eq 0 ] ; then RESULT=10 fi if [ "${RESULT}" -eq 10 ] ; then RESULT=1 else RESULT=0 fi return ${RESULT} } status() { local RESULT= is_zope_dead RESULT=${?} if [ ${RESULT} ] ; then einfo "--> Zope is alive." else ewarn "--> Zope is dead." fi return ${RESULT} } start() { ebegin "Starting zope" start-stop-daemon --start --quiet --exec ${INSTANCE_HOME}/bin/runzope --pidfile ${PIDFILE} > ${EVENT_LOG_FILE} 2>&1 & eend $? "Failed to start zope" } stop() { local RESULT=0 ebegin "Stopping zope" if is_zope_dead ; then ewarn "Zope was already dead." else start-stop-daemon --stop --quiet --pidfile ${PIDFILE} RESULT=${?} fi eend ${RESULT} "Failed to stop zope" }