forked from msimerson/Mail-Toaster-6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision-joomla.sh
executable file
·158 lines (126 loc) · 3.44 KB
/
provision-joomla.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/sh
# shellcheck disable=1091
. mail-toaster.sh || exit
# shellcheck disable=2016
export JAIL_CONF_EXTRA="
mount += \"$ZFS_DATA_MNT/joomla \$path/data nullfs rw 0 0\";"
install_php()
{
tell_status "installing PHP"
# curl so that Joomla updater works
stage_pkg_install php56 php56-curl php56-mysql
}
install_nginx()
{
stage_pkg_install nginx dialog4ports || exit
export BATCH=${BATCH:="1"}
stage_make_conf www_nginx 'www_nginx_SET=HTTP_REALIP'
stage_exec make -C /usr/ports/www/nginx build deinstall install clean
}
install_joomla()
{
install_php || exit
tell_status "installing Joomla 3"
stage_pkg_install joomla3
install_nginx || exit
}
configure_nginx()
{
if [ -f "ZFS_JAIL_MNT/joomla/usr/local/etc/nginx/nginx.conf" ]; then
tell_status "preserving nginx.conf"
cp "ZFS_JAIL_MNT/joomla/usr/local/etc/nginx/nginx.conf" \
"$STAGE_MNT/usr/local/etc/nginx/nginx.conf"
return
fi
local _nginx_conf="$STAGE_MNT/usr/local/etc/nginx/conf.d"
mkdir -p "$_nginx_conf" || exit
tee "$_nginx_conf/joomla.conf" <<EO_NGINX
set_real_ip_from $(get_jail_ip haproxy);
real_ip_header X-Forwarded-For;
client_max_body_size 25m;
location / {
root /usr/local/www/joomla3;
index index.php;
}
location ~ ^/(.+\.php)\$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root/\$1/\$2;
include fastcgi_params;
}
EO_NGINX
patch -d "$STAGE_MNT/usr/local/etc/nginx" <<'EO_NGINX_CONF'
--- nginx.conf-dist 2015-11-28 23:21:55.597113000 -0800
+++ nginx.conf 2015-11-28 23:43:25.508039518 -0800
@@ -34,16 +34,13 @@
server {
listen 80;
- server_name localhost;
+ server_name joomla;
#charset koi8-r;
#access_log logs/host.access.log main;
- location / {
- root /usr/local/www/nginx;
- index index.html index.htm;
- }
+ include conf.d/joomla.conf;
#error_page 404 /404.html;
EO_NGINX_CONF
}
configure_php()
{
local _php_ini="$STAGE_MNT/usr/local/etc/php.ini"
if [ -f "ZFS_JAIL_MNT/joomla/usr/local/etc/php.ini" ]; then
tell_status "preserving php.ini"
cp "ZFS_JAIL_MNT/joomla/usr/local/etc/php.ini" "$_php_ini"
return
fi
cp "$STAGE_MNT/usr/local/etc/php.ini-production" "$_php_ini" || exit
sed -i .bak \
-e 's/^;date.timezone =/date.timezone = America\/Los_Angeles/' \
-e '/^post_max_size/ s/8M/25M/' \
-e '/^upload_max_filesize/ s/2M/25M/' \
"$_php_ini"
}
configure_joomla()
{
configure_nginx
configure_php
_htdocs="$STAGE_MNT/usr/local/www/joomla3"
if [ -f "ZFS_JAIL_MNT/joomla/usr/local/www/joomla3/configuration.php" ]; then
echo "preserving joomla3 configuration.php"
cp "ZFS_JAIL_MNT/joomla/usr/local/www/joomla3/configuration.php" "$_htdocs/"
return
fi
if [ ! -f "$_htdocs/robots.txt" ]; then
tell_status "installing robots.txt"
tee "$_htdocs/robots.txt" <<EO_ROBOTS_TXT
User-agent: *
Disallow: /
EO_ROBOTS_TXT
fi
}
start_joomla()
{
tell_status "starting PHP"
stage_sysrc php_fpm_enable=YES
stage_exec service php-fpm start
tell_status "starting nginx"
stage_sysrc nginx_enable=YES
stage_exec service nginx start
}
test_joomla()
{
tell_status "testing joomla"
stage_exec sockstat -l -4 | grep :80 || exit
stage_exec sockstat -l -4 | grep :9000 || exit
echo "it worked"
}
base_snapshot_exists || exit
create_staged_fs joomla
start_staged_jail
install_joomla
configure_joomla
start_joomla
test_joomla
promote_staged_jail joomla