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
9 [[ -t 0 ]] || exec &>/tmp/website-$(date +%s).log
12 trap "rm -rf '$tmp'" EXIT INT
14 staging="$tmp/staging" # the temporary build dir
15 pubdir=${TARGET:-/srv/www/vhosts/www.exim.org} # publish here
17 if [[ $(git rev-parse --is-inside-work-tree) != true ]]
21 git --work-tree="$workdir" checkout -f refs/heads/master # FIXME: use the receiving branch
25 if ! test -d "$pubdir"
27 echo "Warning: $pubdir does not exist. Did you forget to set the TARGET env in \"local\" mode?" >&2
32 if getent group eximdev
33 then install -m 02775 -g eximdev -d "$staging"
34 else install -d "$staging"
37 cp -r --preserve=timestamps "$pubdir"/exim-+(html|pdf)-* "$staging/" ||:
40 latest=$(cd docbook && compgen -G '[45].*' | sort -V | tail -n1)
44 --spec docbook/[45]*/spec.xml \
45 --filter docbook/[45]*/filter.xml \
50 mv "$staging" "$pubdir.$$" # may take some time (tmp -> data volume)
51 mv "$pubdir" "$pubdir.$(date -Isecond)" # backup
52 mv "$pubdir.$$" "$pubdir" # should be fast
54 echo "*** updated into $pubdir"