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

root/mkzeowmp/trunk/mkzeowmp.sh

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