blob: f659612c4a5c3a250e7ab857e49d6ccd987894a1 (
plain)
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
159
160
161
162
|
#!/bin/bash
function setconf() {
# 1: field / 2: value / 3: file
sed -i "s|^#*\s*\($1\).*|\1 = $2|" $3
}
# care about existing files
function installdir() {
local owner="$1"
local moddir="$2"
local modfile="$3"
local directory="$4"
mkdir -p "$directory"
find $directory -exec chown "$owner" {} \;
find $directory -type f -exec chmod "$modfile" {} \;
find $directory -type d -exec chmod "$moddir" {} \;
}
function installbasics() {
# create tempdirs and users from /usr/lib/*.d
systemd-sysusers
systemd-tmpfiles --create
installdir zarafa:zarafa 0700 0600 /var/log/zarafa
installdir zarafa:zarafa 0700 0600 /var/lib/zarafa
installdir zarafa:zarafa 0700 0600 /var/lib/zarafa/search
installdir zarafa:zarafa 0700 0600 /var/lib/zarafa/presence
# due to a bug/exception it's impossible to execute phps mapi modul without browsable dir
installdir zarafa:zarafa 0755 0600 /etc/zarafa
# fix missing python symlink for presence
if [[ ! -e "/usr/bin/python" ]];
then
ln -s /usr/bin/python2 /usr/bin/python
fi
}
post_install() {
installbasics
# CONFIG
# => defaults
for cfg in /usr/share/doc/zarafa/example-config/*.cfg; do
install --backup=simple --suffix .pacsave -o zarafa -g zarafa -m 0600 ${cfg} /etc/zarafa
done
# => server.cfg
_mysql_password="$(< /dev/urandom tr -dc A-Za-z0-9 | head -c16)"
setconf "mysql_password" "${_mysql_password}" "/etc/zarafa/server.cfg"
# => ical.cfg
if [[ -e "/etc/localtime" ]];
then
setconf "server_timezone" "$(readlink -f /etc/localtime | sed 's|/usr/share/zoneinfo/||' | tr '_' ' ')" "/etc/zarafa/ical.cfg"
fi
# => presence.cfg
_presence_password="$(< /dev/urandom tr -dc A-Za-z0-9 | head -c16)"
setconf "server_secret_key" "${_presence_password}" "/etc/zarafa/presence.cfg"
# => optimization
echo "[....] Install optimizations"
/usr/share/doc/zarafa/zarafa-pietma/install-optimization.sh
echo "[DONE] Install optimizations"
# => mysql-database
if [[ ! -e "/.arch-chroot" ]] \
&& [[ -e "/var/lib/mysql" ]] \
&& [[ "$(ls -A /var/lib/mysql)" == "" ]];
then
echo "[....] Setup database"
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql || true
systemctl start mysqld
/usr/share/doc/zarafa/zarafa-pietma/install-mysql-secure.sh
mysql -u root -e "CREATE DATABASE IF NOT EXISTS zarafa;"
mysql -u root -e "GRANT ALL PRIVILEGES ON zarafa.* TO zarafa@localhost IDENTIFIED BY '${_mysql_password}';"
echo "[DONE] Setup database"
else
cat <<EOF
Please initialize MySQL:
$ mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
$ systemctl start mysqld
$ mysql_secure_installation
Please create Zarafa database:
$ mysql -u root -p
mysql> CREATE DATABASE IF NOT EXISTS zarafa;
mysql> GRANT ALL PRIVILEGES ON zarafa.* TO zarafa@localhost IDENTIFIED BY '${_mysql_password}';
EOF
fi
# => ssl-keys / -certificates
if [[ ! -e "/.arch-chroot" ]] \
&& [ ! -e "/etc/ssl/private/zarafa.key" ] \
&& [ ! -e "/etc/ssl/private/zarafa.crt" ] \
&& [ ! -e "/etc/ssl/private/zarafa.dh" ];
then
echo "[....] Setup SSL keys"
/usr/share/doc/zarafa/zarafa-pietma/install-ssl.sh
echo "[DONE] Setup SSL keys"
else
cat <<EOF
Please create SSL-Keys/ -Certificates
$ /usr/share/doc/zarafa/zarafa-pietma/install-ssl.sh
EOF
fi
cat <<EOF
Please start Zarafa-Server and create tables
$ systemctl start zarafa-server
Read More
https://wiki.archlinux.org/index.php/MySQL
https://pietma.com/run-and-access-zarafa/
https://pietma.com/optimize-zarafa-and-mysql-mariadb/
EOF
return 0
}
post_upgrade() {
local newPackageVersion="$1"
local oldPackageVersion="$2"
case "$oldPackageVersion" in
7.2.1*)
installbasics
# CONFIG
# => defaults
for cfg in /usr/share/doc/zarafa/example-config/*.cfg; do
install --backup=simple -o zarafa -g zarafa -m 0600 ${cfg} /etc/zarafa
done
echo "Please check /etc/zarafa for new configuration values!"
;;
*)
;;
esac
return 0
}
pre_remove() {
return 0
}
|