#!/bin/bash PROD_NAME= PROD_LST= MOD_DIR= # Parameters: # $1 = /path/to/zope/instance # Returns: # echos the /path/location if it finds it find_zope_products_dir() { if [[ -d "${1}/Products" && -d "${1}/var" && -d "${1}/import" && -d "${1}/Extensions" ]] ; then echo ${1}/Products fi } # Summary: # Parameters: # $1 = /path/to/zope/instance/Products # Returns: symlinks_add() { local RESULT=1 if [ -d "${1}" ] ; then for n in ${PROD_LST} ; do ln -fs ${MOD_DIR}${n} ${1} done RESULT=0 fi return ${RESULT} } # Summary: # Parameters: # $1 = /path/to/zope/instance/Products symlinks_del() { local RESULT=1 if [ -d "${1}" ] ; then for n in ${PROD_LST} ; do rm -f ${1}/${n} done RESULT=0 fi return ${RESULT} } # Main PROD_DIR=$(find_zope_products_dir ${2}) if [ "${#}" -ne 2 ] ; then echo Usage: echo -e "\t$(basename ${0}) add /path/to/zope/instance/" echo -e "\t$(basename ${0}) del /path/to/zope/instance/" echo -e "\nSummary:" echo -e "\tAdd or delete ${PROD_NAME} symbolic links in /path/to/zope/instance" elif [ -z ${PROD_DIR} ] ; then echo "Error: ${2} isn't a zope instance directory." exit 1 elif [ "${1}" = "add" ] ; then symlinks_add ${PROD_DIR} elif [ "${1}" = "del" ] ; then symlinks_del ${PROD_DIR} else echo "\"${1}\" is an unknown command. Should be 'add' or 'del'." fi