Google
 

Friday, April 4, 2014

Automated SVN Deployment

After much gnashing of teeth, I've finally managed to build a bash script to automate deployment of my builds to production/staging for my in-progress website.

Note that the SVN hooks directory, as well as the working directories for the SVN must all be owned by the user that the hook script is executing as. In my case, the user was www-data, so I needed to run chown -R www-data /var/svn/repo/hooks, chown -R www-data /var/www/production, and chown -R www-data /var/www/staging. This also needs to be a post-commit script in order to function properly. Staging and production must also be manually set up as working directories. Staging should be on /trunk, but it doesn't particularly matter what production is set to, as it will soon change.

Now, my script isn't the most secure in the world, this I know. Mainly, because I've got the SVN username and password stored in plaintext in the script. At this point, though, I don't care. Here's the script!

#!/bin/sh
USER='username'
PASS='password'
REPOS="$1"
TXN="$2"

/usr/bin/svn update /var/www/staging --non-interactive --trust-server-cert --username-"$USER" --password="$PASS"

SVNLOOK=$(/usr/bin/svnlook history -r "$TXN" "$REPOS" /tags | grep "$TXN")

if [ -n "$SVNLOOK" ]; then
TAG=$(/usr/bin/svn ls "file://$REPOS@$TXN" "^/tags" | tail -1)
/usr/bin/svn switch "file://$REPOS/tags/$TAG" /var/www/production --username="$USER" --password="$PASS"
fi

What It Does:

$1 and $2 are the parameters automatically passed to the post-commit; the name of the repository and the revision number just committed, respectively. First, the staging site is updated to the most recent revision of the trunk (--non-interactive --trust-server-cert is used because my certificates have bad validation :P). Then, the script looks at the SVN history for the current revision, checking whether there's anything in the /tags directory. If there is a change to anything in /tags for this revision, we obtain the most recent folder, and switch to it on production.

The Result:

When you commit a change to the repository, the staging site is updated. When you tag a revision, the production site is updated. Thus, staging will always have the most recent (though possibly broken) build of the application, and production will always have production builds.

Tuesday, July 24, 2012

My Little Exalt

I have recently become a brony, watching My Little Pony: Friendship is Magic. The show's actually quite good.

After becoming a brony, I began to read MLP fanfiction on fimfiction.net. Then a friend of mine talked to me about his ideas for writing his own fanfic, and that spurred me on to write a fic of my own.

All of that boils down to the creation of My Little Exalt, a crossover fanfic between My Little Pony and Exalted. The ponies are in Creation. The Dowager is in Equestria. Pinkie Pie is a Sidereal exalt, Chosen of Serenity (y'know, the party exalted). Let the hijinks ensue.


So far I've published the prologue and two chapters, with many more planned in my crazy-dome. Wish me luck!

Wednesday, March 7, 2012

InkedPlaymats.com

Cruising around the MTG Salvation forums today, I discovered a topic about where to find quality playmats for Magic: the Gathering. One of the posters supplied a link to InkedPlaymats.com. You can purchase playmats with featured designs, generally for $20 plus shipping/tax, though some are listed at $25. But the real draw for the site is the ability to buy totally custom playmats for $25 ($35 if you want the InkedPlaymats guys to do a proof or any editing to your image).

You supply an image file (many file formats are accepted: PDF, CDR, EPS, AI, PSD, TIF, JPG, and even hardcopy via snail mail if you're willing to pay a $10 service fee), and they ship you a 24x14" playmat (machine washable!) with your image printed on it. The InkedPlaymats website has a downloadable PSD template with guides to help design the image.

The whole operation seems pretty sweet, and I've already ordered two playmats with two different images of my design. One mat goes with my five EDH decks (both complete and under construction). The other is a play on Skithiryx, the Blight Dragon; the image of the dragon itself has been adjusted to be bright and colorful, and a rainbow passes behind him. This is now "Skittles, the Bright Dragon". Along the bottom, the text reads "Taste the Infection". Along the left reads the same text, written in the Phyrexian language.