File zope-python-2.4.init of Package zope-python-2.4
#! /bin/sh
# Copyright (c) 2004 SuSE Linux AG, Nuernberg, Germany.
#
# Authors: Michal Cihar <mcihar@suse.cz>
#
# init.d/zope
#
# and symbolic its link
#
# /usr/sbin/rczope
#
# System startup script for the Zope server
#
### BEGIN INIT INFO
# Provides: zope
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start Zope server.
### END INIT INFO
# Source Zope relevant things
. "/etc/sysconfig/zope-python-2.4"
INSTANCES="/var/opt/zope"
[ "$MANAGED_INSTANCES" ] || MANAGED_INSTANCES="ALL"
[ "$ZOPE_SYSCONFIG" ] || ZOPE_SYSCONFIG="yes"
[ "$ZOPE_THREADS" ] || ZOPE_THREADS="4"
[ "$ZOPE_HTTP_PORT" ] || ZOPE_HTTP_PORT="8080"
[ "$ZOPE_FTP" ] || ZOPE_FTP="yes"
[ "$ZOPE_FTP_PORT" ] || ZOPE_FTP_PORT="8021"
[ "$ZOPE_WEBDAV" ] || ZOPE_WEBDAV="yes"
[ "$ZOPE_WEBDAV_PORT" ] || ZOPE_WEBDAV_PORT="8088"
[ "$ZOPE_MONITOR" ] || ZOPE_MONITOR_PORT="no"
[ "$ZOPE_MONITOR_PORT" ] || ZOPE_MONITOR_PORT="8089"
if [ "$MANAGED_INSTANCES" = "ALL" ] ; then
MANAGED_INSTANCES="$(find "$INSTANCES" -follow -mindepth 1 -maxdepth 1 -type d|sed s@$INSTANCES/\\?@@)"
fi
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
updateinstanceconfig () {
# Should we manage configuration?
if [ "$ZOPE_SYSCONFIG" != "yes" ] ; then
return
fi
# Does zope.conf.in exists?
if [ ! -f "$INSTANCES/default/etc/zope.conf.in" ] ; then
echo
echo "$INSTANCES/default/etc/zope.conf.in does not exist, can not manage default instance configuration!"
return
fi
EXPR=''
if [ "$ZOPE_LANG" != "" ] ; then
EXPR="$EXPR s@#SYSCONFIG_LANG#@locale $ZOPE_LANG@;"
else
EXPR="$EXPR s@#SYSCONFIG_LANG#@@;"
fi
if [ "$ZOPE_THREADS" != "" ] ; then
EXPR="$EXPR s@#SYSCONFIG_THREADS#@zserver-threads $ZOPE_THREADS@;"
else
EXPR="$EXPR s@#SYSCONFIG_THREADS#@@;"
fi
if [ "$ZOPE_IP_ADDRESS" != "" ] ; then
EXPR="$EXPR s@#SYSCONFIG_IP_ADDRESS#@ip-address $ZOPE_IP_ADDRESS@;"
else
EXPR="$EXPR s@#SYSCONFIG_IP_ADDRESS#@@;"
fi
if [ "$ZOPE_DEBUG" = "yes" ] ; then
EXPR="$EXPR s@#SYSCONFIG_DEBUG#@debug-mode on@;"
else
EXPR="$EXPR s@#SYSCONFIG_DEBUG#@debug-mode off@;"
fi
SERVERS="<http-server>\\n address $ZOPE_HTTP_PORT\\n</http-server>\\n\\n"
if [ "$ZOPE_FTP" = "yes" ] ; then
SERVERS="$SERVERS<ftp-server>\\n address $ZOPE_FTP_PORT\\n</ftp-server>\\n\\n"
fi
if [ "$ZOPE_WEBDAV" = "yes" ] ; then
SERVERS="$SERVERS<webdav-source-server>\\n address $ZOPE_WEBDAV_PORT\\n</webdav-source-server>\\n\\n"
fi
if [ "$ZOPE_MONITOR" = "yes" ] ; then
SERVERS="$SERVERS<monitor-server>\\n address $ZOPE_MONITOR_PORT\\n</monitor-server>\\n\\n"
fi
EXPR="$EXPR s@#SYSCONFIG_SERVERS#@$SERVERS@;"
cat <<EOT > "$INSTANCES/default/etc/zope.conf"
###############################################################################
# WARNING: Some parts of this file were generated, see /etc/sysconfig/zope #
###############################################################################
EOT
sed -e "$EXPR" "$INSTANCES/default/etc/zope.conf.in" >> "$INSTANCES/default/etc/zope.conf"
}
forallinstances () {
for instance in $MANAGED_INSTANCES ; do
echo -n "$instance "
[ -d $instance ] || instance="$INSTANCES/$instance"
if [ ! -d $instance ] ; then
echo
echo 'Instance was not found!'
rc_failed
fi
if $instance/bin/zopectl $1 > /dev/null ; then
true
else
rc_failed
fi
done
}
forallinstancesstatus () {
TMPFILE=`mktemp`
# in case we won't find any instance running
rc_failed 3
for instance in $MANAGED_INSTANCES ; do
echo -n "$instance: "
[ -d $instance ] || instance="$INSTANCES/$instance"
if [ ! -d $instance ] ; then
echo
echo 'Instance was not found!'
rc_failed
fi
if $instance/bin/zopectl status > $TMPFILE ; then
cat $TMPFILE
if grep -q pid= $TMPFILE ; then
# at least one is running
rc_failed 0
fi
else
rc_failed
fi
done
rm -f $TMPFILE
}
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
case "$1" in
start)
echo -n "Starting zope, instances: "
updateinstanceconfig
forallinstances start
rc_status -v
;;
stop)
echo -n "Shutting down zope, instances: "
forallinstances stop
rc_status -v
;;
try-restart)
updateinstanceconfig
$0 stop >/dev/null && $0 restart
rc_status
;;
restart)
echo -n "Restart service zope, instances: "
updateinstanceconfig
forallinstances restart
rc_status -v
;;
force-reload)
echo -n "Reload service zope, instances: "
forallinstances reload
rc_status -v
;;
reload)
echo -n "Reload service zope, instances: "
updateinstanceconfig
forallinstances reload
rc_status -v
;;
status)
echo "Checking for zope instances:"
forallinstancesstatus
rc_status -v
;;
logrotate)
echo "Reopening zope logs:"
forallinstances logreopen
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload}"
exit 1
;;
esac
rc_exit