#!/bin/sh

SOURCE="http://erlangen.leute.server.de/erlangenaktuell.jpg"

MYDIR=`dirname "$0"`

DATE=`date '+%Y%m%d'`
TIME=`date '+%H%M'`
DATETIME="$DATE-$TIME"
OUTNAME="$MYDIR/$DATE/webcam_erlangen_$DATETIME.jpg"
TMPNAME="/tmp/`basename "$OUTNAME"`"

mkdir -p "$DATE"

wget -O "$TMPNAME" "$SOURCE" >> /tmp/webcam_erlangen.log 2>&1
convert "$TMPNAME" -geometry 1024 -quality 85 "$OUTNAME"

rm "$TMPNAME"
