Provide a generate-preview script that people can use to locally generate the wiki...
[sipb-www.git] / generate-preview.sh
1 #!/bin/bash
2
3 set -e
4
5 export IKIWIKI_PREVIEW_OUTPUT="$1"
6 if [ -z "$IKIWIKI_PREVIEW_OUTPUT" ]; then
7     echo "You must call this script as"
8     echo "./generate-preview.sh OUTPUT_DIR [IKIWIKI_INSTALL_ROOT]"
9     exit 1
10 fi
11
12 srcdir=$(pwd)
13 if [ -n "$2" ]; then
14     tmpoutdir="$2"
15 else
16     tmpdir=`mktemp -d`
17     tmpoutdir=`mktemp -d`
18     echo "Building ikiwiki source in $tmpdir"
19     echo "Building ikiwiki into $tmpoutdir"
20     trap 'rm -rf "$tmpdir"' 0
21     trap 'rm -rf "$tmpoutdir"' 0
22     cd "$tmpdir"
23     (cd "$srcdir/ikiwiki" && tar c .) | (cd "$tmpdir" && tar x)
24     ./Makefile.PL INSTALL_BASE="$tmpoutdir" PREFIX=
25     make install --old-file=docwiki
26 fi
27 cd "$srcdir"
28 export IKIWIKI_SHARE="$tmpoutdir/share/ikiwiki"
29 "$tmpoutdir"/bin/ikiwiki --setup "$srcdir"/ikiwiki.setup