Here’s a nice use of linux find to locate all ssl certificate files on a filesystem stored in directories name /certificates that excludes pesky .svn results:


find . -path "*/certificates/*" -not \( -name .svn -prune \)

I recently used this technique for pulling all certificates that were scatterred throughout a svn repository. Taking this output you can then easily copy them to another location (say for production deployment)

find . -path "*/certificates/*" -not \( -name .svn -prune \) -exec cp '{}' ./deploy/dist/certificates ';'

To go one step further integrating this into an ANT build proved to be a pain in the butt.  The ant exec task was causing me alot of grief so ended up using antcontrib tasks like this:


<target name="distCerts"
description="Prepare folder with all certificates required for deployment.">
<delete  dir="${projectRoot}/deploy/dist/certificates"/>
<mkdir dir="${projectRoot}/deploy/dist/certificates"/>
<shellscript shell="sh" dir="${projectRoot}">
find ./servicegroup -path "*/certificates/*" -not \( -name .svn -prune \) -exec cp '{}' ./deploy/dist/certificates ';'
find ./deploy/certificates -path "*" -not \( -name .svn -prune \) -exec cp '{}' ./deploy/dist/certificates ';'
</shellscript>
</target>

… much easier!

Post to Twitter Tweet This Post