-
Notifications
You must be signed in to change notification settings - Fork 0
/
dokuwiki-entrypoint.sh
50 lines (38 loc) · 1.08 KB
/
dokuwiki-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
function ensure_dir() {
dir_path="$1"
ownership="$2"
perm="$3"
if [ ! -d "${dir_path}" ]; then
mkdir -p "${dir_path}"
fi
# ensure ownership
if [ ! -z "${ownership}" ]; then
chown "${ownership}" -R "${dir_path}"
fi
# ensure permissions
if [ ! -z "${perm}" ]; then
chmod "${perm}" -R "${dir_path}"
fi
}
DOCROOT="/usr/share/nginx/html"
DATA_DIRS=( "pages" "attic" "meta" "media" "media_attic" "media_meta" "cache" "index" "locks" "tmp" )
for data_dir in "${DATA_DIRS[@]}"
do
ensure_dir "${DOCROOT}/data/${data_dir}"
done
if [ -d "${DOCROOT}/_conf" ]; then
# A bit of a hack, but DokuWiki keeps user/conf data in separate dir and is mixed with code :(
cp -r -n ${DOCROOT}/_conf/* "${DOCROOT}/conf"
fi
ensure_dir "${DOCROOT}/data" "www-data:www-data" "0700"
ensure_dir "${DOCROOT}/conf" "www-data:www-data" "0700"
ensure_dir "${DOCROOT}/inc" "www-data:www-data" "0700"
# Run PHP
if [ ! -d /run/php ]; then
mkdir /run/php
fi
php-fpm7.0 --daemonize -c /etc/php/7.0/fpm/php.ini
echo "Running nginx"
# Run nginx
nginx -g "daemon off;"