I've made something similar some time ago...

http://nsdrz.ath.cx/modules/news/article.php?storyid=11