forked from msimerson/Mail-Toaster-6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision-mediawiki.sh
executable file
·138 lines (110 loc) · 2.86 KB
/
provision-mediawiki.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh
# shellcheck disable=1091
. mail-toaster.sh || exit
export JAIL_START_EXTRA=""
export JAIL_CONF_EXTRA=""
mt6-include 'php'
mt6-include nginx
install_mediawiki()
{
assure_jail mysql
install_php 72 "ctype dom fileinfo hash iconv intl gd json mbstring mysqli openssl readline session sockets xml xmlreader zlib"
install_nginx
stage_pkg_install dialog4ports mysql57-client
stage_port_install www/mediawiki131-php72
mkdir -p "$STAGE_MNT/var/cache/mediawiki"
chown 80:80 "$STAGE_MNT/var/cache/mediawiki"
}
configure_nginx_server()
{
local _datadir="$ZFS_DATA_MNT/mediawiki"
if [ ! -d "$_datadir/etc" ]; then mkdir "$_datadir/etc"; fi
if [ -f "$_datadir/etc/nginx-locations.conf" ]; then
tell_status "preserving /data/etc/nginx-locations.conf"
return
fi
tell_status "saving /data/etc/nginx-locations.conf"
tee "$_datadir/etc/nginx-locations.conf" <<'EO_WIKI'
server_name mediawiki;
location = /wiki {
rewrite ^/wiki$ /w/index.php?title=Main_Page;
}
location = /wiki/ {
rewrite ^/wiki/$ /w/index.php?title=Main_Page;
}
location /wiki/ {
alias /usr/local/www/mediawiki;
index index.php;
try_files $uri $uri/ @mw_rewrite;
}
location @mw_rewrite {
rewrite ^/wiki/$ /w/index.php?title=Main_Page;
rewrite ^/wiki/+(.*)$ /w/index.php?title=$1&$args;
}
location ~ ^/w/(.+\.php)$ {
alias /usr/local/www/mediawiki/;
include /usr/local/etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_pass php;
}
location ^~ /(?:w|wiki)/maintenance/ {
return 403;
}
location ~* ^/w/(.+\.(?:js|css|png|jpg|jpeg|gif|ico))$ {
alias /usr/local/www/mediawiki/;
try_files $1 =404;
expires max;
log_not_found off;
}
location ~* ^/(?:w|wiki)/.+\.(js|css|png|jpg|jpeg|gif|ico)$ {
try_files $uri /w/index.php;
expires max;
log_not_found off;
}
location = /_.gif {
expires max;
empty_gif;
}
location ^~ ^/(?:wiki|w)/cache/ {
deny all;
}
location / {
try_files $uri $uri/ @rewrite;
}
EO_WIKI
}
configure_mediawiki()
{
configure_php mediawiki
configure_nginx mediawiki
configure_nginx_server
if [ -f "$ZFS_DATA_MNT/mediawiki/LocalSettings.php" ]; then
tell_status "installing LocalSettings.php"
cp "$ZFS_DATA_MNT/mediawiki/LocalSettings.php" \
"$STAGE_MNT/usr/local/www/mediawiki/" || exit
else
tell_status "no LocalSettings.php found in /data"
echo "Configure mediawiki and then copy LocalSettings.php"
echo "to /data so it gets installed automatically in the future."
fi
}
start_mediawiki()
{
start_php_fpm
start_nginx
}
test_mediawiki()
{
test_nginx || exit
test_php_fpm || exit
echo "it worked"
}
base_snapshot_exists || exit
create_staged_fs mediawiki
start_staged_jail mediawiki
install_mediawiki
configure_mediawiki
start_mediawiki
test_mediawiki
promote_staged_jail mediawiki