#!/bin/bash usage() { echo -e "Usage\t\t: `basename $0` alf-version" exit 1 } # start if [ $# -lt 1 ]; then usage fi # setup ALF_VERSION=$1 TOMCATS_DIR="/opt/alfresco/tomcats" VERSION_DIR="${TOMCATS_DIR}/${ALF_VERSION}" EXTRACTION_DIR="/tmp/alf-extract/${ALF_VERSION}" WEBAPP_DIR="${VERSION_DIR}/tomcat/webapps/alfresco" CLASSES_DIR="${WEBAPP_DIR}/WEB-INF/classes" LIB_DIR="${WEBAPP_DIR}/WEB-INF/lib" EXTRACTED_CONFIG_DIR="${EXTRACTION_DIR}/extracted-config" mkdir -p ${EXTRACTION_DIR} # unzip all jars in a temporary location, one folder per jar for jar in `ls -1 ${LIB_DIR}` ; do mkdir -p "${EXTRACTION_DIR}/$jar" && unzip -o -q "${LIB_DIR}/$jar" -d "${EXTRACTION_DIR}/$jar" ; done ; # create a root subfolder to hold all the extracted config files mkdir ${EXTRACTED_CONFIG_DIR} # locate 'alfresco' config directories in all the extracted jars and merge those config files in the extracted config folder cp -rp $(find ${EXTRACTION_DIR} -type d -name 'alfresco' | grep 'jar/alfresco' | xargs) ${EXTRACTED_CONFIG_DIR} # cleanup the extracted jars for jar in `ls -1 ${LIB_DIR}` ; do rm -r "${EXTRACTION_DIR}/$jar" ; done; # copy remaining config in alfresco webapp cp -rp "${CLASSES_DIR}/alfresco" ${EXTRACTED_CONFIG_DIR} echo "Done. Config for version ${ALF_VERSION} extracted in '${EXTRACTED_CONFIG_DIR}'."