Suggestions for improvement are welcome. This is the first time I have written an init.d script
#!/bin/sh
# /etc/rc.d/init.d/zeo
# Startup script for Zope with ZEOCluster
#
# chkconfig: 345 80 20
# description: Zope, a web application server
# this works as is for a default universal plone linux install
#
# config: /opt/Plone-2.5/zeocluster/client$/etc/zope.conf
# Source function library.
. /etc/init.d/functions
RETVAL=0
# list zeo clients in the list below
zeoclients="client1 client2"
# this is for the default install path for 2.5.1
clusterpath="/opt/Plone-2.5/zeocluster"
prog="ZEOCluster"
start() {
echo -n $"Starting $prog: "
output=`${clusterpath}/server/bin/zeoctl start`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "start"; then
# success
touch /var/lock/subsys/$prog
success
echo
RETVAL=0
else
# failed
failure
echo
RETVAL=1
fi
for client in $zeoclients
do
echo -n $"Starting $client: "
output=`${clusterpath}/${client}/bin/zopectl start`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "start"; then
# success
touch /var/lock/subsys/zope${client}
success
echo
RETVAL=0
else
# failed
failure
echo
RETVAL=1
fi
done
return $RETVAL
}
stop() {
for client in $zeoclients
do
echo -n $"Stopping $client: "
output=`${clusterpath}/${client}/bin/zopectl stop`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "stop"; then
# success
rm /var/lock/subsys/zope${client}
success
echo
RETVAL=0
else
# failed
failure
echo
RETVAL=1
fi
done
echo -n $"Stopping $prog: "
output=`${clusterpath}/server/bin/zeoctl stop`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "stop"; then
# success
rm /var/lock/subsys/$prog
success
echo
RETVAL=0
else
# failed
failure
echo
RETVAL=1
fi
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
echo "ZEO Server:"
output=`${clusterpath}/server/bin/zeoctl status`
echo $output
for client in $zeoclients
do
echo "Zope Client" $client
output=`${clusterpath}/${client}/bin/zopectl status`
echo $output
done
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
RETVAL=2
esac
exit $RETVAL