#!/bin/bash

lockfile /tmp/autoscreenshot_firefox.lock

export HOME=/var/www

/bin/env

/usr/bin/Xvfb :100 -screen 0 820x640x16 2>&1 &

/bin/sleep 5

export DISPLAY=:100

/usr/bin/firefox -width 820 -height 640 "$1" 2>&1 &
/bin/sleep 10
/usr/bin/import -window root "$2" 2>&1
/usr/bin/mogrify -crop '800x600+0+20' "$2" 2>&1

/bin/kill `jobs -p` 2>&1

rm -f /tmp/autoscreenshot_firefox.lock