diff options
Diffstat (limited to 'moin/setup-moin.sh')
-rwxr-xr-x | moin/setup-moin.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/moin/setup-moin.sh b/moin/setup-moin.sh new file mode 100755 index 0000000..9237dea --- /dev/null +++ b/moin/setup-moin.sh | |||
@@ -0,0 +1,34 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | set -e -x | ||
4 | |||
5 | export PATH="/usr/bin:$PATH" | ||
6 | export PYTHONPATH="/srv/wiki-common/config" | ||
7 | |||
8 | # Allow users to specify the UID/GID in the environment but | ||
9 | # default these to the existing owner of the files in their | ||
10 | # mounted config, which should be sane. | ||
11 | DATA_DIR="/srv/wiki/data" | ||
12 | if [[ -d "$DATA_DIR" ]]; then | ||
13 | WIKIUID=${WIKIUID:-$(stat -c "%u" $DATA_DIR)} | ||
14 | WIKIGID=${WIKIGID:-$(stat -c "%u" $DATA_DIR)} | ||
15 | |||
16 | addgroup -g ${WIKIGID} -S wiki | ||
17 | adduser -u ${WIKIUID} -S -H -D -G wiki wiki | ||
18 | else | ||
19 | echo "No data directory found" | ||
20 | # This may be a debug session if a shell was requested otherwise it's a | ||
21 | # hard failure | ||
22 | if [[ "$1" != "/bin/sh" ]]; then | ||
23 | exit 1 | ||
24 | fi | ||
25 | fi | ||
26 | |||
27 | if [[ "$1" == "/bin/sh" ]]; then | ||
28 | exec "$@" | ||
29 | fi | ||
30 | |||
31 | if [[ ! -d "/srv/wiki/data/cache/xapian/index" ]]; then | ||
32 | /sbin/su-exec wiki:wiki \ | ||
33 | moin --config-dir /srv/wiki/config index build --mode=rebuild | ||
34 | fi | ||