NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/mkzeowmp/trunk/mkzeowmp.sh

Revision 12 (checked in by cbc, 17 years ago)

--

Line 
1 #!/bin/bash
2
3 #
4 # Make a new ZEO instance with mount points
5 #    and one client instance in the usual way;
6 #    mix in Plone products while at it.
7 #
8 # This should really be a Python script instead of bash.
9 #    Then the browser ID manager prefix could be modified and
10 #    the mount point folders created for total automation.
11 #
12 # usage: mkzeowmp instance_name       \
13 #                 zeo_port            \
14 #                 zclient_port_base   \
15 #                 http_port           \
16 #                 webdav_port         \
17 #                 client_cpu_affinity \
18 #                 [list of mount point names separated by spaces]*
19 #
20 # v1.1 Chris Calloway March 15, 2007
21 # Copyright 2006 University of North Carolina at Chapel Hill
22 # Department of Marine Science
23 # All Rights Reserved
24 #
25 # v.1.0 June 15, 2006 Initial
26 # v.1.1 March 15, 2007 Modified for Plone 2.5.2
27 #
28
29 set -e
30
31 PYTHON_BASE=/usr/local/Python-2.4.4
32 ZOPE_BASE=/usr/local/Zope-2.9.6
33 ZOPE_INSTANCES=/var/lib/Zope-2.9.6
34 ZOPE_MANAGER=zopemgr
35 ZOPE_OWNER=zopeown
36 ZOPE_RUNNER=zoperun
37 ZEO_NAME=zeo
38 ZCLIENT_NAME=zclient
39 ZCLIENT_INSTANCE=0
40 PLONE_TARBALL_URI_PATH=http://plone.googlecode.com/files/
41 PLONE_TARBALL_URI_FILE=Plone-2.5.2-1
42 PLONE_TARBALL_URI_EXT=.tar.gz
43 PLONE_DIRECTORY=Plone-2.5.2-1
44
45 if [ $(whoami) != ${ZOPE_MANAGER} ]
46 then
47         echo You must be the Zope code base manager in order to run this script.
48         echo Also, never try to create Zope instances while root
49         echo or your permissions will not work.
50
51         exit 1
52 fi
53
54 if [ ${#} -lt 6 ]
55 then
56         echo 'usage: mkzeowmp instance_name       \'
57         echo '                zeo_port            \'
58         echo '                zclient_port_base   \'
59         echo '                http_port           \'
60         echo '                webdav_port         \'
61         echo '                client_cpu_affinity \'
62         echo '                [list of mount point names separated by spaces]*'
63         exit 1
64 fi
65
66 INSTANCE_NAME=${1}
67 shift
68 ZEO_PORT=${1}
69 shift
70 ZCLIENT_PORT_BASE=${1}
71 shift
72 HTTP_PORT=${1}
73 shift
74 WEBDAV_PORT=${1}
75 shift
76 CLIENT_CPU_AFFINITY=${1}
77 shift
78
79 count=$#
80 i=0
81 while (( i < count ))
82 do
83         MOUNT_POINTS[ i++ ]=$1
84         shift
85 done
86
87 echo -n Please enter the Zope instance owner\'s password:
88 stty_orig=$(stty -g)
89 stty -echo
90 read ZOPE_OWNER_PASSWORD
91 stty $stty_orig
92 echo
93 echo -n Please enter the Zope instance owner\'s password again:
94 stty_orig=$(stty -g)
95 stty -echo
96 read ZOPE_OWNER_PASSWORD_TEST
97 stty $stty_orig
98 echo
99
100 if [ ${ZOPE_OWNER_PASSWORD} != ${ZOPE_OWNER_PASSWORD_TEST} ]
101 then
102         echo Sorry, the passwords do no match. Try again.
103         exit 1
104 fi
105
106 ${PYTHON_BASE}/bin/python ${ZOPE_BASE}/bin/mkzeoinstance.py              \
107                           ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME} \
108                           ${ZEO_PORT}
109
110 ${PYTHON_BASE}/bin/python ${ZOPE_BASE}/bin/mkzopeinstance.py                                       \
111                           -d ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE} \
112                           -u ${ZOPE_OWNER}:${ZOPE_OWNER_PASSWORD}
113
114 chmod g+w ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/log/                        \
115           ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/var/                        \
116           ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/log/ \
117           ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/var/
118
119 TEMPDIR=$(mktemp -d /tmp/${$}.XXXXXXXXXX)
120 TEMP=${TEMPDIR}/${0}.${$}
121
122 cat > ${TEMP} <<-EOF
123         {
124                 s/\# user zope/user ${ZOPE_RUNNER}/
125                 /<filestorage 1>/,/<\/filestorage>/c\\
126 EOF
127
128 cat >> ${TEMP} <<-EOF
129         <filestorage main>\\
130           path $(echo '$INSTANCE')/var/Data.fs\\
131         </filestorage>\\
132 EOF
133
134 if [ ${#MOUNT_POINTS[0]} -gt 0 ]
135 then
136         for MOUNT_POINT in "${MOUNT_POINTS[@]}"
137         do
138                 cat >> ${TEMP} <<-EOF
139                         <filestorage ${MOUNT_POINT}>\\
140                           path $(echo '$INSTANCE')/var/$(echo ${MOUNT_POINT:0:1} | tr a-z A-Z )${MOUNT_POINT:1}.fs\\
141                         </filestorage>\\
142 EOF
143         done
144 fi
145
146 cat >> ${TEMP} <<-EOF
147
148         }
149 EOF
150
151 sed -i -f ${TEMP} ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/etc/zeo.conf
152
153 rm -rf ${TEMPDIR}
154
155 TEMPDIR=$(mktemp -d /tmp/${$}.XXXXXXXXXX)
156 TEMP=${TEMPDIR}/${0}.${$}
157
158 cat > ${TEMP} <<-EOF
159         {
160                 s/\#    effective-user chrism/effective-user ${ZOPE_RUNNER}/
161                 s/\#     port-base 1000/port-base ${ZCLIENT_PORT_BASE}/
162                 s/  address 8080/  address ${HTTP_PORT}/
163                 s/\#  <webdav-source-server>/<webdav-source-server>/
164                 s/\#    address 1980/  address ${WEBDAV_PORT}/
165                 s/\#  <\/webdav-source-server>/<\/webdav-source-server>/
166                 s/\#    <environment>/<environment>/
167                 s/\#      MY_PRODUCT_ENVVAR foobar/  ZOPE_PROCESS_AFFINITY ${CLIENT_CPU_AFFINITY}/
168                 s/\#    <\/environment>/<\/environment>/
169                 /$(echo '^')<zodb_db main>/,/$(echo '^')<\/zodb_db>/s/$(echo '^')/# /g
170                 $(echo '$a')\\
171 EOF
172
173 cat >> ${TEMP} <<-EOF
174         <zodb_db main>\\
175           mount-point /\\
176           # ZODB cache, in number of objects\\
177           cache-size 5000\\
178           <zeoclient>\\
179             server localhost:${ZEO_PORT}\\
180             storage main\\
181             name mainzeostorage\\
182             var $(echo '$INSTANCE')/../${ZEO_NAME}/var\\
183             # ZEO client cache, in bytes\\
184             cache-size 20MB\\
185             # Uncomment to have a persistent disk cache\\
186             # client zeomain\\
187           </zeoclient>\\
188         </zodb_db>\\
189 EOF
190
191 if [ ${#MOUNT_POINTS[0]} -gt 0 ]
192 then
193         for MOUNT_POINT in "${MOUNT_POINTS[@]}"
194         do
195                 cat >> ${TEMP} <<-EOF
196                         <zodb_db ${MOUNT_POINT}>\\
197                           mount-point /${MOUNT_POINT}\\
198                           # ZODB cache, in number of objects\\
199                           cache-size 5000\\
200                           <zeoclient>\\
201                             server localhost:${ZEO_PORT}\\
202                             storage ${MOUNT_POINT}\\
203                             name ${MOUNT_POINT}zeostorage\\
204                             var $(echo '$INSTANCE')/../${ZEO_NAME}/var\\
205                             # ZEO client cache, in bytes\\
206                             cache-size 20MB\\
207                             # Uncomment to have a persistent disk cache\\
208                             # client zeo${MOUNT_POINT}\\
209                           </zeoclient>\\
210                         </zodb_db>\\
211 EOF
212         done
213 fi
214
215 cat >> ${TEMP} <<-EOF
216
217         }
218 EOF
219
220 sed -i -f ${TEMP} ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/etc/zope.conf
221
222 rm -rf ${TEMPDIR}
223
224 mv ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/Products/ \
225    ${ZOPE_INSTANCES}/${INSTANCE_NAME}/
226 ln -sf ../Products/ ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/Products
227 cd ${ZOPE_INSTANCES}/${INSTANCE_NAME}/Products/
228 wget ${PLONE_TARBALL_URI_PATH}${PLONE_TARBALL_URI_FILE}${PLONE_TARBALL_URI_EXT}
229 tar -xzvf ${PLONE_TARBALL_URI_FILE}${PLONE_TARBALL_URI_EXT}
230 chown ${ZOPE_MANAGER}:${ZOPE_MANAGER} ${PLONE_DIRECTORY}
231 cd ${PLONE_DIRECTORY}
232 mv * ..
233 cd ..
234 rmdir ${PLONE_DIRECTORY}
235 rm -rf Five
236 ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/bin/runzeo & \
237 ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/bin/zopectl fg
238
239 echo 'If there were no errors in the Zope logs, you may now run (as root):'
240 echo
241 echo ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/bin/zeoctl start
242 echo then
243 echo ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/bin/zopectl start
244 echo
245 echo login as ${ZOPE_OWNER}, change your browser ID manager prefix, and create your mount point folders.
246
247 exit 0
Note: See TracBrowser for help on using the browser.