aboutsummaryrefslogtreecommitdiff
path: root/moin/setup-moin.sh
diff options
context:
space:
mode:
Diffstat (limited to 'moin/setup-moin.sh')
-rwxr-xr-xmoin/setup-moin.sh34
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
3set -e -x
4
5export PATH="/usr/bin:$PATH"
6export 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.
11DATA_DIR="/srv/wiki/data"
12if [[ -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
18else
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
25fi
26
27if [[ "$1" == "/bin/sh" ]]; then
28 exec "$@"
29fi
30
31if [[ ! -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
34fi