2 # Usage: [TARGET=…] $0 [ref]
3 # - Build from either the ref (or refs/heads/master) or from the current working directory
4 # - Can be used as a post-update hook
10 trap "rm -rf '$tmp'" EXIT INT
12 staging="$tmp/staging" # the temporary build dir
13 pubdir=${TARGET:-/srv/www/vhosts/www.exim.org} # publish here
15 if [[ $(git rev-parse --is-inside-work-tree) != true ]]
19 git --work-tree="$workdir" checkout -f refs/heads/master # FIXME: use the receiving branch
23 if ! test -d "$pubdir"
25 echo "Warning: $pubdir does not exist. Did you forget to set the TARGET env in \"local\" mode?" >&2
30 if getent group eximdev
31 then install -m 02775 -g eximdev -d "$staging"
32 else install -d "$staging"
35 cp -r --preserve=timestamps "$pubdir"/exim-+(html|pdf)-* "$staging/" ||:
38 latest=$(cd docbook && compgen -G '[45].*' | sort -V | tail -n1)
42 --spec docbook/[45]*/spec.xml \
43 --filter docbook/[45]*/filter.xml \
48 mv "$staging" "$pubdir.$$" # may take some time (tmp -> data volume)
49 mv "$pubdir" "$pubdir.$(date -Isecond)" # backup
50 mv "$pubdir.$$" "$pubdir" # should be fast
52 echo "*** updated into $pubdir"