Automate SVN Export to Site w/ Bash Script

So at work we are finalizing the setup of a new server environment. The site is in PHP and the code is all in SVN. We were trying to decide what process to use to export the SVN contents to the site and that’s where I decided to learn how to write a bash script. This is my first and with some help from Jess we created the following script. The script does the following:

  • Does an info on the remote repo to get the revision number
  • Checks against local revision number which is stored in a file
  • If the revision numbers don’t match, it does a diff on both revisions and creates an list with the files that were changed
  • It then loops through each file and exports it to the site
  • Finally it stores the new revision number in the file
Feel free to use this and tweak it for your needs. This is our first draft, at this point we’ll start cleaning it up and adding more functionality but it works. Make sure to add a cron job to run it every so often and enjoy.
#!/bin/bash
# need to figure out what to do on files that need to be deleted
TARGET_DIR='/path/to/site'
REPO="svn://path.to.svn/repo"
REVISION_FILE='.revision'

echo "Getting info from remote repo"
REMOTE_VERSION=$(svn info $REPO | grep Revision)
REMOTE_VERSION=${REMOTE_VERSION: -4} # need to update to not hardcode 4 spaces back
CURRENT_VERSION=$(more $REVISION_FILE)

echo "Current Revision: $CURRENT_VERSION"
echo "Remote Revision: $REMOTE_VERSION"

if [ "$REMOTE_VERSION" -eq "$CURRENT_VERSION" ]
then
        echo "No export needed"
        exit 0
fi

echo "Getting diffs between revisions"
difflines=`svn diff --summarize -r $CURRENT_VERSION:$REMOTE_VERSION $REPO 2>&1 | awk '{print $2}'`

URL_LENGTH=${#REPO}

for i in `echo $difflines`; do
   FILENAME=${i:$URL_LENGTH}
   echo "svn export ${i} ${TARGET_DIR}${FILENAME}"
   svn export ${i} ${TARGET_DIR}${FILENAME}
done

echo "Saving revision number"
echo ${REMOTE_VERSION} > $REVISION_FILE

Two thumbs up for the wifey!

So my wife submitted a design for an eco-friendly bag contest for Kroger late last year. There were over 46,000 entries nation wide and she ended up winning second place!!! Great job sweets!

Starting next month (April), if you shop at Kroger, you may be able to purchase her bag from your local Kroger store. Here is an article that just came out today from a local magazine:

http://www.mdjonline.com/view/full_story/6794712/article-Marietta-graphic-designer-takes-2nd-in-Kroger-s-reusable-bag-competition?instance=home_news_1st_right

Feel free to visit Ashley’s blog and let her know she did a great job: Ashley’s Blog

My Dale Carnegie High Impact Presentations Experience/Review

Wow… I can’t stress enough how much improvement I made over the course of two days from taking this program from Dale Carnegie. Before I continue with this post I want to thank Julianne Rivera (Sr. Business Consultant) for encouraging me to take this class. Had it not been for her, my audience would have paid the price. I also want to thank Ercell Charles and April Farlow for being great coaches throughout this program and doing a fantastic job. This was my first time taking a Dale Carnegie class and it won’t be my last. Make sure to watch the before and after videos below to see why.

Why did I want to take this class?

Every time I receive a comment on this blog from my users letting me know that what I wrote helped them in some way, I find it extremely rewarding. I like being able to share my thoughts, knowledge, and experience with others and have decided I want to start presenting to local user groups to further expand my reach. I know my material, but my presentation skills were lacking. I have my first presentation coming up for the Atlanta PHP User Group and I want to make sure I don’t bore my audience. I did a quick dry run to test my presentation and it wasn’t very energetic… it was actually pretty dull. So when the opportunity to take a Dale Carnegie class on presentations presented itself, I took it. Continue reading “My Dale Carnegie High Impact Presentations Experience/Review”