#!/bin/true # REMOTE SCRIPT (can not interact with user) # turn on debug mode (use 'set +x' to disable it) # set -x # {{VAR_NAME}} - template variables ERR_CODE_EXEC_ERROR="{{ERR_CODE_EXEC_ERROR}}" REMOTE_SITE_DIR="{{REMOTE_SITE_DIR}}" REMOTE_WWW_DIR="{{REMOTE_WWW_DIR}}" SVN_BIND_PORT="{{SVN_BIND_PORT}}" JAVA=$(which java) #if test $(uname -n) = "CatZilla"; then # echo "> ERROR: remote script should not be executed on CatZilla" 1>&2 # exit 1 #fi if test -z "$JAVA" ; then echo "> WARNING: can not found java" 1>&2 fi CURRENT_DIR=$(pwd) SITE_PARENT_DIR=$(dirname ${REMOTE_SITE_DIR}) SITE_DIR_NAME=$(basename ${REMOTE_SITE_DIR}) WWW_PARENT_DIR=$(dirname ${REMOTE_WWW_DIR}) WWW_DIR_NAME=$(basename ${REMOTE_WWW_DIR}) if test -n "$JAVA" ; then COMPRESSOR="${REMOTE_SITE_DIR}/bin/yuicompressor.jar" COMPRESSOR_OPT="-Xmx128m" echo "> pack js and css files ..." if test ! -f "$COMPRESSOR" ; then echo "> WARNING: can not found compressor file '${COMPRESSOR}'" 1>&2 else cd ${REMOTE_WWW_DIR} || exit ${ERR_CODE_EXEC_ERROR} FILE_LIST=$(find ./js -name '*.js' -type f | grep -Fv '.pack.' | grep -Fv '.merge.' | grep -Fv './js/ckeditor/') FILE_LIST="$FILE_LIST ./js/ckeditor/ckeditor.js" if test -n "$FILE_LIST" ; then echo "> packing js files ..." $JAVA $COMPRESSOR_OPT -jar $COMPRESSOR -o '.js$:.pack.js' $FILE_LIST 2>&1 fi FILE_LIST=$(find ./css -name '*.css' -type f | grep -Fv '.pack.' | grep -Fv '.merge.') if test -n "$FILE_LIST" ; then echo "> packing css files ..." $JAVA $COMPRESSOR_OPT -jar $COMPRESSOR -o '.css$:.pack.css' $FILE_LIST 2>&1 fi echo echo "> removing *.pack.merge.css files ..." find ${REMOTE_WWW_DIR}/css -type f -name '*.pack.merge.css' -exec rm -f {} \; echo echo "> removing *.pack.merge.js files ..." find ${REMOTE_WWW_DIR}/js -type f -name '*.pack.merge.js' -exec rm -f {} \; fi else echo "No Java installed. Please pack css and js files manually." fi cd ${REMOTE_WWW_DIR} || exit ${ERR_CODE_EXEC_ERROR} echo echo "done" echo exit 0