Index: mkzeowmp/trunk/mkzeowmp.sh =================================================================== --- (revision ) +++ mkzeowmp/trunk/mkzeowmp.sh (revision 9) @@ -1,0 +1,244 @@ +#!/bin/bash + +# +# Make a new ZEO instance with mount points +# and one client instance in the usual way; +# mix in Plone products while at it. +# +# This should really be a Python script instead of bash. +# Then the browser ID manager prefix could be modified and +# the mount point folders created for total automation. +# +# usage: mkzeowmp instance_name \ +# zeo_port \ +# zclient_port_base \ +# http_port \ +# webdav_port \ +# client_cpu_affinity \ +# [list of mount point names separated by spaces]* +# +# v1.0 Chris Calloway June 15, 2006 +# Copyright 2006 University of North Carolina at Chapel Hill +# Department of Marine Science +# All Rights Reserved +# + +set -e + +PYTHON_BASE=/usr/local/Python-2.4.4 +ZOPE_BASE=/usr/local/Zope-2.9.6 +ZOPE_INSTANCES=/var/lib/Zope-2.9.6 +ZOPE_MANAGER=zopemgr +ZOPE_OWNER=zopeown +ZOPE_RUNNER=zoperun +ZEO_NAME=zeo +ZCLIENT_NAME=zclient +ZCLIENT_INSTANCE=0 +PLONE_TARBALL_URI_PATH=http://plone.googlecode.com/files/ +PLONE_TARBALL_URI_FILE=Plone-2.5.2-1 +PLONE_TARBALL_URI_EXT=.tar.gz +PLONE_DIRECTORY=Plone-2.5.2-1 + +if [ $(whoami) != ${ZOPE_MANAGER} ] +then + echo You must be the Zope code base manager in order to run this script. + echo Also, never try to create Zope instances while root + echo or your permissions will not work. + + exit 1 +fi + +if [ ${#} -lt 6 ] +then + echo 'usage: mkzeowmp instance_name \' + echo ' zeo_port \' + echo ' zclient_port_base \' + echo ' http_port \' + echo ' webdav_port \' + echo ' client_cpu_affinity \' + echo ' [list of mount point names separated by spaces]*' + exit 1 +fi + +INSTANCE_NAME=${1} +shift +ZEO_PORT=${1} +shift +ZCLIENT_PORT_BASE=${1} +shift +HTTP_PORT=${1} +shift +WEBDAV_PORT=${1} +shift +CLIENT_CPU_AFFINITY=${1} +shift + +count=$# +i=0 +while (( i < count )) +do + MOUNT_POINTS[ i++ ]=$1 + shift +done + +echo -n Please enter the Zope instance owner\'s password: +stty_orig=$(stty -g) +stty -echo +read ZOPE_OWNER_PASSWORD +stty $stty_orig +echo +echo -n Please enter the Zope instance owner\'s password again: +stty_orig=$(stty -g) +stty -echo +read ZOPE_OWNER_PASSWORD_TEST +stty $stty_orig +echo + +if [ ${ZOPE_OWNER_PASSWORD} != ${ZOPE_OWNER_PASSWORD_TEST} ] +then + echo Sorry, the passwords do no match. Try again. + exit 1 +fi + +${PYTHON_BASE}/bin/python ${ZOPE_BASE}/bin/mkzeoinstance.py \ + ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME} \ + ${ZEO_PORT} + +${PYTHON_BASE}/bin/python ${ZOPE_BASE}/bin/mkzopeinstance.py \ + -d ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE} \ + -u ${ZOPE_OWNER}:${ZOPE_OWNER_PASSWORD} + +chmod g+w ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/log/ \ + ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/var/ \ + ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/log/ \ + ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/var/ + +TEMPDIR=$(mktemp -d /tmp/${$}.XXXXXXXXXX) +TEMP=${TEMPDIR}/${0}.${$} + +cat > ${TEMP} <<-EOF + { + s/\# user zope/user ${ZOPE_RUNNER}/ + //,/<\/filestorage>/c\\ +EOF + +cat >> ${TEMP} <<-EOF + \\ + path $(echo '$INSTANCE')/var/Data.fs\\ + \\ +EOF + +if [ ${#MOUNT_POINTS[0]} -gt 0 ] +then + for MOUNT_POINT in "${MOUNT_POINTS[@]}" + do + cat >> ${TEMP} <<-EOF + \\ + path $(echo '$INSTANCE')/var/$(echo ${MOUNT_POINT:0:1} | tr a-z A-Z )${MOUNT_POINT:1}.fs\\ + \\ +EOF + done +fi + +cat >> ${TEMP} <<-EOF + + } +EOF + +sed -i -f ${TEMP} ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/etc/zeo.conf + +rm -rf ${TEMPDIR} + +TEMPDIR=$(mktemp -d /tmp/${$}.XXXXXXXXXX) +TEMP=${TEMPDIR}/${0}.${$} + +cat > ${TEMP} <<-EOF + { + s/\# effective-user chrism/effective-user ${ZOPE_RUNNER}/ + s/\# port-base 1000/port-base ${ZCLIENT_PORT_BASE}/ + s/ address 8080/ address ${HTTP_PORT}/ + s/\# // + s/\# address 1980/ address ${WEBDAV_PORT}/ + s/\# <\/webdav-source-server>/<\/webdav-source-server>/ + s/\# // + s/\# MY_PRODUCT_ENVVAR foobar/ ZOPE_PROCESS_AFFINITY ${CLIENT_CPU_AFFINITY}/ + s/\# <\/environment>/<\/environment>/ + /$(echo '^')/,/$(echo '^')<\/zodb_db>/s/$(echo '^')/# /g + $(echo '$a')\\ +EOF + +cat >> ${TEMP} <<-EOF + \\ + mount-point /\\ + # ZODB cache, in number of objects\\ + cache-size 5000\\ + \\ + server localhost:${ZEO_PORT}\\ + storage main\\ + name mainzeostorage\\ + var $(echo '$INSTANCE')/../${ZEO_NAME}/var\\ + # ZEO client cache, in bytes\\ + cache-size 20MB\\ + # Uncomment to have a persistent disk cache\\ + # client zeomain\\ + \\ + \\ +EOF + +if [ ${#MOUNT_POINTS[0]} -gt 0 ] +then + for MOUNT_POINT in "${MOUNT_POINTS[@]}" + do + cat >> ${TEMP} <<-EOF + \\ + mount-point /${MOUNT_POINT}\\ + # ZODB cache, in number of objects\\ + cache-size 5000\\ + \\ + server localhost:${ZEO_PORT}\\ + storage ${MOUNT_POINT}\\ + name ${MOUNT_POINT}zeostorage\\ + var $(echo '$INSTANCE')/../${ZEO_NAME}/var\\ + # ZEO client cache, in bytes\\ + cache-size 20MB\\ + # Uncomment to have a persistent disk cache\\ + # client zeo${MOUNT_POINT}\\ + \\ + \\ +EOF + done +fi + +cat >> ${TEMP} <<-EOF + + } +EOF + +sed -i -f ${TEMP} ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/etc/zope.conf + +rm -rf ${TEMPDIR} + +mv ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/Products/ \ + ${ZOPE_INSTANCES}/${INSTANCE_NAME}/ +ln -sf ../Products/ ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/Products +cd ${ZOPE_INSTANCES}/${INSTANCE_NAME}/Products/ +wget ${PLONE_TARBALL_URI_PATH}${PLONE_TARBALL_URI_FILE}${PLONE_TARBALL_URI_EXT} +tar -xzvf ${PLONE_TARBALL_URI_FILE}${PLONE_TARBALL_URI_EXT} +chown ${ZOPE_MANAGER}:${ZOPE_MANAGER} ${PLONE_DIRECTORY} +cd ${PLONE_DIRECTORY} +mv * .. +cd .. +rmdir ${PLONE_DIRECTORY} +rm -rf Five +${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/bin/runzeo & \ +${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/bin/zopectl fg + +echo 'If there were no errors in the Zope logs, you may now run (as root):' +echo +echo ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZEO_NAME}/bin/zeoctl start +echo then +echo ${ZOPE_INSTANCES}/${INSTANCE_NAME}/${ZCLIENT_NAME}${ZCLIENT_INSTANCE}/bin/zopectl start +echo +echo login as ${ZOPE_OWNER}, change your browser ID manager prefix, and create your mount point folders. + +exit 0