# Copyright 1999-2002 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # $Header: S="${WORKDIR}/Zope-${PV}-src" DESCRIPTION="Zope is a web application platform used for building high-performance, dynamic web sites." HOMEPAGE="http://www.zope.org" SRC_URI="http://www.zope.org/Products/Zope/${PV}/Zope-${PV}-src.tgz" LICENSE="ZPL" SLOT="0" KEYWORDS="x86" DEPEND="virtual/glibc =dev-lang/python-2.1.3*" ZOPEDIR="${DESTTREE}/share/zope/${P}/" ZOPEDOC="${DESTTREE}/share/doc/zope/${P}/" CONFD_DIR="/etc/conf.d/" ZUID=zope ZGID=${ZUID}0 # Narrow the scope of ownership/permissions. # Security plan: # * ZUID is the superuser for all zope instances. # * ZGID is for a single instance's administration. # * Other's should not have any access to ${ZOPEDIR}, # because they can work through the Zope web interface. # This should protect our code/data better. #Parameters: # $1 = instance directory # $2 = group setup_security() { chown -R ${ZUID}:${2} ${1} chmod -R g+u ${1} chmod -R o-rwx ${1} chown root ${1}/var/ # needed if $ZOPE_OPTS='-u root' chmod +t ${1}/var/ } pkg_setup() { if ! groupmod ${ZGID} > /dev/null 2>&1 ; then groupadd ${ZGID} || die "Can not add ${ZGID} group!" fi if ! id ${ZUID} > /dev/null 2>&1 ; then useradd -d ${ZOPEDIR} -c "Zope dedicatedr-user" ${ZUID} \ || die "Can not add ${ZUID} user!" fi } src_compile() { python2.1 wo_pcgi.py || die "Failed to compile." } src_install() { dodir ${ZOPEDOC} cp -a LICENSE.txt README.txt ${D}${ZOPEDOC} cp -a doc/ ${D}${ZOPEDOC} # using '/etc/init.d/zope' rm -Rf start stop LICENSE.txt doc/ prepalldocs # copy the remaining contents of ${S} into the ${D}. dodir ${ZOPEDIR} cp -a . ${D}${ZOPEDIR} # Add a rc-script. exeinto /etc/init.d ; newexe ${FILESDIR}/${PV}/zope-r1.initd zope # Add a conf.d script. dodir /etc/conf.d echo "ZOPE_OPTS=\"-u zope\"" | \ cat - ${FILESDIR}/${PV}/zope.envd > ${D}${CONFD_DIR}zope # Fill in environmental variables sed -e "/ZOPE_HOME=/ c\\ZOPE_HOME=${ZOPEDIR}\\ " \ -e "/SOFTWARE_HOME=/ c\\SOFTWARE_HOME=${ZOPEDIR}/lib/python\\ " \ ${D}${CONFD_DIR}zope > ${D}${CONFD_DIR}zope.tmp mv ${D}${CONFD_DIR}zope.tmp ${D}${CONFD_DIR}zope # Useful link dosym ${ZOPEDOC}doc ${ZOPEDIR}doc setup_security ${D}${ZOPEDIR} ${ZGID} } pkg_postinst() { einfo "In order to execute Zope you must execute the following:" einfo "\tebuild /var/db/pkg/net-www/${PF}/${PF}.ebuild config" } INST_DIR= # RETURNS: # 0 = directory created or already exists # 1 = directory is ZOPEHOME setup_inst_home() { local RESULT=0 echo -n "Instance home [${ZOPEDIR}]: " ; read INST_DIR if [ -z "${INST_DIR}" ] ; then INST_DIR=${ZOPEDIR} RESULT=1 elif [ -d "${INST_DIR}" ] ; then echo "${REPLY} already exists." else mkdir ${INST_DIR} fi for n in Extensions Products import var ; do if [ ! -d "${INST_DIR}/${n}" ] ; then mkdir ${INST_DIR}/${n} ; fi done return ${RESULT} } # RETURNS: # 0 = Data.fs exists setup_data_fs() { local RESULT=0 if [ ! -e "${INST_DIR}/var/Data.fs" ] ; then cp ${ZOPEDIR}/var/Data.fs.in ${INST_DIR}/var/Data.fs RESULT=${?} else echo "Do nothing. Data.fs already exists in ${INST_DIR}/var" fi return ${RESULT} } # PARAMETERS: # $1 = ${ZBASE} # Globals: # ZGID is either default value(zope0) or the name of entered group. set_zgid() { local RESULT= while : ; do echo -n "Enter Zope group [${1}]: " ; read if [ -z "${REPLY}" ] ; then REPLY=${1} ; fi groupadd ${REPLY} RESULT=${?} if [ "${RESULT}" -eq 0 ] ; then ZGID=$REPLY ; break elif [ "${RESULT}" -eq 9 ] ; then echo -n "Use group \"${REPLY}\" [y|n]: " ; read -n 1 CHOICE if [ $(echo ${CHOICE} | tr a-z A-Z) = 'Y' ] ; then ZGID=${REPLY} ; break fi fi echo done echo } # Parameters: # $1 = $INST_DIR # $2 = $ZBASE (created in pkg_config) setup_rc() { local INITD="/etc/init.d/" echo -n "Enter RC script's name [${2}]: " ; read if [ -z "${REPLY}" ] ; then REPLY=${2} ; fi if [ ! -f "${REPLY}" ] ; then if [[ -f "${INITD}zope" && -f "${CONFD_DIR}zope" ]] ; then cp ${INITD}zope ${INITD}${REPLY} sed -e "/INSTANCE_HOME=/ c\\INSTANCE_HOME=${1}\\ " \ -e "/CLIENT_HOME=/ c\\CLIENT_HOME=${1}/var\\ " \ ${CONFD_DIR}zope > ${CONFD_DIR}${REPLY} else echo "Do nothing. ${INITD}zope and/or ${CONFD_DIR}zope doesn't exists." fi else echo "Do nothing. ${REPLY} already exists." fi echo ; einfo "If you want multiple zope instances running at the same time, Don't forget to set the ports in variable ZOPE_OPTS located in ${CONFD_DIR}${REPLY}" } # pkg_config() { local RESULT= echo ; einfo ">>> Create/modify Zope instance directory..." setup_inst_home RESULT=${?} ZBASE=$(basename ${INST_DIR}) setup_data_fs || die "Copying Data.fs unsuccessful." if [ "${RESULT}" -eq 0 ] ; then einfo ">>> Create/use zope group..." set_zgid ${ZBASE} echo ; einfo ">>> RC setup..." setup_rc ${INST_DIR} ${ZBASE} fi setup_security ${INST_DIR} ${ZGID} echo ; einfo ">>> Create inital user..." python2.1 ${ZOPEDIR}zpasswd.py ${INST_DIR}/inituser }