Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (27 sloc) 1.01 KB
#! /bin/bash
FILETYPES=( "*.html" "*.woff" "*.css" "*.jpg" "*.jpeg" "*.gif" "*.png" "*.js" )
# specify a list of directories to check recursively
DIRECTORIES="<%= node['wp_install']['server_root'] %>"
for currentdir in $DIRECTORIES
do
for i in "${FILETYPES[@]}"
do
find $currentdir -iname "$i" -exec bash -c 'PLAINFILE={};GZIPPEDFILE={}.gz; \
if [ -e $GZIPPEDFILE ]; then \
if [ `stat --printf=%Y $PLAINFILE` -gt `stat --printf=%Y $GZIPPEDFILE` ]; then \
echo "$GZIPPEDFILE outdated, regenerating"; \
if [ ${PLAINFILE##*.} = "png" ]; then \
echo "Optimizing $PLAINFILE"; \
optipng -o7 -quiet $PLAINFILE; \
fi; \
gzip -9 -f -c $PLAINFILE > $GZIPPEDFILE; \
fi; \
else echo "$GZIPPEDFILE is missing, creating it"; \
if [ ${PLAINFILE##*.} = "png" ]; then \
echo "Optimizing $PLAINFILE"; \
optipng -o7 -quiet $PLAINFILE; \
fi; \
gzip -9 -c $PLAINFILE > $GZIPPEDFILE; \
fi' \;
done
done