summaryrefslogtreecommitdiffstats
path: root/bin/comics/phdcomics
blob: f05304a0f3d91d9c0144ed9238220552424a250f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash

if [ -z "$1" -o ! -d "$1" ]; then
    echo "Usage: $0 <top-directory> [<days ago>]" 1>&2
    exit 1
fi

top="${1}"
shift

source "${top}/etc/settings.sh"

img="http://www.phdcomics.com/comics/archive/phd$(date -d "$daysago days ago" +%m%d%y)s.gif"

browser="Mozilla/4.06 [en] (X11; I; Linux 2.0.35 i586)"

echo "Versuche, $img zu laden"
wget -O "${image_dir}/$day.gif" --user-agent="$browser" "$img"

if [ -s "${image_dir}/$day.gif" ]; then
	rm -f "${comic_dir}/latest.gif"
	ln -s "${image_offset}/$day.gif" "${comic_dir}/latest.gif"
else
	rm -f "${image_dir}/$day.gif"
fi