Archive for October, 2007

Ubuntu Linux: Generate Thumbnail Image of External URL

Wednesday, October 3rd, 2007

This was surprisingly a lot harder to figure out than I initially expected. I was doing a lot of searching and kept finding either solutions for windows or packages that cost money. To add to the problem, I needed a solution that ran in a command line only version of Linux (Ubuntu Server). I guess I was naive to think the PHP gd library would support this. After a lot of digging last night, I found webthumb. Getting it work was surprisingly easy using the instructions provided, just replace mozilla for firefox and add the xwd package:

Code:
apt-get install xvfb
apt-get install firefox
apt-get install netpbm
apt-get install xwd

wget http://www.boutell.com/webthumb/webthumb.tar.gz
tar xvzf webthumb.tar.gz
cd webth*
./webthumb http://www.sematopia.com/ | pnmscale -xysize 100 100 | pnmtojpeg > thumb.jpg

Enjoy

Apache SVN: Auto-Update Server Copy on Commit

Tuesday, October 2nd, 2007

It seems these days I spend more time figuring out annoying problems rather than doing any real work. The following gave me another big headache: Getting SVN to auto-update properly via it’s hooks. SVN provides you the ability to specify hooks after certain events occur with the repository in question. For example, say you have a live application under version control and you want SVN to auto-update the live copy (on the server) after every commit. I guess that makes sense, especially if you want to develop and test in your production environment, on the fly.

In the directory were your repository exists there should be a hooks directory. This directory includes a bunch of tmpl files that get called depending on the event that just occurred. The file that I cared about was the post-commit.tmpl file.

Assuming your running SVN using Apache, then most likely when your post-commit script gets called it will be executed using the user www-data. This is important because it means your repository needs to be checked out via the same user to ensure no permission problems occur. Assuming that OK, then add the following line to your post-commit.tmpl file:

Code:
/usr/bin/svn update <path to repo> --username xxxxxx --password xxxxxx

Hardcoding your SVN password in the file is probably not the best idea, but if your the only one who would have access to the file, then who cares. Notice how I put a full path to SVN, that’s because when the hook scripts get called all environment variables, etc. get removed. The next step, and probably most important, rename the file removing the .tmpl extension and change the ownership so the file becomes executable.

Code:
cp post-commit.tmpl post-commit
chmod +x post-commit

That should do it, so when you update your repository, SVN should auto-update your live working copy. Most likely you’ll run into problems, if so check the links below for more info.

Helpful Link #1
Helpful Link #2
Helpful Link #3

Your Ad Here