summaryrefslogtreecommitdiffstats
path: root/bin/comics/smbc
blob: a83e2427287a201b177540beb36701657f0e825f (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
26
27
#!/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"
tmp="$(mktemp -d)"
cd "${tmp}"

export LANG=C
export LC_ALL=C
export LC_TIME=C

wget ${wget_args} -O "$day.png" "http://www.smbc-comics.com/comics/`date  -d "$daysago days ago 00:00:00" +%Y%m%d`.png"

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

rm -rf "${tmp}"