]> git.pld-linux.org Git - packages/Zope3.git/blame - Zope3.init
- R: rc-scripts added
[packages/Zope3.git] / Zope3.init
CommitLineData
0817c082
JK
1#!/bin/sh
2# Zope 3
3#
4# chkconfig: 345 90 10
5# description: Starts and stops the Zope instances
6#
7#
8
9
10# Source function library.
11. /etc/rc.d/init.d/functions
12
13# Source networking configuration.
14. /etc/sysconfig/network
15
16# Check that networking is up.
17if is_yes "${NETWORKING}"; then
18 if [ ! -f /var/lock/subsys/network ]; then
19 msg_network_down "Zope 3"
20 exit 1
21 fi
22else
23 exit 0
24fi
25
26# Zope settings.
27INSTANCES="main"
28[ -f /etc/sysconfig/zope3 ] && . /etc/sysconfig/zope3
29
30zope_ctl()
31{
32 message="$1"
33 instance_home="$2"
34 action="$3"
35 errors=""
36 typeset -i exit_code=0
37
38 show "$message"; busy
39 if ! cd "$instance_home/var" 2>/dev/null ; then
40 fail
41 log_failes "$message"
42 exit_code=1
43 errors="Cannot chdir to $instance_home/var"
44 elif errors=$(initlog -c "su -s/bin/sh zope -c \"$instance_home/bin/zopectl $action\"" 2>&1) ; then
45 ok
46 log_success "$message"
47 else
48 fail
49 log_failed "$message"
50 exit_code=1
51 fi
52 [ -n "$errors" ] && [ $exit_code -eq 1 ] && echo "$errors"
53 return $exit_code
54}
55
56start_instances()
57{
58 RETVAL=1
59 for INSTANCE_NAME in $INSTANCES
60 do
61 INSTANCE_HOME="/var/lib/zope3/$INSTANCE_NAME"
62
63 if [ -f /var/lock/subsys/"zope3-$INSTANCE_NAME" ]; then
64 msg_already_running "Zope 3 instance $INSTANCE_NAME"
65 continue
66 fi
67
68 zope_ctl "Starting Zope instance $INSTANCE_NAME" "$INSTANCE_HOME" start
69 RET=$?
70 if [ $RET -eq 0 ]; then
71 touch /var/lock/subsys/"zope3-$INSTANCE_NAME"
72 RETVAL=0
73 fi
74 done
75 return $RETVAL
76}
77
78stop_instances()
79{
80 RETVAL=1
81 for INSTANCE_NAME in $INSTANCES
82 do
83 INSTANCE_HOME="/var/lib/zope3/$INSTANCE_NAME"
84
85 if [ ! -f /var/lock/subsys/"zope3-$INSTANCE_NAME" ]; then
86 msg_not_running "Zope 3 instance $INSTANCE_NAME"
87 continue
88 fi
89
90 zope_ctl "Stopping Zope instance $INSTANCE_NAME" "$INSTANCE_HOME" stop
91
92 RET=$?
93 if [ $RET -eq 0 ]; then
94 RETVAL=0
95 fi
96 rm -f /var/lock/subsys/"zope3-$INSTANCE_NAME"
97 done
98 return $RETVAL
99}
100
101stat_instances()
102{
103 for INSTANCE_NAME in $INSTANCES
104 do
105 INSTANCE_HOME=/var/lib/zope3/"$INSTANCE_NAME"
106 echo -n "$INSTANCE_NAME: "
107 cd "$INSTANCE_HOME/var" && "$INSTANCE_HOME"/bin/zopectl status
108 done
109}
110
111# See how we were called.
112case "$1" in
113 start)
114 msg_starting "Zope 3"
115 started
116 start_instances
117 RETVAL=$?
118 if [ "$RETVAL" = 0 ] ; then
119 msg_starting "Zope 3"
120 ok
121 touch /var/lock/subsys/zope
122 else
123 msg_starting "Zope 3"
124 fail
125 fi
126 ;;
127 stop)
128 if [ -f /var/lock/subsys/zope ]; then
129 msg_stopping "Zope 3"
130 started
131 stop_instances
132 RETVAL=$?
133 if [ "$RETVAL" = 0 ] ; then
134 msg_stopping "Zope 3"
135 ok
136 else
137 msg_stopping "Zope 3"
138 fail
139 fi
140 rm -f /var/lock/subsys/zope >/dev/null 2>&1
141 else
142 msg_not_running "Zope 3"
143 exit 1
144 fi
145 ;;
146 status)
147 stat_instances
148 ;;
149 restart|force-reload)
150 $0 stop
151 $0 start
152 exit $?
153 ;;
154 *)
155 msg_usage "$0 {start|stop|restart|force-reload|status}"
156 exit 3
157 ;;
158esac
159
160exit $RETVAL
This page took 0.190125 seconds and 4 git commands to generate.