summaryrefslogtreecommitdiff
path: root/scripts/fetch-intro.sh
blob: 54db7a9d31f414b1bd9236be341ef266347205bd (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/sh
# Installs a picture for the intro page: web/intro.jpg
#
# Nothing so specific is shipped with the repo — the page works with the title alone.
# Give this script a local image (best) or a URL:
#
#   ./scripts/fetch-intro.sh ~/pictures/session.jpg
#   ./scripts/fetch-intro.sh https://example.org/strug.jpg
#
# Whatever you choose must be yours to use: web/intro.jpg is not covered by this
# project's licence, and it is gitignored so it never ends up in a commit.
set -eu
[ $# -ge 1 ] || { sed -n '2,10p' "$0" | sed 's/^# \{0,1\}//'; exit 1; }
src=$1
dest=web/intro.jpg
case "$src" in
  http://*|https://*)
    curl -L --fail -A "Mozilla/5.0" -o "$dest" "$src"
    ;;
  *)
    [ -f "$src" ] || { echo "no such file: $src" >&2; exit 1; }
    cp "$src" "$dest"
    ;;
esac
echo "installed $dest ($(wc -c <"$dest") bytes) — rebuild the binary to embed it"