forked from msimerson/Mail-Toaster-6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision-rainloop.sh
executable file
·146 lines (121 loc) · 2.75 KB
/
provision-rainloop.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
#!/bin/sh
# shellcheck disable=1091
. mail-toaster.sh || exit
export JAIL_START_EXTRA=""
# shellcheck disable=2016
export JAIL_CONF_EXTRA=""
mt6-include 'php'
mt6-include nginx
install_rainloop()
{
install_php 56 || exit
install_nginx || exit
tell_status "installing rainloop"
stage_pkg_install rainloop-community
}
configure_nginx_server()
{
local _datadir="$ZFS_DATA_MNT/rainloop"
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_NGINX_SERVER'
server_name rainloop;
location / {
root /usr/local/www/rainloop;
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
root /usr/local/www/rainloop;
try_files $uri $uri/ /index.php?$query_string;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_keep_conn on;
include /usr/local/etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php;
}
location ~ /\.ht {
deny all;
}
location ^~ /data {
deny all;
}
EO_NGINX_SERVER
}
install_default_ini()
{
local _rlconfdir="$ZFS_DATA_MNT/rainloop/_data_/_default_"
local _dini="$_rlconfdir/domains/default.ini"
if [ -f "$_dini" ]; then
tell_status "preserving default.ini"
return
fi
if [ ! -d "$_rlconfdir/domains" ]; then
tell_status "creating default/domains dir"
mkdir -p "$_rlconfdir/domains" || exit
fi
tell_status "installing domains/default.ini"
tee -a "$_dini" <<EO_INI
imap_host = "dovecot"
imap_port = 143
imap_secure = "None"
imap_short_login = Off
sieve_use = Off
sieve_allow_raw = Off
sieve_host = ""
sieve_port = 4190
sieve_secure = "None"
smtp_host = "haraka"
smtp_port = 587
smtp_secure = "TLS"
smtp_short_login = Off
smtp_auth = On
smtp_php_mail = Off
white_list = ""
EO_INI
}
set_default_path()
{
local _rl_ver;
_rl_ver="$(pkg -j stage info rainloop-community | grep Version | awk '{ print $3 }')"
local _rl_root="$STAGE_MNT/usr/local/www/rainloop/rainloop/v/$_rl_ver"
tee -a "$_rl_root/include.php" <<'EO_INCLUDE'
function __get_custom_data_full_path()
{
return '/data/'; // custom data folder path
}
EO_INCLUDE
}
configure_rainloop()
{
configure_php rainloop
configure_nginx rainloop
configure_nginx_server
# for persistent data storage
chown -R 80:80 "$ZFS_DATA_MNT/rainloop/"
set_default_path
install_default_ini
}
start_rainloop()
{
start_php_fpm
start_nginx
}
test_rainloop()
{
test_nginx
test_php_fpm
echo "it worked"
}
base_snapshot_exists || exit
create_staged_fs rainloop
start_staged_jail rainloop
install_rainloop
configure_rainloop
start_rainloop
test_rainloop
promote_staged_jail rainloop