update gitignore
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
/ireddocker/main.cvd
|
||||
/ireddocker/iredmail-env.conf
|
||||
/cert-dir/
|
||||
/mail-dir/
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# IREDDOCKER
|
||||
|
||||
This is the iRedMail docker image with included external ldap authentication and ability of usage an external mysql database.
|
||||
|
||||
## Install
|
||||
|
||||
Clone git repository to local folder
|
||||
|
||||
```git clone https://github.com/temasky/ireddocker.git```
|
||||
|
||||
## Configure
|
||||
|
||||
create file ```ireddocker/iredmail-env.conf```, like this:
|
||||
```
|
||||
LDAP_EXTERNAL_USE=YES
|
||||
LDAP_EXTERNAL_SERVER=#ldap server address
|
||||
LDAP_EXTERNAL_BINDPW=#bind password for ldap
|
||||
LDAP_EXTERNAL_BINDUSER=#bind user for ldap
|
||||
LDAP_EXTERNAL_BASE=#base dn for mail users
|
||||
FIRST_DOMAIN=#mail domain name
|
||||
MYSQLEXIST=#usage existing databse
|
||||
MYSQL_SERVER_ADDRESS=#server address of mysql external database
|
||||
MYSQL_ROOT_USER=#name for admin(root) user of external database
|
||||
MYSQL_ROOT_PASSWD=#passwd for admin(root) user of external database
|
||||
CUSTOM_CERT_USE:=NO#usage of external cert file. If Yes - place certfile in cert_dir directory, in global catalog
|
||||
CUSTOM_CERT_KEYFILE:=privkey.pem
|
||||
CUSTOM_CERT_CERTFILE:=fullchain.pem
|
||||
```
|
||||
## RUN
|
||||
|
||||
```docker-compose up -d```
|
||||
@@ -0,0 +1,9 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iJwEAAEKAAYFAl8WmosACgkQT06gquUmemySfQP/dV/jDbPss4PgodNkA5FDWM9Z
|
||||
yXslmrCLaXCHO1xvxnbMHq0YlHmCET0G62i4wTMwrA4tywcUixBnwPf9hePHAEq5
|
||||
/hLhRAlNcxJEE1/GZfIsa5jdSfX8rqpUNTc5uRzbZSELMdmMfQHO/k2Qx7qK/sR4
|
||||
S3ipnNuH9g2mCbTNYAs=
|
||||
=5rrH
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,31 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFazCCA1OgAwIBAgIURoVwUBseaj29O8U/GywQ6WAdgrYwDQYJKoZIhvcNAQEL
|
||||
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
|
||||
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMDA4MDQxMDU5MjBaFw0yMTA4
|
||||
MDQxMDU5MjBaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw
|
||||
HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggIiMA0GCSqGSIb3DQEB
|
||||
AQUAA4ICDwAwggIKAoICAQCz6O9SvdGK+EzczQdOtCHBHmmkieIskpwkG0/AZNOM
|
||||
mfbNf3XbjuquFYlvAeZRgKMgJpOhnwVqFJjripYh/EGMPh/KmPIDWk+UysLXEnfj
|
||||
/f87F4SnSp0KbswuDXMWTvgnZ6kwTAACimw1vplLG69srq5i5QJHt2QansetW2sv
|
||||
hOr3MhLFBPz/t6dynYHwSL59Eto5Z5WT0fjXv4IfsWqk6KV+dckUkIBYT2V+7+Rt
|
||||
4tT5x0AlHsBNCO/S7jgGuCioGnpTBQ6x6xX1ibqOeiudduAOQJFJQ390RoWLO5Lc
|
||||
/5IY5NAzMj+ELMA3DnK+AH0zx42lvbZOsTHD5nMVVgLTFP2NiKznfgzrT49OwMk8
|
||||
TaebnFeVtuW1191Da5vJNq/vY8KU9gB3W6An9fBWZ4g+HlnzEzEq+DztPCLbqM48
|
||||
lxoPVO7fGu6ESj2YyC2ct9mEmacyAyxriGbMQ8OlY+H+4gtlBbfkNfYttpb1gXrr
|
||||
upeEFHIkms0bVDnMe06p3RPg22cLL/yvkPmiBTir8XiTD9H3So4www+t5gkTaXvL
|
||||
F5lgNWOlTwvlwgBmsDzRFWBCpWZSFC6msR1HkyKPpPVg/t7cQB0zwMS6ttCHqy5f
|
||||
adymVAXMMl2EOzYaSyW0hxL5MfEWsqofWg/QmPqs/lqkDvd17DShLf2VAnWgne1u
|
||||
gQIDAQABo1MwUTAdBgNVHQ4EFgQUTQBfTMkXkeCEXHvbBHbvCIAFWaYwHwYDVR0j
|
||||
BBgwFoAUTQBfTMkXkeCEXHvbBHbvCIAFWaYwDwYDVR0TAQH/BAUwAwEB/zANBgkq
|
||||
hkiG9w0BAQsFAAOCAgEAc406Qvam6v+uRcX1ejIiMW5WRmZz7fxBJcc6tvWxb146
|
||||
h4Vy3qasLWWRwvy8bswnVskRTozy2XAWJeWtCkTcIPHUrE9Ptmcmd9Lsu4HRZ4Ul
|
||||
/770Od4jaAY3Pkj999rFhK2OseAt/m/eMm4KCOwd0LpaWuUUGjRlswE021dar6Yz
|
||||
gySJF7UlaAvzBUL+CQvzqzTyVnyy04fBc5gz74uVStp0fSldKn/JYJ8dH6BANZFt
|
||||
azEc9JFHmRWOlcP4+VAeHZHwjbJ3qw3GuHotx81fC1ukIEleV82ZPw/X/YCA1uMz
|
||||
5rGyPR/nXuN5mDSTRNiNoEsuVsZicb0EqOZ6YIVecJGQw5Axfa08qohypcM6sa24
|
||||
zbgzyyHu4oB0SRrK0ABO4edCn/TelSKVEkW3PpMpe+fSnyTiHD65DBsG0N7Y1xln
|
||||
35azUe8NH7afSjBI0nb4PsLp9pSM7HkUrmxfy0ZHofaLlNkdGo4MSqzHvROJAgAY
|
||||
Hc3jlYCujrRDktvpRUH3e13k2gKn3o2P+kkpBF+SzO5I+HAry3ASx1E92otA0J+h
|
||||
/uSndKUJaLlXXpn1f/HE9WZvdGUTUhiuE2YJ8efRpeE2NSgU64YntsDpyEL+r1d7
|
||||
LMpWGvTBnVKXjwIC0rhrwODbMX/SPI4NpDYzUfo/frwBM0zwEN65M9yypjh3udY=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,52 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCz6O9SvdGK+Ezc
|
||||
zQdOtCHBHmmkieIskpwkG0/AZNOMmfbNf3XbjuquFYlvAeZRgKMgJpOhnwVqFJjr
|
||||
ipYh/EGMPh/KmPIDWk+UysLXEnfj/f87F4SnSp0KbswuDXMWTvgnZ6kwTAACimw1
|
||||
vplLG69srq5i5QJHt2QansetW2svhOr3MhLFBPz/t6dynYHwSL59Eto5Z5WT0fjX
|
||||
v4IfsWqk6KV+dckUkIBYT2V+7+Rt4tT5x0AlHsBNCO/S7jgGuCioGnpTBQ6x6xX1
|
||||
ibqOeiudduAOQJFJQ390RoWLO5Lc/5IY5NAzMj+ELMA3DnK+AH0zx42lvbZOsTHD
|
||||
5nMVVgLTFP2NiKznfgzrT49OwMk8TaebnFeVtuW1191Da5vJNq/vY8KU9gB3W6An
|
||||
9fBWZ4g+HlnzEzEq+DztPCLbqM48lxoPVO7fGu6ESj2YyC2ct9mEmacyAyxriGbM
|
||||
Q8OlY+H+4gtlBbfkNfYttpb1gXrrupeEFHIkms0bVDnMe06p3RPg22cLL/yvkPmi
|
||||
BTir8XiTD9H3So4www+t5gkTaXvLF5lgNWOlTwvlwgBmsDzRFWBCpWZSFC6msR1H
|
||||
kyKPpPVg/t7cQB0zwMS6ttCHqy5fadymVAXMMl2EOzYaSyW0hxL5MfEWsqofWg/Q
|
||||
mPqs/lqkDvd17DShLf2VAnWgne1ugQIDAQABAoICADw8AtSbBOsYUvOiGY46NQrp
|
||||
Wcli+LyfoXNdSYhKuaFbcww+XoFSCjSatVbbNfeXsAX1pHv6N9/aYZCK59UdFf0U
|
||||
V6SHLI/+zqIseKt1XXqR8cAhEaLJEmcJzYalriCL8/2NcVHgQCiZm70qwTwqWsNy
|
||||
gKRPtEG6nuNiwcvCzdItGFYHB82669HZ9VAkd/qxAEXz5+hMTAIfzMa/MZvW1LO9
|
||||
yJrcaKRf9PicLIkhXEOGLHQsR8el0hB4q4LdixiE0+fkZYwiJ1deNA3vPOyy7qNb
|
||||
x4w+BeaXmLafXdrN6U/gqVN4WFSrwCRKr1g/mB8RHtoVN9GEAOO748OJBoLgNzVQ
|
||||
mWOlgaWPMtypb/PWZ/sQ7MG/4EaGfCpTIIAutpzlVW+BLZsboSfzXiLEtm5PdVBq
|
||||
6s+eks7Ri9d9J9PMAdWt9W93WbL5MUtXMa0mUNkmMJJpL8O8xoZN6jFWEEzyyUt6
|
||||
H3ReAQIe0bWX4RLyjCfTOnuLfyL5Wj3YVRCWTt3NyccYpJ5KfE9aT+9SGIZK3bCf
|
||||
jO/N/+bB6Z7VSj2c2nWxaBivk4tTWJNg54JZ/lSOkojXMjXzI/J+fgKcrekABZ+a
|
||||
pvmpxwDLpkrUFG9sTQqTZKzzl5tv1nq12WYCGIiEH9xQEExZQh/jQTfXgBnxPFOT
|
||||
I38YOQ8AyL8whYRE5vrZAoIBAQDptO+mSP0M7FaFTO9WuAo15RoSGQwceq73YwcS
|
||||
s5f0DAnQq56vkFByYz3WFtC/3unI/Goa4uSVDw/CA7WV3rpF736tlg2PuUakxJ00
|
||||
QFzPdoEwyQJm5a6G1tRQNi4y9FxnbJu2E+HnWJopsgnAc6o1TD/Fwk7+OFc6As8C
|
||||
sLubGd0huwqOpkyari7FWXEMUBGM2Hfcyvf2oUgZFV3jki1RuQLhRL6V/7qhH/HF
|
||||
txn2VW2cHfbnaLswXcv2ZCkxbOVTHTs3gCXPJgktpj9EBkYnaGK+oBoE5Ya/ykCZ
|
||||
YTkw9TiCFa9pCJqGu7AY5lkv4HXpSeErx+QjHyrdlZEzNu5vAoIBAQDFEkqv8yz1
|
||||
PahFSyekK+tnHyKV6T8EoKO27tJZV1CNWkR3wJlAHIbm7UXvTOvcNuxOg5w6VjE+
|
||||
EewGpgJxyyhvmr1OaBNKDj45WmktyvRc2erpWB61zQmhcVzednI7SSv+ln87Lw5r
|
||||
aXdYFL8YwJJ5b8ahHmjwOF8s0y3Hxeako4ESalQ5VGexEgFsuOMqXihEWcJRLnsF
|
||||
+BWXFYKGZthGAdke3ojun8W/SFl1Hqo09rmTMvf3GwYxMhZ5Pwuuj76RJghZUaGq
|
||||
UjLBqnypv0VhK7a8Jh8bvFRr8wz3NDLyJd4uq+nZD56p67d84h5bBCtmZQ41rXQO
|
||||
BZfXTdC2fOoPAoIBAQDiAfpoItmk78FUM+yZPm2RZTdrHRHbUMF3uCqU6V0fw6yS
|
||||
QgW53qQNmu+n5HSHuPj5RzENQzKu+9vPUmr+vmABVfR5xkzjGte4a/NjHoMiloWl
|
||||
Oh66h4/aElNMJrlSyYG6+wsyb9PdOJANloFbvf9yf4SEqL5flvizvxeWkHc9LSvu
|
||||
fMVe4m/efmf4reBned8fCBASU66ssZfZuhIMC8cL6xFf7G0q/h3rx8q127adxEu1
|
||||
2Dx32Y583ZhrdL1pcNftIq2rpJ/rzeq+XLF+BVs+rPIhSw8egSFoxBzot17pe5vk
|
||||
ITh7KLjXZxaLXegOJtGgg7Pf9PUpCfEYTJYYoxy9AoIBAE0R8D+LXIO0T0B6OdCM
|
||||
lI1Jsd7qzwhiQmRiVcU2znvZV3l1yvk1rtRU6srBTGRc3mF+OvTdjHh3zdRzy/Tw
|
||||
vKmY3HvzW8fUdiU75HJSMuq1FpeXLLtwqlmG2gjuTZI99YSlGrDsoDkFj/TUeD+X
|
||||
4DC5s/aCzAtWIHKJTBgany63+txW1QVuqvam0gPQ8pY5KIpCiCnzgY0+DkN92APz
|
||||
6JTIWD8oTGj19wHtq36QNYRtEPouLqdm3C8VJZDZRRpJgP+G3jEAKbdQWiU/JW3F
|
||||
Lb7ot5gxWG0iY+mrreBne50Tjia2eMe4whY15xZh3/k8UjTDRKFdakupiE5dUkhr
|
||||
5aUCggEASvsw244bspBDmXBlbHlpkisv5WoyPFxh6sYwHM1WrYYSJ4uV+yle1m4n
|
||||
UjQez2diBgT0X8UL6jZtesJZRskcXmbGx/L/uOF7RAZE1/Dg9MCqxVpnKpzDV8/U
|
||||
Rh5ypfL/LSxYPGWUebuH7E33pDPZqqVTB3fUg/+vaF06JFXK6XMo6ZswxWIE9k2j
|
||||
d7PSian30jc77n80iuH24iMdjC4FJgm3hEej5WxLtEN0KyXr0Ik5UtJAi+nsfdMZ
|
||||
2Ee/q3cSeDGkEgoA/gbaL2+lxK0MKuXJR3RqUelL98rAdEPZY7MxiQOpQCMEiyD2
|
||||
aF/eflJJhQBfX0kqW5zWx7swAYZYKQ==
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -0,0 +1,44 @@
|
||||
version: '3'
|
||||
|
||||
# TODO
|
||||
# - add `depends_on:`
|
||||
# - add top-level `volumes:`
|
||||
|
||||
|
||||
services:
|
||||
master_mariadb:
|
||||
image: mariadb:latest
|
||||
container_name: master_mariadb
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: "123qweASD"
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- ./mariadb:/etc/mysql/conf.d/
|
||||
|
||||
|
||||
ireddocker:
|
||||
build:
|
||||
dockerfile: ireddocker/Dockerfile
|
||||
context: ireddocker/
|
||||
image: ireddocker:0.1
|
||||
container_name: iredmail-mail
|
||||
hostname: mail.recsds.spbsut.ru
|
||||
env_file:
|
||||
- ireddocker/iredmail-env.conf
|
||||
ports:
|
||||
- "110:110"
|
||||
- "995:995"
|
||||
- "143:143"
|
||||
- "993:993"
|
||||
- "443:443"
|
||||
- "80:80"
|
||||
- "25:25"
|
||||
- "587:587"
|
||||
- "465:465"
|
||||
volumes:
|
||||
- ./cert_dir:/opt/iredmail/ssl
|
||||
- ./mail_dir:/var/vmail/vmail1
|
||||
depends_on:
|
||||
- master_mariadb
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
FROM ubuntu:bionic
|
||||
MAINTAINER Artem Shvidkiy <shvidkiy@sut.ru>
|
||||
RUN apt-get update
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y vim apt-utils postfix postfix-pcre libsasl2-modules \
|
||||
ldap-utils postfix-ldap libnet-ldap-perl libdbd-mysql-perl mariadb-server mariadb-client php-cli \
|
||||
php-fpm php-json php-gd php-curl mcrypt php-intl php-xml php-mbstring php-ldap php-mysql \
|
||||
nginx-full dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-managesieved dovecot-sieve \
|
||||
dovecot-ldap dovecot-mysql amavisd-new libcrypt-openssl-rsa-perl \
|
||||
libmail-dkim-perl clamav-freshclam clamav-daemon spamassassin altermime arj nomarch cpio lzop cabextract \
|
||||
p7zip-full rpm libmail-spf-perl unrar-free pax lrzip libclamunrar7 mlmmj python3-setuptools python3-pip \
|
||||
python3-wheel python3-requests uwsgi uwsgi-plugin-python3 python3-ldap python3-pymysql php-net-ldap3 \
|
||||
python3-sqlalchemy python3-dnspython python3-requests python3-pip python3-ldap python3-pymysql python-jinja2 \
|
||||
python-netifaces python-pycurl python-bcrypt python-dnspython python-webpy python-mysqldb syslog-ng \
|
||||
python-requests uwsgi uwsgi-plugin-python python-ldap python-mysqldb python-pymysql bzip2 acl patch cron \
|
||||
tofrodos logwatch unzip bsdutils liblz4-tool distro-info-data iso-codes libapt-inst2.0 lsb-release powermgmt-base \
|
||||
python-apt-common python3-apt python3-software-properties software-properties-common unattended-upgrades wget dialog libodbc1 slapd
|
||||
ADD main.cvd /var/lib/clamav/main.cvd
|
||||
RUN pip3 install web.py>=0.51 six>=1.15.0
|
||||
ADD init-functions /lib/lsb/init-functions
|
||||
ADD dockerinit.sh /dockerinit.sh
|
||||
RUN ["mkdir", "/iredmail"]
|
||||
ADD iredmail /iredmail
|
||||
RUN ["chmod", "+x", "/dockerinit.sh"]
|
||||
CMD ["/dockerinit.sh"]
|
||||
|
||||
EXPOSE 3306
|
||||
EXPOSE 110
|
||||
EXPOSE 995
|
||||
EXPOSE 143
|
||||
EXPOSE 993
|
||||
EXPOSE 4190
|
||||
EXPOSE 24
|
||||
EXPOSE 12340
|
||||
EXPOSE 24242
|
||||
EXPOSE 7777
|
||||
EXPOSE 7778
|
||||
EXPOSE 3310
|
||||
EXPOSE 25
|
||||
EXPOSE 587
|
||||
EXPOSE 465
|
||||
@@ -0,0 +1,370 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ! -f ".configured" ]]; then
|
||||
|
||||
exec > >(tee -i /iredmail.log)
|
||||
|
||||
exec 2>&1
|
||||
|
||||
set -x
|
||||
|
||||
: ${MYSQL_SERVER_ADDRESS:=127.0.0.1}
|
||||
: ${MYSQL_SERVER_PORT:=3306}
|
||||
: ${MYSQL_ROOT_USER:=admin_iredmail}
|
||||
: ${MYSQL_ROOT_PASSWD:=admin_password}
|
||||
: ${MYSQL_GRANT_HOST:=%}
|
||||
: ${MYSQLEXIST:=NO}
|
||||
: ${CUSTOM_CERT_USE:=NO}
|
||||
: ${CUSTOM_CERT_KEYFILE:=privkey.pem}
|
||||
: ${CUSTOM_CERT_CERTFILE:=fullchain.pem}
|
||||
: ${SETFQDN:=test.testdomain.ru}
|
||||
: ${STORAGE_BASE_DIR:=/var/vmail}
|
||||
: ${WEB_SERVER:=NGINX}
|
||||
: ${BACKEND_ORIG:=OPENLDAP}
|
||||
: ${BACKEND:=OPENLDAP}
|
||||
: ${VMAIL_DB_BIND_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${VMAIL_DB_ADMIN_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${MLMMJADMIN_API_AUTH_TOKEN:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${NETDATA_DB_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${LDAP_SUFFIX:=dc=testdomain,dc=ru}
|
||||
: ${LDAP_BINDPW:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${LDAP_ADMIN_PW:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${LDAP_ROOTPW:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${LDAP_SEARCH_BASE:=cn=users,dc=testdomain,dc=ru}
|
||||
: ${LDAP_EXTERNAL_USE:=YES}
|
||||
: ${LDAP_EXTERNAL_SERVER:=127.0.0.1}
|
||||
: ${LDAP_EXTERNAL_BINDUSER:=vmail}
|
||||
: ${LDAP_EXTERNAL_BINDPW:=$LDAP_BINDPW}
|
||||
: ${LDAP_EXTERNAL_BASE:=dc=testdomain,dc=ru}
|
||||
: ${MYSQL_ROOT_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${FIRST_DOMAIN:=testdomain.ru}
|
||||
: ${DOMAIN_ADMIN_PASSWD_PLAIN:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${USE_IREDADMIN:=YES}
|
||||
: ${USE_ROUNDCUBE:=YES}
|
||||
: ${AMAVISD_DB_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${IREDADMIN_DB_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${RCM_DB_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${SOGO_DB_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${SOGO_SIEVE_MASTER_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${IREDAPD_DB_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${FAIL2BAN_DB_PASSWD:=`eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 20)`}
|
||||
: ${USE_SYSTEMD:=NO}
|
||||
: ${MAILNAME:=`hostname -f`}
|
||||
|
||||
if [[ X"${MYSQLEXIST}" == X'YES' || X"${MYSQLEXIST}" == X'yes' ]]; then
|
||||
: ${USE_EXISTING_MYSQL:=YES}
|
||||
fi
|
||||
|
||||
|
||||
if [[ X"${MYSQLEXIST}" == X'YES' || X"${MYSQLEXIST}" == X'yes' ]]; then
|
||||
while ! mysqladmin ping -h"${MYSQL_SERVER_ADDRESS}" --silent; do
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
|
||||
|
||||
cat <<EOF > /etc/mailname
|
||||
$MAILNAME
|
||||
EOF
|
||||
|
||||
echo '>create initial config file'
|
||||
|
||||
cat <<EOF > /iredmail/config
|
||||
export STORAGE_BASE_DIR='$STORAGE_BASE_DIR'
|
||||
export WEB_SERVER='$WEB_SERVER'
|
||||
export BACKEND_ORIG='$BACKEND_ORIG'
|
||||
export BACKEND='$BACKEND'
|
||||
export VMAIL_DB_BIND_PASSWD='$VMAIL_DB_BIND_PASSWD'
|
||||
export VMAIL_DB_ADMIN_PASSWD='$VMAIL_DB_ADMIN_PASSWD'
|
||||
export MLMMJADMIN_API_AUTH_TOKEN='$MLMMJADMIN_API_AUTH_TOKEN'
|
||||
export NETDATA_DB_PASSWD='$NETDATA_DB_PASSWD'
|
||||
export LDAP_SUFFIX='$LDAP_SUFFIX'
|
||||
export LDAP_BINDPW='$LDAP_BINDPW'
|
||||
export LDAP_ADMIN_PW='$LDAP_ADMIN_PW'
|
||||
export LDAP_ROOTPW='$LDAP_ROOTPW'
|
||||
export MYSQL_ROOT_PASSWD='$MYSQL_ROOT_PASSWD'
|
||||
export FIRST_DOMAIN='$FIRST_DOMAIN'
|
||||
export DOMAIN_ADMIN_PASSWD_PLAIN='$DOMAIN_ADMIN_PASSWD_PLAIN'
|
||||
export USE_IREDADMIN='$USE_IREDADMIN'
|
||||
export USE_ROUNDCUBE='$USE_ROUNDCUBE'
|
||||
export AMAVISD_DB_PASSWD='$AMAVISD_DB_PASSWD'
|
||||
export IREDADMIN_DB_PASSWD='$IREDADMIN_DB_PASSWD'
|
||||
export RCM_DB_PASSWD='$RCM_DB_PASSWD'
|
||||
export SOGO_DB_PASSWD='$SOGO_DB_PASSWD'
|
||||
export SOGO_SIEVE_MASTER_PASSWD='$SOGO_DB_PASSWD'
|
||||
export IREDAPD_DB_PASSWD='$SOGO_DB_PASSWD'
|
||||
export FAIL2BAN_DB_PASSWD='$SOGO_DB_PASSWD'
|
||||
#EOF
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
echo '> install iredmail'
|
||||
|
||||
|
||||
# Install iredmail
|
||||
|
||||
if [[ X"${MYSQLEXIST}" == X'YES' || X"${MYSQLEXIST}" == X'yes' ]]; then
|
||||
USE_EXISTING_MYSQL=YES MYSQL_SERVER_ADDRESS=$MYSQL_SERVER_ADDRESS \
|
||||
MYSQL_SERVER_PORT=$MYSQL_SERVER_PORT MYSQL_ROOT_USER=$MYSQL_ROOT_USER \
|
||||
MYSQL_ROOT_PASSWD=$MYSQL_ROOT_PASSWD MYSQL_GRANT_HOST=$MYSQL_GRANT_HOST \
|
||||
AUTO_USE_EXISTING_CONFIG_FILE=y AUTO_INSTALL_WITHOUT_CONFIRM=y \
|
||||
AUTO_CLEANUP_REMOVE_SENDMAIL=y AUTO_CLEANUP_REPLACE_MYSQL_CONFIG=y \
|
||||
bash /iredmail/iRedMail.sh
|
||||
echo $MYSQL_SERVER_ADDRESS
|
||||
echo $MYSQL_GRANT_HOST
|
||||
else
|
||||
AUTO_USE_EXISTING_CONFIG_FILE=y AUTO_INSTALL_WITHOUT_CONFIRM=y \
|
||||
AUTO_CLEANUP_REMOVE_SENDMAIL=y AUTO_CLEANUP_REPLACE_MYSQL_CONFIG=y \
|
||||
bash /iredmail/iRedMail.sh
|
||||
fi
|
||||
|
||||
cp /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini /etc/uwsgi/apps-enabled/iredadmin.ini
|
||||
cp /opt/mlmmjadmin/rc_scripts/uwsgi/debian.ini /etc/uwsgi/apps-enabled/mlmmjadmin.ini
|
||||
|
||||
|
||||
external_ldap_config()
|
||||
{
|
||||
|
||||
# Enable external AD authentication
|
||||
|
||||
postconf -e virtual_alias_maps=''
|
||||
postconf -e sender_bcc_maps=''
|
||||
postconf -e recipient_bcc_maps=''
|
||||
postconf -e relay_domains=''
|
||||
postconf -e relay_recipient_maps=''
|
||||
postconf -e sender_dependent_relayhost_maps=''
|
||||
postconf -e smtpd_sasl_local_domain=$FIRST_DOMAIN
|
||||
postconf -e virtual_mailbox_domains=$FIRST_DOMAIN
|
||||
postconf -e transport_maps='hash:/etc/postfix/transport'
|
||||
postconf -e smtpd_sender_login_maps='proxy:ldap:/etc/postfix/ad_sender_login_maps.cf'
|
||||
postconf -e virtual_mailbox_maps='proxy:ldap:/etc/postfix/ad_virtual_mailbox_maps.cf'
|
||||
postconf -e virtual_alias_maps='proxy:ldap:/etc/postfix/ad_virtual_group_maps.cf'
|
||||
|
||||
cat <<EOF > /etc/postfix/transport
|
||||
$FIRST_DOMAIN dovecot
|
||||
EOF
|
||||
|
||||
postmap hash:/etc/postfix/transport
|
||||
|
||||
cat <<EOF > /etc/postfix/ad_sender_login_maps.cf
|
||||
server_host = $LDAP_EXTERNAL_SERVER
|
||||
server_port = 389
|
||||
version = 3
|
||||
bind = yes
|
||||
start_tls = no
|
||||
bind_dn = $LDAP_EXTERNAL_BINDUSER
|
||||
bind_pw = $LDAP_EXTERNAL_BINDPW
|
||||
search_base = $LDAP_EXTERNAL_BASE
|
||||
scope = sub
|
||||
query_filter = (&(userPrincipalName=%s)(objectClass=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
|
||||
result_attribute= userPrincipalName
|
||||
debuglevel = 0
|
||||
EOF
|
||||
|
||||
cat <<EOF > /etc/postfix/ad_virtual_mailbox_maps.cf
|
||||
server_host = $LDAP_EXTERNAL_SERVER
|
||||
server_port = 389
|
||||
version = 3
|
||||
bind = yes
|
||||
start_tls = no
|
||||
bind_dn = $LDAP_EXTERNAL_BINDUSER
|
||||
bind_pw = $LDAP_EXTERNAL_BINDPW
|
||||
search_base = $LDAP_EXTERNAL_BASE
|
||||
scope = sub
|
||||
query_filter = (&(objectclass=person)(userPrincipalName=%s))
|
||||
result_attribute= userPrincipalName
|
||||
result_format = %d/%u/Maildir/
|
||||
debuglevel = 0
|
||||
EOF
|
||||
|
||||
cat <<EOF > /etc/postfix/ad_virtual_group_maps.cf
|
||||
server_host = $LDAP_EXTERNAL_SERVER
|
||||
server_port = 389
|
||||
version = 3
|
||||
bind = yes
|
||||
start_tls = no
|
||||
bind_dn = $LDAP_EXTERNAL_BINDUSER
|
||||
bind_pw = $LDAP_EXTERNAL_BINDPW
|
||||
search_base = $LDAP_EXTERNAL_BASE
|
||||
scope = sub
|
||||
query_filter = (&(objectClass=group)(mail=%s))
|
||||
special_result_attribute = member
|
||||
#leaf_result_attribute = mail
|
||||
result_attribute= userPrincipalName
|
||||
debuglevel = 0
|
||||
EOF
|
||||
|
||||
sed -i '/check_policy_service inet:127.0.0.1:7777/d' /etc/postfix/main.cf
|
||||
|
||||
rm -rf /etc/dovecot/dovecot-ldap.conf
|
||||
|
||||
cat <<EOF > /etc/dovecot/dovecot-ldap.conf
|
||||
hosts = $LDAP_EXTERNAL_SERVER:389
|
||||
ldap_version = 3
|
||||
auth_bind = yes
|
||||
dn = $LDAP_EXTERNAL_BINDUSER
|
||||
dnpass = $LDAP_EXTERNAL_BINDPW
|
||||
base = $LDAP_EXTERNAL_BASE
|
||||
scope = subtree
|
||||
deref = never
|
||||
|
||||
# Below two are required by command 'doveadm mailbox ...'
|
||||
iterate_attrs = userPrincipalName=user
|
||||
iterate_filter = (&(userPrincipalName=*)(objectClass=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
|
||||
|
||||
user_filter = (&(userPrincipalName=%u)(objectClass=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
|
||||
pass_filter = (&(userPrincipalName=%u)(objectClass=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
|
||||
pass_attrs = userPassword=password
|
||||
default_pass_scheme = CRYPT
|
||||
user_attrs = =home=/var/vmail/vmail1/%Ld/%Ln/,=mail=maildir:~/Maildir/
|
||||
EOF
|
||||
|
||||
sed -i '/Global\ LDAP\ address\ book/,$d' /opt/www/roundcubemail/config/config.inc.php
|
||||
|
||||
cat <<EOF >> /opt/www/roundcubemail/config/config.inc.php
|
||||
#
|
||||
# "sql" is personal address book stored in roundcube database.
|
||||
# "global_ldap_abook" is the new LDAP address book for AD, we will create it below.
|
||||
#
|
||||
\$config['autocomplete_addressbooks'] = array("sql", "global_ldap_abook");
|
||||
|
||||
# Enable setting below if Roundcube returns 'user@127.0.0.1' as email address
|
||||
#\$config['mail_domain'] = '%d';
|
||||
|
||||
#
|
||||
# Global LDAP Address Book with AD.
|
||||
#
|
||||
\$config['ldap_public']["global_ldap_abook"] = array(
|
||||
'name' => 'Global Address Book',
|
||||
'hosts' => array("$LDAP_EXTERNAL_SERVER"), // <- Set AD hostname or IP address here.
|
||||
'port' => 389,
|
||||
'use_tls' => false, // <- Set to true if you want to use LDAP over TLS.
|
||||
'ldap_version' => '3',
|
||||
'network_timeout' => 10,
|
||||
'user_specific' => false,
|
||||
|
||||
'base_dn' => "$LDAP_EXTERNAL_BASE", // <- Set base dn in AD
|
||||
'bind_dn' => "$LDAP_EXTERNAL_BINDUSER", // <- bind dn
|
||||
'bind_pass' => "$LDAP_EXTERNAL_BINDPW", // <- bind password
|
||||
'writable' => false, // <- Do not allow mail user write data back to AD.
|
||||
|
||||
'search_fields' => array('mail', 'cn', 'sAMAccountName', 'displayname', 'sn', 'givenName'),
|
||||
|
||||
// mapping of contact fields to directory attributes
|
||||
'fieldmap' => array(
|
||||
'name' => 'cn',
|
||||
'displayname' => 'displayName',
|
||||
'surname' => 'sn',
|
||||
'firstname' => 'givenName',
|
||||
'jobtitle' => 'title',
|
||||
'department' => 'department',
|
||||
'company' => 'company',
|
||||
'email' => 'mail:*',
|
||||
'phone:work' => 'telephoneNumber',
|
||||
'phone:home' => 'homePhone',
|
||||
'phone:mobile' => 'mobile',
|
||||
'phone:workfax' => 'facsimileTelephoneNumber',
|
||||
'phone:pager' => 'pager',
|
||||
'phone:other' => 'ipPhone',
|
||||
'street:work' => 'streetAddress',
|
||||
'zipcode:work' => 'postalCode',
|
||||
'locality:work' => 'l',
|
||||
'region:work' => 'st',
|
||||
'country:work' => 'c',
|
||||
'notes' => 'description',
|
||||
'photo' => 'jpegPhoto', // Might be 'thumbnailPhoto' for
|
||||
// compatibility with some other
|
||||
// Microsoft software
|
||||
'website' => 'wWWHomePage',
|
||||
),
|
||||
'sort' => 'cn',
|
||||
'scope' => 'sub',
|
||||
'filter' => "(&(|(objectclass=person)(objectclass=group))(!(userAccountControl:1.2.840.113556.1.4.803:=2)))",
|
||||
'fuzzy_search' => true,
|
||||
'vlv' => false, // Enable Virtual List View to more
|
||||
// efficiently fetch paginated data
|
||||
// (if server supports it)
|
||||
'sizelimit' => '0', // Enables you to limit the count of
|
||||
// entries fetched. Setting this to 0
|
||||
// means no limit.
|
||||
'timelimit' => '0', // Sets the number of seconds how long
|
||||
// is spend on the search. Setting this
|
||||
// to 0 means no limit.
|
||||
'referrals' => false, // Sets the LDAP_OPT_REFERRALS option.
|
||||
// Mostly used in multi-domain Active
|
||||
// Directory setups
|
||||
);
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
if [[ X"${LDAP_EXTERNAL_USE}" == X'YES' || X"${LDAP_EXTERNAL_USE}" == X'yes' ]]; then
|
||||
external_ldap_config
|
||||
fi
|
||||
|
||||
|
||||
touch /.configured
|
||||
|
||||
# Replace certs
|
||||
|
||||
if [[ X"${CUSTOM_CERT_USE}" == X'YES' || X"${CUSTOM_CERT_USE}" == X'yes' ]]; then
|
||||
rm -f /etc/ssl/private/iRedMail.key
|
||||
rm -f /etc/ssl/certs/iRedMail.crt
|
||||
ln -s /opt/iredmail/ssl/$CUSTOM_CERT_KEYFILE /etc/ssl/private/iRedMail.key
|
||||
ln -s /opt/iredmail/ssl/$CUSTOM_CERT_CERTFILE /etc/ssl/certs/iRedMail.crt
|
||||
fi
|
||||
|
||||
else
|
||||
#does not start, if mysql stopped
|
||||
|
||||
while ! mysqladmin ping -h"${MYSQL_SERVER_ADDRESS}" --silent; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [[ X"${CUSTOM_CERT_USE}" == X'YES' || X"${CUSTOM_CERT_USE}" == X'yes' ]]; then
|
||||
rm -f /etc/ssl/private/iRedMail.key
|
||||
rm -f /etc/ssl/certs/iRedMail.crt
|
||||
mv /tmp/cert/$CUSTOM_CERT_KEYFILE /opt/iredmail/ssl/$CUSTOM_CERT_KEYFILE
|
||||
mv /tmp/cert/$CUSTOM_CERT_CERTFILE /opt/iredmail/ssl/$CUSTOM_CERT_CERTFILE
|
||||
ln -s /opt/iredmail/ssl/$CUSTOM_CERT_KEYFILE /etc/ssl/private/iRedMail.key
|
||||
ln -s /opt/iredmail/ssl/$CUSTOM_CERT_CERTFILE /etc/ssl/certs/iRedMail.crt
|
||||
fi
|
||||
|
||||
|
||||
# Start syslog-ng
|
||||
|
||||
/usr/sbin/syslog-ng -F --no-caps &
|
||||
|
||||
|
||||
if [[ X"${MYSQLEXIST}" != X'YES' || X"${MYSQLEXIST}" != X'yes' ]]; then
|
||||
service mysql start
|
||||
fi
|
||||
|
||||
service dovecot start
|
||||
service nginx start
|
||||
service php7.2-fpm start
|
||||
|
||||
# Start postfix
|
||||
start-stop-daemon --start --exec /usr/sbin/postmulti -- -i - -x /usr/sbin/postfix quiet-quick-start
|
||||
|
||||
service clamav-daemon start
|
||||
service clamav-freshclam start
|
||||
service spamassasin start
|
||||
service amavis start
|
||||
service mlmmjadmin_enable start
|
||||
service uwsgi start
|
||||
|
||||
if [[ X"${LDAP_EXTERNAL_USE}" != X'YES' || X"${LDAP_EXTERNAL_USE}" != X'yes' ]]; then
|
||||
service slapd start
|
||||
service iredapd start
|
||||
fi
|
||||
|
||||
while mysqladmin ping -h"${MYSQL_SERVER_ADDRESS}" --silent; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
fi
|
||||
@@ -0,0 +1,433 @@
|
||||
# /lib/lsb/init-functions for Debian -*- shell-script -*-
|
||||
#
|
||||
#Copyright (c) 2002-08 Chris Lawrence
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions
|
||||
#are met:
|
||||
#1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#3. Neither the name of the author nor the names of other contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
#ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
||||
#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
start_daemon () {
|
||||
local force nice pidfile exec args OPTIND
|
||||
force=""
|
||||
nice=0
|
||||
pidfile=/dev/null
|
||||
|
||||
OPTIND=1
|
||||
while getopts fn:p: opt ; do
|
||||
case "$opt" in
|
||||
f) force="force";;
|
||||
n) nice="$OPTARG";;
|
||||
p) pidfile="$OPTARG";;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
if [ "$1" = '--' ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
exec="$1"; shift
|
||||
|
||||
args="--start --nicelevel $nice --quiet --oknodo"
|
||||
if [ "$force" ]; then
|
||||
/sbin/start-stop-daemon $args \
|
||||
--chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@"
|
||||
elif [ $pidfile ]; then
|
||||
/sbin/start-stop-daemon $args \
|
||||
--chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@"
|
||||
else
|
||||
/sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
pidofproc () {
|
||||
local pidfile base status specified pid OPTIND
|
||||
pidfile=
|
||||
specified=
|
||||
|
||||
OPTIND=1
|
||||
while getopts p: opt ; do
|
||||
case "$opt" in
|
||||
p) pidfile="$OPTARG"
|
||||
specified="specified"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "$0: invalid arguments" >&2
|
||||
return 4
|
||||
fi
|
||||
|
||||
base=${1##*/}
|
||||
if [ ! "$specified" ]; then
|
||||
pidfile="/var/run/$base.pid"
|
||||
fi
|
||||
|
||||
if [ -n "${pidfile:-}" ]; then
|
||||
if [ -e "$pidfile" ]; then
|
||||
if [ -r "$pidfile" ]; then
|
||||
read pid < "$pidfile"
|
||||
if [ -n "${pid:-}" ]; then
|
||||
if $(kill -0 "${pid:-}" 2> /dev/null); then
|
||||
echo "$pid" || true
|
||||
return 0
|
||||
elif ps "${pid:-}" >/dev/null 2>&1; then
|
||||
echo "$pid" || true
|
||||
return 0 # program is running, but not owned by this user
|
||||
else
|
||||
return 1 # program is dead and /var/run pid file exists
|
||||
fi
|
||||
fi
|
||||
else
|
||||
return 4 # pid file not readable, hence status is unknown.
|
||||
fi
|
||||
else
|
||||
# pid file doesn't exist, try to find the pid nevertheless
|
||||
if [ -x /bin/pidof ] && [ ! "$specified" ]; then
|
||||
status="0"
|
||||
/bin/pidof -o %PPID -x $1 || status="$?"
|
||||
if [ "$status" = 1 ]; then
|
||||
return 3 # program is not running
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
return 3 # specified pid file doesn't exist, program probably stopped
|
||||
fi
|
||||
fi
|
||||
if [ "$specified" ]; then
|
||||
return 3 # almost certain it's not running
|
||||
fi
|
||||
return 4 # Unable to determine status
|
||||
}
|
||||
|
||||
# start-stop-daemon uses the same algorithm as "pidofproc" above.
|
||||
killproc () {
|
||||
local pidfile sig status base name_param is_term_sig OPTIND
|
||||
pidfile=
|
||||
name_param=
|
||||
is_term_sig=
|
||||
|
||||
OPTIND=1
|
||||
while getopts p: opt ; do
|
||||
case "$opt" in
|
||||
p) pidfile="$OPTARG";;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
base=${1##*/}
|
||||
if [ ! $pidfile ]; then
|
||||
name_param="--name $base --pidfile /var/run/$base.pid"
|
||||
else
|
||||
name_param="--pidfile $pidfile"
|
||||
fi
|
||||
|
||||
sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/')
|
||||
sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
|
||||
if [ "$sig" = 15 ] || [ "$sig" = TERM ]; then
|
||||
is_term_sig="terminate_signal"
|
||||
fi
|
||||
status=0
|
||||
if [ ! "$is_term_sig" ]; then
|
||||
if [ -n "$sig" ]; then
|
||||
/sbin/start-stop-daemon --stop --signal "$sig" \
|
||||
--quiet $name_param || status="$?"
|
||||
else
|
||||
/sbin/start-stop-daemon --stop \
|
||||
--retry 5 \
|
||||
--quiet $name_param || status="$?"
|
||||
fi
|
||||
else
|
||||
/sbin/start-stop-daemon --stop --quiet \
|
||||
--oknodo $name_param || status="$?"
|
||||
fi
|
||||
if [ "$status" = 1 ]; then
|
||||
if [ -z "$sig" ]; then
|
||||
return 0
|
||||
fi
|
||||
return 3 # program is not running
|
||||
fi
|
||||
|
||||
if [ "$status" = 0 ] && [ "$is_term_sig" ] && [ "$pidfile" ]; then
|
||||
pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Return LSB status
|
||||
status_of_proc () {
|
||||
local pidfile daemon name status OPTIND
|
||||
|
||||
pidfile=
|
||||
OPTIND=1
|
||||
while getopts p: opt ; do
|
||||
case "$opt" in
|
||||
p) pidfile="$OPTARG";;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ -n "$pidfile" ]; then
|
||||
pidfile="-p $pidfile"
|
||||
fi
|
||||
daemon="$1"
|
||||
name="$2"
|
||||
|
||||
status="0"
|
||||
pidofproc $pidfile $daemon >/dev/null || status="$?"
|
||||
if [ "$status" = 0 ]; then
|
||||
log_success_msg "$name is running"
|
||||
return 0
|
||||
elif [ "$status" = 4 ]; then
|
||||
log_failure_msg "could not access PID file for $name"
|
||||
return $status
|
||||
else
|
||||
log_failure_msg "$name is not running"
|
||||
return $status
|
||||
fi
|
||||
}
|
||||
|
||||
log_use_fancy_output () {
|
||||
TPUT=/usr/bin/tput
|
||||
EXPR=/usr/bin/expr
|
||||
if [ -t 1 ] &&
|
||||
[ "x${TERM:-}" != "x" ] &&
|
||||
[ "x${TERM:-}" != "xdumb" ] &&
|
||||
[ -x $TPUT ] && [ -x $EXPR ] &&
|
||||
$TPUT hpa 60 >/dev/null 2>&1 &&
|
||||
$TPUT setaf 1 >/dev/null 2>&1
|
||||
then
|
||||
[ -z $FANCYTTY ] && FANCYTTY=1 || true
|
||||
else
|
||||
FANCYTTY=0
|
||||
fi
|
||||
case "$FANCYTTY" in
|
||||
1|Y|yes|true) true;;
|
||||
*) false;;
|
||||
esac
|
||||
}
|
||||
|
||||
log_success_msg () {
|
||||
if [ -n "${1:-}" ]; then
|
||||
log_begin_msg $@
|
||||
fi
|
||||
log_end_msg 0
|
||||
}
|
||||
|
||||
log_failure_msg () {
|
||||
if [ -n "${1:-}" ]; then
|
||||
log_begin_msg $@ "..."
|
||||
fi
|
||||
log_end_msg 1 || true
|
||||
}
|
||||
|
||||
log_warning_msg () {
|
||||
if [ -n "${1:-}" ]; then
|
||||
log_begin_msg $@ "..."
|
||||
fi
|
||||
log_end_msg 255 || true
|
||||
}
|
||||
|
||||
#
|
||||
# NON-LSB HELPER FUNCTIONS
|
||||
#
|
||||
# int get_lsb_header_val (char *scriptpathname, char *key)
|
||||
get_lsb_header_val () {
|
||||
if [ ! -f "$1" ] || [ -z "${2:-}" ]; then
|
||||
return 1
|
||||
fi
|
||||
LSB_S="### BEGIN INIT INFO"
|
||||
LSB_E="### END INIT INFO"
|
||||
sed -n "/$LSB_S/,/$LSB_E/ s/# $2: \+\(.*\)/\1/p" "$1"
|
||||
}
|
||||
|
||||
# If the currently running init daemon is upstart, return zero; if the
|
||||
# calling init script belongs to a package which also provides a native
|
||||
# upstart job, it should generally exit non-zero in this case.
|
||||
init_is_upstart()
|
||||
{
|
||||
if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | /bin/grep -q upstart; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# int log_begin_message (char *message)
|
||||
log_begin_msg () {
|
||||
log_begin_msg_pre "$@"
|
||||
if [ -z "${1:-}" ]; then
|
||||
return 1
|
||||
fi
|
||||
echo -n "$@" || true
|
||||
log_begin_msg_post "$@"
|
||||
}
|
||||
|
||||
# Sample usage:
|
||||
# log_daemon_msg "Starting GNOME Login Manager" "gdm"
|
||||
#
|
||||
# On Debian, would output "Starting GNOME Login Manager: gdm"
|
||||
# On Ubuntu, would output " * Starting GNOME Login Manager..."
|
||||
#
|
||||
# If the second argument is omitted, logging suitable for use with
|
||||
# log_progress_msg() is used:
|
||||
#
|
||||
# log_daemon_msg "Starting remote filesystem services"
|
||||
#
|
||||
# On Debian, would output "Starting remote filesystem services:"
|
||||
# On Ubuntu, would output " * Starting remote filesystem services..."
|
||||
|
||||
log_daemon_msg () {
|
||||
if [ -z "${1:-}" ]; then
|
||||
return 1
|
||||
fi
|
||||
log_daemon_msg_pre "$@"
|
||||
|
||||
if [ -z "${2:-}" ]; then
|
||||
echo -n "$1:" || true
|
||||
return
|
||||
fi
|
||||
|
||||
echo -n "$1: $2" || true
|
||||
log_daemon_msg_post "$@"
|
||||
}
|
||||
|
||||
# #319739
|
||||
#
|
||||
# Per policy docs:
|
||||
#
|
||||
# log_daemon_msg "Starting remote file system services"
|
||||
# log_progress_msg "nfsd"; start-stop-daemon --start --quiet nfsd
|
||||
# log_progress_msg "mountd"; start-stop-daemon --start --quiet mountd
|
||||
# log_progress_msg "ugidd"; start-stop-daemon --start --quiet ugidd
|
||||
# log_end_msg 0
|
||||
#
|
||||
# You could also do something fancy with log_end_msg here based on the
|
||||
# return values of start-stop-daemon; this is left as an exercise for
|
||||
# the reader...
|
||||
#
|
||||
# On Ubuntu, one would expect log_progress_msg to be a no-op.
|
||||
log_progress_msg () {
|
||||
if [ -z "${1:-}" ]; then
|
||||
return 1
|
||||
fi
|
||||
echo -n " $@" || true
|
||||
}
|
||||
|
||||
|
||||
# int log_end_message (int exitstatus)
|
||||
log_end_msg () {
|
||||
# If no arguments were passed, return
|
||||
if [ -z "${1:-}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local retval
|
||||
retval=$1
|
||||
|
||||
log_end_msg_pre "$@"
|
||||
|
||||
# Only do the fancy stuff if we have an appropriate terminal
|
||||
# and if /usr is already mounted
|
||||
if log_use_fancy_output; then
|
||||
RED=$( $TPUT setaf 1)
|
||||
YELLOW=$( $TPUT setaf 3)
|
||||
NORMAL=$( $TPUT op)
|
||||
else
|
||||
RED=''
|
||||
YELLOW=''
|
||||
NORMAL=''
|
||||
fi
|
||||
|
||||
if [ $1 -eq 0 ]; then
|
||||
echo "." || true
|
||||
elif [ $1 -eq 255 ]; then
|
||||
/bin/echo -e " ${YELLOW}(warning).${NORMAL}" || true
|
||||
else
|
||||
/bin/echo -e " ${RED}failed!${NORMAL}" || true
|
||||
fi
|
||||
log_end_msg_post "$@"
|
||||
return $retval
|
||||
}
|
||||
|
||||
log_action_msg () {
|
||||
log_action_msg_pre "$@"
|
||||
echo "$@." || true
|
||||
log_action_msg_post "$@"
|
||||
}
|
||||
|
||||
log_action_begin_msg () {
|
||||
log_action_begin_msg_pre "$@"
|
||||
echo -n "$@..." || true
|
||||
log_action_begin_msg_post "$@"
|
||||
}
|
||||
|
||||
log_action_cont_msg () {
|
||||
echo -n "$@..." || true
|
||||
}
|
||||
|
||||
log_action_end_msg () {
|
||||
local end
|
||||
log_action_end_msg_pre "$@"
|
||||
if [ -z "${2:-}" ]; then
|
||||
end="."
|
||||
else
|
||||
end=" ($2)."
|
||||
fi
|
||||
|
||||
if [ $1 -eq 0 ]; then
|
||||
echo "done${end}" || true
|
||||
else
|
||||
if log_use_fancy_output; then
|
||||
RED=$( $TPUT setaf 1)
|
||||
NORMAL=$( $TPUT op)
|
||||
/bin/echo -e "${RED}failed${end}${NORMAL}" || true
|
||||
else
|
||||
echo "failed${end}" || true
|
||||
fi
|
||||
fi
|
||||
log_action_end_msg_post "$@"
|
||||
}
|
||||
|
||||
# Pre&Post empty function declaration, to be overriden from /lib/lsb/init-functions.d/*
|
||||
log_daemon_msg_pre () { :; }
|
||||
log_daemon_msg_post () { :; }
|
||||
log_begin_msg_pre () { :; }
|
||||
log_begin_msg_post () { :; }
|
||||
log_end_msg_pre () { :; }
|
||||
log_end_msg_post () { :; }
|
||||
log_action_msg_pre () { :; }
|
||||
log_action_msg_post () { :; }
|
||||
log_action_begin_msg_pre () { :; }
|
||||
log_action_begin_msg_post () { :; }
|
||||
log_action_end_msg_pre () { :; }
|
||||
log_action_end_msg_post () { :; }
|
||||
|
||||
# Include hooks from other packages in /lib/lsb/init-functions.d
|
||||
for hook in $(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null); do
|
||||
[ -r $hook ] && . $hook || true
|
||||
done
|
||||
|
||||
FANCYTTY=
|
||||
[ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
* iRedMail web site: https://www.iredmail.org/
|
||||
* Documentations: https://docs.iredmail.org/
|
||||
* Support Forum: https://forum.iredmail.org/
|
||||
* iRedMail upgrade tutorials: https://docs.iredmail.org/iredmail.releases.html
|
||||
* iRedAdmin upgrade tutorials: https://docs.iredmail.org/migrate.or.upgrade.iredadmin.html
|
||||
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Warning: Please source 'conf/postfix' first.
|
||||
|
||||
export SYS_USER_AMAVISD='amavis'
|
||||
export SYS_GROUP_AMAVISD='amavis'
|
||||
export AMAVISD_QUARANTINE_PORT='9998'
|
||||
export AMAVISD_LOGFILE='/var/log/amavisd.log'
|
||||
export AMAVISD_LOGROTATE_FILE="${LOGROTATE_DIR}/amavisd"
|
||||
export AMAVISD_DKIM_SELECTOR='dkim'
|
||||
export AMAVISD_RC_SCRIPT_NAME='amavisd'
|
||||
|
||||
export AMAVISD_SPOOL_DIR='/var/spool/amavisd'
|
||||
export AMAVISD_DKIM_DIR="${AMAVISD_DKIM_DIR:=/var/lib/dkim}"
|
||||
|
||||
# Network ports
|
||||
export AMAVISD_SMTP_PORT='10024'
|
||||
export AMAVISD_ORIGINATING_PORT='10026'
|
||||
export AMAVISD_MLMMJ_PORT='10027'
|
||||
export AMAVISD_QUARANTINE_PORT='9998'
|
||||
|
||||
# Database used to store incoming & outgoing email related information.
|
||||
export AMAVISD_DB_NAME='amavisd'
|
||||
export AMAVISD_DB_USER='amavisd'
|
||||
|
||||
# Altermime.
|
||||
export CMD_ALTERMIME='/usr/bin/altermime'
|
||||
export DISCLAIMER_DIR="${POSTFIX_ROOTDIR}/disclaimer"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
export AMAVISD_BIN='/usr/sbin/amavisd'
|
||||
export AMAVISD_LDAP_SCHEMA_NAME='amavisd-new.schema'
|
||||
export AMAVISD_VAR_RUN_DIR='/var/run/amavisd'
|
||||
|
||||
export AMAVISD_CONF='/etc/amavisd/amavisd.conf'
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
export AMAVISD_BIN='/usr/sbin/amavisd-new'
|
||||
export AMAVISD_CONF_DIR='/etc/amavis/conf.d'
|
||||
export AMAVISD_CONF='/etc/amavis/conf.d/50-user'
|
||||
export AMAVISD_RC_SCRIPT_NAME='amavis'
|
||||
export AMAVISD_LDAP_SCHEMA_NAME='amavis.schema'
|
||||
|
||||
export AMAVISD_SPOOL_DIR='/var/lib/amavis'
|
||||
export AMAVISD_VAR_RUN_DIR='/var/run/amavis'
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Override global setting: user/group.
|
||||
export SYS_USER_AMAVISD='vscan'
|
||||
export SYS_GROUP_AMAVISD='vscan'
|
||||
|
||||
export AMAVISD_BIN='/usr/local/sbin/amavisd'
|
||||
export AMAVISD_CONF='/usr/local/etc/amavisd.conf'
|
||||
export AMAVISD_LDAP_SCHEMA_NAME='amavisd-new.schema'
|
||||
|
||||
export AMAVISD_SPOOL_DIR='/var/amavis'
|
||||
export AMAVISD_VAR_RUN_DIR="${AMAVISD_SPOOL_DIR}/var"
|
||||
|
||||
# Override location of command 'altermime'
|
||||
export CMD_ALTERMIME='/usr/local/bin/altermime'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export SYS_USER_AMAVISD='_vscan'
|
||||
export SYS_GROUP_AMAVISD='_vscan'
|
||||
|
||||
export AMAVISD_BIN='/usr/local/sbin/amavisd'
|
||||
export AMAVISD_CONF='/etc/amavisd.conf'
|
||||
export AMAVISD_LDAP_SCHEMA_NAME='amavisd.schema'
|
||||
|
||||
export AMAVISD_SPOOL_DIR='/var/amavisd'
|
||||
export AMAVISD_VAR_RUN_DIR="${AMAVISD_SPOOL_DIR}"
|
||||
|
||||
# Override location of command 'altermime'
|
||||
export CMD_ALTERMIME='/usr/local/bin/altermime'
|
||||
|
||||
fi
|
||||
|
||||
export CRON_FILE_AMAVISD="${CRON_SPOOL_DIR}/${SYS_USER_AMAVISD}"
|
||||
|
||||
export AMAVISD_DB_DIR="${AMAVISD_SPOOL_DIR}/db"
|
||||
export AMAVISD_QUARANTINE_DIR="${AMAVISD_SPOOL_DIR}/quarantine"
|
||||
export AMAVISD_TEMP_DIR="${AMAVISD_SPOOL_DIR}/tmp"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
export AMAVISD_VIRUSMAILS_DIR="${AMAVISD_QUARANTINE_DIR}"
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
export AMAVISD_VIRUSMAILS_DIR="${AMAVISD_SPOOL_DIR}/virusmails"
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export AMAVISD_VIRUSMAILS_DIR='/var/virusmails'
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export AMAVISD_VIRUSMAILS_DIR='/var/virusmails'
|
||||
fi
|
||||
|
||||
export AMAVISD_LOCK_FILE="${AMAVISD_VAR_RUN_DIR}/amavisd.lock"
|
||||
export AMAVISD_PID_FILE="${AMAVISD_VAR_RUN_DIR}/amavisd.pid"
|
||||
export AMAVISD_SOCKET_FILE="${AMAVISD_VAR_RUN_DIR}/amavisd.socket"
|
||||
|
||||
export AMAVISD_DB_MYSQL_TMPL="${SAMPLE_DIR}/amavisd/amavisd.mysql"
|
||||
export AMAVISD_DB_PGSQL_TMPL="${SAMPLE_DIR}/amavisd/amavisd.pgsql"
|
||||
|
||||
# Value of Postfix parameter `content_filter=`.
|
||||
export AMAVISD_CONTENT_FILTER_ORIGINATING="smtp-amavis:[${SMTP_SERVER}]:${AMAVISD_ORIGINATING_PORT}"
|
||||
|
||||
# mynetworks, inet_acl
|
||||
export AMAVISD_MYNETWORKS='127.0.0.0/8'
|
||||
export AMAVISD_INET_ACL='127.0.0.1 [::1]'
|
||||
if [ X"${LOCAL_ADDRESS}" != X'127.0.0.1' ]; then
|
||||
export AMAVISD_MYNETWORKS="${AMAVISD_MYNETWORKS},${LOCAL_ADDRESS}"
|
||||
export AMAVISD_INET_ACL="${AMAVISD_INET_ACL} ${LOCAL_ADDRESS}"
|
||||
fi
|
||||
|
||||
# Num of pre-forked children.
|
||||
# Try to set it to memory size (in GB)
|
||||
export AMAVISD_MAX_SERVERS='2'
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
_mem_size_gb="$(free -g | grep '^Mem:' | awk '{print $2}')"
|
||||
export AMAVISD_MAX_SERVERS="$((${_mem_size_gb} + 1))"
|
||||
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
_mem_size="$(sysctl hw.realmem | awk '{print $2}')"
|
||||
export AMAVISD_MAX_SERVERS="$((${_mem_size} / 1024 / 1024 / 1024 + 1))"
|
||||
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
_mem_size="$(sysctl hw.physmem | awk -F'=' '{print $2}')"
|
||||
export AMAVISD_MAX_SERVERS="$((${_mem_size} / 1024 / 1024 / 1024 + 1))"
|
||||
fi
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
export SYS_USER_CLAMAV='clamav'
|
||||
export SYS_GROUP_CLAMAV='clamav'
|
||||
export CLAMAV_CLAMD_SERVICE_NAME='clamd'
|
||||
export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='freshclamd'
|
||||
|
||||
export CLAMD_CONF='/etc/clamd.conf'
|
||||
export CLAMD_LOG_DIR='/var/log/clamav'
|
||||
export CLAMD_LOGFILE="${CLAMD_LOG_DIR}/clamd.log"
|
||||
# CLAMD_BIND_HOST is configured in conf/global
|
||||
export CLAMD_LOCAL_SOCKET='/tmp/clamd.socket'
|
||||
|
||||
export FRESHCLAM_CONF='/etc/freshclam.conf'
|
||||
export FRESHCLAM_LOGFILE="${CLAMD_LOG_DIR}/freshclam.log"
|
||||
export FRESHCLAM_PID_FILE='/var/run/clamav/freshclam.pid'
|
||||
|
||||
# Update database immediately
|
||||
export FRESHCLAM_UPDATE_IMMEDIATELY="${FRESHCLAM_UPDATE_IMMEDIATELY:=YES}"
|
||||
|
||||
# Clamav.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
export SYS_USER_CLAMAV='amavis'
|
||||
export SYS_GROUP_CLAMAV='amavis'
|
||||
|
||||
export CLAMD_CONF='/etc/clamd.d/amavisd.conf'
|
||||
export CLAMD_LOCAL_SOCKET='/var/run/clamd.amavisd/clamd.socket'
|
||||
|
||||
export CLAMAV_CLAMD_SERVICE_NAME='clamd@amavisd'
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
export CLAMAV_CLAMD_SERVICE_NAME='clamav-daemon'
|
||||
export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='clamav-freshclam'
|
||||
|
||||
export CLAMD_CONF='/etc/clamav/clamd.conf'
|
||||
export FRESHCLAM_CONF='/etc/clamav/freshclam.conf'
|
||||
|
||||
export CLAMD_LOCAL_SOCKET='/var/run/clamav/clamd.ctl'
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export CLAMD_CONF='/usr/local/etc/clamd.conf'
|
||||
export FRESHCLAM_CONF='/usr/local/etc/freshclam.conf'
|
||||
export CLAMD_LOCAL_SOCKET='/var/run/clamav/clamd.sock'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export SYS_USER_CLAMAV='_clamav'
|
||||
export SYS_GROUP_CLAMAV='_clamav'
|
||||
export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='freshclam'
|
||||
|
||||
export FRESHCLAM_PID_FILE='/var/run/freshclam.pid'
|
||||
fi
|
||||
@@ -0,0 +1,624 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
ECHO_INFO()
|
||||
{
|
||||
if [ X"$1" == X"-n" ]; then
|
||||
shift 1
|
||||
echo -ne "${_INFO_FLAG} $@"
|
||||
else
|
||||
echo -e "${_INFO_FLAG} $@"
|
||||
fi
|
||||
echo -e "${_INFO_FLAG} $@" >> ${INSTALL_LOG}
|
||||
}
|
||||
|
||||
ECHO_SKIP()
|
||||
{
|
||||
echo -e "${_SKIP_FLAG} $@"
|
||||
echo -e "${_SKIP_FLAG} $@" >> ${INSTALL_LOG}
|
||||
}
|
||||
|
||||
ECHO_QUESTION()
|
||||
{
|
||||
if [ X"$1" == X"-n" ]; then
|
||||
shift 1
|
||||
echo -ne "${_QUESTION_FLAG} $@"
|
||||
else
|
||||
echo -e "${_QUESTION_FLAG} $@"
|
||||
fi
|
||||
}
|
||||
|
||||
ECHO_ERROR()
|
||||
{
|
||||
echo -e "${_ERROR_FLAG} $@"
|
||||
echo -e "${_ERROR_FLAG} $@" >> ${INSTALL_LOG}
|
||||
}
|
||||
|
||||
ECHO_DEBUG()
|
||||
{
|
||||
echo -e "${_DEBUG_FLAG} $@" >> ${INSTALL_LOG}
|
||||
}
|
||||
|
||||
read_setting()
|
||||
{
|
||||
answer="${1}"
|
||||
if [ ! -z "${answer}" ]; then
|
||||
ANSWER="${answer}"
|
||||
echo ${ANSWER}
|
||||
else
|
||||
read ANSWER
|
||||
fi
|
||||
}
|
||||
|
||||
backup_file()
|
||||
{
|
||||
# Usage: backup_file file1 [file2 file3 ... fileN]
|
||||
if [ X"$#" != X"0" ]; then
|
||||
for f in $@; do
|
||||
if [ -f ${f} ]; then
|
||||
if [ X"${IREDMAIL_DEBUG}" == X'YES' ]; then
|
||||
echo -e "${_BACKUP_FLAG} ${f} -> ${f}.${DATE}."
|
||||
fi
|
||||
cp -f ${f} ${f}.${DATE}
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
check_user()
|
||||
{
|
||||
# Check special user privilege to execute this script.
|
||||
if [ X"$(id -u)" != X"$(id -u ${1})" ]; then
|
||||
ECHO_ERROR "Please run this script as user: ${1}."
|
||||
exit 255
|
||||
else
|
||||
if [ X"$(id -u)" == X"0" ]; then
|
||||
export PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_hostname()
|
||||
{
|
||||
echo ${HOSTNAME} | grep '.\..*' &>/dev/null
|
||||
[ X"$?" != X'0' ] && \
|
||||
ECHO_ERROR "Please configure a fully qualified domain name (FQDN) in /etc/hosts before we go further.\n\nExample:\n\n127.0.0.1 mail.iredmail.org mail localhost\n" && \
|
||||
exit 255
|
||||
}
|
||||
|
||||
check_openbsd_install_url()
|
||||
{
|
||||
touch /etc/installurl
|
||||
|
||||
# Make sure it contains a http/ftp/scp URL
|
||||
if ! grep -Ei '^(ftp|http|https|scp)://' /etc/installurl &>/dev/null; then
|
||||
ECHO_INFO "No valid OpenBSD mirror server URL found in file /etc/installurl."
|
||||
ECHO_INFO "We will use the fastly CDN for this iRedMail installation:"
|
||||
ECHO_INFO ''
|
||||
ECHO_INFO " - https://fastly.cdn.openbsd.org/pub/OpenBSD"
|
||||
ECHO_INFO ''
|
||||
ECHO_INFO "If you prefer a nearest mirror site, please check links below:"
|
||||
ECHO_INFO ''
|
||||
ECHO_INFO " - Mirror sites: http://www.openbsd.org/ftp.html"
|
||||
ECHO_INFO " - installurl(5): http://man.openbsd.org/installurl.5"
|
||||
ECHO_INFO ''
|
||||
echo 'https://fastly.cdn.openbsd.org/pub/OpenBSD' >> /etc/installurl
|
||||
fi
|
||||
}
|
||||
|
||||
check_pkg()
|
||||
{
|
||||
# Usage: check_pkg <command> <package>
|
||||
# It means: <package> owns <command>
|
||||
cmd="$1"
|
||||
pkg="$2"
|
||||
|
||||
for i in $(echo $PATH|sed 's/:/ /g'); do
|
||||
[ -x $i/${cmd} ] && export HAS_CMD='YES' && break
|
||||
done
|
||||
|
||||
if [ X"${HAS_CMD}" != X'YES' ]; then
|
||||
ECHO_INFO "Install package: ${pkg}"
|
||||
eval ${install_pkg} ${pkg}
|
||||
if [ X"$?" != X"0" ]; then
|
||||
ECHO_ERROR "Please install package ${pkg} first." && exit 255
|
||||
fi
|
||||
fi
|
||||
|
||||
unset HAS_CMD
|
||||
}
|
||||
|
||||
check_runtime_dir() {
|
||||
[ -d ${RUNTIME_DIR} ] || mkdir -p ${RUNTIME_DIR}
|
||||
|
||||
# Cleanup
|
||||
rm -f ${RUNTIME_DIR}/.pkg_install_failed &>/dev/null
|
||||
}
|
||||
|
||||
check_required_os_dirs() {
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
[ -d ${LOGROTATE_DIR} ] || mkdir -p ${LOGROTATE_DIR}
|
||||
fi
|
||||
}
|
||||
|
||||
# Check necessery privileges/files/dirs.
|
||||
check_env()
|
||||
{
|
||||
check_runtime_dir
|
||||
check_required_os_dirs
|
||||
|
||||
# Check user privilege.
|
||||
check_user root
|
||||
|
||||
# Check FQDN hostname.
|
||||
check_hostname
|
||||
|
||||
[ X"${DISTRO}" == X'OPENBSD' ] && check_openbsd_install_url
|
||||
|
||||
# Check config tool: dialog.
|
||||
check_pkg ${BIN_DIALOG} ${PKG_DIALOG}
|
||||
|
||||
ECHO_INFO -n "Checking configuration file: ${IREDMAIL_CONFIG_FILE} ..."
|
||||
if [ -f ${IREDMAIL_CONFIG_FILE} ]; then
|
||||
if grep '^#EOF$' ${IREDMAIL_CONFIG_FILE} >/dev/null; then
|
||||
echo -e " [FOUND]"
|
||||
ECHO_QUESTION -n "Use it for mail server setting? [y|N]"
|
||||
read_setting ${AUTO_USE_EXISTING_CONFIG_FILE}
|
||||
case ${ANSWER} in
|
||||
Y|y|[Yy][Ee][Ss] )
|
||||
ECHO_INFO "Use config file: ${IREDMAIL_CONFIG_FILE} for mail server setting."
|
||||
. ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
# Check installation status.
|
||||
# After each component installation was completed, there
|
||||
# should be a variable in ${STATUS_FILE}, e.g.
|
||||
#
|
||||
# export STATUS_PHP_INSTALLATION='DONE'
|
||||
# export STATUS_PHP_CONFIGURATION='DONE'
|
||||
#
|
||||
if [ -f ${STATUS_FILE} ]; then
|
||||
ECHO_INFO "Import installation process status from file: ${STATUS_FILE}."
|
||||
. ${STATUS_FILE}
|
||||
else
|
||||
echo '' > ${STATUS_FILE}
|
||||
fi
|
||||
|
||||
# Initialize tip file.
|
||||
if [ ! -f ${TIP_FILE} ]; then
|
||||
cat > ${TIP_FILE} <<EOF
|
||||
${CONF_MSG}
|
||||
EOF
|
||||
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${TIP_FILE}
|
||||
chmod 0400 ${TIP_FILE}
|
||||
fi
|
||||
;;
|
||||
N|n|* )
|
||||
ECHO_INFO "Skip configuration file: ${IREDMAIL_CONFIG_FILE}."
|
||||
backup_file ${IREDMAIL_CONFIG_FILE}
|
||||
. ${CONFIG_VIA_DIALOG}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
ECHO_INFO "Found, but not finished. Launching installation wizard."
|
||||
. ${CONFIG_VIA_DIALOG}
|
||||
fi
|
||||
else
|
||||
ECHO_INFO "NOT FOUND. Launching installation wizard."
|
||||
. ${CONFIG_VIA_DIALOG}
|
||||
fi
|
||||
}
|
||||
|
||||
extract_pkg()
|
||||
{
|
||||
if [ X"$2" = X"" ]; then
|
||||
DST='.'
|
||||
else
|
||||
DST="$2"
|
||||
fi
|
||||
|
||||
if echo $1 | grep '.tar.gz$' &>/dev/null; then
|
||||
ECHO_DEBUG "Extracting: $1 -> ${DST}"
|
||||
tar zxf $1 -C $DST
|
||||
elif echo $1 | grep '.tgz$' &>/dev/null; then
|
||||
ECHO_DEBUG "Extracting: $1 -> ${DST}"
|
||||
tar zxf $1 -C $DST
|
||||
elif echo $1 | grep '.tar.bz2$' &>/dev/null; then
|
||||
# Install bzip2 first.
|
||||
check_pkg ${BIN_BZIP2} ${PKG_BZIP2}
|
||||
|
||||
ECHO_DEBUG "Extracting: $1 -> ${DST}"
|
||||
tar xjf $1 -C $DST
|
||||
else
|
||||
ECHO_ERROR "Unknown archive format."
|
||||
fi
|
||||
}
|
||||
|
||||
check_status_before_run()
|
||||
{
|
||||
# If function was successfully executed, this function will write one line
|
||||
# in $STATUS_FILE:
|
||||
#
|
||||
# export status_[function_name]='DONE'
|
||||
#
|
||||
function_name="${1}"
|
||||
function_status_name="status_${function_name}"
|
||||
function_status_value="$(eval echo \$${function_status_name})"
|
||||
if [ X"${function_status_value}" == X"DONE" ]; then
|
||||
ECHO_SKIP "Function: $1."
|
||||
else
|
||||
$function_name
|
||||
fi
|
||||
}
|
||||
|
||||
# Hash maildir string.
|
||||
hash_maildir()
|
||||
{
|
||||
# Usage:
|
||||
#
|
||||
# hash_maildir username
|
||||
# hash_maildir --no-timestamp username
|
||||
#
|
||||
# With '--no-timestamp', the maildir path will not contain timestamp string
|
||||
if [ X"$1" == X'--no-timestamp' ]; then
|
||||
_timestamp=''
|
||||
shift 1
|
||||
else
|
||||
_timestamp="-${DATE}"
|
||||
fi
|
||||
|
||||
username="$( echo $1 | tr '[A-Z]' '[a-z]' )"
|
||||
|
||||
# Different maildir style: hashed, normal.
|
||||
if [ X"${MAILDIR_STYLE}" == X"hashed" ]; then
|
||||
str1="$(echo ${username} | cut -c1)"
|
||||
str2="$(echo ${username} | cut -c2)"
|
||||
str3="$(echo ${username} | cut -c3)"
|
||||
|
||||
if [ X"${username}" == X"${str1}" ]; then
|
||||
# Username has only one character
|
||||
str2="${str1}"
|
||||
str3="${str1}"
|
||||
elif [ X"${username}" == X"${str1}${str2}" ]; then
|
||||
str3="${str2}"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
maildir="${str1}/${str2}/${str3}/${username}${_timestamp}/"
|
||||
else
|
||||
maildir="${username}${_timestamp}/"
|
||||
fi
|
||||
|
||||
echo ${maildir}
|
||||
}
|
||||
|
||||
# All Linux/BSD distributions: for one service:
|
||||
# service_control [enable|disable|start|stop|restart] <service>
|
||||
# Linux: for multiple services:
|
||||
# service_control [enable|disable|start|stop|restart] <service1> <service2> <service3> ...
|
||||
# FreeBSD: for one service:
|
||||
# service_control enable '<service>_enable' 'YES'
|
||||
service_control()
|
||||
{
|
||||
action="$1" # enable, disable, start, stop, restart
|
||||
shift 1
|
||||
service="$1" # first service name
|
||||
services="$@" # all service names
|
||||
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
ECHO_DEBUG "Service control: ${action} ${services}."
|
||||
if [ X"${USE_SYSTEMD}" == X'YES' ]; then
|
||||
service ${services} ${action}
|
||||
else
|
||||
for srv in ${services}; do
|
||||
rc_script="${DIR_RC_SCRIPTS}/$srv"
|
||||
${rc_script} $action
|
||||
done
|
||||
fi
|
||||
|
||||
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
if [ X"${action}" == X'enable' ]; then
|
||||
if [ X"$#" == X'2' ]; then
|
||||
${SYSRC} -f ${RC_CONF_LOCAL} ${1}="${2}" >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
elif [ X"${action}" == X'disable' ]; then
|
||||
# Already handled in functions/*.sh.
|
||||
:
|
||||
else
|
||||
${DIR_RC_SCRIPTS}/${service} $action >/dev/null
|
||||
fi
|
||||
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
for srv in ${services}; do
|
||||
rcctl ${action} ${srv} >> ${INSTALL_LOG} 2>&1
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
generate_password_hash()
|
||||
{
|
||||
_scheme="${1}"
|
||||
_password="${2}"
|
||||
|
||||
if [ X"${_scheme}" == X'BCRYPT' ]; then
|
||||
_scheme='BLF-CRYPT'
|
||||
fi
|
||||
|
||||
doveadm pw -s "${_scheme}" -p "${_password}"
|
||||
}
|
||||
|
||||
# Create SSL certs/private files.
|
||||
generate_ssl_keys()
|
||||
{
|
||||
ECHO_INFO "Generate self-signed SSL cert (${SSL_KEY_SIZE} bits, expire in 10 years)."
|
||||
|
||||
# Create necessary directories.
|
||||
mkdir -p ${SSL_KEY_DIR} ${SSL_CERT_DIR} &>/dev/null
|
||||
|
||||
openssl req \
|
||||
-x509 \
|
||||
-nodes \
|
||||
-days 3650 \
|
||||
-sha256 \
|
||||
-subj "/C=${TLS_COUNTRY}/ST=${TLS_STATE}/L=${TLS_CITY}/O=${TLS_COMPANY}/OU=${TLS_DEPARTMENT}/CN=${TLS_HOSTNAME}/emailAddress=${TLS_ADMIN}/" \
|
||||
-newkey rsa:${SSL_KEY_SIZE} \
|
||||
-out ${SSL_CERT_FILE} \
|
||||
-keyout ${SSL_KEY_FILE} &>/dev/null
|
||||
|
||||
# Set correct file permission.
|
||||
chmod +r ${SSL_CERT_FILE}
|
||||
chmod +r ${SSL_KEY_FILE}
|
||||
|
||||
# Fix 'The Logjam Attack'. References:
|
||||
# - https://weakdh.org/
|
||||
# - https://weakdh.org/sysadmin.html
|
||||
ECHO_INFO "Generate Diffie Hellman Group with openssl, please wait."
|
||||
openssl dhparam -out ${SSL_DH512_PARAM_FILE} 512 5>&1 &>/dev/null
|
||||
openssl dhparam -out ${SSL_DH1024_PARAM_FILE} 2048 5>&1 &>/dev/null
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
|
||||
SSL cert keys (size: ${SSL_KEY_SIZE}):
|
||||
- ${SSL_CERT_FILE}
|
||||
- ${SSL_KEY_FILE}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_generate_ssl_keys="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
# Add alias entry in Postfix /etc/postfix/aliases.
|
||||
add_postfix_alias()
|
||||
{
|
||||
# Usage: add_postfix_alias [src_username] [dest_username or email address]
|
||||
# File ${POSTFIX_FILE_ALIASES} will be created if not exist.
|
||||
export alias_src="${1}"
|
||||
export alias_dest="${2}"
|
||||
|
||||
if [ ! -f ${POSTFIX_FILE_ALIASES} ]; then
|
||||
if [ -f /etc/aliases ]; then
|
||||
cp -f /etc/aliases ${POSTFIX_FILE_ALIASES}
|
||||
else
|
||||
# Create an empty file
|
||||
touch ${POSTFIX_FILE_ALIASES}
|
||||
fi
|
||||
fi
|
||||
|
||||
# If alias_src exists, comment it out
|
||||
if grep "^${alias_src}:" ${POSTFIX_FILE_ALIASES} &>/dev/null; then
|
||||
perl -pi -e 's/^($ENV{alias_src}:.*)/#${1}/' ${POSTFIX_FILE_ALIASES}
|
||||
fi
|
||||
|
||||
# Add new alias
|
||||
echo "${alias_src}: ${alias_dest}" >> ${POSTFIX_FILE_ALIASES}
|
||||
|
||||
postalias hash:${POSTFIX_FILE_ALIASES} &>/dev/null
|
||||
unset alias_src
|
||||
unset alias_dest
|
||||
}
|
||||
|
||||
# Install/Remove binary packages on RHEL/CentOS.
|
||||
install_pkg_rhel()
|
||||
{
|
||||
ECHO_INFO "Installing package(s): $@"
|
||||
${YUM} -y --disablerepo=rpmforge,ius,remi,atrpms install $@
|
||||
|
||||
# Leave a mark if package installation failed.
|
||||
if [ X"$?" != X'0' ]; then
|
||||
echo '' > ${RUNTIME_DIR}/.pkg_install_failed
|
||||
fi
|
||||
}
|
||||
|
||||
remove_pkg_rhel()
|
||||
{
|
||||
ECHO_INFO "Removing package(s): $@"
|
||||
${YUM} remove -y $@
|
||||
if [ X"$?" != X"0" ]; then
|
||||
ECHO_ERROR "Package removed failed, please check the terminal output."
|
||||
echo '' > ${RUNTIME_DIR}/.pkg_remove_failed
|
||||
fi
|
||||
}
|
||||
|
||||
# Install/Remove binary packages on Debian/Ubuntu.
|
||||
install_pkg_debian()
|
||||
{
|
||||
ECHO_INFO "Installing package(s): $@"
|
||||
${APTGET} install -y $@
|
||||
|
||||
# Leave a mark if package installation failed.
|
||||
if [ X"$?" != X"0" ]; then
|
||||
echo '' > ${RUNTIME_DIR}/.pkg_install_failed
|
||||
fi
|
||||
}
|
||||
|
||||
remove_pkg_debian()
|
||||
{
|
||||
ECHO_INFO "Removing package(s): $@"
|
||||
${APTGET} purge -y $@
|
||||
if [ X"$?" != X"0" ]; then
|
||||
ECHO_ERROR "Package removed failed, please check the terminal output."
|
||||
echo '' > ${RUNTIME_DIR}/.pkg_remove_failed
|
||||
fi
|
||||
}
|
||||
|
||||
install_pkg_openbsd()
|
||||
{
|
||||
ECHO_INFO "Installing packages (pkg_add -i -m): $@"
|
||||
|
||||
pkg_add -i -m $@
|
||||
|
||||
# Leave a mark if package installation failed.
|
||||
if [ X"$?" != X"0" ]; then
|
||||
echo '' > ${RUNTIME_DIR}/.pkg_install_failed
|
||||
fi
|
||||
}
|
||||
|
||||
freebsd_make_conf_add()
|
||||
{
|
||||
# USAGE: freebsd_make_conf_add VAR VALUE
|
||||
[ -f ${FREEBSD_MAKE_CONF} ] || touch ${FREEBSD_MAKE_CONF}
|
||||
if [ X"$#" == X'2' ]; then
|
||||
var="${1}"
|
||||
value="${2}"
|
||||
final_option="${1}=${2}"
|
||||
comment_mark="# ${PROG_NAME}-${var}"
|
||||
if ! grep "^${comment_mark}$" ${FREEBSD_MAKE_CONF} &>/dev/null; then
|
||||
ECHO_DEBUG "Update ${FREEBSD_MAKE_CONF}: ${final_option}"
|
||||
echo "${comment_mark}" >> ${FREEBSD_MAKE_CONF}
|
||||
echo "${final_option}" >> ${FREEBSD_MAKE_CONF}
|
||||
else
|
||||
ECHO_DEBUG "Skip adding option in ${FREEBSD_MAKE_CONF}: ${final_option}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
freebsd_make_conf_plus_option()
|
||||
{
|
||||
# USAGE: freebsd_make_conf_plus_option VAR VALUE
|
||||
[ -f ${FREEBSD_MAKE_CONF} ] || touch ${FREEBSD_MAKE_CONF}
|
||||
if [ X"$#" == X'2' ]; then
|
||||
var="${1}"
|
||||
value="${2}"
|
||||
final_option="${1}+=${2}"
|
||||
comment_mark="# ${PROG_NAME}-${var}-${value}"
|
||||
if ! grep "^${comment_mark}$" ${FREEBSD_MAKE_CONF} &>/dev/null; then
|
||||
ECHO_DEBUG "Update ${FREEBSD_MAKE_CONF}: ${final_option}"
|
||||
echo "${comment_mark}" >> ${FREEBSD_MAKE_CONF}
|
||||
echo "${final_option}" >> ${FREEBSD_MAKE_CONF}
|
||||
else
|
||||
ECHO_DEBUG "Skip adding option in ${FREEBSD_MAKE_CONF}: ${final_option}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ask_confirm()
|
||||
{
|
||||
# Usage: ask_confirm 'prompt text'
|
||||
prompt_text="${1}"
|
||||
echo -ne "${prompt_text} [y|N]"
|
||||
read ANSWER
|
||||
case ${ANSWER} in
|
||||
Y|y ) : ;;
|
||||
N|n|* ) echo "Exit." && exit ;;
|
||||
esac
|
||||
}
|
||||
|
||||
add_sys_user_group()
|
||||
{
|
||||
_user="$1"
|
||||
_group="$2"
|
||||
_uid="$3"
|
||||
_gid="$4"
|
||||
|
||||
_home="$5"
|
||||
_shell="$6"
|
||||
|
||||
_args_u="-m -g ${_group}"
|
||||
_args_g=''
|
||||
if [ X"${_uid}" != X'' ]; then
|
||||
_args_u="${_args_u} -u ${_uid}"
|
||||
fi
|
||||
|
||||
if [ X"${_gid}" != X'' ]; then
|
||||
_args_g="${_args_g} -g ${_gid}"
|
||||
fi
|
||||
|
||||
if [ X"${_home}" != X'' ]; then
|
||||
_args_u="${_args_u} -d ${_home}"
|
||||
fi
|
||||
|
||||
if [ X"${_shell}" == X'' ]; then
|
||||
_shell="${SHELL_NOLOGIN}"
|
||||
fi
|
||||
_args_u="${_args_u} -s ${_shell}"
|
||||
|
||||
ECHO_DEBUG "Create system account: ${_user}:${_group}."
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
pw groupadd ${_args_g} -n ${_group} >> ${INSTALL_LOG} 2>&1
|
||||
pw useradd ${_args_u} -n ${_user} >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
groupadd ${_args_g} ${_user} >> ${INSTALL_LOG} 2>&1
|
||||
useradd \
|
||||
-u ${_uid} \
|
||||
-g ${_group} \
|
||||
-s ${_shell} \
|
||||
${_user} >> ${INSTALL_LOG} 2>&1
|
||||
else
|
||||
groupadd ${_args_g} ${_group} >> ${INSTALL_LOG} 2>&1
|
||||
useradd ${_args_u} ${_user} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
update_sysctl_param()
|
||||
{
|
||||
export _param="$1"
|
||||
export _value="$2"
|
||||
|
||||
if grep "^${_param}\>" ${SYSCTL_CONF} &>/dev/null; then
|
||||
# param exists, updating it.
|
||||
perl -pi -e 's#^($ENV{_param})[ =].*#${1}=$ENV{_value}#' ${SYSCTL_CONF}
|
||||
else
|
||||
# param doesn't exist. add a new one.
|
||||
echo "${_param}=${_value}" >> ${SYSCTL_CONF}
|
||||
fi
|
||||
|
||||
unset _param _value
|
||||
}
|
||||
|
||||
write_iredmail_kv()
|
||||
{
|
||||
# usage: write_iredmail_kv <param> <value>
|
||||
# Storage value to file /root/.iredmail/kv/<param>.
|
||||
param="$1"
|
||||
value="$2"
|
||||
|
||||
[[ -f ${IREDMAIL_KV_DIR} ]] || mkdir -p ${IREDMAIL_KV_DIR}
|
||||
|
||||
f="${IREDMAIL_KV_DIR}/${param}"
|
||||
echo "${value}" > ${f}
|
||||
|
||||
chown -R ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${IREDMAIL_KV_DIR}
|
||||
chmod -R 0400 ${IREDMAIL_KV_DIR}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------
|
||||
# For Dovecot and dovecot-sieve.
|
||||
# ----------------------------------------
|
||||
|
||||
# Major version number of Dovecot package: 2.2, 2.3.
|
||||
export DOVECOT_VERSION='2.3'
|
||||
|
||||
# Dovecot user & group.
|
||||
export SYS_USER_DOVECOT='dovecot'
|
||||
export SYS_GROUP_DOVECOT='dovecot'
|
||||
export DOVECOT_RC_SCRIPT_NAME='dovecot'
|
||||
|
||||
export DOVECOT_BIN='/usr/sbin/dovecot'
|
||||
export DOVECOT_DOVEADM_BIN='/usr/bin/doveadm'
|
||||
export DOVECOT_SIEVEC='/usr/libexec/dovecot/sievec'
|
||||
|
||||
# Dovecot running directory, required by dovecot-2.x.
|
||||
export DOVECOT_BASE_DIR='/var/run/dovecot'
|
||||
|
||||
# Enabled plugins for protocol 'lda' and 'imap'.
|
||||
export DOVECOT_LDA_PLUGINS='quota sieve autocreate'
|
||||
export DOVECOT_IMAP_PLUGINS='quota imap_quota autocreate'
|
||||
|
||||
# Default quota type: maildir, dict:user::proxy::quotadict (quotadict).
|
||||
export DOVECOT_QUOTA_TYPE='dict:user::proxy::quotadict'
|
||||
|
||||
# Do not starts with dot (.).
|
||||
export SIEVE_RULE_FILENAME='dovecot.sieve'
|
||||
export DOVECOT_GLOBAL_SIEVE_FILE="${SIEVE_DIR}/${SIEVE_RULE_FILENAME}"
|
||||
|
||||
# Directory used to store Dovecot config files
|
||||
export DOVECOT_CONF_DIR='/etc/dovecot'
|
||||
export DOVECOT_CONF_INCLUDE_DIR='/etc/dovecot/iredmail'
|
||||
|
||||
# Path to Dovecot deliver agant
|
||||
export DOVECOT_DELIVER_BIN='/usr/libexec/dovecot/deliver'
|
||||
|
||||
# main log file
|
||||
export DOVECOT_LOG_DIR='/var/log/dovecot'
|
||||
export DOVECOT_LOG_FILE="${DOVECOT_LOG_DIR}/dovecot.log"
|
||||
# Log files when we use Dovecot internal log system
|
||||
export DOVECOT_SIEVE_LOG_FILE="${DOVECOT_LOG_DIR}/sieve.log"
|
||||
export DOVECOT_LMTP_LOG_FILE="${DOVECOT_LOG_DIR}/lmtp.log"
|
||||
# Log files when we use syslog
|
||||
export DOVECOT_SYSLOG_FILE_LDA="${DOVECOT_LOG_DIR}/lda.log"
|
||||
export DOVECOT_SYSLOG_FILE_IMAP="${DOVECOT_LOG_DIR}/imap.log"
|
||||
export DOVECOT_SYSLOG_FILE_POP3="${DOVECOT_LOG_DIR}/pop3.log"
|
||||
export DOVECOT_SYSLOG_FILE_SIEVE="${DOVECOT_LOG_DIR}/sieve.log"
|
||||
|
||||
# Log rotate config file
|
||||
export DOVECOT_LOGROTATE_FILE="${LOGROTATE_DIR}/dovecot"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
export DOVECOT_VERSION='2.2'
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
export DOVECOT_DELIVER_BIN='/usr/lib/dovecot/deliver'
|
||||
|
||||
# Debian 9, Ubuntu 18.04.
|
||||
if [ X"${DISTRO_CODENAME}" == X'stretch' -o X"${DISTRO_CODENAME}" == X'bionic' ]; then
|
||||
export DOVECOT_VERSION='2.2'
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export DOVECOT_CONF_DIR='/usr/local/etc/dovecot'
|
||||
export DOVECOT_DELIVER_BIN='/usr/local/libexec/dovecot/deliver'
|
||||
export DOVECOT_DOVEADM_BIN='/usr/local/bin/doveadm'
|
||||
export DOVECOT_CONF_INCLUDE_DIR='/usr/local/etc/dovecot/iredmail'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export SYS_USER_DOVECOT='_dovecot'
|
||||
export SYS_GROUP_DOVECOT='_dovecot'
|
||||
export DOVECOT_DELIVER_BIN='/usr/local/libexec/dovecot/deliver'
|
||||
export DOVECOT_DOVEADM_BIN='/usr/local/bin/doveadm'
|
||||
fi
|
||||
|
||||
# Dovecot config files
|
||||
export DOVECOT_CONF="${DOVECOT_CONF_DIR}/dovecot.conf"
|
||||
export DOVECOT_LDAP_CONF="${DOVECOT_CONF_DIR}/dovecot-ldap.conf"
|
||||
export DOVECOT_MYSQL_CONF="${DOVECOT_CONF_DIR}/dovecot-mysql.conf"
|
||||
export DOVECOT_PGSQL_CONF="${DOVECOT_CONF_DIR}/dovecot-pgsql.conf"
|
||||
export DOVECOT_REALTIME_QUOTA_CONF="${DOVECOT_CONF_DIR}/dovecot-used-quota.conf"
|
||||
export DOVECOT_SHARE_FOLDER_CONF="${DOVECOT_CONF_DIR}/dovecot-share-folder.conf"
|
||||
export DOVECOT_LAST_LOGIN_CONF="${DOVECOT_CONF_DIR}/dovecot-last-login.conf"
|
||||
export DOVECOT_MASTER_USER_PASSWORD_FILE="${DOVECOT_CONF_DIR}/dovecot-master-users"
|
||||
export DOVECOT_MASTER_USER_DOMAIN="${DOVECOT_MASTER_USER_DOMAIN:=not-exist.com}"
|
||||
|
||||
# Dovecot auth socket and pid file.
|
||||
# Relative path of Dovecot auth socket under Postfix chroot directory.
|
||||
export DOVECOT_SASL_AUTH_SOCKET='private/dovecot-auth'
|
||||
export DOVECOT_AUTH_MASTER_PATH="${DOVECOT_BASE_DIR}/auth-master"
|
||||
export DOVECOT_MASTER_PID="${DOVECOT_BASE_DIR}/master.pid"
|
||||
|
||||
# Protocols.
|
||||
export DOVECOT_PROTOCOLS="pop3 imap sieve lmtp"
|
||||
|
||||
# Plugin: Expire.
|
||||
# NOTE: dict process currently runs as root, so this file will be owned as root.
|
||||
export DOVECOT_EXPIRE_DICT_BDB='/var/lib/dovecot/expire/expire.db'
|
||||
|
||||
# Plugin: quota warning.
|
||||
export DOVECOT_QUOTA_WARNING_SCRIPT='/usr/local/bin/dovecot-quota-warning.sh'
|
||||
# Plugin: share folder.
|
||||
export DOVECOT_SHARE_FOLDER_DB_TABLE='share_folder'
|
||||
export DOVECOT_SHARE_FOLDER_ANYONE_DB_TABLE='anyone_shares'
|
||||
export DOVECOT_REALTIME_QUOTA_TABLE='used_quota'
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
export DOVECOT_SQL_DBN='mysql'
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
export DOVECOT_SQL_DBN='pgsql'
|
||||
fi
|
||||
|
||||
# Plugin: stats
|
||||
export DOVECOT_SERVICE_STATS_USER="${SYS_USER_VMAIL}"
|
||||
export DOVECOT_SERVICE_STATS_GROUP="${SYS_GROUP_VMAIL}"
|
||||
export DOVECOT_SERVICE_STATS_PORT='24242'
|
||||
# FYI: https://wiki.dovecot.org/Quota#Quota_service
|
||||
export DOVECOT_SERVICE_QUOTA_STATUS_PORT='12340'
|
||||
|
||||
# Local (Mail) Delivery Agent
|
||||
# - dovecot
|
||||
# - lmtp:unix:private/dovecot-lmtp
|
||||
# - lmtp:inet:<ip>:<port>
|
||||
export DOVECOT_LDA_DELIVER='dovecot'
|
||||
|
||||
# Directory used to store mailbox INDEX files
|
||||
# - '' (empty value): use mailbox as index directory.
|
||||
# - '/path/to/dir': specify an absolute path as index directory.
|
||||
export MAILBOX_INDEX_DIR="${MAILBOX_INDEX_DIR:=}"
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Variables for Fail2ban and related.
|
||||
|
||||
export FAIL2BAN_CONF_ROOT='/etc/fail2ban'
|
||||
|
||||
if [ X"${DISTRO}" == X"FREEBSD" ]; then
|
||||
export FAIL2BAN_CONF_ROOT='/usr/local/etc/fail2ban'
|
||||
export FAIL2BAN_SOCKET='/var/run/fail2ban.sock'
|
||||
fi
|
||||
|
||||
export FAIL2BAN_MAIN_CONF="${FAIL2BAN_CONF_ROOT}/fail2ban.local"
|
||||
export FAIL2BAN_JAIL_CONF="${FAIL2BAN_CONF_ROOT}/jail.conf"
|
||||
export FAIL2BAN_JAIL_LOCAL_CONF="${FAIL2BAN_CONF_ROOT}/jail.local"
|
||||
export FAIL2BAN_JAIL_CONF_DIR="${FAIL2BAN_CONF_ROOT}/jail.d"
|
||||
export FAIL2BAN_FILTER_DIR="${FAIL2BAN_CONF_ROOT}/filter.d"
|
||||
export FAIL2BAN_ACTION_DIR="${FAIL2BAN_CONF_ROOT}/action.d"
|
||||
|
||||
export FAIL2BAN_FILTER_POSTFIX="postfix.iredmail"
|
||||
export FAIL2BAN_FILTER_ROUNDCUBE="roundcube.iredmail"
|
||||
export FAIL2BAN_FILTER_DOVECOT="dovecot.iredmail"
|
||||
|
||||
export FAIL2BAN_DISABLED_SERVICES="${PORT_HTTP},${HTTPS_PORT},25,587,465,110,995,143,993,${MANAGESIEVE_PORT}"
|
||||
|
||||
export FAIL2BAN_LOG_FILE='/var/log/fail2ban.log'
|
||||
export FAIL2BAN_SYSLOG_FACILITY='daemon'
|
||||
|
||||
# Firewall command (fail2ban/action.d/[NAME].conf)
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
export FAIL2BAN_ACTION='iptables-multiport'
|
||||
|
||||
if [ X"${DISTRO_CODENAME}" == X'buster' ]; then
|
||||
export FAIL2BAN_ACTION='nftables-multiport'
|
||||
fi
|
||||
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
# Use ipfw by default
|
||||
export FAIL2BAN_ACTION='ipfw'
|
||||
|
||||
# Use pf if it's loaded.
|
||||
if grep '^pf_load=.YES' /boot/defaults/loader.conf >/dev/null; then
|
||||
export FAIL2BAN_ACTION='pf'
|
||||
fi
|
||||
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
export FAIL2BAN_ACTION='pf'
|
||||
fi
|
||||
|
||||
# SQL db.
|
||||
export FAIL2BAN_DB_NAME='fail2ban'
|
||||
export FAIL2BAN_DB_USER='fail2ban'
|
||||
@@ -0,0 +1,724 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
export PROG_NAME='iRedMail'
|
||||
export PROG_NAME_LOWERCASE='iredmail'
|
||||
export PROG_VERSION='1.3.1'
|
||||
|
||||
export DATE="$(/bin/date +%Y.%m.%d.%H.%M.%S)"
|
||||
|
||||
# For perl and run-time locale setting.
|
||||
export LC_ALL=C
|
||||
export LC_CTYPE=C
|
||||
export LANG=C
|
||||
|
||||
# Tells ncurses (dialog) to use Unicode values which correspond to the VT100
|
||||
# line-drawing glyphs.
|
||||
export NCURSES_NO_UTF8_ACS=1
|
||||
|
||||
# Debug mode: YES, NO.
|
||||
export IREDMAIL_DEBUG="${IREDMAIL_DEBUG:=NO}"
|
||||
|
||||
# -----------------
|
||||
# ---- Generic ----
|
||||
# -----------------
|
||||
# Maildir style: hashed, normal.
|
||||
export MAILDIR_STYLE='hashed'
|
||||
|
||||
# Mailboxes will be stored under sub-directory ${STORAGE_NODE} of vmail user's
|
||||
# home directory. e.g. home directory is /var/vmail, the mailboxes will be
|
||||
# /var/vmail/vmail1.
|
||||
export STORAGE_NODE="${STORAGE_NODE:=vmail1}"
|
||||
|
||||
# Enabled backends.
|
||||
export ENABLE_BACKEND_OPENLDAP='YES'
|
||||
export ENABLE_BACKEND_PGSQL='YES'
|
||||
export ENABLE_BACKEND_MARIADB='YES'
|
||||
|
||||
# For better distributed deployment
|
||||
#
|
||||
# IP address of localhost.
|
||||
# Usually it's 127.0.0.1, but not in FreeBSD Jail.
|
||||
export LOCAL_ADDRESS="${LOCAL_ADDRESS:=127.0.0.1}"
|
||||
|
||||
# LDAP server
|
||||
export LDAP_SERVER_HOST="${LDAP_SERVER_HOST:=${LOCAL_ADDRESS}}"
|
||||
export LDAP_SERVER_PORT="${LDAP_SERVER_PORT:=389}"
|
||||
|
||||
# MySQL server
|
||||
export MYSQL_SERVER_ADDRESS="${MYSQL_SERVER_ADDRESS:=${LOCAL_ADDRESS}}"
|
||||
export MYSQL_SERVER_PORT="${MYSQL_SERVER_PORT:=3306}"
|
||||
export MYSQL_ROOT_USER="${MYSQL_ROOT_USER:=root}"
|
||||
|
||||
# Use existing MySQL server, no matter it's local or remote.
|
||||
export USE_EXISTING_MYSQL="${USE_EXISTING_MYSQL:=NO}"
|
||||
# Create required SQL databases and records for applications
|
||||
# Should be set to NO if you're installing iRedMail with a MySQL cluster, and
|
||||
# you're installing on second or later nodes.
|
||||
export INITIALIZE_SQL_DATA="${INITIALIZE_SQL_DATA:=YES}"
|
||||
|
||||
# PGSQL server
|
||||
export PGSQL_SERVER_ADDRESS="${PGSQL_SERVER_ADDRESS:=${LOCAL_ADDRESS}}"
|
||||
export PGSQL_SERVER_PORT="${PGSQL_SERVER_PORT:=5432}"
|
||||
# host address used in ~postgres/.pgpass
|
||||
export PGSQL_PGPASS_HOST='localhost'
|
||||
if [ X"${LOCAL_ADDRESS}" != X'127.0.0.1' ]; then
|
||||
export PGSQL_PGPASS_HOST="${LOCAL_ADDRESS}"
|
||||
fi
|
||||
|
||||
# Dovecot: POP3, IMAP, managesieve
|
||||
export IMAP_SERVER="${IMAP_SERVER:=${LOCAL_ADDRESS}}"
|
||||
export LMTP_BIND_ADDRESS="${LMTP_BIND_ADDRESS:=${LOCAL_ADDRESS}}"
|
||||
export LMTP_BIND_PORT="${LMTP_BIND_PORT:=24}"
|
||||
export MANAGESIEVE_BIND_HOST="${MANAGESIEVE_BIND_HOST:=${LOCAL_ADDRESS}}"
|
||||
export MANAGESIEVE_BIND_PORT="${MANAGESIEVE_BIND_PORT:=4190}"
|
||||
export MANAGESIEVE_SERVER="${MANAGESIEVE_SERVER:=${LOCAL_ADDRESS}}"
|
||||
export MANAGESIEVE_PORT="${MANAGESIEVE_PORT:=4190}"
|
||||
export DOVECOT_SERVICE_QUOTA_STATUS_BIND_ADDRESS="${DOVECOT_QUOTA_STATUS_BIND_ADDRESS:=127.0.0.1}"
|
||||
# SMTP server (Postfix)
|
||||
export SMTP_SERVER="${SMTP_SERVER:=${LOCAL_ADDRESS}}"
|
||||
# php-fpm
|
||||
export PHP_FPM_BIND_HOST="${PHP_FPM_BIND_HOST:=${LOCAL_ADDRESS}}"
|
||||
export PHP_FPM_PORT="${PHP_FPM_PORT:=9999}"
|
||||
# Amavisd
|
||||
export AMAVISD_SERVER="${LOCAL_ADDRESS}"
|
||||
# ClamAV
|
||||
export CLAMD_BIND_HOST="${LOCAL_ADDRESS}"
|
||||
# iRedAPD
|
||||
export IREDAPD_BIND_HOST="${LOCAL_ADDRESS}"
|
||||
export IREDAPD_SERVER_ADDRESS="${IREDAPD_SERVER_ADDRESS:=${IREDAPD_BIND_HOST}}"
|
||||
# mlmmjadmin
|
||||
export MLMMJADMIN_BIND_HOST="${LOCAL_ADDRESS}"
|
||||
export MLMMJADMIN_SERVER_ADDRESS="${MLMMJADMIN_SERVER_ADDRESS:=${MLMMJADMIN_BIND_HOST}}"
|
||||
# For managesieve service and software.
|
||||
export USE_MANAGESIEVE='YES'
|
||||
|
||||
# vmail user/group name, uid and gid.
|
||||
export SYS_USER_VMAIL='vmail'
|
||||
export SYS_GROUP_VMAIL='vmail'
|
||||
|
||||
# netdata
|
||||
export SYS_USER_NETDATA='netdata'
|
||||
export SYS_GROUP_NETDATA='netdata'
|
||||
|
||||
# Specify UID/GID for system accounts. Required if you have multiple LDA/LMTP
|
||||
# servers access same mailbox storage. e.g. cluster environment.
|
||||
# vmail
|
||||
export SYS_USER_VMAIL_UID='2000'
|
||||
export SYS_GROUP_VMAIL_GID='2000'
|
||||
# iredadmin
|
||||
export SYS_USER_IREDADMIN_UID='2001'
|
||||
export SYS_GROUP_IREDADMIN_GID='2001'
|
||||
# netdata
|
||||
export SYS_USER_IREDAPD_UID='2002'
|
||||
export SYS_GROUP_IREDAPD_GID='2002'
|
||||
# mlmmj
|
||||
export SYS_USER_MLMMJ_UID='2003'
|
||||
export SYS_GROUP_MLMMJ_GID='2003'
|
||||
# netdata
|
||||
export SYS_USER_NETDATA_UID='2004'
|
||||
export SYS_GROUP_NETDATA_GID='2004'
|
||||
|
||||
# Default SQL database name used to store mail accounts.
|
||||
export VMAIL_DB_NAME='vmail'
|
||||
export VMAIL_DB_BIND_USER='vmail'
|
||||
export VMAIL_DB_ADMIN_USER='vmailadmin'
|
||||
|
||||
# Default virtual domain admin name without domain name (@example.com).
|
||||
export DOMAIN_ADMIN_NAME='postmaster'
|
||||
|
||||
# Directory used to store mailboxes
|
||||
export STORAGE_BASE_DIR="${STORAGE_BASE_DIR:=/var/vmail}"
|
||||
|
||||
# Tools.
|
||||
export CONFIG_VIA_DIALOG="${DIALOG_DIR}/config_via_dialog.sh"
|
||||
# Note: config file will be sourced in file 'conf/core', function 'check_env()'.
|
||||
export IREDMAIL_CONFIG_FILE="${ROOTDIR}/config"
|
||||
export TIP_FILE="${ROOTDIR}/${PROG_NAME}.tips"
|
||||
export DOC_FILE="${ROOTDIR}/Documentations"
|
||||
export STATUS_FILE="${RUNTIME_DIR}/install.status"
|
||||
export INSTALL_LOG="${RUNTIME_DIR}/install.log"
|
||||
export PKG_INSTALL_LOG="${RUNTIME_DIR}/pkg.install.log"
|
||||
# Directory used to store kv files (one value in one file).
|
||||
export IREDMAIL_KV_DIR='/root/.iredmail/kv'
|
||||
|
||||
# Output flag.
|
||||
export _INFO_FLAG="[ INFO ]"
|
||||
export _SKIP_FLAG="< SKIP >"
|
||||
export _ERROR_FLAG="<< ERROR >>"
|
||||
export _QUESTION_FLAG="< Question >"
|
||||
export _BACKUP_FLAG=" + < Backup >"
|
||||
export _DEBUG_FLAG=" + < DEBUG >"
|
||||
|
||||
export CONF_MSG="#
|
||||
# File generated by ${PROG_NAME} (${DATE}):
|
||||
#
|
||||
# Version: ${PROG_VERSION}
|
||||
# Project: https://www.iredmail.org/
|
||||
#
|
||||
# Community: https://forum.iredmail.org/
|
||||
#
|
||||
"
|
||||
|
||||
# TERM.
|
||||
if [ X"${TERM}" == X"" ]; then
|
||||
export TERM='xterm'
|
||||
fi
|
||||
|
||||
# Logrotate configuration directory.
|
||||
export LOGROTATE_DIR='/etc/logrotate.d'
|
||||
|
||||
# Kernel name, in upper cases.
|
||||
export KERNEL_NAME="$(uname -s | tr '[a-z]' '[A-Z]')"
|
||||
|
||||
# Command used to genrate a random string.
|
||||
# Usage: str="$(${RANDOM_STRING})"
|
||||
if [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
export RANDOM_STRING='eval </dev/random tr -cd [:alnum:] | fold -w 32 | head -1'
|
||||
else
|
||||
# Linux/FreeBSD
|
||||
export RANDOM_STRING='eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 32)'
|
||||
fi
|
||||
|
||||
# command: dialog.
|
||||
export BIN_DIALOG="dialog"
|
||||
export PKG_DIALOG="dialog"
|
||||
|
||||
# command: bzip2.
|
||||
export BIN_BZIP2='bzip2'
|
||||
export PKG_BZIP2='bzip2'
|
||||
|
||||
# Shells
|
||||
export SHELL_NOLOGIN='/sbin/nologin'
|
||||
export SHELL_BASH='/bin/bash'
|
||||
|
||||
# Path to some programs
|
||||
export CMD_PYTHON2='python2'
|
||||
export CMD_PYTHON3='python3'
|
||||
export CMD_PIP2='pip2'
|
||||
export CMD_PIP3='pip3'
|
||||
|
||||
# Default password scheme for SQL backends.
|
||||
# LDAP backend will use SSHA instead (defined in file
|
||||
# dialog/config_via_dialog.sh), because many applications need to bind as user.
|
||||
export DEFAULT_PASSWORD_SCHEME='SSHA512'
|
||||
|
||||
# Check distribution.
|
||||
# - DISTRO
|
||||
# - DISTRO_VERSION
|
||||
# - DISTRO_CODENAME
|
||||
#
|
||||
# UNSUPPORTED_RELEASE will be set to 'YES' if current Linux/BSD release is
|
||||
# an old release and unsupported anymore.
|
||||
export UNSUPPORTED_RELEASE='NO'
|
||||
|
||||
# Detect distro name and release version.
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
# Directory of RC scripts.
|
||||
export DIR_RC_SCRIPTS='/etc/init.d'
|
||||
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
# RHEL/CentOS
|
||||
export DISTRO='RHEL'
|
||||
|
||||
# Get distribution version
|
||||
if grep '\ 7\.' /etc/redhat-release &>/dev/null; then
|
||||
# version 7.x
|
||||
export DISTRO_VERSION='7'
|
||||
elif grep '\ 8\.' /etc/redhat-release &>/dev/null; then
|
||||
# version 8.x
|
||||
export DISTRO_VERSION='8'
|
||||
else
|
||||
export UNSUPPORTED_RELEASE='YES'
|
||||
fi
|
||||
|
||||
# Get distribution name as DISTRO_CODENAME
|
||||
if grep '^Red' /etc/redhat-release &>/dev/null; then
|
||||
# RHEL
|
||||
export DISTRO_CODENAME='rhel'
|
||||
elif grep '^CentOS' /etc/redhat-release &>/dev/null; then
|
||||
# CentOS
|
||||
export DISTRO_CODENAME='centos'
|
||||
elif grep '^Scientific' /etc/redhat-release &>/dev/null; then
|
||||
# Scientific Linux
|
||||
export DISTRO_CODENAME='scientific'
|
||||
else
|
||||
export UNSUPPORTED_RELEASE='YES'
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
# CentOS 8: Installed with pip2.
|
||||
export CMD_UWSGI='/usr/bin/uwsgi'
|
||||
# Installed with pip3.
|
||||
export CMD_UWSGI_PY3='/usr/local/bin/uwsgi'
|
||||
fi
|
||||
elif [ -f /etc/lsb-release ] && grep -i 'DISTRIB_ID=Ubuntu' /etc/lsb-release &>/dev/null; then
|
||||
# Ubuntu
|
||||
export DISTRO='UBUNTU'
|
||||
|
||||
# Ubuntu version number and code name:
|
||||
# - 18.04: bionic
|
||||
# - 20.04: focal
|
||||
export DISTRO_VERSION="$(awk -F'=' '/^DISTRIB_RELEASE/ {print $2}' /etc/lsb-release)"
|
||||
export DISTRO_CODENAME="$(awk -F'=' '/^DISTRIB_CODENAME/ {print $2}' /etc/lsb-release)"
|
||||
|
||||
# Unsupported releases: 16.x, 17.x, 18.10, 19.x
|
||||
if echo "${DISTRO_VERSION}" | grep -E '^(16|17|18\.10|19\.)' &>/dev/null ; then
|
||||
export UNSUPPORTED_RELEASE='YES'
|
||||
fi
|
||||
|
||||
export UWSGI_PY2_PLUGIN_NAME='python27'
|
||||
if [ X"${DISTRO_CODENAME}" == X'bionic' ]; then
|
||||
# Ubuntu 18.04
|
||||
export UWSGI_PY3_PLUGIN_NAME='python36'
|
||||
elif [ X"${DISTRO_CODENAME}" == X'focal' ]; then
|
||||
# Ubuntu 20.04: Installed with pip2.
|
||||
export CMD_UWSGI='/usr/local/bin/uwsgi'
|
||||
export UWSGI_PY3_PLUGIN_NAME='python38'
|
||||
fi
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
# Debian
|
||||
export DISTRO='DEBIAN'
|
||||
|
||||
# Set distro code name and unsupported releases.
|
||||
if grep -i '^10' /etc/debian_version &>/dev/null; then
|
||||
export DISTRO_VERSION='10'
|
||||
export DISTRO_CODENAME='buster'
|
||||
export UWSGI_PY3_PLUGIN_NAME='python37'
|
||||
elif grep '^9' /etc/debian_version &>/dev/null || \
|
||||
grep -i '^stretch' /etc/debian_version &>/dev/null; then
|
||||
export DISTRO_VERSION='9'
|
||||
export DISTRO_CODENAME='stretch'
|
||||
export UWSGI_PY3_PLUGIN_NAME='python35'
|
||||
else
|
||||
export UNSUPPORTED_RELEASE='YES'
|
||||
fi
|
||||
else
|
||||
export UNSUPPORTED_RELEASE='YES'
|
||||
fi
|
||||
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
export DISTRO='FREEBSD'
|
||||
export DISTRO_VERSION="$(uname -r |awk -F'[.-]' '{print $1}')"
|
||||
|
||||
# Directory of RC scripts.
|
||||
export DIR_RC_SCRIPTS='/usr/local/etc/rc.d'
|
||||
export RC_CONF_LOCAL='/etc/rc.conf.local'
|
||||
|
||||
export CMD_PYTHON2='/usr/local/bin/python2'
|
||||
export CMD_PYTHON3='/usr/local/bin/python3'
|
||||
|
||||
# Unsupported releases: 7, 8.
|
||||
if echo "${DISTRO_VERSION}" | grep '^[78]' &>/dev/null ; then
|
||||
export UNSUPPORTED_RELEASE='YES'
|
||||
fi
|
||||
|
||||
export SHELL_BASH='/usr/local/bin/bash'
|
||||
|
||||
# Default password scheme.
|
||||
export DEFAULT_PASSWORD_SCHEME='BCRYPT'
|
||||
|
||||
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
export DISTRO='OPENBSD'
|
||||
export DISTRO_VERSION="$(uname -r)"
|
||||
|
||||
# Default password scheme.
|
||||
export DEFAULT_PASSWORD_SCHEME='BCRYPT'
|
||||
|
||||
# Directory of RC scripts.
|
||||
export DIR_RC_SCRIPTS='/etc/rc.d'
|
||||
export RC_CONF_LOCAL='/etc/rc.conf.local'
|
||||
export SHELL_BASH='/usr/local/bin/bash'
|
||||
export CMD_PYTHON2='/usr/local/bin/python2'
|
||||
export CMD_PYTHON3='/usr/local/bin/python3'
|
||||
export CMD_PIP2='pip2.7'
|
||||
export CMD_PIP3='pip3.7'
|
||||
|
||||
# Unsupported release: 6.6 and earlier versions.
|
||||
if echo "${DISTRO_VERSION}" | grep '^6.[0123456]' &>/dev/null ; then
|
||||
export UNSUPPORTED_RELEASE='YES'
|
||||
fi
|
||||
else
|
||||
# Not support *BSD and other distrobutions yet.
|
||||
echo "Error: Your OS is not supported yet."
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# Exit and prompt to use a supported Linux/BSD distribution
|
||||
if [ X"${UNSUPPORTED_RELEASE}" == X'YES' ]; then
|
||||
cat <<EOF
|
||||
********* ERROR *********
|
||||
Release version of the operating system on this server is unsupported by
|
||||
iRedMail, please access below link to get the latest iRedMail and a list
|
||||
of supported Linux/BSD distributions and release versions.
|
||||
|
||||
http://www.iredmail.org/download.html
|
||||
|
||||
*************************
|
||||
EOF
|
||||
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# Check processor type.
|
||||
if [ X"${DISTRO}" == X'DEBIAN' ]; then
|
||||
arch="$(uname -m)"
|
||||
else
|
||||
arch="$(uname -p)"
|
||||
fi
|
||||
|
||||
case $arch in
|
||||
i[3456]86) export OS_ARCH='i386' ;;
|
||||
x86_64|amd64) export OS_ARCH='x86_64' ;;
|
||||
*) export OS_ARCH="${arch}" ;;
|
||||
esac
|
||||
|
||||
# Hostname.
|
||||
if [ X"${IREDMAIL_HOSTNAME}" != X'' ]; then
|
||||
# Read from 'IREDMAIL_HOSTNAME'
|
||||
export HOSTNAME="${IREDMAIL_HOSTNAME}"
|
||||
else
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export HOSTNAME="$(hostname)"
|
||||
else
|
||||
export HOSTNAME="$(hostname -f)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# root user/group name. Note: not all OSes have group 'root'.
|
||||
export SYS_USER_ROOT='root'
|
||||
export SYS_GROUP_ROOT='root'
|
||||
|
||||
# Syslog
|
||||
export USE_RSYSLOG='YES'
|
||||
export USE_BSD_SYSLOG='NO'
|
||||
export SYS_USER_SYSLOG='root'
|
||||
export SYS_GROUP_SYSLOG='root'
|
||||
export SYSLOG_POSTROTATE_CMD=''
|
||||
export SYSLOG_SOCKET='/dev/log'
|
||||
export IREDMAIL_SYSLOG_FACILITY='local5'
|
||||
# rsyslog
|
||||
export SYSLOG_CONF_DIR='/etc/rsyslog.d'
|
||||
|
||||
# Use systemd
|
||||
export USE_SYSTEMD='YES'
|
||||
export SYSTEMD_SERVICE_DIR='/lib/systemd/system'
|
||||
|
||||
# install_pkg: function used to install packages without confirm.
|
||||
# remove_pkg: function used to remove packages without confirm.
|
||||
# LIST_ALL_PKGS: command used to list all installed packages.
|
||||
# LIST_FILES_IN_PKG: command used to list files installed by special package.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
# RHEL/CentOS.
|
||||
# Package management.
|
||||
if [ X"${YUM}" != X"" ]; then
|
||||
export YUM="${YUM}"
|
||||
else
|
||||
export YUM="yum -d 2"
|
||||
fi
|
||||
export install_pkg='install_pkg_rhel'
|
||||
export remove_pkg="remove_pkg_rhel"
|
||||
export LIST_ALL_PKGS='rpm -qa'
|
||||
export LIST_FILES_IN_PKG='rpm -ql'
|
||||
|
||||
# Directory /etc/sysconfig/ on RHEL/CentOS.
|
||||
export ETC_SYSCONFIG_DIR='/etc/sysconfig'
|
||||
|
||||
# Firewalld
|
||||
export USE_FIREWALLD='YES'
|
||||
export FIREWALLD_CONF_DIR='/etc/firewalld'
|
||||
export FIREWALLD_CONF='/etc/firewalld/firewalld.conf'
|
||||
export FIREWALL_RULE_CONF="${FIREWALLD_CONF_DIR}/zones/iredmail.xml"
|
||||
|
||||
# main config file
|
||||
export SYSLOG_CONF='/etc/rsyslog.conf'
|
||||
export SYSLOG_POSTROTATE_CMD='/bin/kill -HUP $(cat /var/run/syslogd.pid 2>/dev/null) 2>/dev/null || true'
|
||||
|
||||
# SSHD log file
|
||||
export SSHD_LOGFILE='/var/log/secure'
|
||||
|
||||
# Crontab related.
|
||||
export CRON_SPOOL_DIR='/var/spool/cron'
|
||||
|
||||
# Directory used to store SSL/TLS key/cert file.
|
||||
export SSL_FILE_DIR="/etc/pki/tls"
|
||||
|
||||
# Yum repository related.
|
||||
export YUM_REPOS_DIR='/etc/yum.repos.d'
|
||||
export LOCAL_REPO_NAME="${PROG_NAME}"
|
||||
export LOCAL_REPO_FILE="${YUM_REPOS_DIR}/${LOCAL_REPO_NAME}.repo"
|
||||
|
||||
# Override default value.
|
||||
export PKG_DIALOG="dialog"
|
||||
export PKG_BZIP2="bzip2"
|
||||
|
||||
if [ X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
export UWSGI_PY3_PLUGIN_NAME='python36'
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# Ubuntu & Debian.
|
||||
export DEBIAN_FRONTEND='noninteractive'
|
||||
export SHELL_NOLOGIN='/usr/sbin/nologin'
|
||||
|
||||
# Package management.
|
||||
if [ X"${APTGET}" != X"" ]; then
|
||||
export APTGET="${APTGET}"
|
||||
else
|
||||
# "WARNING: apt does not have a stable CLI interface. Use with caution in scripts."
|
||||
export APTGET='apt-get'
|
||||
fi
|
||||
|
||||
# Package management.
|
||||
export install_pkg='install_pkg_debian'
|
||||
export remove_pkg='remove_pkg_debian'
|
||||
export LIST_ALL_PKGS="dpkg -l |awk '{print $2}'"
|
||||
export LIST_FILES_IN_PKG='dpkg -L'
|
||||
|
||||
# Syslog
|
||||
export SYS_GROUP_SYSLOG='adm'
|
||||
if [ X"${DISTRO}" == X'DEBIAN' ]; then
|
||||
export SYSLOG_CONF='/etc/rsyslog.conf'
|
||||
elif [ X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
export SYS_USER_SYSLOG='syslog'
|
||||
export SYSLOG_CONF='/etc/rsyslog.d/iredmail.conf'
|
||||
fi
|
||||
|
||||
# SSHD log file
|
||||
export SSHD_LOGFILE='/var/log/auth.log'
|
||||
|
||||
# Crontab related.
|
||||
export CRON_SPOOL_DIR='/var/spool/cron/crontabs'
|
||||
|
||||
# Directory /etc/default/ on Debian/Ubuntu.
|
||||
export ETC_SYSCONFIG_DIR='/etc/default'
|
||||
|
||||
# iptables rule file.
|
||||
export FIREWALL_RULE_CONF="${ETC_SYSCONFIG_DIR}/iptables"
|
||||
export FIREWALL_RULE_CONF6="${ETC_SYSCONFIG_DIR}/ip6tables"
|
||||
|
||||
if [ X"${DISTRO_CODENAME}" == X'buster' ]; then
|
||||
export USE_NFTABLES='YES'
|
||||
export NFTABLES_CONF='/etc/nftables.conf'
|
||||
export FIREWALL_RULE_CONF="${NFTABLES_CONF}"
|
||||
fi
|
||||
|
||||
# Directory used to store SSL/TLS key/cert file.
|
||||
export SSL_FILE_DIR="/etc/ssl"
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export USE_SYSTEMD='NO'
|
||||
export SYS_GROUP_ROOT='wheel'
|
||||
export SYSLOG_SOCKET='/var/run/log'
|
||||
|
||||
# sysrc: safely edit system rc files
|
||||
export SYSRC='/usr/sbin/sysrc'
|
||||
|
||||
# Package management.
|
||||
if [ X"${PKGADD}" != X"" ]; then
|
||||
export PKGADD="${PKGADD}"
|
||||
else
|
||||
export PKGADD="pkg_add"
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO_VERSION}" == X'9' ]; then
|
||||
export LIST_ALL_PKGS="pkg_info | awk '{print $1}'"
|
||||
export LIST_FILES_IN_PKG='pkg_info -L'
|
||||
else
|
||||
# use pkgng on FreeBSD 10 and later releases.
|
||||
export LIST_ALL_PKGS="pkg info | awk '{print $1}'"
|
||||
export LIST_FILES_IN_PKG='pkg query "%Fp"'
|
||||
fi
|
||||
|
||||
# Port directory
|
||||
export PORT_WORKDIRPREFIX='/usr/ports'
|
||||
|
||||
# Syslog (newsyslog)
|
||||
export USE_RSYSLOG='NO'
|
||||
export USE_BSD_SYSLOG='YES'
|
||||
export SYS_GROUP_SYSLOG='wheel'
|
||||
export SYSLOG_CONF='/etc/syslog.conf'
|
||||
export SYSLOG_CONF_DIR='/usr/local/etc/syslog.d'
|
||||
|
||||
# SSHD log file
|
||||
export SSHD_LOGFILE='/var/log/auth.log'
|
||||
|
||||
# Crontab related.
|
||||
export CRON_SPOOL_DIR='/var/cron/tabs'
|
||||
|
||||
export ETC_SYSCONFIG_DIR='/etc/defaults'
|
||||
export FREEBSD_MAKE_CONF='/etc/make.conf'
|
||||
|
||||
# IPFW rule file.
|
||||
export FIREWALL_RULE_CONF="${ETC_SYSCONFIG_DIR}/ipfw.rules"
|
||||
|
||||
# Directory used to store SSL/TLS key/cert file.
|
||||
export SSL_FILE_DIR="/etc/ssl"
|
||||
|
||||
# Logrotate directory.
|
||||
export LOGROTATE_DIR='/usr/local/etc/newsyslog.conf.d'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export USE_SYSTEMD='NO'
|
||||
export SYS_GROUP_ROOT='wheel'
|
||||
|
||||
# Package management.
|
||||
export install_pkg='install_pkg_openbsd'
|
||||
export remove_pkg='pkg_delete'
|
||||
export LIST_ALL_PKGS="pkg_info -a | awk '{print $1}'"
|
||||
export LIST_FILES_IN_PKG='pkg_info -L'
|
||||
|
||||
# Syslog (newsyslog)
|
||||
export USE_RSYSLOG='NO'
|
||||
export USE_BSD_SYSLOG='YES'
|
||||
export SYS_GROUP_SYSLOG='wheel'
|
||||
export SYSLOG_CONF='/etc/syslog.conf'
|
||||
|
||||
# SSHD log file
|
||||
export SSHD_LOGFILE='/var/log/authlog'
|
||||
|
||||
# Crontab related.
|
||||
export CRON_SPOOL_DIR='/var/cron/tabs'
|
||||
|
||||
# PF rule file.
|
||||
export FIREWALL_RULE_CONF="/etc/pf.conf"
|
||||
|
||||
# Directory used to store SSL/TLS key/cert file.
|
||||
export SSL_FILE_DIR="/etc/ssl"
|
||||
else
|
||||
# Not support yet.
|
||||
echo "Your distrobution is not supported yet."
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# Use a seperated directory to store iRedMail certs/keys.
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export SSL_CERT_DIR="${SSL_FILE_DIR}"
|
||||
export SSL_KEY_DIR="${SSL_FILE_DIR}"
|
||||
else
|
||||
export SSL_CERT_DIR="${SSL_FILE_DIR}/certs"
|
||||
export SSL_KEY_DIR="${SSL_FILE_DIR}/private"
|
||||
fi
|
||||
|
||||
# Root's cron file
|
||||
export CRON_FILE_ROOT="${CRON_SPOOL_DIR}/${SYS_USER_ROOT}"
|
||||
|
||||
# dhparam file required to fix 'The Logjam Attack'.
|
||||
export SSL_DH512_PARAM_FILE="${SSL_FILE_DIR}/dh512_param.pem"
|
||||
export SSL_DH1024_PARAM_FILE="${SSL_FILE_DIR}/dh2048_param.pem"
|
||||
|
||||
# use of the most secure ciphers first and gradually fall back to
|
||||
# less-preferred ciphers should the client not support them.
|
||||
export SSL_CIPHERS='EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'
|
||||
|
||||
# SSL key.
|
||||
export OPENSSL_CONF="${SSL_FILE_DIR}/openssl.cnf"
|
||||
export SSL_CERT_FILE="${SSL_CERT_DIR}/iRedMail.crt"
|
||||
export SSL_KEY_FILE="${SSL_KEY_DIR}/iRedMail.key"
|
||||
export TLS_COUNTRY='CN'
|
||||
export TLS_STATE='GuangDong'
|
||||
export TLS_CITY='ShenZhen'
|
||||
export TLS_COMPANY="${HOSTNAME}"
|
||||
export TLS_DEPARTMENT='IT'
|
||||
export TLS_HOSTNAME="${HOSTNAME}"
|
||||
export TLS_ADMIN="root@${HOSTNAME}"
|
||||
|
||||
# Default SSL key size in bits
|
||||
export SSL_KEY_SIZE='4096'
|
||||
default_ssl_key_size="$(awk '/^default_bits/ {print $3}' ${OPENSSL_CONF} 2>/dev/null)"
|
||||
if [ -z ${default_ssl_key_size} ]; then
|
||||
:
|
||||
elif [ ${default_ssl_key_size} -ge ${SSL_KEY_SIZE} ]; then
|
||||
export SSL_KEY_SIZE="${default_ssl_key_size}"
|
||||
fi
|
||||
|
||||
# Location of sshd_config
|
||||
export SSHD_CONFIG='/etc/ssh/sshd_config'
|
||||
|
||||
if [[ -f ${SSHD_CONFIG} ]]; then
|
||||
export SSHD_PORT="$(awk '/^Port/ {print $2}' ${SSHD_CONFIG} | head -1)"
|
||||
export SSHD_PORT2="$(awk '/^Port/ {print $2}' ${SSHD_CONFIG} | tail -1)"
|
||||
fi
|
||||
|
||||
if [ X"${SSHD_PORT}" == X'' ]; then
|
||||
# No port number defined, use default port number (22).
|
||||
export SSHD_PORT='22'
|
||||
export SSHD_PORT2='22'
|
||||
fi
|
||||
|
||||
export SSHD_PORTS_WITH_COMMA="${SSHD_PORT}"
|
||||
export SSHD_PORTS_WITH_SPACE="${SSHD_PORT}"
|
||||
|
||||
if [ X"${SSHD_PORT}" != X'' -a X"${SSHD_PORT2}" != X'' -a X"${SSHD_PORT}" != X"${SSHD_PORT2}" ]; then
|
||||
export SSHD_PORTS_WITH_COMMA="${SSHD_PORT},${SSHD_PORT2}"
|
||||
export SSHD_PORTS_WITH_SPACE="${SSHD_PORT} ${SSHD_PORT2}"
|
||||
fi
|
||||
|
||||
# sysctl.conf
|
||||
export SYSCTL_CONF='/etc/sysctl.conf'
|
||||
|
||||
# Command use to fetch source tarballs.
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
if [ -f /usr/local/etc/ssl/cert.pem ]; then
|
||||
# require package/port 'security/ca_root_nss'
|
||||
FETCH_CMD='fetch'
|
||||
else
|
||||
FETCH_CMD='fetch --no-verify-hostname --no-verify-peer'
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# -i: Turns off interactive prompting during multiple file transfers.
|
||||
# -V: Disable verbose and progress
|
||||
FETCH_CMD='ftp -iV'
|
||||
else
|
||||
# -c: Continue getting a partially-downloaded file.
|
||||
# -q: Turn off Wget's output.
|
||||
FETCH_CMD="wget -cq --timeout=30"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
FETCH_CMD="${FETCH_CMD} --ca-certificate=${SSL_CERT_DIR}/ca-bundle.crt"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Detect IPv6 support with `ping6`.
|
||||
export IREDMAIL_HAS_IPV6='NO'
|
||||
ping6 -c 1 ::1 &>/dev/null
|
||||
if [ X"$?" == X'0' ]; then
|
||||
IREDMAIL_HAS_IPV6='YES'
|
||||
fi
|
||||
|
||||
# Backup script file names.
|
||||
export BACKUP_SCRIPT_LDAP_NAME='backup_openldap.sh'
|
||||
export BACKUP_SCRIPT_MYSQL_NAME='backup_mysql.sh'
|
||||
export BACKUP_SCRIPT_PGSQL_NAME='backup_pgsql.sh'
|
||||
|
||||
#
|
||||
# Mirror sites
|
||||
#
|
||||
# Where to fetch/store binary packages and source tarball.
|
||||
export IREDMAIL_MIRROR="${IREDMAIL_MIRROR:=https://dl.iredmail.org}"
|
||||
|
||||
# Ubuntu mirror site. For example: https://archive.ubuntu.com/ubuntu
|
||||
export UBUNTU_MIRROR_SITE="${UBUNTU_MIRROR_SITE:=}"
|
||||
|
||||
# pip mirror site. Use `pypi.org` if not set.
|
||||
export PIP_MIRROR_SITE="${PIP_MIRROR_SITE:=}"
|
||||
export PIP_TRUSTED_HOST="${PIP_TRUSTED_HOST:=}"
|
||||
# URL to download `get-pip.py`, used to install `pip2`.
|
||||
export URL_GET_PIP_PY="${URL_GET_PIP_PY:=https://bootstrap.pypa.io/get-pip.py}"
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
export IREDADMIN_VERSION='1.0'
|
||||
export IREDADMIN_TARBALL="iRedAdmin-${IREDADMIN_VERSION}.tar.bz2"
|
||||
export IREDADMIN_HTTPD_ROOT="${HTTPD_SERVERROOT}/iRedAdmin-${IREDADMIN_VERSION}"
|
||||
export IREDADMIN_HTTPD_ROOT_SYMBOL_LINK="${HTTPD_SERVERROOT}/iredadmin"
|
||||
|
||||
export IREDADMIN_HOME_DIR='/home/iredadmin'
|
||||
export SYS_USER_IREDADMIN='iredadmin'
|
||||
export SYS_GROUP_IREDADMIN="${SYS_USER_IREDADMIN}"
|
||||
|
||||
# MySQL database name, username and password.
|
||||
export IREDADMIN_DB_NAME="${SYS_USER_IREDADMIN}"
|
||||
export IREDADMIN_DB_USER="${SYS_USER_IREDADMIN}"
|
||||
|
||||
export IREDADMIN_BIND_ADDRESS='127.0.0.1'
|
||||
export IREDADMIN_LISTEN_PORT='7791'
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
export IREDAPD_VERSION='4.3'
|
||||
export SYS_USER_IREDAPD='iredapd'
|
||||
export SYS_GROUP_IREDAPD='iredapd'
|
||||
|
||||
export IREDAPD_TARBALL="iRedAPD-${IREDAPD_VERSION}.tar.gz"
|
||||
export IREDAPD_PARENT_DIR='/opt'
|
||||
export IREDAPD_ROOT_DIR="${IREDAPD_PARENT_DIR}/iRedAPD-${IREDAPD_VERSION}"
|
||||
export IREDAPD_ROOT_DIR_SYMBOL_LINK="${IREDAPD_PARENT_DIR}/iredapd"
|
||||
export IREDAPD_CONF="${IREDAPD_ROOT_DIR_SYMBOL_LINK}/settings.py"
|
||||
|
||||
# IREDAPD_BIND_HOST is configured in conf/global
|
||||
export IREDAPD_LISTEN_PORT='7777'
|
||||
export IREDAPD_SRS_FORWARD_PORT='7778'
|
||||
export IREDAPD_SRS_REVERSE_PORT='7779'
|
||||
export IREDAPD_SRS_SECRET="$(${RANDOM_STRING})"
|
||||
|
||||
export IREDAPD_PID_FILE='/var/run/iredapd.pid'
|
||||
export IREDAPD_LOG_DIR='/var/log/iredapd'
|
||||
export IREDAPD_LOG_FILE="${IREDAPD_LOG_DIR}/iredapd.log"
|
||||
export IREDAPD_LOGROTATE_FILE="${LOGROTATE_DIR}/iredapd"
|
||||
|
||||
# Database
|
||||
# IREDAPD_DB_PASSWD is generated in dialog/optional_components.sh.
|
||||
export IREDAPD_DB_NAME='iredapd'
|
||||
export IREDAPD_DB_USER='iredapd'
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Memcached
|
||||
export MEMCACHED_BIND_ADDRESS="${MEMCACHED_BIND_ADDRESS:=${LOCAL_ADDRESS}}"
|
||||
|
||||
export MEMCACHED_RC_SCRIPT_NAME='memcached'
|
||||
|
||||
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
export MEMCACHED_CONF='/etc/memcached.conf'
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export MEMCACHED_DAEMIN_USER='_memcached'
|
||||
fi
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# mlmmj user/group name
|
||||
export SYS_USER_MLMMJ='mlmmj'
|
||||
export SYS_GROUP_MLMMJ='mlmmj'
|
||||
|
||||
# Directory used to store mailing list accounts and archive of in/out mails
|
||||
export MLMMJ_SPOOL_DIR="${STORAGE_BASE_DIR}/mlmmj"
|
||||
export MLMMJ_HOME_DIR="${MLMMJ_SPOOL_DIR}"
|
||||
# Directory used to store archived mailing list accounts and data.
|
||||
export MLMMJ_ARCHIVE_DIR="${STORAGE_BASE_DIR}/mlmmj-archive"
|
||||
# Directory which stores skel files (templates in different languages)
|
||||
export MLMMJ_SKEL_DIR='/usr/share/mlmmj/text.skel'
|
||||
|
||||
export CMD_MLMMJ_RECEIVE='/usr/bin/mlmmj-receive'
|
||||
export CMD_MLMMJ_MAINTD='/usr/bin/mlmmj-maintd'
|
||||
export CMD_MLMMJ_AMIME_RECEIVE='/usr/bin/mlmmj-amime-receive'
|
||||
|
||||
export CRON_FILE_MLMMJ="${CRON_SPOOL_DIR}/${SYS_USER_MLMMJ}"
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' -o X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export CMD_MLMMJ_RECEIVE='/usr/local/bin/mlmmj-receive'
|
||||
export CMD_MLMMJ_MAINTD='/usr/local/bin/mlmmj-maintd'
|
||||
export CMD_MLMMJ_AMIME_RECEIVE='/usr/local/bin/mlmmj-amime-receive'
|
||||
export MLMMJ_SKEL_DIR='/usr/local/share/mlmmj/text.skel'
|
||||
fi
|
||||
|
||||
#
|
||||
# mlmmjadmin: RESTful API server used to manage mlmmj mailing lists
|
||||
#
|
||||
export MLMMJADMIN_RC_SCRIPT_NAME='mlmmjadmin'
|
||||
export MLMMJADMIN_RC_SCRIPT_PATH="${DIR_RC_SCRIPTS}/${MLMMJADMIN_RC_SCRIPT_NAME}"
|
||||
|
||||
export MLMMJADMIN_LISTEN_PORT='7790'
|
||||
export MLMMJADMIN_PID_FILE='/var/run/mlmmjadmin/mlmmjadmin.pid'
|
||||
|
||||
export MLMMJADMIN_VERSION='3.0'
|
||||
export MLMMJADMIN_TARBALL="mlmmjadmin-${MLMMJADMIN_VERSION}.tar.gz"
|
||||
|
||||
export MLMMJADMIN_PARENT_DIR='/opt'
|
||||
export MLMMJADMIN_ROOT_DIR="${MLMMJADMIN_PARENT_DIR}/mlmmjadmin-${MLMMJADMIN_VERSION}"
|
||||
export MLMMJADMIN_ROOT_DIR_SYMBOL_LINK="${MLMMJADMIN_PARENT_DIR}/mlmmjadmin"
|
||||
export MLMMJADMIN_CONF="${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/settings.py"
|
||||
|
||||
export MLMMJADMIN_LOG_DIR='/var/log/mlmmjadmin'
|
||||
export MLMMJADMIN_LOG_FILE="${MLMMJADMIN_LOG_DIR}/mlmmjadmin.log"
|
||||
export MLMMJADMIN_LOGROTATE_FILE="${LOGROTATE_DIR}/mlmmjadmin"
|
||||
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Variables for MySQL database server and related.
|
||||
# MYSQL_SERVER_ADDRESS and MYSQL_SERVER_PORT are defined in conf/global.
|
||||
# SQL_SERVER_ADDRESS and SQL_SERVER_PORT are defined in dialog/config_via_dialog.sh.
|
||||
|
||||
export MYSQL_MY_CNF='/etc/my.cnf'
|
||||
export MYSQL_MY_CNF_SAMPLE="${SAMPLE_DIR}/mysql/my.cnf"
|
||||
|
||||
export MYSQL_RC_SCRIPT_NAME='mysql'
|
||||
|
||||
# MySQL config file.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
export MYSQL_RC_SCRIPT_NAME='mariadb'
|
||||
|
||||
elif [ X"${DISTRO}" == X'UBUNTU' -o X"${DISTRO}" == X'DEBIAN' ]; then
|
||||
export MYSQL_MY_CNF='/etc/mysql/my.cnf'
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export MYSQL_RC_SCRIPT_NAME='mysql-server'
|
||||
export MYSQL_MY_CNF='/usr/local/etc/mysql/conf.d/server.cnf'
|
||||
export MYSQL_MY_CNF_SAMPLE='/usr/local/share/mysql/my-large.cnf'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export MYSQL_RC_SCRIPT_NAME='mysqld'
|
||||
fi
|
||||
|
||||
export MYSQLD_RC_SCRIPT="${DIR_RC_SCRIPTS}/${MYSQL_RC_SCRIPT_NAME}"
|
||||
export MYSQL_INIT_SQL="${RUNTIME_DIR}/mysql_init.sql"
|
||||
export MYSQL_VMAIL_SQL="${RUNTIME_DIR}/mysql_vmail.sql"
|
||||
|
||||
# SQL structure of MySQL vmail database.
|
||||
export MYSQL_VMAIL_STRUCTURE_SAMPLE="${SAMPLE_DIR}/iredmail/iredmail.mysql"
|
||||
|
||||
# File used to stores MySQL root password to avoid warning:
|
||||
# "Using a password on the command line interface can be insecure."
|
||||
# File will be copied to /root/.my.cnf after iRedMail installation.
|
||||
# WARNING: Do NOT set it to /root/.my.cnf here.
|
||||
export MYSQL_DEFAULTS_FILE_ROOT="/root/.my.cnf"
|
||||
export MYSQL_CLIENT_ROOT="mysql --defaults-file=${MYSQL_DEFAULTS_FILE_ROOT}"
|
||||
|
||||
# Hostname or IP address used in MySQL GRANT command (allow remote access from
|
||||
# this hostname/IP).
|
||||
# Usually it's 'localhost', but not in FreeBSD Jail (use ${LOCAL_ADDRESS} or
|
||||
# hostname of Jail instead).
|
||||
if [ X"${LOCAL_ADDRESS}" == X'127.0.0.1' ]; then
|
||||
# Pre-define MYSQL_GRANT_HOST while running iRedMail to use a remote MySQL
|
||||
# server. For example:
|
||||
# MYSQL_GRANT_HOST='192.168.1.2' bash iRedMail.sh
|
||||
export MYSQL_GRANT_HOST="${MYSQL_GRANT_HOST:=localhost}"
|
||||
else
|
||||
export MYSQL_GRANT_HOST="${LOCAL_ADDRESS}"
|
||||
fi
|
||||
|
||||
# Custom settings
|
||||
export MYSQL_MAX_CONNECTIONS="${MYSQL_MAX_CONNECTIONS:=1024}"
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# netdata: https://my-netdata.io
|
||||
#
|
||||
export NETDATA_VERSION='1.23.1'
|
||||
export NETDATA_PKG_NAME="netdata-v${NETDATA_VERSION}.gz.run"
|
||||
|
||||
# iRedMail install netdata with the '.bin' package on Linux, it installs
|
||||
# netdata application files under '/opt/netdata' by default.
|
||||
# Directory contains all config files
|
||||
export NETDATA_CONF_DIR="/opt/netdata/etc/netdata"
|
||||
|
||||
# Log directory
|
||||
export NETDATA_LOG_DIR="/opt/netdata/var/log/netdata"
|
||||
|
||||
if [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
export NETDATA_CONF_DIR='/usr/local/etc/netdata'
|
||||
export NETDATA_LOG_DIR='/var/log/netdata'
|
||||
fi
|
||||
|
||||
export NETDATA_PORT='19999'
|
||||
export NETDATA_RC_SCRIPT_NAME='netdata'
|
||||
|
||||
# Main config file.
|
||||
export NETDATA_CONF="${NETDATA_CONF_DIR}/netdata.conf"
|
||||
export NETDATA_HEALTH_ALARM_NOTIFY_CONF="${NETDATA_CONF_DIR}/health_alarm_notify.conf"
|
||||
export NETDATA_PYTHON_D_CONF="${NETDATA_CONF_DIR}/python.d.conf"
|
||||
export NETDATA_GO_D_CONF="${NETDATA_CONF_DIR}/go.d.conf"
|
||||
|
||||
# web auth file
|
||||
export NETDATA_HTTPD_AUTH_FILE="${HTTPD_CONF_ROOT}/netdata.users"
|
||||
|
||||
# .my.cnf used to access MySQL db.
|
||||
export NETDATA_DOT_MY_CNF="${NETDATA_CONF_DIR}/my.cnf"
|
||||
|
||||
# Modular config files.
|
||||
export NETDATA_CONF_HEALTH_ALARM_NOTIFY="${NETDATA_CONF_DIR}/health_alarm_notify.conf"
|
||||
|
||||
export NETDATA_GO_D_CONF_DIR="${NETDATA_CONF_DIR}/go.d"
|
||||
export NETDATA_GO_D_CONF_PHPFPM="${NETDATA_GO_D_CONF_DIR}/phpfpm.conf"
|
||||
export NETDATA_GO_D_CONF_NGINX="${NETDATA_GO_D_CONF_DIR}/nginx.conf"
|
||||
export NETDATA_GO_D_CONF_MYSQL="${NETDATA_GO_D_CONF_DIR}/mysql.conf"
|
||||
|
||||
# Plugin config files.
|
||||
export NETDATA_PYTHON_D_CONF_DIR="${NETDATA_CONF_DIR}/python.d"
|
||||
export NETDATA_PYTHON_D_CONF_PGSQL="${NETDATA_PYTHON_D_CONF_DIR}/postgres.conf"
|
||||
export NETDATA_PYTHON_D_CONF_OPENLDAP="${NETDATA_PYTHON_D_CONF_DIR}/openldap.conf"
|
||||
|
||||
# Database
|
||||
# NETDATA_DB_PASSWD is generated in dialog/optional_components.sh.
|
||||
export NETDATA_DB_USER='netdata'
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# RC scripts
|
||||
export NGINX_RC_SCRIPT_NAME='nginx'
|
||||
|
||||
# Configuration files
|
||||
export HTTPD_CONF_ROOT='/etc/nginx'
|
||||
|
||||
# Log directory.
|
||||
export NGINX_LOG_DIR='/var/log/nginx'
|
||||
|
||||
# PID file
|
||||
export NGINX_PID='/var/run/nginx.pid'
|
||||
|
||||
# Directory for storing temporary files holding client request bodies.
|
||||
export NGINX_CLIENT_BODY_TEMP_PATH='/var/lib/nginx_tmp_client_body'
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
# Daemon user.
|
||||
export HTTPD_USER='nginx'
|
||||
export HTTPD_GROUP='nginx'
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export HTTPD_CONF_ROOT="/usr/local/etc/nginx"
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export NGINX_LOG_DIR='/var/www/logs'
|
||||
|
||||
fi
|
||||
|
||||
# Log files.
|
||||
export NGINX_LOG_ACCESSLOG="${NGINX_LOG_DIR}/access.log"
|
||||
export NGINX_LOG_ERRORLOG="${NGINX_LOG_DIR}/error.log"
|
||||
|
||||
export HTTPD_CONF_DIR_AVAILABLE_CONF="${HTTPD_CONF_ROOT}/conf-available"
|
||||
export HTTPD_CONF_DIR_ENABLED_CONF="${HTTPD_CONF_ROOT}/conf-enabled"
|
||||
|
||||
# Directory used to store all sites. Note: not loaded by default.
|
||||
export HTTPD_CONF_DIR_AVAILABLE_SITES="${HTTPD_CONF_ROOT}/sites-available"
|
||||
# Directory used to store site config files which will be loaded by default.
|
||||
# Usually we just create a symbol link to file under ${HTTPD_CONF_DIR_AVAILABLE_SITES}
|
||||
export HTTPD_CONF_DIR_ENABLED_SITES="${HTTPD_CONF_ROOT}/sites-enabled"
|
||||
|
||||
export NGINX_CONF="${HTTPD_CONF_ROOT}/nginx.conf"
|
||||
export NGINX_CONF_SITE_DEFAULT="${HTTPD_CONF_DIR_AVAILABLE_SITES}/00-default.conf"
|
||||
export NGINX_CONF_SITE_DEFAULT_SSL="${HTTPD_CONF_DIR_AVAILABLE_SITES}/00-default-ssl.conf"
|
||||
export NGINX_CONF_TMPL_DIR="${HTTPD_CONF_ROOT}/templates"
|
||||
|
||||
export NGINX_MIME_TYPES="${HTTPD_CONF_ROOT}/mime.types"
|
||||
@@ -0,0 +1,168 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Variables for OpenLDAP and related. Refer to 'dialog/ldap_config.sh'.
|
||||
|
||||
# OpenLDAP version number.
|
||||
export OPENLDAP_VERSION='2.4'
|
||||
|
||||
# Support password verification with SSHA512. Require OpenLDAP-2.4.32 or later.
|
||||
export OPENLDAP_HAS_SHA2='YES'
|
||||
# Module name
|
||||
export OPENLDAP_MOD_PW_SHA2='pw-sha2'
|
||||
|
||||
# LDAP service info.
|
||||
# LDAP_SERVER_HOST, LDAP_SERVER_PORT are defined in conf/global
|
||||
export LDAP_USE_TLS='NO'
|
||||
export LDAP_BIND='yes'
|
||||
export LDAP_BIND_VERSION='3'
|
||||
|
||||
# OpenLDAP daemon user and group name.
|
||||
export SYS_USER_LDAP='ldap'
|
||||
export SYS_GROUP_LDAP='ldap'
|
||||
|
||||
export OPENLDAP_RC_SCRIPT_NAME='slapd'
|
||||
|
||||
# Configuration files.
|
||||
export OPENLDAP_CONF_ROOT='/etc/openldap'
|
||||
|
||||
# Database backend type.
|
||||
export OPENLDAP_DEFAULT_DBTYPE='mdb'
|
||||
|
||||
# Default LDAP data directory.
|
||||
export OPENLDAP_DATA_DIR='/var/lib/ldap' # Do *NOT* end with '/'.
|
||||
|
||||
export OPENLDAP_PID_FILE='/var/run/openldap/slapd.pid'
|
||||
export OPENLDAP_ARGS_FILE='/var/run/openldap/slapd.args'
|
||||
|
||||
# Configure.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
export OPENLDAP_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/slapd"
|
||||
|
||||
# Module related.
|
||||
export OPENLDAP_MODULE_PATH='/usr/lib/openldap'
|
||||
if [ X"${OS_ARCH}" == X'x86_64' ]; then
|
||||
export OPENLDAP_MODULE_PATH='/usr/lib64/openldap'
|
||||
fi
|
||||
|
||||
export OPENLDAP_HAS_SHA2='NO'
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# LDAP daemon user & group.
|
||||
export SYS_USER_LDAP='openldap'
|
||||
export SYS_GROUP_LDAP='openldap'
|
||||
|
||||
# Configuration files.
|
||||
export OPENLDAP_CONF_ROOT="/etc/ldap"
|
||||
|
||||
export OPENLDAP_PID_FILE='/var/run/slapd/slapd.pid'
|
||||
export OPENLDAP_ARGS_FILE='/var/run/slapd/slapd.args'
|
||||
|
||||
export OPENLDAP_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/slapd"
|
||||
|
||||
# Module related.
|
||||
export OPENLDAP_MODULE_PATH='/usr/lib/ldap'
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Configuration files.
|
||||
export OPENLDAP_CONF_ROOT='/usr/local/etc/openldap'
|
||||
|
||||
# Module related.
|
||||
export OPENLDAP_MODULE_PATH='/usr/local/libexec/openldap'
|
||||
|
||||
# Override default setting.
|
||||
export OPENLDAP_DATA_DIR='/var/db/openldap-data' # Do *NOT* end with '/'.
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# LDAP daemon user & group.
|
||||
export SYS_USER_LDAP='_openldap'
|
||||
export SYS_GROUP_LDAP='_openldap'
|
||||
|
||||
# mdb is not available on OpenBSD.
|
||||
export OPENLDAP_DEFAULT_DBTYPE='hdb'
|
||||
|
||||
export OPENLDAP_DB_CONFIG_SAMPLE='/usr/local/share/examples/openldap/DB_CONFIG'
|
||||
|
||||
# Module related.
|
||||
export OPENLDAP_HAS_SHA2='NO'
|
||||
export OPENLDAP_MODULE_PATH='/usr/local/libexec/openldap'
|
||||
fi
|
||||
|
||||
# RC script.
|
||||
export OPENLDAP_RC_SCRIPT="${DIR_RC_SCRIPTS}/${OPENLDAP_RC_SCRIPT_NAME}"
|
||||
|
||||
export OPENLDAP_SCHEMA_DIR="${OPENLDAP_CONF_ROOT}/schema"
|
||||
export OPENLDAP_SLAPD_CONF="${OPENLDAP_CONF_ROOT}/slapd.conf"
|
||||
export OPENLDAP_LDAP_CONF="${OPENLDAP_CONF_ROOT}/ldap.conf"
|
||||
|
||||
# Log
|
||||
# OpenLDAP logs to local4 by default.
|
||||
export OPENLDAP_SYSLOG_FACILITY='local4'
|
||||
export OPENLDAP_LOG_DIR='/var/log/openldap'
|
||||
export OPENLDAP_LOG_FILE="${OPENLDAP_LOG_DIR}/openldap.log"
|
||||
export OPENLDAP_LOGROTATE_FILE="${LOGROTATE_DIR}/openldap"
|
||||
|
||||
# LDAP data directory.
|
||||
export ldap_suffix_to_domain_name="$(echo ${LDAP_SUFFIX} | sed -e 's/dc=//g' -e 's/,/./g')"
|
||||
export LDAP_DATA_DIR="${OPENLDAP_DATA_DIR}/${ldap_suffix_to_domain_name}"
|
||||
|
||||
# Setting for one instance. You can edit ${OPENLDAP_SLAPD_CONF} manually to hold
|
||||
# multi instances.
|
||||
export LDAP_INIT_LDIF="${RUNTIME_DIR}/ldap_init.ldif"
|
||||
|
||||
##################################################
|
||||
# iRedMail LDAP schema related
|
||||
#
|
||||
export LDAP_IREDMAIL_SCHEMA="${SAMPLE_DIR}/iredmail/iredmail.schema"
|
||||
|
||||
# Domain admin related.
|
||||
export LDAP_ATTR_DOMAINADMIN_DN_NAME='domainAdmins'
|
||||
|
||||
# Container which includes all mail accounts: o=domains,dc=xx,dc=xx
|
||||
export LDAP_BASEDN_NAME='domains'
|
||||
|
||||
# Domain related attributes.
|
||||
export LDAP_ATTR_DOMAIN_RDN='domainName'
|
||||
|
||||
# Group related.
|
||||
export LDAP_ATTR_GROUP_RDN='ou'
|
||||
export LDAP_ATTR_GROUP_USERS='Users'
|
||||
export LDAP_ATTR_GROUP_GROUPS='Groups'
|
||||
export LDAP_ATTR_GROUP_ALIASES='Aliases'
|
||||
export LDAP_ATTR_GROUP_EXTERNALS='Externals'
|
||||
|
||||
# Attributes of user object.
|
||||
export LDAP_ATTR_USER_RDN='mail'
|
||||
|
||||
##################################################
|
||||
# Password scheme
|
||||
#
|
||||
# If no pw-sha2 support, use SSHA instead.
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -a X"${OPENLDAP_HAS_SHA2}" != X'YES' ]; then
|
||||
export DEFAULT_PASSWORD_SCHEME='SSHA'
|
||||
fi
|
||||
|
||||
export LDAP_BINDDN="cn=${SYS_USER_VMAIL},${LDAP_SUFFIX}"
|
||||
export LDAP_ADMIN_DN="cn=${VMAIL_DB_ADMIN_USER},${LDAP_SUFFIX}"
|
||||
export LDAP_ROOTDN="cn=Manager,${LDAP_SUFFIX}"
|
||||
export LDAP_BASEDN="o=${LDAP_BASEDN_NAME},${LDAP_SUFFIX}"
|
||||
export LDAP_ADMIN_BASEDN="o=${LDAP_ATTR_DOMAINADMIN_DN_NAME},${LDAP_SUFFIX}"
|
||||
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# path to php program
|
||||
export PHP_BIN='/usr/bin/php'
|
||||
|
||||
# Path used to store php sessions (session.save_path)
|
||||
export PHP_SESSION_SAVE_PATH='/var/lib/php/sessions'
|
||||
|
||||
# php-fpm
|
||||
export PHP_FPM_RC_SCRIPT_NAME='php-fpm'
|
||||
export PHP_FPM_CONF='/etc/php-fpm.conf'
|
||||
export PHP_FPM_POOL_DIR='/etc/php-fpm.d'
|
||||
export PHP_FPM_LOGROTATE_CONF='/etc/logrotate.d/php-fpm'
|
||||
|
||||
# Disabled PHP functions.
|
||||
# - Roundcube requires: proc_open, proc_close, escapeshellarg.
|
||||
export PHP_DISABLE_FUNCTIONS='posix_uname,eval,pcntl_wexitstatus,posix_getpwuid,xmlrpc_entity_decode,pcntl_wifstopped,pcntl_wifexited,pcntl_wifsignaled,phpAds_XmlRpc,pcntl_strerror,ftp_exec,pcntl_wtermsig,mysql_pconnect,proc_nice,pcntl_sigtimedwait,posix_kill,pcntl_sigprocmask,fput,phpinfo,system,phpAds_remoteInfo,ftp_login,inject_code,posix_mkfifo,highlight_file,escapeshellcmd,show_source,pcntl_wifcontinued,fp,pcntl_alarm,pcntl_wait,ini_alter,posix_setpgid,parse_ini_file,ftp_raw,pcntl_waitpid,pcntl_getpriority,ftp_connect,pcntl_signal_dispatch,pcntl_wstopsig,ini_restore,ftp_put,passthru,proc_terminate,posix_setsid,pcntl_signal,pcntl_setpriority,phpAds_xmlrpcEncode,pcntl_exec,ftp_nb_fput,ftp_get,phpAds_xmlrpcDecode,pcntl_sigwaitinfo,shell_exec,pcntl_get_last_error,ftp_rawlist,pcntl_fork,posix_setuid'
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
export PHP_INI='/etc/php.ini'
|
||||
export PHP_FPM_PID_FILE='/run/php-fpm/php-fpm.pid'
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ X"${DISTRO_CODENAME}" == X'stretch' ]; then
|
||||
# Debian 9
|
||||
export PHP_VERSION='7.0'
|
||||
elif [ X"${DISTRO_CODENAME}" == X'buster' ]; then
|
||||
# Debian 10
|
||||
export PHP_VERSION='7.3'
|
||||
elif [ X"${DISTRO_CODENAME}" == X'bionic' ]; then
|
||||
# Ubuntu 18.04
|
||||
export PHP_VERSION='7.2'
|
||||
else
|
||||
# Ubuntu 20.04
|
||||
export PHP_VERSION='7.4'
|
||||
fi
|
||||
|
||||
export PHP_INI="/etc/php/${PHP_VERSION}/fpm/php.ini"
|
||||
export PHP_FPM_CONF="/etc/php/${PHP_VERSION}/fpm/php-fpm.conf"
|
||||
export PHP_FPM_PID_FILE='/run/php/php-fpm.pid'
|
||||
export PHP_FPM_LOGROTATE_CONF="${LOGROTATE_DIR}/php${PHP_VERSION}-fpm"
|
||||
export PHP_FPM_POOL_DIR="/etc/php/${PHP_VERSION}/fpm/pool.d"
|
||||
export PHP_FPM_RC_SCRIPT_NAME="php${PHP_VERSION}-fpm"
|
||||
export PHPENMOD_BIN='phpenmod'
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export PHP_BIN='/usr/local/bin/php'
|
||||
|
||||
# Copy from example: /usr/local/etc/php.ini-production
|
||||
export PHP_INI='/usr/local/etc/php.ini'
|
||||
export PHP_FPM_CONF='/usr/local/etc/php-fpm.conf'
|
||||
export PHP_FPM_POOL_DIR='/usr/local/etc/php-fpm.d'
|
||||
export PHP_FPM_LOGROTATE_CONF="${LOGROTATE_DIR}/php-fpm"
|
||||
export PHP_FPM_PID_FILE='/var/run/php-fpm.pid'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export OB_PHP_VERSION='7.4'
|
||||
export PHP_FPM_RC_SCRIPT_NAME='php74_fpm'
|
||||
|
||||
export PHP_BIN="/usr/local/bin/php-${OB_PHP_VERSION}"
|
||||
export PHP_INI="/etc/php-${OB_PHP_VERSION}.ini"
|
||||
export PHP_FPM_PID_FILE='/var/run/php-fpm.pid'
|
||||
fi
|
||||
|
||||
# PHP-FPM
|
||||
export PHP_FPM_POOL_WWW_CONF="${PHP_FPM_POOL_DIR}/www.conf"
|
||||
# log
|
||||
export PHP_FPM_LOG_DIR='/var/log/php-fpm'
|
||||
export PHP_FPM_LOG_MAIN="${PHP_FPM_LOG_DIR}/php-fpm.log"
|
||||
export PHP_FPM_LOG_SLOW="${PHP_FPM_LOG_DIR}/slow.log"
|
||||
# parameters
|
||||
export PHP_FPM_REQUEST_SLOWLOG_TIMEOUT='10s'
|
||||
export PHP_FPM_URI_STATUS='status'
|
||||
export PHP_FPM_URI_PING='ping'
|
||||
export PHP_FPM_POOL_MAX_CHILDREN=100
|
||||
export PHP_FPM_POOL_START_SERVERS=5
|
||||
export PHP_FPM_POOL_MIN_SPARE_SERVERS=5
|
||||
export PHP_FPM_POOL_MAX_SPARE_SERVERS=10
|
||||
export PHP_FPM_POOL_MAX_REQUESTS=100
|
||||
export PHP_FPM_POOL_REQUEST_TERMINATE_TIMEOUT='60s'
|
||||
|
||||
# connection type: mysql, mysqli (recommended for MySQL/MariaDB), pgsql.
|
||||
export PHP_CONN_TYPE='mysqli'
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && export PHP_CONN_TYPE='pgsql'
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Variables for Postfix and related.
|
||||
|
||||
#
|
||||
# You do *NOT* need to modify them.
|
||||
#
|
||||
# ---- Postfix ----
|
||||
export SYS_USER_POSTFIX='postfix'
|
||||
export SYS_GROUP_POSTFIX='postfix'
|
||||
|
||||
export POSTFIX_ROOTDIR='/etc/postfix'
|
||||
export POSTFIX_RC_SCRIPT_NAME='postfix'
|
||||
|
||||
# Log file
|
||||
export MAILLOG='/var/log/maillog'
|
||||
|
||||
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
export MAILLOG='/var/log/mail.log'
|
||||
export MAILLOG_INFO='/var/log/mail.info'
|
||||
export MAILLOG_ERROR='/var/log/mail.err'
|
||||
export MAILLOG_WARN='/var/log/mail.warn'
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export POSTFIX_ROOTDIR='/usr/local/etc/postfix'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export SYS_USER_POSTFIX='_postfix'
|
||||
export SYS_GROUP_POSTFIX='_postfix'
|
||||
fi
|
||||
|
||||
# You do *NOT* need to modify them.
|
||||
export POSTFIX_CHROOT_DIR='/var/spool/postfix'
|
||||
|
||||
export POSTFIX_FILE_MAIN_CF="${POSTFIX_ROOTDIR}/main.cf"
|
||||
export POSTFIX_FILE_MASTER_CF="${POSTFIX_ROOTDIR}/master.cf"
|
||||
export POSTFIX_FILE_ALIASES="${POSTFIX_ROOTDIR}/aliases"
|
||||
export POSTFIX_FILE_HELO_ACCESS="${POSTFIX_ROOTDIR}/helo_access.pcre"
|
||||
export POSTFIX_FILE_SMTPD_COMMAND_FILTER="${POSTFIX_ROOTDIR}/command_filter.pcre"
|
||||
|
||||
export POSTFIX_FILE_HEADER_CHECKS="${POSTFIX_ROOTDIR}/header_checks"
|
||||
export POSTFIX_FILE_BODY_CHECKS="${POSTFIX_ROOTDIR}/body_checks.pcre"
|
||||
# used for sender white/blacklist with pcre support
|
||||
export POSTFIX_FILE_SENDER_ACCESS="${POSTFIX_ROOTDIR}/sender_access.pcre"
|
||||
|
||||
export POSTSCREEN_FILE_DNSBL_REPLY="${POSTFIX_ROOTDIR}/postscreen_dnsbl_reply"
|
||||
export POSTSCREEN_FILE_ACCESS_CIDR="${POSTFIX_ROOTDIR}/postscreen_access.cidr"
|
||||
|
||||
# Default transport or LDA (local deliver agent).
|
||||
export TRANSPORT="${TRANSPORT:=${DOVECOT_LDA_DELIVER}}"
|
||||
|
||||
# Set 'message_size_limit', in 'byte' and 'kilobytes'.
|
||||
# Default is 15M (final message will be slight larger after encoding).
|
||||
export MESSAGE_SIZE_LIMIT_MB="${MESSAGE_SIZE_LIMIT_MB:=15}"
|
||||
export MESSAGE_SIZE_LIMIT_BYTES="$((MESSAGE_SIZE_LIMIT_MB * 1024 * 1024))"
|
||||
export MESSAGE_SIZE_LIMIT_KB="$((MESSAGE_SIZE_LIMIT_MB * 1024))"
|
||||
|
||||
# LDAP/MYSQL/PGSQL lookup configuration files.
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
export POSTFIX_LOOKUP_DB='ldap'
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
export POSTFIX_LOOKUP_DB='mysql'
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
export POSTFIX_LOOKUP_DB='pgsql'
|
||||
else
|
||||
export POSTFIX_LOOKUP_DIR="${POSTFIX_ROOTDIR}/lookups"
|
||||
fi
|
||||
|
||||
export POSTFIX_LOOKUP_DIR="${POSTFIX_ROOTDIR}/${POSTFIX_LOOKUP_DB}"
|
||||
export POSTFIX_MAIL_REINJECT_PORT='10025'
|
||||
export POSTFIX_MLMMJ_REINJECT_PORT='10028'
|
||||
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Variables for PostgreSQL database server and related.
|
||||
# PGSQL_SERVER_ADDRESS and PGSQL_SERVER_PORT are defined in conf/global.
|
||||
# SQL_SERVER_ADDRESS and SQL_SERVER_PORT are defined in dialog/config_via_dialog.sh.
|
||||
|
||||
export SYS_USER_PGSQL='postgres'
|
||||
export SYS_GROUP_PGSQL='postgres'
|
||||
|
||||
export PGSQL_RC_SCRIPT_NAME='postgresql'
|
||||
|
||||
export PGSQL_INIT_SQL_SAMPLE="${RUNTIME_DIR}/pgsql_init.pgsql"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
export PGSQL_USER_HOMEDIR='/var/lib/pgsql'
|
||||
export PGSQL_DATA_DIR="${PGSQL_USER_HOMEDIR}/data"
|
||||
|
||||
export PGSQL_CONF_POSTGRESQL="${PGSQL_DATA_DIR}/postgresql.conf"
|
||||
export PGSQL_CONF_PG_HBA="${PGSQL_DATA_DIR}/pg_hba.conf"
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ X"${DISTRO_CODENAME}" == X'stretch' ]; then
|
||||
# Debian 9
|
||||
export PGSQL_VERSION='9.6'
|
||||
elif [ X"${DISTRO_CODENAME}" == X'bionic' ]; then
|
||||
# Ubuntu 18.04
|
||||
export PGSQL_VERSION='10'
|
||||
elif [ X"${DISTRO_CODENAME}" == X'buster' ]; then
|
||||
# Debian 10
|
||||
export PGSQL_VERSION='11'
|
||||
else
|
||||
# Ubuntu 20.04
|
||||
export PGSQL_VERSION='12'
|
||||
fi
|
||||
|
||||
export PGSQL_USER_HOMEDIR='/var/lib/postgresql'
|
||||
export PGSQL_DATA_DIR="/var/lib/postgresql/${PGSQL_VERSION}/main"
|
||||
export PGSQL_CONF_DIR="/etc/postgresql/${PGSQL_VERSION}/main"
|
||||
export PGSQL_CONF_POSTGRESQL="${PGSQL_CONF_DIR}/postgresql.conf"
|
||||
export PGSQL_CONF_PG_HBA="${PGSQL_CONF_DIR}/pg_hba.conf"
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export SYS_USER_PGSQL='postgres'
|
||||
export SYS_GROUP_PGSQL='postgres'
|
||||
export PGSQL_USER_HOMEDIR='/var/db/postgres'
|
||||
export PGSQL_VERSION='12'
|
||||
|
||||
export PGSQL_DATA_DIR="${PGSQL_USER_HOMEDIR}/data${PGSQL_VERSION}"
|
||||
export PGSQL_CONF_POSTGRESQL="${PGSQL_DATA_DIR}/postgresql.conf"
|
||||
export PGSQL_CONF_PG_HBA="${PGSQL_DATA_DIR}/pg_hba.conf"
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export SYS_USER_PGSQL='_postgresql'
|
||||
export SYS_GROUP_PGSQL='_postgresql'
|
||||
export PGSQL_USER_HOMEDIR='/var/postgresql'
|
||||
|
||||
export PGSQL_DATA_DIR="${PGSQL_USER_HOMEDIR}/data"
|
||||
export PGSQL_CONF_POSTGRESQL="${PGSQL_DATA_DIR}/postgresql.conf"
|
||||
export PGSQL_CONF_PG_HBA="${PGSQL_DATA_DIR}/pg_hba.conf"
|
||||
fi
|
||||
|
||||
export PGSQL_ROOT_USER="${SYS_USER_PGSQL}"
|
||||
export PGSQL_RC_SCRIPT="${DIR_RC_SCRIPTS}/${PGSQL_RC_SCRIPT_NAME}"
|
||||
|
||||
# ~/.pgpass
|
||||
export PGSQL_DOT_PGPASS="${PGSQL_USER_HOMEDIR}/.pgpass"
|
||||
|
||||
# SSL cert/key
|
||||
export PGSQL_SSL_CERT="${SSL_CERT_DIR}/iRedMail_CA_PostgreSQL.pem"
|
||||
export PGSQL_SSL_KEY="${SSL_KEY_DIR}/iRedMail_PostgreSQL.key"
|
||||
|
||||
# Commands
|
||||
export PGSQL_BIN_PG_DUMP='/usr/bin/pg_dump'
|
||||
export PGSQL_BIN_PG_DUMPALL='/usr/bin/pg_dumpall'
|
||||
if [ X"${DISTRO}" == X"FREEBSD" -o X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export PGSQL_BIN_PG_DUMP='/usr/local/bin/pg_dump'
|
||||
export PGSQL_BIN_PG_DUMPALL='/usr/local/bin/pg_dumpall'
|
||||
fi
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# ---------------------------------------
|
||||
# RoundcubeMail. http://roundcube.net
|
||||
# ---------------------------------------
|
||||
export RCM_VERSION='1.4.7'
|
||||
export RCM_TARBALL="roundcubemail-${RCM_VERSION}-complete.tar.gz"
|
||||
export RCM_USE_SOURCE='YES'
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Install via ports tree
|
||||
export RCM_USE_SOURCE='NO'
|
||||
fi
|
||||
|
||||
if [ X"${RCM_USE_SOURCE}" == X'YES' ]; then
|
||||
export RCM_HTTPD_ROOT="${HTTPD_SERVERROOT}/roundcubemail-${RCM_VERSION}"
|
||||
export RCM_HTTPD_ROOT_SYMBOL_LINK="${HTTPD_SERVERROOT}/roundcubemail"
|
||||
else
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export RCM_HTTPD_ROOT="${HTTPD_SERVERROOT}/roundcube"
|
||||
export RCM_HTTPD_ROOT_SYMBOL_LINK="${RCM_HTTPD_ROOT}"
|
||||
fi
|
||||
fi
|
||||
|
||||
export RCM_CONF_DIR="${RCM_HTTPD_ROOT}/config"
|
||||
export RCM_CONF="${RCM_CONF_DIR}/config.inc.php"
|
||||
|
||||
# Syslog log file.
|
||||
export RCM_LOGFILE="${MAILLOG}"
|
||||
|
||||
# Database setting.
|
||||
export RCM_DB_NAME="roundcubemail"
|
||||
export RCM_DB_USER="roundcube"
|
||||
|
||||
# this key is used to encrypt the users imap password which is stored
|
||||
# in the session record (and the client cookie if remember password is enabled).
|
||||
# please provide a string of exactly 24 chars.
|
||||
export tmp_rcm_des_key="$(${RANDOM_STRING} | cut -c-24)"
|
||||
export RCM_DES_KEY="${tmp_rcm_des_key}"
|
||||
|
||||
# Directory used to store PGP keys generated with Roundcube plugin `enigma`
|
||||
export RCM_PLUGIN_ENIGMA_PGP_HOMEDIR="${RCM_PLUGIN_ENIGMA_PGP_HOMEDIR:=${STORAGE_BASE_DIR}/pgp-keys}"
|
||||
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Official SOGo package repo.
|
||||
export SOGO_PKG_MIRROR="${SOGO_PKG_MIRROR:=https://packages.inverse.ca}"
|
||||
# APT key of SOGo official apt repo: 0x810273C4.
|
||||
export SOGO_PKG_MIRROR_APT_KEY="${SOGO_PKG_MIRROR_APT_KEY:=0x810273C4}"
|
||||
|
||||
# Major SOGo version number: 3, 4.
|
||||
export SOGO_VERSION='4'
|
||||
|
||||
export SYS_USER_SOGO='sogo'
|
||||
export SYS_GROUP_SOGO='sogo'
|
||||
|
||||
export SOGO_PID_FILE='/var/run/sogo/sogo.pid'
|
||||
export SOGO_LOG_FILE='/var/log/sogo/sogo.log'
|
||||
|
||||
export SOGO_CONF_DIR='/etc/sogo'
|
||||
export SOGO_SIEVE_MASTER_USER="${SOGO_SIEVE_MASTER_USER:=sogo_sieve_master}"
|
||||
export SOGO_RC_SCRIPT_NAME='sogod'
|
||||
|
||||
# SOGo deamon listens on port 127.0.0.1:20000 by default.
|
||||
export SOGO_BIND_ADDRESS="${LOCAL_ADDRESS:=127.0.0.1}"
|
||||
export SOGO_BIND_PORT='20000'
|
||||
|
||||
# SMTP port used by SOGo for smtp auth without SSL/TLS support.
|
||||
#
|
||||
# SOGo doesn't support SMTP auth over TLS or SSL, so if SOGo and Postfix are
|
||||
# running on different servers, SOGo needs another smtp port to send email.
|
||||
export SOGO_SMTP_PORT="${SOGO_SMTP_PORT:=1025}"
|
||||
|
||||
# SOGo proxy timeout (in seconds)
|
||||
export SOGO_PROXY_TIMEOUT='3540'
|
||||
|
||||
# SOGo SQL database.
|
||||
export SOGO_DB_NAME='sogo'
|
||||
export SOGO_DB_USER='sogo'
|
||||
export SOGO_DB_VIEW_AUTH='users'
|
||||
export SOGO_DB_VIEW_ALIASES='aliases'
|
||||
export SOGO_DB_TABLE_USER_PROFILE='sogo_user_profile'
|
||||
export SOGO_DB_TABLE_FOLDER_INFO='sogo_folder_info'
|
||||
export SOGO_DB_TABLE_SESSIONS_FOLDER='sogo_sessions_folder'
|
||||
export SOGO_DB_TABLE_ALARMS='sogo_alarms_folder'
|
||||
export SOGO_DB_TABLE_STORE='sogo_store'
|
||||
export SOGO_DB_TABLE_ACL='sogo_acl'
|
||||
export SOGO_DB_TABLE_CACHE_FOLDER='sogo_cache_folder'
|
||||
|
||||
export SOGO_CMD_TOOL='/usr/sbin/sogo-tool'
|
||||
export SOGO_CMD_EALARMS_NOTIFY='/usr/sbin/sogo-ealarms-notify'
|
||||
export SOGO_GNUSTEP_DIR="/usr/lib/GNUstep/SOGo"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ X"${OS_ARCH}" == X'x86_64' ]; then
|
||||
export SOGO_GNUSTEP_DIR="/usr/lib64/GNUstep/SOGo"
|
||||
fi
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
export SOGO_RC_SCRIPT_NAME='sogo'
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export SYS_USER_SOGO='sogod'
|
||||
export SYS_GROUP_SOGO='sogod'
|
||||
|
||||
export SOGO_GNUSTEP_DIR='/usr/local/GNUstep/Local/Library/SOGo'
|
||||
export SOGO_RC_SCRIPT_NAME='sogod'
|
||||
export SOGO_CONF_DIR='/usr/local/etc/sogo'
|
||||
|
||||
export SOGO_CMD_TOOL='/usr/local/GNUstep/Local/Tools/Admin/sogo-tool'
|
||||
export SOGO_CMD_EALARMS_NOTIFY='/usr/local/GNUstep/Local/Tools/Admin/sogo-ealarms-notify'
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export SYS_USER_SOGO='_sogo'
|
||||
export SYS_GROUP_SOGO='_sogo'
|
||||
|
||||
export SOGO_GNUSTEP_DIR='/usr/local/lib/GNUstep/SOGo'
|
||||
export SOGO_CMD_TOOL='/usr/local/sbin/sogo-tool'
|
||||
export SOGO_CMD_EALARMS_NOTIFY='/usr/local/sbin/sogo-ealarms-notify'
|
||||
fi
|
||||
|
||||
export SOGO_CONF="${SOGO_CONF_DIR}/sogo.conf"
|
||||
export SOGO_SIEVE_CREDENTIAL_FILE="${SOGO_CONF_DIR}/sieve.cred"
|
||||
export CRON_FILE_SOGO="${CRON_SPOOL_DIR}/${SYS_USER_SOGO}"
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
export SOGO_DB_TYPE='mysql'
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
export SOGO_DB_TYPE='postgresql'
|
||||
fi
|
||||
|
||||
# Script used to backup SOGo data.
|
||||
export BACKUP_SCRIPT_SOGO="${BACKUP_DIR}/backup_sogo.sh"
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# For SpamAssassin.
|
||||
|
||||
export SA_CONF_DIR='/etc/mail/spamassassin'
|
||||
export SA_RULES_DIR='/usr/share/spamassassin'
|
||||
export BIN_SA_UPDATE='sa-update'
|
||||
export BIN_SA_COMPILE='sa-compile'
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export SA_CONF_DIR='/usr/local/etc/mail/spamassassin'
|
||||
export SA_RULES_DIR='/usr/local/share/spamassassin'
|
||||
export BIN_SA_UPDATE='/usr/local/bin/sa-update'
|
||||
export BIN_SA_COMPILE='/usr/local/bin/sa-compile'
|
||||
fi
|
||||
|
||||
export SA_INIT_PRE="${SA_CONF_DIR}/init.pre"
|
||||
export SA_LOCAL_CF="${SA_CONF_DIR}/local.cf"
|
||||
export SA_PLUGIN_RAZOR_CONF="${SA_CONF_DIR}/razor.conf"
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# web servers and PHP
|
||||
export PORT_HTTP="${PORT_HTTP:=80}"
|
||||
export HTTPS_PORT="${HTTPS_PORT:=443}"
|
||||
|
||||
# store extra web applications
|
||||
export HTTPD_SERVERROOT='/opt/www'
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
# Web data.
|
||||
export HTTPD_DOCUMENTROOT='/var/www/html'
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# Web data.
|
||||
export HTTPD_DOCUMENTROOT='/var/www/html'
|
||||
|
||||
# Daemon user.
|
||||
export HTTPD_USER='www-data'
|
||||
export HTTPD_GROUP='www-data'
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Daemon user.
|
||||
export HTTPD_USER='www'
|
||||
export HTTPD_GROUP='www'
|
||||
|
||||
# Web data.
|
||||
export HTTPD_SERVERROOT='/usr/local/www'
|
||||
export HTTPD_DOCUMENTROOT='/usr/local/www/htdocs'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# Daemon user.
|
||||
export HTTPD_USER='www'
|
||||
export HTTPD_GROUP='www'
|
||||
|
||||
# Web data.
|
||||
export HTTPD_DOCUMENTROOT="/var/www/htdocs"
|
||||
|
||||
fi
|
||||
|
||||
[ X"${WEB_SERVER}" == X'NGINX' ] && . ${CONF_DIR}/nginx
|
||||
|
||||
. ${CONF_DIR}/php
|
||||
@@ -0,0 +1,254 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Note: config file will be sourced in 'conf/core', function `check_env()`.
|
||||
|
||||
. ${CONF_DIR}/global
|
||||
. ${CONF_DIR}/core
|
||||
. ${CONF_DIR}/openldap
|
||||
. ${CONF_DIR}/postfix
|
||||
. ${CONF_DIR}/roundcube
|
||||
. ${CONF_DIR}/iredadmin
|
||||
|
||||
trap "exit 255" 2
|
||||
|
||||
# Initialize config file.
|
||||
echo '' > ${IREDMAIL_CONFIG_FILE}
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${IREDMAIL_CONFIG_FILE}
|
||||
chmod 0400 ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
DIALOG="dialog --colors --no-collapse --insecure --ok-label Next \
|
||||
--no-cancel --backtitle ${PROG_NAME}:_Open_Source_Mail_Server_Solution"
|
||||
|
||||
# Welcome message.
|
||||
${DIALOG} \
|
||||
--title "Welcome and thanks for your use" \
|
||||
--yesno "\
|
||||
Welcome to the iRedMail setup wizard, we will ask you some simple questions required to setup a mail server. If you encounter any trouble or issues, please report to our support forum: https://forum.iredmail.org/
|
||||
|
||||
NOTE: You can abort this installation wizard by pressing key Ctrl-C.
|
||||
" 20 76
|
||||
|
||||
# Exit when user choose 'exit'.
|
||||
[ X"$?" != X"0" ] && ECHO_INFO "Exit." && exit 0
|
||||
|
||||
# Storage base directory
|
||||
while :; do
|
||||
${DIALOG} \
|
||||
--title "Default mail storage path" \
|
||||
--inputbox "\
|
||||
Please specify a directory (in lowercase) used to store user mailboxes.
|
||||
Default is: ${STORAGE_BASE_DIR}
|
||||
|
||||
NOTES:
|
||||
|
||||
* Depends on the mail traffic, it may take large disk space.
|
||||
* Maildir path will be converted to lowercases, so please create this
|
||||
directory in lowcases.
|
||||
* It cannot be /var/mail or /root.
|
||||
* Mailboxes will be stored under its sub-directory: ${STORAGE_BASE_DIR}/${STORAGE_NODE}/
|
||||
* Daily backup of SQL/LDAP databases will be stored under another sub-directory: /var/vmail/backup.
|
||||
" 20 76 "${STORAGE_BASE_DIR}" 2>${RUNTIME_DIR}/.storage_base_dir
|
||||
|
||||
export STORAGE_BASE_DIR="$(cat ${RUNTIME_DIR}/.storage_base_dir | tr '[A-Z]' '[a-z]')"
|
||||
|
||||
# Make sure storage directory is not one of:
|
||||
# - /var/mail: it's used to store mails for system accounts
|
||||
# - /root: only root user can access it, mail services won't work.
|
||||
if echo ${STORAGE_BASE_DIR} | grep -iE '^(/var/mail\>|/root\>)' &>/dev/null; then
|
||||
:
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f ${RUNTIME_DIR}/.storage_base_dir &>/dev/null
|
||||
|
||||
export STORAGE_BASE_DIR="${STORAGE_BASE_DIR}"
|
||||
echo "export STORAGE_BASE_DIR='${STORAGE_BASE_DIR}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
# --------------------------------------------------
|
||||
# ------------ Default web server ------------------
|
||||
# --------------------------------------------------
|
||||
export DISABLE_WEB_SERVER='NO'
|
||||
export WEB_SERVER=''
|
||||
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
while : ; do
|
||||
${DIALOG} \
|
||||
--title "Preferred web server" \
|
||||
--radiolist "Choose a web server you want to run.
|
||||
|
||||
TIP: Use SPACE key to select item." \
|
||||
20 76 3 \
|
||||
"Nginx" "The fastest web server" "on" \
|
||||
"No web server" "I don't need any web applications on this server" "off" \
|
||||
2>${RUNTIME_DIR}/.web_server
|
||||
|
||||
web_server_case_sensitive="$(cat ${RUNTIME_DIR}/.web_server)"
|
||||
web_server="$(echo ${web_server_case_sensitive} | tr '[a-z]' '[A-Z]')"
|
||||
[ X"${web_server}" != X"" ] && break
|
||||
done
|
||||
|
||||
rm -f ${RUNTIME_DIR}/.web_server
|
||||
else
|
||||
while : ; do
|
||||
${DIALOG} \
|
||||
--title "Preferred web server" \
|
||||
--radiolist "Choose a web server you want to run.
|
||||
|
||||
TIP: Use SPACE key to select item." \
|
||||
20 76 3 \
|
||||
"Nginx" "The fastest web server" "on" \
|
||||
"No web server" "I don't need any web applications on this server" "off" \
|
||||
2>${RUNTIME_DIR}/.web_server
|
||||
|
||||
web_server_case_sensitive="$(cat ${RUNTIME_DIR}/.web_server)"
|
||||
web_server="$(echo ${web_server_case_sensitive} | tr '[a-z]' '[A-Z]')"
|
||||
[ X"${web_server}" != X"" ] && break
|
||||
done
|
||||
|
||||
rm -f ${RUNTIME_DIR}/.web_server
|
||||
fi
|
||||
|
||||
if [ X"${web_server}" == X'NGINX' ]; then
|
||||
export WEB_SERVER='NGINX'
|
||||
else
|
||||
export DISABLE_WEB_SERVER='YES'
|
||||
echo "export DISABLE_WEB_SERVER='YES'" >>${IREDMAIL_CONFIG_FILE}
|
||||
fi
|
||||
|
||||
echo "export WEB_SERVER='${WEB_SERVER}'" >>${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
# --------------------------------------------------
|
||||
# --------------------- Backends --------------------
|
||||
# --------------------------------------------------
|
||||
export DIALOG_AVAILABLE_BACKENDS=''
|
||||
if [ X"${ENABLE_BACKEND_OPENLDAP}" == X'YES' ]; then
|
||||
export DIALOG_AVAILABLE_BACKENDS="${DIALOG_AVAILABLE_BACKENDS} OpenLDAP An_open_source_implementation_of_LDAP_protocol off"
|
||||
fi
|
||||
|
||||
if [ X"${ENABLE_BACKEND_MARIADB}" == X'YES' ]; then
|
||||
export DIALOG_AVAILABLE_BACKENDS="${DIALOG_AVAILABLE_BACKENDS} MariaDB An_enhanced,_drop-in_replacement_for_MySQL off"
|
||||
fi
|
||||
|
||||
if [ X"${ENABLE_BACKEND_PGSQL}" == X'YES' ]; then
|
||||
export DIALOG_AVAILABLE_BACKENDS="${DIALOG_AVAILABLE_BACKENDS} PostgreSQL Powerful,_open_source_database_system off"
|
||||
fi
|
||||
|
||||
while : ; do
|
||||
${DIALOG} \
|
||||
--title "Choose preferred backend used to store mail accounts" \
|
||||
--radiolist "It's strongly recommended to choose the one you're familiar with for easy maintenance. They all use the same webmail (Roundcube) and admin panel (iRedAdmin), and no big feature differences between them.
|
||||
|
||||
TIP: Use SPACE key to select item.
|
||||
" 20 76 4 ${DIALOG_AVAILABLE_BACKENDS} 2>${RUNTIME_DIR}/.backend
|
||||
|
||||
BACKEND_ORIG_CASE_SENSITIVE="$(cat ${RUNTIME_DIR}/.backend)"
|
||||
BACKEND_ORIG="$(echo ${BACKEND_ORIG_CASE_SENSITIVE} | tr '[a-z]' '[A-Z]')"
|
||||
[ X"${BACKEND_ORIG}" != X"" ] && break
|
||||
done
|
||||
|
||||
rm -f ${RUNTIME_DIR}/.backend &>/dev/null
|
||||
if [ X"${BACKEND_ORIG}" == X'OPENLDAP' ]; then
|
||||
export BACKEND='OPENLDAP'
|
||||
elif [ X"${BACKEND_ORIG}" == X'MARIADB' ]; then
|
||||
export BACKEND='MYSQL'
|
||||
elif [ X"${BACKEND_ORIG}" == X'POSTGRESQL' ]; then
|
||||
export BACKEND='PGSQL'
|
||||
export BACKEND_ORIG='PGSQL'
|
||||
fi
|
||||
|
||||
echo "export BACKEND_ORIG='${BACKEND_ORIG}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
echo "export BACKEND='${BACKEND}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
# Read-only SQL user/role, used to query mail accounts in Postfix, Dovecot.
|
||||
export VMAIL_DB_BIND_PASSWD="$(${RANDOM_STRING})"
|
||||
echo "export VMAIL_DB_BIND_PASSWD='${VMAIL_DB_BIND_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
# For database management: vmail.
|
||||
export VMAIL_DB_ADMIN_PASSWD="$(${RANDOM_STRING})"
|
||||
echo "export VMAIL_DB_ADMIN_PASSWD='${VMAIL_DB_ADMIN_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
# For mlmmj mailing list manager
|
||||
export MLMMJADMIN_API_AUTH_TOKEN="$(${RANDOM_STRING})"
|
||||
echo "export MLMMJADMIN_API_AUTH_TOKEN='${MLMMJADMIN_API_AUTH_TOKEN}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
# For database management: vmail.
|
||||
export NETDATA_DB_PASSWD="$(${RANDOM_STRING})"
|
||||
echo "export NETDATA_DB_PASSWD='${NETDATA_DB_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
. ${DIALOG_DIR}/ldap_config.sh
|
||||
. ${DIALOG_DIR}/mysql_config.sh
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
. ${DIALOG_DIR}/mysql_config.sh
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
. ${DIALOG_DIR}/pgsql_config.sh
|
||||
fi
|
||||
|
||||
# Virtual domain configuration.
|
||||
. ${DIALOG_DIR}/virtual_domain_config.sh
|
||||
|
||||
# Optional components.
|
||||
. ${DIALOG_DIR}/optional_components.sh
|
||||
|
||||
# Append EOF tag in config file.
|
||||
echo "#EOF" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
#
|
||||
# Ending message.
|
||||
#
|
||||
cat <<EOF
|
||||
*************************************************************************
|
||||
***************************** WARNING ***********************************
|
||||
*************************************************************************
|
||||
* *
|
||||
* Below file contains sensitive infomation (username/password), please *
|
||||
* do remember to *MOVE* it to a safe place after installation. *
|
||||
* *
|
||||
* * ${IREDMAIL_CONFIG_FILE}
|
||||
* *
|
||||
*************************************************************************
|
||||
********************** Review your settings *****************************
|
||||
*************************************************************************
|
||||
|
||||
* Storage base directory: ${STORAGE_BASE_DIR}
|
||||
* Mailboxes: ${STORAGE_MAILBOX_DIR}
|
||||
* Daily backup of SQL/LDAP databases: ${BACKUP_DIR}
|
||||
* Store mail accounts in: ${BACKEND_ORIG_CASE_SENSITIVE}
|
||||
* Web server: ${web_server_case_sensitive}
|
||||
* First mail domain name: ${FIRST_DOMAIN}
|
||||
* Mail domain admin: ${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}
|
||||
* Additional components: ${OPTIONAL_COMPONENTS}
|
||||
|
||||
EOF
|
||||
|
||||
ECHO_QUESTION -n "Continue? [y|N]"
|
||||
read_setting ${AUTO_INSTALL_WITHOUT_CONFIRM}
|
||||
case ${ANSWER} in
|
||||
Y|y) : ;;
|
||||
N|n|*)
|
||||
ECHO_INFO "Cancelled, Exit."
|
||||
exit 255
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# --------------------------------------------------
|
||||
# --------------------- LDAP -----------------------
|
||||
# --------------------------------------------------
|
||||
|
||||
# LDAP suffix.
|
||||
while : ; do
|
||||
${DIALOG} \
|
||||
--title "LDAP suffix (root dn)" \
|
||||
--inputbox "\
|
||||
Please specify your LDAP suffix (root dn):
|
||||
|
||||
EXAMPLE:
|
||||
|
||||
* Domain 'example.com': dc=example,dc=com
|
||||
* Domain 'test.com.cn': dc=test,dc=com,dc=cn
|
||||
|
||||
Note: Password for LDAP rootdn (cn=Manager,dc=xx,dc=xx) will be
|
||||
generated randomly.
|
||||
" 20 76 "dc=example,dc=com" 2>${RUNTIME_DIR}/.ldap_suffix
|
||||
|
||||
LDAP_SUFFIX="$(cat ${RUNTIME_DIR}/.ldap_suffix)"
|
||||
[ X"${LDAP_SUFFIX}" != X"" ] && break
|
||||
done
|
||||
|
||||
rm -f ${RUNTIME_DIR}/.ldap_suffix
|
||||
|
||||
export LDAP_SUFFIX="${LDAP_SUFFIX}"
|
||||
echo "export LDAP_SUFFIX='${LDAP_SUFFIX}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
# LDAP bind dn, passwords.
|
||||
export LDAP_BINDPW="$(${RANDOM_STRING})"
|
||||
export LDAP_ADMIN_PW="$(${RANDOM_STRING})"
|
||||
export LDAP_ROOTPW="$(${RANDOM_STRING})"
|
||||
echo "export LDAP_BINDPW='${LDAP_BINDPW}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
echo "export LDAP_ADMIN_PW='${LDAP_ADMIN_PW}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
echo "export LDAP_ROOTPW='${LDAP_ROOTPW}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# --------------------------------------------------
|
||||
# --------------------- MySQL ----------------------
|
||||
# --------------------------------------------------
|
||||
|
||||
. ${CONF_DIR}/mysql
|
||||
|
||||
if [ -z "${MYSQL_ROOT_PASSWD}" ]; then
|
||||
# set a new MySQL root password.
|
||||
while : ; do
|
||||
${DIALOG} \
|
||||
--title "Password for MySQL administrator: ${MYSQL_ROOT_USER}" \
|
||||
--passwordbox "\
|
||||
Please specify password for MySQL administrator ${MYSQL_ROOT_USER} on server
|
||||
${MYSQL_SERVER_ADDRESS}.
|
||||
|
||||
WARNING:
|
||||
|
||||
* Do *NOT* use double quote (\") in password.
|
||||
* EMPTY password is *NOT* permitted.
|
||||
* Sample password: $(${RANDOM_STRING})
|
||||
" 20 76 2>${RUNTIME_DIR}/.mysql_rootpw
|
||||
|
||||
MYSQL_ROOT_PASSWD="$(cat ${RUNTIME_DIR}/.mysql_rootpw)"
|
||||
|
||||
[ X"${MYSQL_ROOT_PASSWD}" != X'' ] && break
|
||||
done
|
||||
|
||||
export MYSQL_ROOT_PASSWD="${MYSQL_ROOT_PASSWD}"
|
||||
fi
|
||||
|
||||
echo "export MYSQL_ROOT_PASSWD='${MYSQL_ROOT_PASSWD}'" >>${IREDMAIL_CONFIG_FILE}
|
||||
rm -f ${RUNTIME_DIR}/.mysql_rootpw &>/dev/null
|
||||
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------
|
||||
# Optional components for special backend.
|
||||
# ----------------------------------------
|
||||
# Construct dialog menu list
|
||||
# Format: item_name item_descrition on/off
|
||||
# Note: item_descrition must be concatenated by '_'.
|
||||
export LIST_OF_OPTIONAL_COMPONENTS=''
|
||||
|
||||
# Fail2ban
|
||||
export DIALOG_SELECTABLE_FAIL2BAN='YES'
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export DIALOG_SELECTABLE_FAIL2BAN='NO'
|
||||
fi
|
||||
|
||||
# Web applications
|
||||
if [ X"${DISABLE_WEB_SERVER}" != X'YES' ]; then
|
||||
. ${DIALOG_DIR}/web_applications.sh
|
||||
fi
|
||||
|
||||
# iRedAdmin. Although it's a web application, but it's also able to run with
|
||||
# WSGI server instead of web server.
|
||||
LIST_OF_OPTIONAL_COMPONENTS="${LIST_OF_OPTIONAL_COMPONENTS} iRedAdmin Official_web-based_Admin_Panel on"
|
||||
|
||||
# Fail2ban.
|
||||
if [ X"${DIALOG_SELECTABLE_FAIL2BAN}" == X'YES' ]; then
|
||||
LIST_OF_OPTIONAL_COMPONENTS="${LIST_OF_OPTIONAL_COMPONENTS} Fail2ban Ban_IP_with_too_many_password_failures on"
|
||||
fi
|
||||
|
||||
export tmp_config_optional_components="${ROOTDIR}/.optional_components"
|
||||
|
||||
if echo ${LIST_OF_OPTIONAL_COMPONENTS} | grep 'o' &>/dev/null; then
|
||||
${DIALOG} \
|
||||
--title "Optional components" \
|
||||
--checklist "\
|
||||
* DKIM signing/verification and SPF validation are enabled by default.
|
||||
* DNS records for SPF and DKIM are required after installation.
|
||||
|
||||
Refer to below file for more detail after installation:
|
||||
|
||||
* ${TIP_FILE}
|
||||
" 20 76 6 \
|
||||
${LIST_OF_OPTIONAL_COMPONENTS} \
|
||||
2>${tmp_config_optional_components}
|
||||
|
||||
OPTIONAL_COMPONENTS="$(cat ${tmp_config_optional_components})"
|
||||
rm -f ${tmp_config_optional_components} &>/dev/null
|
||||
fi
|
||||
|
||||
if echo ${OPTIONAL_COMPONENTS} | grep -i 'iredadmin' &>/dev/null; then
|
||||
export USE_IREDADMIN='YES'
|
||||
echo "export USE_IREDADMIN='YES'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
fi
|
||||
|
||||
if echo ${OPTIONAL_COMPONENTS} | grep -i 'roundcubemail' &>/dev/null; then
|
||||
export USE_ROUNDCUBE='YES'
|
||||
echo "export USE_ROUNDCUBE='YES'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
fi
|
||||
|
||||
if echo ${OPTIONAL_COMPONENTS} | grep -i 'sogo' &>/dev/null; then
|
||||
export USE_SOGO='YES'
|
||||
echo "export USE_SOGO='YES'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
fi
|
||||
|
||||
if echo ${OPTIONAL_COMPONENTS} | grep -i 'netdata' &>/dev/null; then
|
||||
export USE_NETDATA='YES'
|
||||
echo "export USE_NETDATA='YES'" >>${IREDMAIL_CONFIG_FILE}
|
||||
fi
|
||||
|
||||
if echo ${OPTIONAL_COMPONENTS} | grep -i 'fail2ban' &>/dev/null; then
|
||||
export USE_FAIL2BAN='YES'
|
||||
echo "export USE_FAIL2BAN='YES'" >>${IREDMAIL_CONFIG_FILE}
|
||||
fi
|
||||
|
||||
export random_pw="$(${RANDOM_STRING})"
|
||||
export AMAVISD_DB_PASSWD="${AMAVISD_DB_PASSWD:=${random_pw}}"
|
||||
echo "export AMAVISD_DB_PASSWD='${AMAVISD_DB_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
export random_pw="$(${RANDOM_STRING})"
|
||||
export IREDADMIN_DB_PASSWD="${IREDADMIN_DB_PASSWD:=${random_pw}}"
|
||||
echo "export IREDADMIN_DB_PASSWD='${IREDADMIN_DB_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
export random_pw="$(${RANDOM_STRING})"
|
||||
export RCM_DB_PASSWD="${RCM_DB_PASSWD:=${random_pw}}"
|
||||
echo "export RCM_DB_PASSWD='${RCM_DB_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
export random_pw="$(${RANDOM_STRING})"
|
||||
export SOGO_DB_PASSWD="${SOGO_DB_PASSWD:=${random_pw}}"
|
||||
echo "export SOGO_DB_PASSWD='${SOGO_DB_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
export random_pw="$(${RANDOM_STRING})"
|
||||
export SOGO_SIEVE_MASTER_PASSWD="${SOGO_SIEVE_MASTER_PASSWD:=${random_pw}}"
|
||||
echo "export SOGO_SIEVE_MASTER_PASSWD='${SOGO_SIEVE_MASTER_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
export random_pw="$(${RANDOM_STRING})"
|
||||
export IREDAPD_DB_PASSWD="${IREDAPD_DB_PASSWD:=${random_pw}}"
|
||||
echo "export IREDAPD_DB_PASSWD='${IREDAPD_DB_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
|
||||
export random_pw="$(${RANDOM_STRING})"
|
||||
export FAIL2BAN_DB_PASSWD="${FAIL2BAN_DB_PASSWD:=${random_pw}}"
|
||||
echo "export FAIL2BAN_DB_PASSWD='${FAIL2BAN_DB_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# --------------------------------------------------
|
||||
# --------------------- MySQL ----------------------
|
||||
# --------------------------------------------------
|
||||
|
||||
. ${CONF_DIR}/postgresql
|
||||
|
||||
# Root password.
|
||||
while : ; do
|
||||
${DIALOG} \
|
||||
--title "Password for PostgreSQL administrator: ${PGSQL_ROOT_USER}" \
|
||||
--passwordbox "\
|
||||
Please specify password for PostgreSQL administrator: ${PGSQL_ROOT_USER}
|
||||
|
||||
WARNING:
|
||||
|
||||
* Do *NOT* use special characters in password right now. e.g. $, #, @, space.
|
||||
* EMPTY password is *NOT* permitted.
|
||||
* Sample password: $(${RANDOM_STRING})
|
||||
" 20 76 2>${RUNTIME_DIR}/.pgsql_rootpw
|
||||
|
||||
PGSQL_ROOT_PASSWD="$(cat ${RUNTIME_DIR}/.pgsql_rootpw)"
|
||||
|
||||
# Check $, #, space
|
||||
echo ${PGSQL_ROOT_PASSWD} | grep '[\$\#\ ]' &>/dev/null
|
||||
[ X"$?" != X'0' -a X"${PGSQL_ROOT_PASSWD}" != X'' ] && break
|
||||
done
|
||||
|
||||
export PGSQL_ROOT_PASSWD="${PGSQL_ROOT_PASSWD}"
|
||||
echo "export PGSQL_ROOT_PASSWD='${PGSQL_ROOT_PASSWD}'" >>${IREDMAIL_CONFIG_FILE}
|
||||
rm -f ${RUNTIME_DIR}/.pgsql_rootpw
|
||||
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# First domain name.
|
||||
while : ; do
|
||||
${DIALOG} \
|
||||
--title "Your first mail domain name" \
|
||||
--inputbox "\
|
||||
Please specify your first mail domain name.
|
||||
|
||||
EXAMPLE:
|
||||
|
||||
* example.com
|
||||
|
||||
WARNING:
|
||||
|
||||
It can *NOT* be the same as server hostname: ${HOSTNAME}.
|
||||
|
||||
We need Postfix to accept emails sent to system accounts (e.g. root), if your mail domain is same as server hostname, Postfix won't accept any email sent to this mail domain.
|
||||
" 20 76 2>${RUNTIME_DIR}/.first_domain
|
||||
|
||||
FIRST_DOMAIN="$(cat ${RUNTIME_DIR}/.first_domain | tr '[A-Z]' '[a-z]')"
|
||||
|
||||
echo "${FIRST_DOMAIN}" | grep '\.' &>/dev/null
|
||||
[ X"$?" == X"0" -a X"${FIRST_DOMAIN}" != X"${HOSTNAME}" ] && break
|
||||
done
|
||||
|
||||
export FIRST_DOMAIN="${FIRST_DOMAIN}"
|
||||
echo "export FIRST_DOMAIN='${FIRST_DOMAIN}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
rm -f ${RUNTIME_DIR}/.first_domain
|
||||
|
||||
# Domain admin password
|
||||
while : ; do
|
||||
${DIALOG} \
|
||||
--title "Password for the mail domain administrator" \
|
||||
--passwordbox "\
|
||||
Please specify password for the mail domain administrator:
|
||||
|
||||
* ${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}
|
||||
|
||||
You can login to webmail and iRedAdmin with this account.
|
||||
|
||||
WARNING:
|
||||
|
||||
* Do *NOT* use special characters (like \$, white space) in password.
|
||||
* EMPTY password is *NOT* permitted.
|
||||
* Sample password: $(${RANDOM_STRING})
|
||||
" 20 76 2>${RUNTIME_DIR}/.first_domain_admin_passwd
|
||||
|
||||
DOMAIN_ADMIN_PASSWD_PLAIN="$(cat ${RUNTIME_DIR}/.first_domain_admin_passwd)"
|
||||
|
||||
[ X"${DOMAIN_ADMIN_PASSWD_PLAIN}" != X"" ] && break
|
||||
done
|
||||
|
||||
export DOMAIN_ADMIN_PASSWD_PLAIN="${DOMAIN_ADMIN_PASSWD_PLAIN}"
|
||||
echo "export DOMAIN_ADMIN_PASSWD_PLAIN='${DOMAIN_ADMIN_PASSWD_PLAIN}'" >> ${IREDMAIL_CONFIG_FILE}
|
||||
rm -f ${RUNTIME_DIR}/.first_domain_admin_passwd
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Admin of domain ${FIRST_DOMAIN}:
|
||||
|
||||
* Account: ${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}
|
||||
* Password: ${DOMAIN_ADMIN_PASSWD_PLAIN}
|
||||
|
||||
You can login to iRedAdmin with this account, login name is full email address.
|
||||
|
||||
First mail user:
|
||||
* Username: ${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}
|
||||
* Password: ${DOMAIN_ADMIN_PASSWD_PLAIN}
|
||||
* SMTP/IMAP auth type: login
|
||||
* Connection security: STARTTLS or SSL/TLS
|
||||
|
||||
You can login to webmail with this account, login name is full email address.
|
||||
|
||||
EOF
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# Optional web applications
|
||||
# ---------------------------------------------------------------
|
||||
if [ X"${DISABLE_WEB_SERVER}" != X'YES' ]; then
|
||||
export DIALOG_SELECTABLE_ROUNDCUBE='YES'
|
||||
export DIALOG_SELECTABLE_NETDATA='YES'
|
||||
export DIALOG_SELECTABLE_SOGO='NO'
|
||||
|
||||
# SOGo team doesn't offer binary packages for arm platform.
|
||||
if [ X"${OS_ARCH}" == X'i386' -o X"${OS_ARCH}" == X'x86_64' ]; then
|
||||
export DIALOG_SELECTABLE_SOGO='YES'
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# OpenBSD doesn't have 'libuuid' which required by netdata
|
||||
export DIALOG_SELECTABLE_NETDATA='NO'
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# netdata-1.22.1 doesn't work with libressl, it's marked as broken in
|
||||
# ports tree, but development edition works fine.
|
||||
# Have to wait for next release.
|
||||
export DIALOG_SELECTABLE_NETDATA='NO'
|
||||
fi
|
||||
fi
|
||||
|
||||
# iRedAdmin
|
||||
if [ X"${DIALOG_SELECTABLE_IREDADMIN}" == X'YES' ]; then
|
||||
LIST_OF_OPTIONAL_COMPONENTS="${LIST_OF_OPTIONAL_COMPONENTS} iRedAdmin Official_web-based_Admin_Panel on"
|
||||
fi
|
||||
|
||||
# Roundcube
|
||||
if [ X"${DIALOG_SELECTABLE_ROUNDCUBE}" == X'YES' ]; then
|
||||
LIST_OF_OPTIONAL_COMPONENTS="${LIST_OF_OPTIONAL_COMPONENTS} Roundcubemail Popular_webmail_built_with_PHP_and_AJAX on"
|
||||
fi
|
||||
|
||||
# SOGo
|
||||
if [ X"${DIALOG_SELECTABLE_SOGO}" == X'YES' ]; then
|
||||
LIST_OF_OPTIONAL_COMPONENTS="${LIST_OF_OPTIONAL_COMPONENTS} SOGo Webmail,_Calendar,_Address_book off"
|
||||
fi
|
||||
|
||||
# netdata
|
||||
if [ X"${DIALOG_SELECTABLE_NETDATA}" == X'YES' ]; then
|
||||
LIST_OF_OPTIONAL_COMPONENTS="${LIST_OF_OPTIONAL_COMPONENTS} netdata Awesome_system_monitor on"
|
||||
fi
|
||||
@@ -0,0 +1,257 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# --------------------------------------------
|
||||
# Amavisd-new.
|
||||
# --------------------------------------------
|
||||
|
||||
amavisd_initialize_db()
|
||||
{
|
||||
ECHO_DEBUG "Import Amavisd database and grant privileges."
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
${MYSQL_CLIENT_ROOT} <<EOF
|
||||
-- Create database
|
||||
CREATE DATABASE ${AMAVISD_DB_NAME} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
|
||||
-- Grant privileges
|
||||
GRANT SELECT,INSERT,UPDATE,DELETE ON ${AMAVISD_DB_NAME}.* TO '${AMAVISD_DB_USER}'@'${MYSQL_GRANT_HOST}' IDENTIFIED BY '${AMAVISD_DB_PASSWD}';
|
||||
-- GRANT SELECT,INSERT,UPDATE,DELETE ON ${AMAVISD_DB_NAME}.* TO '${AMAVISD_DB_USER}'@'${HOSTNAME}' IDENTIFIED BY '${AMAVISD_DB_PASSWD}';
|
||||
|
||||
-- Import Amavisd SQL template
|
||||
USE ${AMAVISD_DB_NAME};
|
||||
SOURCE ${AMAVISD_DB_MYSQL_TMPL};
|
||||
SOURCE ${SAMPLE_DIR}/amavisd/default_spam_policy.sql;
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
|
||||
# Generate .my.cnf file
|
||||
cat > /root/.my.cnf-${AMAVISD_DB_USER} <<EOF
|
||||
[client]
|
||||
host=${MYSQL_SERVER_ADDRESS}
|
||||
port=${MYSQL_SERVER_PORT}
|
||||
user=${AMAVISD_DB_USER}
|
||||
password="${AMAVISD_DB_PASSWD}"
|
||||
EOF
|
||||
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
cp -f ${AMAVISD_DB_PGSQL_TMPL} ${PGSQL_USER_HOMEDIR}/amavisd.sql >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SAMPLE_DIR}/amavisd/default_spam_policy.sql ${PGSQL_USER_HOMEDIR}/default_spam_policy.sql >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0777 ${PGSQL_USER_HOMEDIR}/amavisd.sql >/dev/null
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
-- Create database
|
||||
CREATE DATABASE ${AMAVISD_DB_NAME} WITH TEMPLATE template0 ENCODING 'UTF8';
|
||||
|
||||
-- Create user
|
||||
CREATE USER ${AMAVISD_DB_USER} WITH ENCRYPTED PASSWORD '${AMAVISD_DB_PASSWD}' NOSUPERUSER NOCREATEDB NOCREATEROLE;
|
||||
|
||||
ALTER DATABASE ${AMAVISD_DB_NAME} OWNER TO ${AMAVISD_DB_USER};
|
||||
EOF
|
||||
|
||||
# Import Amavisd SQL template
|
||||
su - ${SYS_USER_PGSQL} -c "psql -U ${AMAVISD_DB_USER} -d ${AMAVISD_DB_NAME}" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
\i ${PGSQL_USER_HOMEDIR}/amavisd.sql;
|
||||
\i ${PGSQL_USER_HOMEDIR}/default_spam_policy.sql;
|
||||
EOF
|
||||
rm -f ${PGSQL_USER_HOMEDIR}/{amavisd,bypass}.sql >> ${INSTALL_LOG}
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -U ${AMAVISD_DB_USER} -d ${AMAVISD_DB_NAME}" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
ALTER DATABASE ${AMAVISD_DB_NAME} SET bytea_output TO 'escape';
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo 'export status_amavisd_initialize_db="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
amavisd_config()
|
||||
{
|
||||
ECHO_INFO "Configure Amavisd-new (interface between MTA and content checkers)."
|
||||
|
||||
backup_file ${AMAVISD_CONF}
|
||||
|
||||
#
|
||||
# DKIM
|
||||
#
|
||||
export AMAVISD_FIRST_DOMAIN_DKIM_KEY="${AMAVISD_DKIM_DIR}/${FIRST_DOMAIN}.pem"
|
||||
|
||||
ECHO_DEBUG "Generate DKIM pem files: ${AMAVISD_FIRST_DOMAIN_DKIM_KEY}."
|
||||
mkdir -p ${AMAVISD_DKIM_DIR} &>/dev/null && \
|
||||
chown -R ${SYS_USER_AMAVISD}:${SYS_GROUP_AMAVISD} ${AMAVISD_DKIM_DIR}
|
||||
chmod -R 0700 ${AMAVISD_DKIM_DIR}
|
||||
|
||||
# Create DKIM key if not exists.
|
||||
if [ ! -f ${AMAVISD_FIRST_DOMAIN_DKIM_KEY} ]; then
|
||||
# Not all DNS vendor supports key length >= 2048, so we stick to 2048.
|
||||
${AMAVISD_BIN} genrsa ${AMAVISD_FIRST_DOMAIN_DKIM_KEY} 2048 &>/dev/null
|
||||
fi
|
||||
|
||||
chown -R ${SYS_USER_AMAVISD}:${SYS_GROUP_AMAVISD} ${AMAVISD_FIRST_DOMAIN_DKIM_KEY}
|
||||
chmod 0400 ${AMAVISD_FIRST_DOMAIN_DKIM_KEY}
|
||||
|
||||
#
|
||||
# Disclaimer
|
||||
#
|
||||
# Create directory to store disclaimer files if not exist.
|
||||
[ -d ${DISCLAIMER_DIR} ] || mkdir -p ${DISCLAIMER_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
# Create a empty disclaimer.
|
||||
echo -e '\n----' > ${DISCLAIMER_DIR}/default.txt
|
||||
|
||||
#
|
||||
# SQL integration
|
||||
#
|
||||
# Integrate SQL. Used to store incoming & outgoing related mail information.
|
||||
if [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
export AMAVISD_PERL_SQL_DBI='Pg'
|
||||
else
|
||||
export AMAVISD_PERL_SQL_DBI='mysql'
|
||||
fi
|
||||
|
||||
#
|
||||
# Main config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/amavisd/amavisd.conf ${AMAVISD_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_SYS_USER_AMAVISD#$ENV{SYS_USER_AMAVISD}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_SYS_GROUP_AMAVISD#$ENV{SYS_GROUP_AMAVISD}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_HOSTNAME#$ENV{HOSTNAME}#g' ${AMAVISD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_AMAVISD_SPOOL_DIR#$ENV{AMAVISD_SPOOL_DIR}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_TEMP_DIR#$ENV{AMAVISD_TEMP_DIR}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_DB_DIR#$ENV{AMAVISD_DB_DIR}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_QUARANTINE_DIR#$ENV{AMAVISD_QUARANTINE_DIR}#g' ${AMAVISD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_AMAVISD_LOCK_FILE#$ENV{AMAVISD_LOCK_FILE}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_PID_FILE#$ENV{AMAVISD_PID_FILE}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_SOCKET_FILE#$ENV{AMAVISD_SOCKET_FILE}#g' ${AMAVISD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_AMAVISD_SMTP_PORT#$ENV{AMAVISD_SMTP_PORT}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_ORIGINATING_PORT#$ENV{AMAVISD_ORIGINATING_PORT}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_QUARANTINE_PORT#$ENV{AMAVISD_QUARANTINE_PORT}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_POSTFIX_MAIL_REINJECT_PORT#$ENV{POSTFIX_MAIL_REINJECT_PORT}#g' ${AMAVISD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_AMAVISD_MLMMJ_PORT#$ENV{AMAVISD_MLMMJ_PORT}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_POSTFIX_MLMMJ_REINJECT_PORT#$ENV{POSTFIX_MLMMJ_REINJECT_PORT}#g' ${AMAVISD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_CLAMD_LOCAL_SOCKET#$ENV{CLAMD_LOCAL_SOCKET}#g' ${AMAVISD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_FIRST_DOMAIN#$ENV{FIRST_DOMAIN}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_FIRST_DOMAIN_DKIM_KEY#$ENV{AMAVISD_FIRST_DOMAIN_DKIM_KEY}#g' ${AMAVISD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_CMD_ALTERMIME#$ENV{CMD_ALTERMIME}#g' ${AMAVISD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_AMAVISD_PERL_SQL_DBI#$ENV{AMAVISD_PERL_SQL_DBI}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_DB_NAME#$ENV{AMAVISD_DB_NAME}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_SQL_SERVER_ADDRESS#$ENV{SQL_SERVER_ADDRESS}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_SQL_SERVER_PORT#$ENV{SQL_SERVER_PORT}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_DB_USER#$ENV{AMAVISD_DB_USER}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_DB_PASSWD#$ENV{AMAVISD_DB_PASSWD}#g' ${AMAVISD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_LOCAL_ADDRESS#$ENV{LOCAL_ADDRESS}#g' ${AMAVISD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_MAX_SERVERS#$ENV{AMAVISD_MAX_SERVERS}#g' ${AMAVISD_CONF}
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
usermod -G ${SYS_GROUP_AMAVISD} ${SYS_USER_CLAMAV} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' \
|
||||
-o X"${DISTRO}" == X'FREEBSD' \
|
||||
-o X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
chgrp ${SYS_GROUP_AMAVISD} ${AMAVISD_CONF}
|
||||
chmod 0640 ${AMAVISD_CONF}
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# Make sure clamav is configured to init supplementary
|
||||
# groups when it drops priviledges, and that you add the
|
||||
# clamav user to the amavis group.
|
||||
adduser --quiet ${SYS_USER_CLAMAV} ${SYS_GROUP_AMAVISD} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Start service when system start up.
|
||||
service_control enable 'amavisd_enable' 'YES'
|
||||
service_control enable 'amavisd_pidfile' "${AMAVISD_PID_FILE}"
|
||||
service_control enable 'amavis_milter_enable' 'NO'
|
||||
service_control enable 'amavis_p0fanalyzer_enable' 'NO'
|
||||
fi
|
||||
|
||||
#
|
||||
# Postfix integration
|
||||
#
|
||||
cat ${SAMPLE_DIR}/postfix/main.cf.amavisd >> ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_SMTP_SERVER#$ENV{SMTP_SERVER}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
# Add postfix alias for user: amavis.
|
||||
add_postfix_alias ${SYS_USER_AMAVISD} ${SYS_USER_ROOT}
|
||||
|
||||
#
|
||||
# Cron jobs
|
||||
#
|
||||
if [ -n "${AMAVISD_VIRUSMAILS_DIR}" ]; then
|
||||
ECHO_DEBUG "Setting cron job for vmail user to delete virus mail per month."
|
||||
cat >> ${CRON_FILE_AMAVISD} <<EOF
|
||||
${CONF_MSG}
|
||||
# Delete virus mails which created 15 days ago.
|
||||
1 5 * * * touch ${AMAVISD_VIRUSMAILS_DIR}; find ${AMAVISD_VIRUSMAILS_DIR}/ -mtime +15 | xargs rm -rf {}
|
||||
|
||||
EOF
|
||||
fi
|
||||
|
||||
#
|
||||
# Populate SQL data
|
||||
#
|
||||
if [ X"${INITIALIZE_SQL_DATA}" == X'YES' ]; then
|
||||
check_status_before_run amavisd_initialize_db
|
||||
fi
|
||||
|
||||
#
|
||||
# Tip file
|
||||
#
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Amavisd-new:
|
||||
* Configuration files:
|
||||
- ${AMAVISD_CONF}
|
||||
- ${POSTFIX_FILE_MASTER_CF}
|
||||
- ${POSTFIX_FILE_MAIN_CF}
|
||||
* RC script:
|
||||
- ${DIR_RC_SCRIPTS}/${AMAVISD_RC_SCRIPT_NAME}
|
||||
* SQL Database:
|
||||
- Database name: ${AMAVISD_DB_NAME}
|
||||
- Database user: ${AMAVISD_DB_USER}
|
||||
- Database password: ${AMAVISD_DB_PASSWD}
|
||||
|
||||
DNS record for DKIM support:
|
||||
|
||||
EOF
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
$(${AMAVISD_BIN} -c ${AMAVISD_CONF} showkeys 2>> ${INSTALL_LOG})
|
||||
EOF
|
||||
else
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
$(${AMAVISD_BIN} showkeys 2>> ${INSTALL_LOG})
|
||||
EOF
|
||||
fi
|
||||
|
||||
write_iredmail_kv "sql_user_${AMAVISD_DB_USER}" "${AMAVISD_DB_PASSWD}"
|
||||
echo 'export status_amavisd_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------
|
||||
# ------------- Install and config backend. -------------
|
||||
# -------------------------------------------------------
|
||||
backend_install()
|
||||
{
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
export SQL_SERVER_ADDRESS="${MYSQL_SERVER_ADDRESS}"
|
||||
export SQL_SERVER_PORT="${MYSQL_SERVER_PORT}"
|
||||
export SQL_ROOT_USER="${MYSQL_ROOT_USER}"
|
||||
export SQL_ROOT_PASSWD="${MYSQL_ROOT_PASSWD}"
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
export SQL_SERVER_ADDRESS="${PGSQL_SERVER_ADDRESS}"
|
||||
export SQL_SERVER_PORT="${PGSQL_SERVER_PORT}"
|
||||
export SQL_ROOT_USER="${PGSQL_ROOT_USER}"
|
||||
export SQL_ROOT_PASSWD="${PGSQL_ROOT_PASSWD}"
|
||||
fi
|
||||
|
||||
# Check whether remote MySQL server is an IPv6 address.
|
||||
SQL_SERVER_ADDRESS_IS_IPV6='NO'
|
||||
if echo ${SQL_SERVER_ADDRESS} | grep ':' &>/dev/null; then
|
||||
SQL_SERVER_ADDRESS_IS_IPV6='YES'
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Generate sample Dovecot config files first to use `doveadm pw`.
|
||||
# `dovecot.conf` will be re-generated, `conf.d/` will be removed.
|
||||
if [ ! -f ${DOVECOT_CONF} ]; then
|
||||
cp -rf /usr/local/etc/dovecot/example-config/{dovecot.conf,conf.d} /usr/local/etc/dovecot/
|
||||
fi
|
||||
fi
|
||||
|
||||
# Hashed admin password. It requies Python.
|
||||
export DOMAIN_ADMIN_PASSWD_HASH="$(generate_password_hash ${DEFAULT_PASSWORD_SCHEME} ${DOMAIN_ADMIN_PASSWD_PLAIN})"
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
# Install, config and initialize LDAP server
|
||||
check_status_before_run ldap_server_config
|
||||
check_status_before_run ldap_server_cron_backup
|
||||
|
||||
# Setup MySQL database server.
|
||||
ECHO_INFO "Configure MariaDB database server."
|
||||
|
||||
check_status_before_run mysql_initialize_db
|
||||
check_status_before_run mysql_generate_defaults_file_root
|
||||
check_status_before_run mysql_remove_insecure_data
|
||||
check_status_before_run mysql_cron_backup
|
||||
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
check_status_before_run mysql_setup
|
||||
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
check_status_before_run pgsql_setup
|
||||
fi
|
||||
|
||||
write_iredmail_kv first_domain_admin_password "${DOMAIN_ADMIN_PASSWD_PLAIN}"
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# --------------------------------------------
|
||||
# ClamAV.
|
||||
# --------------------------------------------
|
||||
|
||||
clamav_config()
|
||||
{
|
||||
ECHO_INFO "Configure ClamAV (anti-virus toolkit)."
|
||||
backup_file ${CLAMD_CONF} ${FRESHCLAM_CONF}
|
||||
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
perl -pi -e 's/^(Example)/#${1}/' ${CLAMD_CONF} ${FRESHCLAM_CONF}
|
||||
mkdir /var/log/clamav
|
||||
chown ${SYS_USER_CLAMAV}:${SYS_GROUP_CLAMAV} /var/log/clamav
|
||||
fi
|
||||
|
||||
[ -f ${FRESHCLAM_CONF} ] && perl -pi -e 's#^Example##' ${FRESHCLAM_CONF}
|
||||
|
||||
export CLAMD_LOCAL_SOCKET CLAMD_BIND_HOST
|
||||
ECHO_DEBUG "Configure ClamAV: ${CLAMD_CONF}."
|
||||
perl -pi -e 's/^(TCPSocket .*)/#${1}/' ${CLAMD_CONF}
|
||||
perl -pi -e 's#^(TCPAddr ).*#${1} $ENV{CLAMD_BIND_HOST}#' ${CLAMD_CONF}
|
||||
|
||||
# Disable log file
|
||||
perl -pi -e 's/^(LogFile .*)/#${1}/' ${CLAMD_CONF}
|
||||
|
||||
# Set CLAMD_LOCAL_SOCKET
|
||||
perl -pi -e 's/^(LocalSocket ).*/${1}$ENV{CLAMD_LOCAL_SOCKET}/' ${CLAMD_CONF}
|
||||
perl -pi -e 's/^#(LocalSocket ).*/${1}$ENV{CLAMD_LOCAL_SOCKET}/' ${CLAMD_CONF}
|
||||
|
||||
ECHO_DEBUG "Configure freshclam: ${FRESHCLAM_CONF}."
|
||||
perl -pi -e 's#^(UpdateLogFile ).*#${1}$ENV{FRESHCLAM_LOGFILE}#' ${FRESHCLAM_CONF}
|
||||
|
||||
# Official database only
|
||||
perl -pi -e 's/^#(OfficialDatabaseOnly ).*/${1} yes/' ${CLAMD_CONF}
|
||||
|
||||
# Enable AllowSupplementaryGroups
|
||||
perl -pi -e 's/^(AllowSupplementaryGroups.*)/#${1}/' ${CLAMD_CONF}
|
||||
if [ X"${DISTRO_CODENAME}" != X'stretch' \
|
||||
-a X"${DISTRO_CODENAME}" != X'bionic' \
|
||||
-a X"${DISTRO_CODENAME}" != X'disco' \
|
||||
-a X"${DISTRO}" != X'FREEBSD' ]; then
|
||||
echo 'AllowSupplementaryGroups true' >> ${CLAMD_CONF}
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ECHO_DEBUG "Add clamav and freshclam daemon users to amavid group."
|
||||
usermod ${SYS_USER_CLAMAV} -G ${SYS_GROUP_AMAVISD}
|
||||
usermod clamupdate -G ${SYS_GROUP_AMAVISD} 2>/dev/null
|
||||
|
||||
ECHO_DEBUG "Set correct permission for database directory."
|
||||
chmod 0775 /var/lib/clamav 2>/dev/null
|
||||
|
||||
ECHO_DEBUG "Set permission to 750: ${AMAVISD_TEMP_DIR}, ${AMAVISD_QUARANTINE_DIR},"
|
||||
chmod -R 750 ${AMAVISD_TEMP_DIR} ${AMAVISD_QUARANTINE_DIR}
|
||||
|
||||
if [ X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
# Enable freshclam
|
||||
perl -pi -e 's/^(FRESHCLAM_DELAY.*)/#${1}/g' ${ETC_SYSCONFIG_DIR}/freshclam
|
||||
|
||||
# Increase clamd timeout.
|
||||
mkdir -p /etc/systemd/system/${CLAMAV_CLAMD_SERVICE_NAME}.service.d >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SAMPLE_DIR}/systemd/clamd.service.d/override.conf /etc/systemd/system/${CLAMAV_CLAMD_SERVICE_NAME}.service.d/ >> ${INSTALL_LOG} 2>&1
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
ECHO_DEBUG "Add clamav user to amavid group."
|
||||
pw usermod ${SYS_USER_CLAMAV} -G ${SYS_GROUP_AMAVISD}
|
||||
|
||||
# Start service when system start up.
|
||||
service_control enable 'clamav_clamd_enable' 'YES'
|
||||
service_control enable 'clamav_freshclam_enable' 'YES'
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
usermod -G ${SYS_GROUP_AMAVISD} ${SYS_USER_CLAMAV}
|
||||
|
||||
perl -pi -e 's#^(AllowSupplementaryGroups.*)##g' ${CLAMD_CONF}
|
||||
# Remove all `StatsXXX` parameters
|
||||
perl -pi -e 's#^(Stats.*)##g' ${CLAMD_CONF}
|
||||
fi
|
||||
|
||||
# Add user alias in Postfix
|
||||
add_postfix_alias ${SYS_USER_CLAMAV} ${SYS_USER_ROOT}
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
ClamAV:
|
||||
* Configuration files:
|
||||
- ${CLAMD_CONF}
|
||||
- ${FRESHCLAM_CONF}
|
||||
- /etc/logrotate.d/clamav
|
||||
* RC scripts:
|
||||
+ ${DIR_RC_SCRIPTS}/${CLAMAV_CLAMD_SERVICE_NAME}
|
||||
+ ${DIR_RC_SCRIPTS}/${CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_clamav_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Available variables for automate installation (value should be 'y' or 'n'):
|
||||
#
|
||||
# AUTO_CLEANUP_REMOVE_SENDMAIL
|
||||
# AUTO_CLEANUP_REPLACE_FIREWALL_RULES
|
||||
# AUTO_CLEANUP_RESTART_FIREWALL
|
||||
# AUTO_CLEANUP_REPLACE_MYSQL_CONFIG
|
||||
#
|
||||
# Usage:
|
||||
# # AUTO_CLEANUP_REMOVE_SENDMAIL=y [...] bash iRedMail.sh
|
||||
|
||||
# -------------------------------------------
|
||||
# Misc.
|
||||
# -------------------------------------------
|
||||
# Set cron file permission to 0600.
|
||||
cleanup_set_cron_file_permission()
|
||||
{
|
||||
for f in ${CRON_FILE_ROOT} ${CRON_FILE_AMAVISD} ${CRON_FILE_SOGO}; do
|
||||
if [ -f ${f} ]; then
|
||||
ECHO_DEBUG "Set file permission to 0600: ${f}."
|
||||
chmod 0600 ${f}
|
||||
fi
|
||||
done
|
||||
|
||||
echo 'export status_cleanup_set_cron_file_permission="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
cleanup_disable_selinux()
|
||||
{
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ECHO_INFO "Disable SELinux in /etc/selinux/config."
|
||||
[ -f /etc/selinux/config ] && perl -pi -e 's#^(SELINUX=)(.*)#${1}disabled#' /etc/selinux/config
|
||||
|
||||
setenforce 0 >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
echo 'export status_cleanup_disable_selinux="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
cleanup_remove_sendmail()
|
||||
{
|
||||
# Remove sendmail.
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
eval ${LIST_ALL_PKGS} | grep '^sendmail' &>/dev/null
|
||||
|
||||
if [ X"$?" == X"0" ]; then
|
||||
ECHO_QUESTION -n "Would you like to *REMOVE* sendmail now? [Y|n]"
|
||||
read_setting ${AUTO_CLEANUP_REMOVE_SENDMAIL}
|
||||
case ${ANSWER} in
|
||||
N|n )
|
||||
ECHO_INFO "Disable sendmail, it is replaced by Postfix." && \
|
||||
service_control disable sendmail
|
||||
;;
|
||||
Y|y|* )
|
||||
eval ${remove_pkg} sendmail
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
echo 'export status_cleanup_remove_sendmail="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
cleanup_replace_firewall_rules()
|
||||
{
|
||||
# Replace ssh numbers.
|
||||
if [ X"${SSHD_PORT2}" != X'22' ]; then
|
||||
# Append second ssh port number.
|
||||
perl -pi -e 's#(.*22.*)#${1}\n <port protocol="tcp" port="$ENV{SSHD_PORT2}"/>#' ${SAMPLE_DIR}/firewall/firewalld/services/ssh.xml
|
||||
perl -pi -e 's#(.* 22 .*)#${1}\n-A INPUT -p tcp --dport $ENV{SSHD_PORT2} -j ACCEPT#' ${SAMPLE_DIR}/firewall/iptables/iptables.rules
|
||||
perl -pi -e 's#(.* 22 .*)#${1}\n-A INPUT -p tcp --dport $ENV{SSHD_PORT2} -j ACCEPT#' ${SAMPLE_DIR}/firewall/iptables/ip6tables.rules
|
||||
|
||||
# Replace first ssh port number
|
||||
perl -pi -e 's#(.*)"22"(.*)#${1}"$ENV{SSHD_PORT}"${2}#' ${SAMPLE_DIR}/firewall/firewalld/services/ssh.xml
|
||||
perl -pi -e 's#(.*) 22 (.*)#${1} $ENV{SSHD_PORT} -j ACCEPT#' ${SAMPLE_DIR}/firewall/iptables/iptables.rules
|
||||
perl -pi -e 's#(.*) 22 (.*)#${1} $ENV{SSHD_PORT} -j ACCEPT#' ${SAMPLE_DIR}/firewall/iptables/ip6tables.rules
|
||||
fi
|
||||
|
||||
perl -pi -e 's#(.*mail_services=.*)ssh(.*)#${1}$ENV{SSHD_PORTS_WITH_COMMA}${2}#' ${SAMPLE_DIR}/openbsd/pf.conf
|
||||
|
||||
ECHO_QUESTION "Would you like to use firewall rules provided by iRedMail?"
|
||||
ECHO_QUESTION -n "File: ${FIREWALL_RULE_CONF}, with SSHD ports: ${SSHD_PORTS_WITH_COMMA}. [Y|n]"
|
||||
read_setting ${AUTO_CLEANUP_REPLACE_FIREWALL_RULES}
|
||||
case ${ANSWER} in
|
||||
N|n ) ECHO_INFO "Skip firewall rules." ;;
|
||||
Y|y|* )
|
||||
backup_file ${FIREWALL_RULE_CONF}
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
ECHO_INFO "Copy firewall sample rules."
|
||||
|
||||
if [ X"${USE_FIREWALLD}" == X'YES' ]; then
|
||||
cp -f ${SAMPLE_DIR}/firewall/firewalld/zones/iredmail.xml ${FIREWALL_RULE_CONF}
|
||||
perl -pi -e 's#^(DefaultZone=).*#${1}iredmail#g' ${FIREWALLD_CONF}
|
||||
|
||||
cp -f ${SAMPLE_DIR}/firewall/firewalld/services/ssh.xml ${FIREWALLD_CONF_DIR}/services/
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
cd ${ETC_SYSCONFIG_DIR}/network-scripts/
|
||||
perl -pi -e 's#ZONE=public#ZONE=iredmail#g' *
|
||||
fi
|
||||
|
||||
service_control enable firewalld >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
elif [ X"${USE_NFTABLES}" == X'YES' ]; then
|
||||
cp -f ${SAMPLE_DIR}/firewall/nftables.conf ${NFTABLES_CONF}
|
||||
|
||||
perl -pi -e 's#(.*) 80 (.*)#${1} $ENV{PORT_HTTP} ${2}#' ${NFTABLES_CONF}
|
||||
if [ X"${SSHD_PORT}" == X"${SSHD_PORT2}" ]; then
|
||||
perl -pi -e 's#(.*) 22 (.*)#${1} $ENV{SSHD_PORT} ${2}#' ${NFTABLES_CONF}
|
||||
elif [ X"${SSHD_PORT}" != X'' -a X"${SSHD_PORT2}" != X'' -a X"${SSHD_PORT}" != X"${SSHD_PORT2}" ]; then
|
||||
perl -pi -e 's#(.*) 22 (.*)#${1} {$ENV{SSHD_PORTS_WITH_COMMA}} ${2}#' ${NFTABLES_CONF}
|
||||
fi
|
||||
|
||||
service_control enable nftables >> ${INSTALL_LOG} 2>&1
|
||||
else
|
||||
cp -f ${SAMPLE_DIR}/firewall/iptables/iptables.rules ${FIREWALL_RULE_CONF}
|
||||
cp -f ${SAMPLE_DIR}/firewall/iptables/ip6tables.rules ${FIREWALL_RULE_CONF6}
|
||||
|
||||
service_control enable iptables >> ${INSTALL_LOG} 2>&1
|
||||
service_control enable ip6tables >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
# Replace HTTP port.
|
||||
[ X"${PORT_HTTP}" != X"80" ]&& \
|
||||
perl -pi -e 's#(.*)80(,.*)#${1}$ENV{PORT_HTTP}${2}#' ${FIREWALL_RULE_CONF}
|
||||
|
||||
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
# Enable pf
|
||||
service_control enable pf >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# Whitelist file required by spamd(8)
|
||||
touch /etc/mail/nospamd
|
||||
|
||||
ECHO_INFO "Copy firewall sample rules: ${FIREWALL_RULE_CONF}."
|
||||
cp -f ${SAMPLE_DIR}/openbsd/pf.conf ${FIREWALL_RULE_CONF}
|
||||
fi
|
||||
|
||||
# Prompt to restart iptables.
|
||||
ECHO_QUESTION -n "Restart firewall now (with ssh ports: ${SSHD_PORTS_WITH_COMMA})? [y|N]"
|
||||
read_setting ${AUTO_CLEANUP_RESTART_FIREWALL}
|
||||
case ${ANSWER} in
|
||||
Y|y )
|
||||
ECHO_INFO "Restarting firewall ..."
|
||||
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
/sbin/pfctl -ef ${FIREWALL_RULE_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
else
|
||||
if [ X"${USE_FIREWALLD}" == X'YES' ]; then
|
||||
firewall-cmd --complete-reload >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${USE_NFTABLES}" == X'YES' ]; then
|
||||
service_control restart nftables >> ${INSTALL_LOG} 2>&1
|
||||
else
|
||||
service_control restart iptables >> ${INSTALL_LOG} 2>&1
|
||||
service_control restart ip6tables >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*) : ;;
|
||||
esac
|
||||
esac
|
||||
|
||||
echo 'export status_cleanup_replace_firewall_rules="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
cleanup_replace_mysql_config()
|
||||
{
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ X"${BACKEND}" == X'MYSQL' -o X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
# Both MySQL and OpenLDAP backend need MySQL database server, so prompt
|
||||
# this config file replacement.
|
||||
ECHO_QUESTION "Would you like to use MySQL configuration file shipped within iRedMail now?"
|
||||
ECHO_QUESTION -n "File: ${MYSQL_MY_CNF}. [Y|n]"
|
||||
read_setting ${AUTO_CLEANUP_REPLACE_MYSQL_CONFIG}
|
||||
case ${ANSWER} in
|
||||
N|n ) ECHO_INFO "Skip copy and modify MySQL config file." ;;
|
||||
Y|y|* )
|
||||
backup_file ${MYSQL_MY_CNF}
|
||||
ECHO_INFO "Copy MySQL sample file: ${MYSQL_MY_CNF}."
|
||||
cp -f ${SAMPLE_DIR}/mysql/my.cnf ${MYSQL_MY_CNF}
|
||||
|
||||
ECHO_INFO "Enable SSL support for MySQL server."
|
||||
perl -pi -e 's/^#(ssl-cert.*=)(.*)/${1} $ENV{SSL_CERT_FILE}/' ${MYSQL_MY_CNF}
|
||||
perl -pi -e 's/^#(ssl-key.*=)(.*)/${1} $ENV{SSL_KEY_FILE}/' ${MYSQL_MY_CNF}
|
||||
perl -pi -e 's/^#(ssl-cipher.*)/${1}/' ${MYSQL_MY_CNF}
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
echo 'export status_cleanup_replace_mysql_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
cleanup_update_compile_spamassassin_rules()
|
||||
{
|
||||
# Required on FreeBSD to start Amavisd-new.
|
||||
ECHO_INFO "Updating SpamAssassin rules (sa-update), please wait ..."
|
||||
${BIN_SA_UPDATE} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_INFO "Compiling SpamAssassin rulesets (sa-compile), please wait ..."
|
||||
${BIN_SA_COMPILE} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
echo 'export status_cleanup_update_compile_spamassassin_rules="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
cleanup_update_clamav_signatures()
|
||||
{
|
||||
# Update clamav before start clamav-clamd service.
|
||||
if [ X"${FRESHCLAM_UPDATE_IMMEDIATELY}" == X'YES' ]; then
|
||||
ECHO_INFO "Updating ClamAV database (freshclam), please wait ..."
|
||||
freshclam 2>/dev/null
|
||||
fi
|
||||
|
||||
echo 'export status_cleanup_update_clamav_signatures="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
cleanup_feedback()
|
||||
{
|
||||
# Send names of chosen package to iRedMail project to help developers
|
||||
# understand which packages are most important to users.
|
||||
url="${BACKEND_ORIG}=YES"
|
||||
url="${url}&ROUNDCUBE=${USE_ROUNDCUBE}"
|
||||
url="${url}&SOGO=${USE_SOGO}"
|
||||
url="${url}&NETDATA=${USE_NETDATA}"
|
||||
url="${url}&FAIL2BAN=${USE_FAIL2BAN}"
|
||||
url="${url}&IREDADMIN=${USE_IREDADMIN}"
|
||||
[ X"${WEB_SERVER}" == X'NGINX' ] && url="${url}&NGINX=YES"
|
||||
|
||||
ECHO_DEBUG "Send info of chosed packages to iRedMail team to help improve iRedMail:"
|
||||
ECHO_DEBUG ""
|
||||
ECHO_DEBUG "\t${BACKEND_ORIG}=YES"
|
||||
ECHO_DEBUG "\tWEB_SERVER=${WEB_SERVER}"
|
||||
ECHO_DEBUG "\tROUNDCUBE=${USE_ROUNDCUBE}"
|
||||
ECHO_DEBUG "\tSOGO=${USE_SOGO}"
|
||||
ECHO_DEBUG "\tNETDATA=${USE_NETDATA}"
|
||||
ECHO_DEBUG "\tFAIL2BAN=${USE_FAIL2BAN}"
|
||||
ECHO_DEBUG "\tIREDADMIN=${USE_IREDADMIN}"
|
||||
ECHO_DEBUG ""
|
||||
|
||||
cd /tmp
|
||||
${FETCH_CMD} "https://lic.iredmail.org/check_version/iredmail_pkgs?${url}" &>/dev/null
|
||||
rm -f /tmp/iredmail_pkgs* &>/dev/null
|
||||
|
||||
echo 'export status_cleanup_feedback="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
# Store iRedMail version number in /etc/iredmail-release
|
||||
cat > /etc/${PROG_NAME_LOWERCASE}-release <<EOF
|
||||
${PROG_VERSION} ${BACKEND_ORIG} edition.
|
||||
# Get professional support from iRedMail Team: http://www.iredmail.org/support.html
|
||||
EOF
|
||||
|
||||
cat <<EOF
|
||||
|
||||
*************************************************************************
|
||||
* ${PROG_NAME}-${PROG_VERSION} installation and configuration complete.
|
||||
*************************************************************************
|
||||
|
||||
EOF
|
||||
|
||||
# Mail installation related info to postmaster@
|
||||
msg_date="$(date "+%a, %d %b %Y %H:%M:%S %z")"
|
||||
|
||||
ECHO_DEBUG "Mail sensitive administration info to ${DOMAIN_ADMIN_EMAIL}."
|
||||
FILE_IREDMAIL_INSTALLATION_DETAILS="${DOMAIN_ADMIN_MAILDIR_INBOX}/details.eml"
|
||||
FILE_IREDMAIL_LINKS="${DOMAIN_ADMIN_MAILDIR_INBOX}/links.eml"
|
||||
FILE_IREDMAIL_MUA_SETTINGS="${DOMAIN_ADMIN_MAILDIR_INBOX}/mua.eml"
|
||||
|
||||
cat > ${FILE_IREDMAIL_INSTALLATION_DETAILS} <<EOF
|
||||
From: root@${HOSTNAME}
|
||||
To: ${DOMAIN_ADMIN_EMAIL}
|
||||
Date: ${msg_date}
|
||||
Subject: Details of this iRedMail installation
|
||||
|
||||
$(cat ${TIP_FILE})
|
||||
EOF
|
||||
|
||||
cat > ${FILE_IREDMAIL_LINKS} <<EOF
|
||||
From: root@${HOSTNAME}
|
||||
To: ${DOMAIN_ADMIN_EMAIL}
|
||||
Date: ${msg_date}
|
||||
Subject: Useful resources for iRedMail administrator
|
||||
|
||||
$(cat ${DOC_FILE})
|
||||
EOF
|
||||
|
||||
cat > ${FILE_IREDMAIL_MUA_SETTINGS} <<EOF
|
||||
From: root@${HOSTNAME}
|
||||
To: ${DOMAIN_ADMIN_EMAIL}
|
||||
Date: ${msg_date}
|
||||
Subject: How to configure your mail client applications (MUA)
|
||||
|
||||
|
||||
* POP3 service: port 110 over STARTTLS (recommended), or port 995 with SSL.
|
||||
* IMAP service: port 143 over STARTTLS (recommended), or port 993 with SSL.
|
||||
* SMTP service: port 587 over STARTTLS.
|
||||
If you need to support old mail clients with SMTP over SSL (port 465),
|
||||
please check our tutorial: https://docs.iredmail.org/enable.smtps.html
|
||||
* CalDAV and CardDAV server addresses: https://<server>/SOGo/dav/<full email address>
|
||||
|
||||
For more details, please check detailed documentations:
|
||||
https://docs.iredmail.org/#mua
|
||||
EOF
|
||||
|
||||
for f in ${FILE_IREDMAIL_INSTALLATION_DETAILS} \
|
||||
${FILE_IREDMAIL_LINKS} \
|
||||
${FILE_IREDMAIL_MUA_SETTINGS}; do
|
||||
chown -R ${SYS_USER_VMAIL}:${SYS_GROUP_VMAIL} ${f}
|
||||
chmod -R 0700 ${f}
|
||||
done
|
||||
|
||||
check_status_before_run cleanup_set_cron_file_permission
|
||||
check_status_before_run cleanup_disable_selinux
|
||||
check_status_before_run cleanup_remove_sendmail
|
||||
|
||||
[ X"${KERNEL_NAME}" == X'LINUX' -o X"${KERNEL_NAME}" == X'OPENBSD' ] && \
|
||||
check_status_before_run cleanup_replace_firewall_rules
|
||||
|
||||
check_status_before_run cleanup_replace_mysql_config
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' -o X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
check_status_before_run cleanup_update_compile_spamassassin_rules
|
||||
fi
|
||||
|
||||
check_status_before_run cleanup_update_clamav_signatures
|
||||
check_status_before_run cleanup_feedback
|
||||
|
||||
cat <<EOF
|
||||
********************************************************************
|
||||
* URLs of installed web applications:
|
||||
*
|
||||
EOF
|
||||
|
||||
if [ X"${USE_ROUNDCUBE}" == X'YES' ]; then
|
||||
cat <<EOF
|
||||
* - Roundcube webmail: https://${HOSTNAME}/mail/
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ X"${USE_SOGO}" == X'YES' ]; then
|
||||
cat <<EOF
|
||||
* - SOGo groupware: https://${HOSTNAME}/SOGo/
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ X"${USE_NETDATA}" == X'YES' ]; then
|
||||
cat <<EOF
|
||||
* - netdata (monitor): https://${HOSTNAME}/netdata/
|
||||
EOF
|
||||
fi
|
||||
cat <<EOF
|
||||
*
|
||||
* - Web admin panel (iRedAdmin): https://${HOSTNAME}/iredadmin/
|
||||
*
|
||||
* You can login to above links with below credential:
|
||||
*
|
||||
* - Username: ${DOMAIN_ADMIN_EMAIL}
|
||||
* - Password: ${DOMAIN_ADMIN_PASSWD_PLAIN}
|
||||
*
|
||||
*
|
||||
********************************************************************
|
||||
* Congratulations, mail server setup completed successfully. Please
|
||||
* read below file for more information:
|
||||
*
|
||||
* - ${TIP_FILE}
|
||||
*
|
||||
* And it's sent to your mail account ${DOMAIN_ADMIN_EMAIL}.
|
||||
*
|
||||
********************* WARNING **************************************
|
||||
*
|
||||
* Please reboot your system to enable all mail services.
|
||||
*
|
||||
********************************************************************
|
||||
EOF
|
||||
|
||||
echo 'export status_cleanup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,561 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------
|
||||
# Dovecot & dovecot-sieve.
|
||||
# -------------------------------------------------------
|
||||
|
||||
dovecot_config()
|
||||
{
|
||||
ECHO_INFO "Configure Dovecot (POP3/IMAP/Managesieve/LMTP/LDA)."
|
||||
|
||||
backup_file ${DOVECOT_CONF}
|
||||
|
||||
# CentOS 7: Dovecot-2.2.36+
|
||||
# CentOS 8: Dovecot-2.3.8+
|
||||
# Debian 9: Dovecot-2.2.27
|
||||
# Debian 10: Dovecot-2.3.4+
|
||||
# Ubuntu 18.04: Dovecot-2.2.33
|
||||
# Ubuntu 20.04: Dovecot-2.3.7+
|
||||
# FreeBSD: Dovecot-2.3.0+
|
||||
# OpenBSD 6.7: Dovecot-2.3.10+
|
||||
ECHO_DEBUG "Copy sample Dovecot config file to ${DOVECOT_CONF}."
|
||||
if [ X"${DOVECOT_VERSION}" == X'2.2' ]; then
|
||||
cp ${SAMPLE_DIR}/dovecot/dovecot22.conf ${DOVECOT_CONF}
|
||||
else
|
||||
cp ${SAMPLE_DIR}/dovecot/dovecot23.conf ${DOVECOT_CONF}
|
||||
fi
|
||||
|
||||
chmod 0664 ${DOVECOT_CONF}
|
||||
|
||||
ECHO_DEBUG "Configure dovecot: ${DOVECOT_CONF}."
|
||||
|
||||
perl -pi -e 's#PH_DOVECOT_CONF_INCLUDE_DIR#$ENV{DOVECOT_CONF_INCLUDE_DIR}#g' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_SSL_DH1024_PARAM_FILE#$ENV{SSL_DH1024_PARAM_FILE}#g' ${DOVECOT_CONF}
|
||||
|
||||
# Listen address
|
||||
if [ X"${IREDMAIL_HAS_IPV6}" == X'NO' ]; then
|
||||
perl -pi -e 's#^(listen.*=).*#${1} \*#g' ${DOVECOT_CONF}
|
||||
fi
|
||||
|
||||
# Service listen addresses and ports.
|
||||
perl -pi -e 's#PH_LOCAL_ADDRESS#$ENV{LOCAL_ADDRESS}#g' ${DOVECOT_CONF}
|
||||
|
||||
#
|
||||
# Listen on localhost
|
||||
#
|
||||
# Managesieve
|
||||
perl -pi -e 's#PH_MANAGESIEVE_BIND_HOST#$ENV{MANAGESIEVE_BIND_HOST}#g' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_MANAGESIEVE_BIND_PORT#$ENV{MANAGESIEVE_BIND_PORT}#g' ${DOVECOT_CONF}
|
||||
|
||||
# LMTP
|
||||
perl -pi -e 's#PH_LMTP_BIND_ADDRESS#$ENV{LMTP_BIND_ADDRESS}#g' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_LMTP_BIND_PORT#$ENV{LMTP_BIND_PORT}#' ${DOVECOT_CONF}
|
||||
|
||||
# Base directory.
|
||||
perl -pi -e 's#PH_BASE_DIR#$ENV{DOVECOT_BASE_DIR}#' ${DOVECOT_CONF}
|
||||
# base_dir is required on OpenBSD
|
||||
[ X"${DISTRO}" == X'OPENBSD' ] && \
|
||||
perl -pi -e 's/^#(base_dir.*)/${1}/' ${DOVECOT_CONF}
|
||||
|
||||
# Public mailbox directory
|
||||
perl -pi -e 's#PH_PUBLIC_MAILBOX_DIR#$ENV{PUBLIC_MAILBOX_DIR}#' ${DOVECOT_CONF}
|
||||
|
||||
# Mailbox index directory
|
||||
if [ -n "${MAILBOX_INDEX_DIR}" ]; then
|
||||
perl -pi -e 's#^(mail_location.*:INDEX=)%Lh/Maildir/#${1}$ENV{MAILBOX_INDEX_DIR}/%Ld/%Ln/#' ${DOVECOT_CONF}
|
||||
|
||||
# Per-user seen flags. Maildir indexes are not shared. INDEXPVT requires v2.2+.
|
||||
perl -pi -e 's#(location.*:INDEX=)(.*/Shared/.*)#${1}$ENV{MAILBOX_INDEX_DIR}/%Ld/%Ln/Shared/%%Ld/%%Ln:INDEXPVT=$ENV{MAILBOX_INDEX_DIR}/%Ld/%Ln/Shared/%%Ld/%%Ln#g' ${DOVECOT_CONF}
|
||||
fi
|
||||
|
||||
# Provided services.
|
||||
export DOVECOT_PROTOCOLS
|
||||
perl -pi -e 's#PH_PROTOCOLS#$ENV{DOVECOT_PROTOCOLS}#' ${DOVECOT_CONF}
|
||||
|
||||
# Set correct uid/gid.
|
||||
perl -pi -e 's#PH_MAIL_UID#$ENV{SYS_USER_VMAIL_UID}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_MAIL_GID#$ENV{SYS_GROUP_VMAIL_GID}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_FIRST_VALID_UID#$ENV{SYS_USER_VMAIL_UID}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_LAST_VALID_UID#$ENV{SYS_USER_VMAIL_UID}#' ${DOVECOT_CONF}
|
||||
|
||||
# syslog and log file.
|
||||
perl -pi -e 's#PH_IREDMAIL_SYSLOG_FACILITY#$ENV{IREDMAIL_SYSLOG_FACILITY}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_LOG_PATH#$ENV{DOVECOT_LOG_FILE}#' ${DOVECOT_CONF}
|
||||
|
||||
# Authentication related settings.
|
||||
# Append this domain name if client gives empty realm.
|
||||
export FIRST_DOMAIN
|
||||
perl -pi -e 's#PH_AUTH_DEFAULT_REALM#$ENV{FIRST_DOMAIN}#' ${DOVECOT_CONF}
|
||||
|
||||
# service auth {}
|
||||
perl -pi -e 's#PH_DOVECOT_AUTH_USER#$ENV{SYS_USER_POSTFIX}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_AUTH_GROUP#$ENV{SYS_GROUP_POSTFIX}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_AUTH_MASTER_USER#$ENV{SYS_USER_VMAIL}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_AUTH_MASTER_GROUP#$ENV{SYS_GROUP_VMAIL}#' ${DOVECOT_CONF}
|
||||
|
||||
# service stats {}
|
||||
perl -pi -e 's#PH_DOVECOT_SERVICE_STATS_PORT#$ENV{DOVECOT_SERVICE_STATS_PORT}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SERVICE_STATS_USER#$ENV{DOVECOT_SERVICE_STATS_USER}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SERVICE_STATS_GROUP#$ENV{DOVECOT_SERVICE_STATS_GROUP}#' ${DOVECOT_CONF}
|
||||
|
||||
# Virtual mail accounts.
|
||||
# Reference: http://wiki2.dovecot.org/AuthDatabase/LDAP
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
perl -pi -e 's#PH_USERDB_ARGS#$ENV{DOVECOT_LDAP_CONF}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_USERDB_DRIVER#ldap#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_PASSDB_ARGS#$ENV{DOVECOT_LDAP_CONF}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_PASSDB_DRIVER#ldap#' ${DOVECOT_CONF}
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
# MySQL.
|
||||
perl -pi -e 's#PH_USERDB_ARGS#$ENV{DOVECOT_MYSQL_CONF}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_USERDB_DRIVER#sql#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_PASSDB_ARGS#$ENV{DOVECOT_MYSQL_CONF}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_PASSDB_DRIVER#sql#' ${DOVECOT_CONF}
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
# PostgreSQL.
|
||||
perl -pi -e 's#PH_USERDB_ARGS#$ENV{DOVECOT_PGSQL_CONF}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_USERDB_DRIVER#sql#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_PASSDB_ARGS#$ENV{DOVECOT_PGSQL_CONF}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_PASSDB_DRIVER#sql#' ${DOVECOT_CONF}
|
||||
fi
|
||||
|
||||
# Master user.
|
||||
perl -pi -e 's#PH_DOVECOT_MASTER_USER_PASSWORD_FILE#$ENV{DOVECOT_MASTER_USER_PASSWORD_FILE}#' ${DOVECOT_CONF}
|
||||
touch ${DOVECOT_MASTER_USER_PASSWORD_FILE}
|
||||
chown ${SYS_USER_DOVECOT}:${SYS_GROUP_DOVECOT} ${DOVECOT_MASTER_USER_PASSWORD_FILE}
|
||||
chmod 0500 ${DOVECOT_MASTER_USER_PASSWORD_FILE}
|
||||
|
||||
perl -pi -e 's#PH_DOVECOT_AUTH_MASTER_PATH#$ENV{DOVECOT_AUTH_MASTER_PATH}#' ${DOVECOT_CONF}
|
||||
|
||||
# Quota.
|
||||
perl -pi -e 's#PH_QUOTA_TYPE#$ENV{DOVECOT_QUOTA_TYPE}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_QUOTA_WARNING_SCRIPT#$ENV{DOVECOT_QUOTA_WARNING_SCRIPT}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_QUOTA_WARNING_USER#$ENV{SYS_USER_VMAIL}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_QUOTA_WARNING_GROUP#$ENV{SYS_GROUP_VMAIL}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SERVICE_QUOTA_STATUS_BIND_ADDRESS#$ENV{DOVECOT_SERVICE_QUOTA_STATUS_BIND_ADDRESS}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SERVICE_QUOTA_STATUS_PORT#$ENV{DOVECOT_SERVICE_QUOTA_STATUS_PORT}#' ${DOVECOT_CONF}
|
||||
|
||||
# Quota dict.
|
||||
perl -pi -e 's#PH_SERVICE_DICT_USER#$ENV{SYS_USER_VMAIL}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_SERVICE_DICT_GROUP#$ENV{SYS_GROUP_VMAIL}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SQL_DBN#$ENV{DOVECOT_SQL_DBN}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_REALTIME_QUOTA_CONF#$ENV{DOVECOT_REALTIME_QUOTA_CONF}#' ${DOVECOT_CONF}
|
||||
|
||||
# Sieve.
|
||||
perl -pi -e 's#PH_SIEVE_DIR#$ENV{SIEVE_DIR}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SIEVE_LOG_FILE#$ENV{DOVECOT_SIEVE_LOG_FILE}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_SIEVE_RULE_FILENAME#$ENV{SIEVE_RULE_FILENAME}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_GLOBAL_SIEVE_FILE#$ENV{DOVECOT_GLOBAL_SIEVE_FILE}#' ${DOVECOT_CONF}
|
||||
|
||||
# LMTP
|
||||
perl -pi -e 's#PH_DOVECOT_LMTP_LOG_FILE#$ENV{DOVECOT_LMTP_LOG_FILE}#' ${DOVECOT_CONF}
|
||||
|
||||
# SSL.
|
||||
perl -pi -e 's#PH_SSL_CERT#$ENV{SSL_CERT_FILE}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_SSL_KEY#$ENV{SSL_KEY_FILE}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_SSL_CIPHERS#$ENV{SSL_CIPHERS}#' ${DOVECOT_CONF}
|
||||
|
||||
# Distros ships newer openssl which doesn't support SSLv2 anymore.
|
||||
if [ X"${DISTRO}" == X'DEBIAN' -a X"${DISTRO_CODENAME}" == X'stretch' ] \
|
||||
|| [ X"${DISTRO}" == X'UBUNTU' -a X"${DISTRO_CODENAME}" == X'bionic' ] \
|
||||
|| [ X"${DISTRO}" == X'RHEL' -a X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
perl -pi -e 's#^(ssl_protocols).*#ssl_protocols = !SSLv3#' ${DOVECOT_CONF}
|
||||
fi
|
||||
|
||||
# PHP on CentOS 7 doesn't support TLSv1.
|
||||
if [ X"${DISTRO}" == X'RHEL' -a X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
perl -pi -e 's#^(ssl_protocols.*) !TLSv1( .*)#${1}${2}#' ${DOVECOT_CONF}
|
||||
fi
|
||||
|
||||
perl -pi -e 's#PH_POSTFIX_CHROOT_DIR#$ENV{POSTFIX_CHROOT_DIR}#' ${DOVECOT_CONF}
|
||||
|
||||
# Generate dovecot quota warning script.
|
||||
mkdir -p $(dirname ${DOVECOT_QUOTA_WARNING_SCRIPT}) >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
backup_file ${DOVECOT_QUOTA_WARNING_SCRIPT}
|
||||
rm -f ${DOVECOT_QUOTA_WARNING_SCRIPT} >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SAMPLE_DIR}/dovecot/dovecot2-quota-warning.sh ${DOVECOT_QUOTA_WARNING_SCRIPT}
|
||||
if [ X"${DOVECOT_QUOTA_TYPE}" == X'maildir' ]; then
|
||||
perl -pi -e 's#(.*)(-o.*plugin.*)#${1}#' ${DOVECOT_QUOTA_WARNING_SCRIPT}
|
||||
fi
|
||||
|
||||
# on OpenBSD: get FQDN with command 'hostname', not 'hostname -f'.
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
perl -pi -e 's#hostname -f#hostname#g' ${DOVECOT_QUOTA_WARNING_SCRIPT}
|
||||
fi
|
||||
|
||||
export DOVECOT_DELIVER_BIN HOSTNAME
|
||||
perl -pi -e 's#PH_DOVECOT_DELIVER_BIN#$ENV{DOVECOT_DELIVER_BIN}#' ${DOVECOT_QUOTA_WARNING_SCRIPT}
|
||||
perl -pi -e 's#PH_HOSTNAME#$ENV{HOSTNAME}#' ${DOVECOT_QUOTA_WARNING_SCRIPT}
|
||||
|
||||
chown root ${DOVECOT_QUOTA_WARNING_SCRIPT}
|
||||
chmod 0755 ${DOVECOT_QUOTA_WARNING_SCRIPT}
|
||||
|
||||
# Use '/usr/local/bin/bash' as shabang line, otherwise quota warning will fail.
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
perl -pi -e 's#(.*)/usr/bin/env bash.*#${1}/usr/local/bin/bash#' ${DOVECOT_QUOTA_WARNING_SCRIPT}
|
||||
fi
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
backup_file ${DOVECOT_LDAP_CONF}
|
||||
cp -f ${SAMPLE_DIR}/dovecot/dovecot-ldap.conf ${DOVECOT_LDAP_CONF}
|
||||
perl -pi -e 's/^#(iterate_.*)/${1}/' ${DOVECOT_LDAP_CONF}
|
||||
|
||||
perl -pi -e 's#PH_LDAP_SERVER_HOST#$ENV{LDAP_SERVER_HOST}#' ${DOVECOT_LDAP_CONF}
|
||||
perl -pi -e 's#PH_LDAP_SERVER_PORT#$ENV{LDAP_SERVER_PORT}#' ${DOVECOT_LDAP_CONF}
|
||||
perl -pi -e 's#PH_LDAP_BIND_VERSION#$ENV{LDAP_BIND_VERSION}#' ${DOVECOT_LDAP_CONF}
|
||||
perl -pi -e 's#PH_LDAP_BINDDN#$ENV{LDAP_BINDDN}#' ${DOVECOT_LDAP_CONF}
|
||||
perl -pi -e 's#PH_LDAP_BINDPW#$ENV{LDAP_BINDPW}#' ${DOVECOT_LDAP_CONF}
|
||||
perl -pi -e 's#PH_LDAP_BASEDN#$ENV{LDAP_BASEDN}#' ${DOVECOT_LDAP_CONF}
|
||||
|
||||
# Set file permission.
|
||||
chmod 0500 ${DOVECOT_LDAP_CONF}
|
||||
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
|
||||
backup_file ${DOVECOT_MYSQL_CONF}
|
||||
cp -f ${SAMPLE_DIR}/dovecot/dovecot-sql.conf ${DOVECOT_MYSQL_CONF}
|
||||
perl -pi -e 's/^#(iterate_.*)/${1}/' ${DOVECOT_MYSQL_CONF}
|
||||
perl -pi -e 's#(.*mailbox.)(enable.*Lc)(=1)#${1}`${2}`${3}#' ${DOVECOT_MYSQL_CONF}
|
||||
|
||||
perl -pi -e 's#PH_SQL_SERVER_ADDRESS#$ENV{SQL_SERVER_ADDRESS}#' ${DOVECOT_MYSQL_CONF}
|
||||
perl -pi -e 's#PH_SQL_SERVER_PORT#$ENV{SQL_SERVER_PORT}#' ${DOVECOT_MYSQL_CONF}
|
||||
perl -pi -e 's#PH_SQL_DRIVER#mysql#' ${DOVECOT_MYSQL_CONF}
|
||||
perl -pi -e 's#PH_VMAIL_DB_NAME#$ENV{VMAIL_DB_NAME}#' ${DOVECOT_MYSQL_CONF}
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_USER#$ENV{VMAIL_DB_BIND_USER}#' ${DOVECOT_MYSQL_CONF}
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_PASSWD#$ENV{VMAIL_DB_BIND_PASSWD}#' ${DOVECOT_MYSQL_CONF}
|
||||
|
||||
# Set file permission.
|
||||
chmod 0550 ${DOVECOT_MYSQL_CONF}
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
|
||||
backup_file ${DOVECOT_PGSQL_CONF}
|
||||
cp -f ${SAMPLE_DIR}/dovecot/dovecot-sql.conf ${DOVECOT_PGSQL_CONF}
|
||||
|
||||
perl -pi -e 's#(.*mailbox.)(enable.*Lc)(=1)#${1}"${2}"${3}#' ${DOVECOT_PGSQL_CONF}
|
||||
perl -pi -e 's/^#(iterate_.*)/${1}/' ${DOVECOT_PGSQL_CONF}
|
||||
perl -pi -e 's#PH_SQL_DRIVER#pgsql#' ${DOVECOT_PGSQL_CONF}
|
||||
perl -pi -e 's#PH_SQL_SERVER_ADDRESS#$ENV{SQL_SERVER_ADDRESS}#' ${DOVECOT_PGSQL_CONF}
|
||||
perl -pi -e 's#PH_SQL_SERVER_PORT#$ENV{SQL_SERVER_PORT}#' ${DOVECOT_PGSQL_CONF}
|
||||
perl -pi -e 's#PH_VMAIL_DB_NAME#$ENV{VMAIL_DB_NAME}#' ${DOVECOT_PGSQL_CONF}
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_USER#$ENV{VMAIL_DB_BIND_USER}#' ${DOVECOT_PGSQL_CONF}
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_PASSWD#$ENV{VMAIL_DB_BIND_PASSWD}#' ${DOVECOT_PGSQL_CONF}
|
||||
|
||||
# Set file permission.
|
||||
chmod 0550 ${DOVECOT_PGSQL_CONF}
|
||||
fi
|
||||
|
||||
backup_file ${DOVECOT_LAST_LOGIN_CONF} ${DOVECOT_SHARE_FOLDER_CONF}
|
||||
|
||||
# Track last login.
|
||||
cp ${SAMPLE_DIR}/dovecot/dovecot-last-login.conf ${DOVECOT_LAST_LOGIN_CONF}
|
||||
cp ${SAMPLE_DIR}/dovecot/dovecot-used-quota.conf ${DOVECOT_REALTIME_QUOTA_CONF}
|
||||
cp ${SAMPLE_DIR}/dovecot/dovecot-share-folder.conf ${DOVECOT_SHARE_FOLDER_CONF}
|
||||
|
||||
chown ${SYS_USER_DOVECOT}:${SYS_GROUP_DOVECOT} \
|
||||
${DOVECOT_LAST_LOGIN_CONF} \
|
||||
${DOVECOT_REALTIME_QUOTA_CONF} \
|
||||
${DOVECOT_SHARE_FOLDER_CONF}
|
||||
|
||||
chmod 0500 ${DOVECOT_LAST_LOGIN_CONF} \
|
||||
${DOVECOT_REALTIME_QUOTA_CONF} \
|
||||
${DOVECOT_SHARE_FOLDER_CONF}
|
||||
|
||||
perl -pi -e 's#PH_DOVECOT_SHARE_FOLDER_CONF#$ENV{DOVECOT_SHARE_FOLDER_CONF}#' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_LAST_LOGIN_CONF#$ENV{DOVECOT_LAST_LOGIN_CONF}#' ${DOVECOT_CONF}
|
||||
|
||||
# Replace place holders in sample config file
|
||||
perl -pi -e 's#PH_SQL_SERVER_ADDRESS#$ENV{SQL_SERVER_ADDRESS}#' ${DOVECOT_REALTIME_QUOTA_CONF} \
|
||||
${DOVECOT_REALTIME_QUOTA_CONF} \
|
||||
${DOVECOT_LAST_LOGIN_CONF}
|
||||
perl -pi -e 's#PH_SQL_SERVER_PORT#$ENV{SQL_SERVER_PORT}#' ${DOVECOT_REALTIME_QUOTA_CONF} \
|
||||
${DOVECOT_REALTIME_QUOTA_CONF} \
|
||||
${DOVECOT_LAST_LOGIN_CONF}
|
||||
|
||||
# Realtime quota and last login
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
export realtime_quota_db_name="${IREDADMIN_DB_NAME}"
|
||||
export realtime_quota_db_user="${IREDADMIN_DB_USER}"
|
||||
export realtime_quota_db_passwd="${IREDADMIN_DB_PASSWD}"
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
export realtime_quota_db_name="${VMAIL_DB_NAME}"
|
||||
export realtime_quota_db_user="${VMAIL_DB_ADMIN_USER}"
|
||||
export realtime_quota_db_passwd="${VMAIL_DB_ADMIN_PASSWD}"
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
export realtime_quota_db_name="${VMAIL_DB_NAME}"
|
||||
export realtime_quota_db_user="${VMAIL_DB_BIND_USER}"
|
||||
export realtime_quota_db_passwd="${VMAIL_DB_BIND_PASSWD}"
|
||||
fi
|
||||
|
||||
# realtime quota and last login
|
||||
perl -pi -e 's#PH_REALTIME_QUOTA_DB_NAME#$ENV{realtime_quota_db_name}#' ${DOVECOT_REALTIME_QUOTA_CONF} ${DOVECOT_LAST_LOGIN_CONF}
|
||||
perl -pi -e 's#PH_REALTIME_QUOTA_DB_USER#$ENV{realtime_quota_db_user}#' ${DOVECOT_REALTIME_QUOTA_CONF} ${DOVECOT_LAST_LOGIN_CONF}
|
||||
perl -pi -e 's#PH_REALTIME_QUOTA_DB_PASSWORD#$ENV{realtime_quota_db_passwd}#' ${DOVECOT_REALTIME_QUOTA_CONF} ${DOVECOT_LAST_LOGIN_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_REALTIME_QUOTA_TABLE#$ENV{DOVECOT_REALTIME_QUOTA_TABLE}#' ${DOVECOT_REALTIME_QUOTA_CONF}
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
export share_folder_db_name="${IREDADMIN_DB_NAME}"
|
||||
export share_folder_db_user="${IREDADMIN_DB_USER}"
|
||||
export share_folder_db_passwd="${IREDADMIN_DB_PASSWD}"
|
||||
elif [ X"${BACKEND}" == X'MYSQL' -o X"${BACKEND}" == X'PGSQL' ]; then
|
||||
export share_folder_db_name="${VMAIL_DB_NAME}"
|
||||
export share_folder_db_user="${VMAIL_DB_ADMIN_USER}"
|
||||
export share_folder_db_passwd="${VMAIL_DB_ADMIN_PASSWD}"
|
||||
fi
|
||||
|
||||
# Replace place holders in sample config file
|
||||
perl -pi -e 's#PH_SQL_SERVER_ADDRESS#$ENV{SQL_SERVER_ADDRESS}#' ${DOVECOT_SHARE_FOLDER_CONF}
|
||||
perl -pi -e 's#PH_SQL_SERVER_PORT#$ENV{SQL_SERVER_PORT}#' ${DOVECOT_SHARE_FOLDER_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SHARE_FOLDER_DB_NAME#$ENV{share_folder_db_name}#' ${DOVECOT_SHARE_FOLDER_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SHARE_FOLDER_DB_USER#$ENV{share_folder_db_user}#' ${DOVECOT_SHARE_FOLDER_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SHARE_FOLDER_DB_PASSWORD#$ENV{share_folder_db_passwd}#' ${DOVECOT_SHARE_FOLDER_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SHARE_FOLDER_DB_TABLE#$ENV{DOVECOT_SHARE_FOLDER_DB_TABLE}#' ${DOVECOT_SHARE_FOLDER_CONF}
|
||||
perl -pi -e 's#PH_DOVECOT_SHARE_FOLDER_ANYONE_DB_TABLE#$ENV{DOVECOT_SHARE_FOLDER_ANYONE_DB_TABLE}#' ${DOVECOT_SHARE_FOLDER_CONF}
|
||||
|
||||
ECHO_DEBUG "Copy global sieve filter rule file: ${DOVECOT_GLOBAL_SIEVE_FILE}."
|
||||
cp -f ${SAMPLE_DIR}/dovecot/dovecot.sieve ${DOVECOT_GLOBAL_SIEVE_FILE}
|
||||
chown ${SYS_USER_VMAIL}:${SYS_GROUP_VMAIL} ${DOVECOT_GLOBAL_SIEVE_FILE}
|
||||
chmod 0500 ${DOVECOT_GLOBAL_SIEVE_FILE}
|
||||
|
||||
ECHO_DEBUG "Enable dovecot SASL support in postfix: ${POSTFIX_FILE_MAIN_CF}."
|
||||
cat ${SAMPLE_DIR}/postfix/main.cf.dovecot >> ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
perl -pi -e 's#PH_DOVECOT_SASL_AUTH_SOCKET#$ENV{DOVECOT_SASL_AUTH_SOCKET}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_DOVECOT_SASL_AUTH_PATH#$ENV{_dovecot_sasl_auth_path}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_DOVECOT_DELIVER_BIN#$ENV{DOVECOT_DELIVER_BIN}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_TRANSPORT#$ENV{TRANSPORT}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
ECHO_DEBUG "Create directory for Dovecot plugin: Expire."
|
||||
dovecot_expire_dict_dir="$(dirname ${DOVECOT_EXPIRE_DICT_BDB})"
|
||||
mkdir -p ${dovecot_expire_dict_dir} && \
|
||||
chown -R ${SYS_USER_DOVECOT}:${SYS_GROUP_DOVECOT} ${dovecot_expire_dict_dir} && \
|
||||
chmod -R 0750 ${dovecot_expire_dict_dir}
|
||||
|
||||
# Prevent read-only files forced by systemd.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
mkdir -p /etc/systemd/system/dovecot.service.d >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SAMPLE_DIR}/dovecot/systemd/override.conf /etc/systemd/system/dovecot.service.d >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
# Unfortunately, PostgreSQL doesn't support tracking last login.
|
||||
if [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
perl -pi -e 's/.*# Track user last login//' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#.*last_login_.*##' ${DOVECOT_CONF}
|
||||
perl -pi -e 's#(.*mail_plugins = .*)last_login(.*)#${1}${2}#' ${DOVECOT_CONF}
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Dovecot:
|
||||
* Configuration files:
|
||||
- ${DOVECOT_CONF}
|
||||
- ${DOVECOT_LDAP_CONF} (For OpenLDAP backend)
|
||||
- ${DOVECOT_MYSQL_CONF} (For MySQL backend)
|
||||
- ${DOVECOT_PGSQL_CONF} (For PostgreSQL backend)
|
||||
- ${DOVECOT_REALTIME_QUOTA_CONF} (For real-time quota usage)
|
||||
- ${DOVECOT_SHARE_FOLDER_CONF} (For IMAP sharing folder)
|
||||
* Syslog config file:
|
||||
- ${SYSLOG_CONF_DIR}/1-iredmail-dovecot.conf (present if rsyslog >= 8.x)
|
||||
* RC script: ${DIR_RC_SCRIPTS}/${DOVECOT_RC_SCRIPT_NAME}
|
||||
* Log files:
|
||||
- ${DOVECOT_LOG_FILE}
|
||||
- ${DOVECOT_SIEVE_LOG_FILE}
|
||||
- ${DOVECOT_LMTP_LOG_FILE}
|
||||
- ${DOVECOT_SYSLOG_FILE_LDA} (present if rsyslog >= 8.x)
|
||||
- ${DOVECOT_SYSLOG_FILE_IMAP} (present if rsyslog >= 8.x)
|
||||
- ${DOVECOT_SYSLOG_FILE_POP3} (present if rsyslog >= 8.x)
|
||||
- ${DOVECOT_SYSLOG_FILE_SIEVE} (present if rsyslog >= 8.x)
|
||||
* See also:
|
||||
- ${DOVECOT_GLOBAL_SIEVE_FILE}
|
||||
- Logrotate config file: ${DOVECOT_LOGROTATE_FILE}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_dovecot_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
dovecot_log() {
|
||||
ECHO_DEBUG "Configure Dovecot logging."
|
||||
|
||||
mkdir -p ${DOVECOT_LOG_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
chown ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${DOVECOT_LOG_DIR}
|
||||
touch ${DOVECOT_LOG_FILE}
|
||||
chown ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${DOVECOT_LOG_FILE}
|
||||
chmod 0640 ${DOVECOT_LOG_FILE}
|
||||
|
||||
ECHO_DEBUG "Generate modular syslog and log rotate config files for dovecot log files."
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
# Use rsyslog.
|
||||
# Copy rsyslog config file used to filter Dovecot log
|
||||
cp ${SAMPLE_DIR}/rsyslog.d/1-iredmail-dovecot.conf ${SYSLOG_CONF_DIR}
|
||||
|
||||
perl -pi -e 's#PH_IREDMAIL_SYSLOG_FACILITY#$ENV{IREDMAIL_SYSLOG_FACILITY}#g' ${SYSLOG_CONF_DIR}/1-iredmail-dovecot.conf
|
||||
perl -pi -e 's#PH_DOVECOT_LOG_FILE#$ENV{DOVECOT_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/1-iredmail-dovecot.conf
|
||||
perl -pi -e 's#PH_DOVECOT_SYSLOG_FILE_LDA#$ENV{DOVECOT_SYSLOG_FILE_LDA}#g' ${SYSLOG_CONF_DIR}/1-iredmail-dovecot.conf
|
||||
perl -pi -e 's#PH_DOVECOT_SYSLOG_FILE_IMAP#$ENV{DOVECOT_SYSLOG_FILE_IMAP}#g' ${SYSLOG_CONF_DIR}/1-iredmail-dovecot.conf
|
||||
perl -pi -e 's#PH_DOVECOT_SYSLOG_FILE_POP3#$ENV{DOVECOT_SYSLOG_FILE_POP3}#g' ${SYSLOG_CONF_DIR}/1-iredmail-dovecot.conf
|
||||
perl -pi -e 's#PH_DOVECOT_SYSLOG_FILE_SIEVE#$ENV{DOVECOT_SYSLOG_FILE_SIEVE}#g' ${SYSLOG_CONF_DIR}/1-iredmail-dovecot.conf
|
||||
|
||||
# Although no need to create log files manually, but fail2ban will skip
|
||||
# the log file which doesn't exist while fail2ban starts up, so we
|
||||
# create it manually to avoid this.
|
||||
for f in ${DOVECOT_LOG_FILE} \
|
||||
${DOVECOT_SYSLOG_FILE_LDA} \
|
||||
${DOVECOT_SYSLOG_FILE_IMAP} \
|
||||
${DOVECOT_SYSLOG_FILE_POP3} \
|
||||
${DOVECOT_SYSLOG_FILE_SIEVE}; do
|
||||
ECHO_DEBUG "Create dovecot log file: ${f}."
|
||||
touch ${f}
|
||||
chown ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${f}
|
||||
chmod 0640 ${f}
|
||||
done
|
||||
|
||||
cp -f ${SAMPLE_DIR}/logrotate/dovecot ${DOVECOT_LOGROTATE_FILE}
|
||||
chmod 0644 ${DOVECOT_LOGROTATE_FILE}
|
||||
|
||||
perl -pi -e 's#PH_DOVECOT_LOG_DIR#$ENV{DOVECOT_LOG_DIR}#g' ${DOVECOT_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYSLOG_POSTROTATE_CMD#$ENV{SYSLOG_POSTROTATE_CMD}#g' ${DOVECOT_LOGROTATE_FILE}
|
||||
|
||||
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/syslog.d/dovecot.conf ${SYSLOG_CONF_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_IREDMAIL_SYSLOG_FACILITY#$ENV{IREDMAIL_SYSLOG_FACILITY}#g' ${SYSLOG_CONF_DIR}/dovecot.conf
|
||||
perl -pi -e 's#PH_DOVECOT_LOG_FILE#$ENV{DOVECOT_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/dovecot.conf
|
||||
|
||||
#
|
||||
# modular log rotate config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/newsyslog.conf.d/dovecot ${DOVECOT_LOGROTATE_FILE}
|
||||
|
||||
perl -pi -e 's#PH_DOVECOT_MASTER_PID#$ENV{DOVECOT_MASTER_PID}#g' ${DOVECOT_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_DOVECOT_LOG_FILE#$ENV{DOVECOT_LOG_FILE}#g' ${DOVECOT_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_DOVECOT_SIEVE_LOG_FILE#$ENV{DOVECOT_SIEVE_LOG_FILE}#g' ${DOVECOT_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_DOVECOT_LMTP_LOG_FILE#$ENV{DOVECOT_LMTP_LOG_FILE}#g' ${DOVECOT_LOGROTATE_FILE}
|
||||
|
||||
perl -pi -e 's#PH_SYS_USER_SYSLOG#$ENV{SYS_USER_SYSLOG}#g' ${DOVECOT_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYS_GROUP_SYSLOG#$ENV{SYS_GROUP_SYSLOG}#g' ${DOVECOT_LOGROTATE_FILE}
|
||||
|
||||
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
if ! grep "${DOVECOT_LOG_FILE}" ${SYSLOG_CONF} &>/dev/null; then
|
||||
# '!!' means abort further evaluation after first match
|
||||
echo '!!dovecot' >> ${SYSLOG_CONF}
|
||||
echo "${IREDMAIL_SYSLOG_FACILITY}.* ${DOVECOT_LOG_FILE}" >> ${SYSLOG_CONF}
|
||||
fi
|
||||
|
||||
if ! grep "${DOVECOT_LOG_FILE}" /etc/newsyslog.conf &>/dev/null; then
|
||||
# Define command used to reopen log service after rotated
|
||||
cat >> /etc/newsyslog.conf <<EOF
|
||||
${DOVECOT_LOG_FILE} ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} 600 7 * 24 Z "${DOVECOT_DOVEADM_BIN} log reopen"
|
||||
EOF
|
||||
fi
|
||||
|
||||
if ! grep "${DOVECOT_SIEVE_LOG_FILE}" /etc/newsyslog.conf &>/dev/null; then
|
||||
# Define command used to reopen log service after rotated
|
||||
cat >> /etc/newsyslog.conf <<EOF
|
||||
${DOVECOT_SIEVE_LOG_FILE} ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} 600 7 * 24 Z "${DOVECOT_DOVEADM_BIN} log reopen"
|
||||
EOF
|
||||
fi
|
||||
|
||||
if ! grep "${DOVECOT_LMTP_LOG_FILE}" /etc/newsyslog.conf &>/dev/null; then
|
||||
# Define command used to reopen log service after rotated
|
||||
cat >> /etc/newsyslog.conf <<EOF
|
||||
${DOVECOT_LMTP_LOG_FILE} ${SYS_USER_VMAIL}:${SYS_GROUP_VMAIL} 600 7 * 24 Z "${DOVECOT_DOVEADM_BIN} log reopen"
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
echo 'export status_dovecot_log="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
dovecot_initialize_db_for_ldap() {
|
||||
# Create MySQL database ${IREDADMIN_DB_USER} and addition tables:
|
||||
# - used_quota: used to store realtime quota.
|
||||
# - share_folder: used to store share folder settings.
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
# If iRedAdmin is not used, create database and import table here.
|
||||
${MYSQL_CLIENT_ROOT} >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
-- Create databases.
|
||||
CREATE DATABASE IF NOT EXISTS ${IREDADMIN_DB_NAME} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
|
||||
-- Import SQL template.
|
||||
USE ${IREDADMIN_DB_NAME};
|
||||
|
||||
-- used_quota, share_folder, last_login
|
||||
SOURCE ${SAMPLE_DIR}/dovecot/sql/used_quota.mysql;
|
||||
SOURCE ${SAMPLE_DIR}/dovecot/sql/imap_share_folder.mysql;
|
||||
SOURCE ${SAMPLE_DIR}/dovecot/sql/last_login.mysql;
|
||||
|
||||
GRANT ALL ON ${IREDADMIN_DB_NAME}.* TO "${IREDADMIN_DB_USER}"@"${MYSQL_GRANT_HOST}" IDENTIFIED BY "${IREDADMIN_DB_PASSWD}";
|
||||
GRANT ALL ON ${IREDADMIN_DB_NAME}.* TO "${IREDADMIN_DB_USER}"@"${HOSTNAME}" IDENTIFIED BY "${IREDADMIN_DB_PASSWD}";
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo 'export status_dovecot_initialize_db_for_ldap="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
dovecot_setup()
|
||||
{
|
||||
check_status_before_run dovecot_config
|
||||
check_status_before_run dovecot_log
|
||||
check_status_before_run dovecot_initialize_db_for_ldap
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Remove the temporary sample config files copied in `functions/backend.sh`.
|
||||
rm -rf /usr/local/etc/dovecot/conf.d &>/dev/null
|
||||
|
||||
# It seems there's a bug in Dovecot port, it will try to invoke '/usr/lib/sendmail'
|
||||
# to send vacation response which should be '/usr/sbin/mailwrapper'.
|
||||
[ ! -e /usr/lib/sendmail ] && ln -s /usr/sbin/mailwrapper /usr/lib/sendmail >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# Start service when system start up.
|
||||
service_control enable 'dovecot_enable' 'YES'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# By default, the _dovecot user, and so the Dovecot processes run in
|
||||
# the login(1) class of "daemon". On a busy server, it may be advisable
|
||||
# to put the _dovecot user and processes in their own login(1) class
|
||||
# with tuned resources, such as more open file descriptors etc.
|
||||
if [ -f /etc/login.conf ]; then
|
||||
if ! grep '^dovecot:' /etc/login.conf &>/dev/null; then
|
||||
cat >> /etc/login.conf <<EOF
|
||||
dovecot:\\
|
||||
:openfiles-cur=1024:\\
|
||||
:openfiles-max=4096:\\
|
||||
:tc=daemon:
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Rebuild the login.conf.db file if necessary
|
||||
[ -f /etc/login.conf.db ] && cap_mkdb /etc/login.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
echo 'export status_dovecot_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
_enable_jail() {
|
||||
_jail_conf="${FAIL2BAN_JAIL_CONF_DIR}/${1}"
|
||||
|
||||
if [ -e ${_jail_conf} ]; then
|
||||
perl -pi -e 's#(enabled.*=.*)false#${1}true#' ${_jail_conf}
|
||||
fi
|
||||
}
|
||||
|
||||
fail2ban_initialize_db() {
|
||||
ECHO_DEBUG "Import Fail2ban database and grant privileges."
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
${MYSQL_CLIENT_ROOT} <<EOF
|
||||
-- Create database
|
||||
CREATE DATABASE ${FAIL2BAN_DB_NAME} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
|
||||
-- Grant privileges
|
||||
GRANT ALL ON ${FAIL2BAN_DB_NAME}.* TO '${FAIL2BAN_DB_USER}'@'${MYSQL_GRANT_HOST}' IDENTIFIED BY '${FAIL2BAN_DB_PASSWD}';
|
||||
|
||||
-- Import Amavisd SQL template
|
||||
USE ${FAIL2BAN_DB_NAME};
|
||||
SOURCE ${SAMPLE_DIR}/fail2ban/sql/fail2ban.mysql;
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
|
||||
cat > /root/.my.cnf-${FAIL2BAN_DB_USER} <<EOF
|
||||
[client]
|
||||
host=${MYSQL_SERVER_ADDRESS}
|
||||
port=${MYSQL_SERVER_PORT}
|
||||
user=${FAIL2BAN_DB_USER}
|
||||
password="${FAIL2BAN_DB_PASSWD}"
|
||||
EOF
|
||||
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
cp -f ${SAMPLE_DIR}/fail2ban/sql/fail2ban.pgsql /tmp/fail2ban.pgsql
|
||||
chmod 0755 /tmp/fail2ban.pgsql
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1" >> ${INSTALL_LOG} <<EOF
|
||||
-- Create database
|
||||
CREATE DATABASE ${FAIL2BAN_DB_NAME} WITH TEMPLATE template0 ENCODING 'UTF8';
|
||||
|
||||
-- Create user
|
||||
CREATE USER ${FAIL2BAN_DB_USER} WITH ENCRYPTED PASSWORD '${FAIL2BAN_DB_PASSWD}' NOSUPERUSER NOCREATEDB NOCREATEROLE;
|
||||
|
||||
ALTER DATABASE ${FAIL2BAN_DB_NAME} OWNER TO ${FAIL2BAN_DB_USER};
|
||||
EOF
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -U ${FAIL2BAN_DB_USER} -d ${FAIL2BAN_DB_NAME}" >> ${INSTALL_LOG} <<EOF
|
||||
\i /tmp/fail2ban.pgsql;
|
||||
EOF
|
||||
rm -f /tmp/fail2ban.pgsql
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -U ${FAIL2BAN_DB_USER} -d ${FAIL2BAN_DB_NAME}" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
ALTER DATABASE ${FAIL2BAN_DB_NAME} SET bytea_output TO 'escape';
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Copy action config file.
|
||||
cp -f ${SAMPLE_DIR}/fail2ban/action.d/banned_db.conf ${FAIL2BAN_ACTION_DIR}/
|
||||
chmod 0755 ${FAIL2BAN_ACTION_DIR}/banned_db.conf
|
||||
|
||||
# Copy script used to handle sql data.
|
||||
cp -f ${SAMPLE_DIR}/fail2ban/bin/fail2ban_banned_db /usr/local/bin/
|
||||
chmod 0550 /usr/local/bin/fail2ban_banned_db
|
||||
|
||||
cat >> ${CRON_FILE_ROOT} <<EOF
|
||||
# Fail2ban: Unban IP addresses pending for removal (stored in SQL db).
|
||||
* * * * * ${SHELL_BASH} /usr/local/bin/fail2ban_banned_db unban_db
|
||||
EOF
|
||||
|
||||
echo 'export status_fail2ban_initialize_db="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
fail2ban_config() {
|
||||
ECHO_DEBUG "Disable all default filters in ${FAIL2BAN_JAIL_CONF}."
|
||||
perl -pi -e 's#^(enabled).*=.*#${1} = false#' ${FAIL2BAN_JAIL_CONF}
|
||||
|
||||
ECHO_DEBUG "Create main Fail2ban config file: ${FAIL2BAN_MAIN_CONF}."
|
||||
backup_file ${FAIL2BAN_MAIN_CONF}
|
||||
cp -f ${SAMPLE_DIR}/fail2ban/fail2ban.local ${FAIL2BAN_MAIN_CONF}
|
||||
perl -pi -e 's#PH_SYSLOG_SOCKET#$ENV{SYSLOG_SOCKET}#' ${FAIL2BAN_MAIN_CONF}
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
perl -pi -e 's#^(socket).*#${1} = $ENV{FAIL2BAN_SOCKET}#' ${FAIL2BAN_MAIN_CONF}
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
perl -pi -e 's/^#(syslogsocket.*)/${1}/' ${FAIL2BAN_MAIN_CONF}
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Create Fail2ban config file: ${FAIL2BAN_JAIL_LOCAL_CONF}."
|
||||
backup_file ${FAIL2BAN_JAIL_LOCAL_CONF}
|
||||
cp -f ${SAMPLE_DIR}/fail2ban/jail.local ${FAIL2BAN_JAIL_LOCAL_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Create Fail2ban directory: ${FAIL2BAN_JAIL_CONF_DIR}."
|
||||
mkdir -p ${FAIL2BAN_JAIL_CONF_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
perl -pi -e 's#PH_LOCAL_ADDRESS#$ENV{LOCAL_ADDRESS}#' ${FAIL2BAN_JAIL_LOCAL_CONF}
|
||||
|
||||
ECHO_DEBUG "Copy modular Fail2ban jail config files to ${FAIL2BAN_JAIL_CONF_DIR}."
|
||||
cp -f ${SAMPLE_DIR}/fail2ban/jail.d/*.local ${FAIL2BAN_JAIL_CONF_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# Firewall command
|
||||
perl -pi -e 's#PH_FAIL2BAN_ACTION#$ENV{FAIL2BAN_ACTION}#' ${FAIL2BAN_JAIL_CONF_DIR}/*.local
|
||||
|
||||
perl -pi -e 's#PH_SSHD_LOGFILE#$ENV{SSHD_LOGFILE}#' ${FAIL2BAN_JAIL_CONF_DIR}/*.local
|
||||
perl -pi -e 's#PH_NGINX_LOG_ERRORLOG#$ENV{NGINX_LOG_ERRORLOG}#' ${FAIL2BAN_JAIL_CONF_DIR}/*.local
|
||||
perl -pi -e 's#PH_RCM_LOGFILE#$ENV{RCM_LOGFILE}#' ${FAIL2BAN_JAIL_CONF_DIR}/*.local
|
||||
perl -pi -e 's#PH_MAILLOG#$ENV{MAILLOG}#' ${FAIL2BAN_JAIL_CONF_DIR}/*.local
|
||||
perl -pi -e 's#PH_SOGO_LOG_FILE#$ENV{SOGO_LOG_FILE}#' ${FAIL2BAN_JAIL_CONF_DIR}/*.local
|
||||
perl -pi -e 's#PH_DOVECOT_LOG_FILE#$ENV{DOVECOT_LOG_DIR}/*.log#' ${FAIL2BAN_JAIL_CONF_DIR}/*.local
|
||||
perl -pi -e 's#PH_FAIL2BAN_DISABLED_SERVICES#$ENV{FAIL2BAN_DISABLED_SERVICES}#' ${FAIL2BAN_JAIL_CONF_DIR}/*.local
|
||||
|
||||
perl -pi -e 's#PH_SSHD_PORT#$ENV{SSHD_PORTS_WITH_COMMA}#' ${FAIL2BAN_JAIL_CONF_DIR}/*.local
|
||||
|
||||
ECHO_DEBUG "Copy sample Fail2ban filter config files."
|
||||
cp -f ${SAMPLE_DIR}/fail2ban/filter.d/*.conf ${FAIL2BAN_FILTER_DIR}
|
||||
|
||||
# Enable jail for optional components.
|
||||
[ X"${WEB_SERVER}" == X'NGINX' ] && _enable_jail nginx-http-auth.local
|
||||
[ X"${USE_ROUNDCUBE}" == X'YES' ] && _enable_jail roundcube.local
|
||||
[ X"${USE_SOGO}" == X'YES' ] && _enable_jail sogo.local
|
||||
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# Copy rc script and enable service.
|
||||
cp ${SAMPLE_DIR}/fail2ban/openbsd/rc /etc/rc.d/fail2ban
|
||||
chmod 0755 /etc/rc.d/fail2ban
|
||||
service_control enable fail2ban >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
echo 'export status_fail2ban_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
fail2ban_syslog_setup() {
|
||||
ECHO_DEBUG "Generate modular syslog and log rotate config files for Fail2ban."
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
cp ${SAMPLE_DIR}/rsyslog.d/1-iredmail-fail2ban.conf ${SYSLOG_CONF_DIR}
|
||||
perl -pi -e 's#PH_FAIL2BAN_LOG_FILE#$ENV{FAIL2BAN_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/1-iredmail-fail2ban.conf
|
||||
|
||||
touch ${FAIL2BAN_LOG_FILE}
|
||||
chown ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${FAIL2BAN_LOG_FILE}
|
||||
chmod 0755 ${FAIL2BAN_LOG_FILE}
|
||||
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
cp -f ${SAMPLE_DIR}/freebsd/syslog.d/fail2ban.conf ${SYSLOG_CONF_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_FAIL2BAN_SYSLOG_FACILITY#$ENV{FAIL2BAN_SYSLOG_FACILITY}#g' ${SYSLOG_CONF_DIR}/fail2ban.conf
|
||||
perl -pi -e 's#PH_FAIL2BAN_LOG_FILE#$ENV{FAIL2BAN_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/fail2ban.conf
|
||||
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
touch ${FAIL2BAN_LOG_FILE}
|
||||
chown ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${FAIL2BAN_LOG_FILE}
|
||||
chmod 0755 ${FAIL2BAN_LOG_FILE}
|
||||
|
||||
if ! grep "${FAIL2BAN_LOG_FILE}" ${SYSLOG_CONF} &>/dev/null; then
|
||||
# '!!' means abort further evaluation after first match
|
||||
echo '' >> ${SYSLOG_CONF}
|
||||
echo '!!fail2ban*' >> ${SYSLOG_CONF}
|
||||
echo "${FAIL2BAN_SYSLOG_FACILITY}.* ${FAIL2BAN_LOG_FILE}" >> ${SYSLOG_CONF}
|
||||
fi
|
||||
|
||||
if ! grep "${FAIL2BAN_LOG_FILE}" /etc/newsyslog.conf &>/dev/null; then
|
||||
cat >> /etc/newsyslog.conf <<EOF
|
||||
${FAIL2BAN_LOG_FILE} ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} 640 7 * 24 Z
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
echo 'export status_fail2ban_syslog_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
fail2ban_setup() {
|
||||
ECHO_INFO "Configure Fail2ban (authentication failure monitor)."
|
||||
|
||||
check_status_before_run fail2ban_initialize_db
|
||||
check_status_before_run fail2ban_config
|
||||
check_status_before_run fail2ban_syslog_setup
|
||||
|
||||
echo 'export status_fail2ban_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
# Purpose: Install & config necessary packages for iRedAdmin.
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
iredadmin_install()
|
||||
{
|
||||
ECHO_INFO "Configure iRedAdmin (official web-based admin panel)."
|
||||
|
||||
cd ${PKG_MISC_DIR}
|
||||
|
||||
# Extract source tarball.
|
||||
extract_pkg ${IREDADMIN_TARBALL} ${HTTPD_SERVERROOT}
|
||||
|
||||
# Create symbol link, so that we don't need to modify web server config
|
||||
# file to set new version number after upgrading this software.
|
||||
ln -s ${IREDADMIN_HTTPD_ROOT} ${IREDADMIN_HTTPD_ROOT_SYMBOL_LINK} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Set correct permission for iRedAdmin: ${IREDADMIN_HTTPD_ROOT}."
|
||||
chown -R ${SYS_USER_IREDADMIN}:${SYS_GROUP_IREDADMIN} ${IREDADMIN_HTTPD_ROOT}
|
||||
chmod -R 0555 ${IREDADMIN_HTTPD_ROOT}
|
||||
|
||||
echo 'export status_iredadmin_install="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredadmin_web_config() {
|
||||
# Copy sample configure file.
|
||||
cd ${IREDADMIN_HTTPD_ROOT}/
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
cp settings.py.ldap.sample settings.py
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
cp settings.py.mysql.sample settings.py
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
cp settings.py.pgsql.sample settings.py
|
||||
fi
|
||||
|
||||
chown -R ${SYS_USER_IREDADMIN}:${SYS_GROUP_IREDADMIN} settings.py
|
||||
chmod 0400 settings.py
|
||||
|
||||
echo 'export status_iredadmin_web_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredadmin_initialize_db() {
|
||||
ECHO_DEBUG "Import iRedAdmin database template."
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
# Required by MySQL-5.6: TEXT/BLOB column cannot have a default value.
|
||||
perl -pi -e 's#(.*maildir.*)TEXT(.*)#${1}VARCHAR\(255\)${2}#g' ${IREDADMIN_HTTPD_ROOT}/SQL/iredadmin.mysql;
|
||||
|
||||
${MYSQL_CLIENT_ROOT} <<EOF
|
||||
# Create databases.
|
||||
CREATE DATABASE IF NOT EXISTS ${IREDADMIN_DB_NAME} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
|
||||
# Import SQL template.
|
||||
USE ${IREDADMIN_DB_NAME};
|
||||
SOURCE ${IREDADMIN_HTTPD_ROOT}/SQL/iredadmin.mysql;
|
||||
GRANT ALL ON ${IREDADMIN_DB_NAME}.* TO '${IREDADMIN_DB_USER}'@'${MYSQL_GRANT_HOST}' IDENTIFIED BY '${IREDADMIN_DB_PASSWD}';
|
||||
-- GRANT ALL ON ${IREDADMIN_DB_NAME}.* TO '${IREDADMIN_DB_USER}'@'${HOSTNAME}' IDENTIFIED BY '${IREDADMIN_DB_PASSWD}';
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
|
||||
# Generate .my.cnf file
|
||||
cat > /root/.my.cnf-${IREDADMIN_DB_USER} <<EOF
|
||||
[client]
|
||||
host=${MYSQL_SERVER_ADDRESS}
|
||||
port=${MYSQL_SERVER_PORT}
|
||||
user=${IREDADMIN_DB_USER}
|
||||
password="${IREDADMIN_DB_PASSWD}"
|
||||
EOF
|
||||
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
cp -f ${IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/SQL/iredadmin.pgsql ${PGSQL_DATA_DIR}/ >/dev/null
|
||||
chmod 0777 ${PGSQL_DATA_DIR}/iredadmin.pgsql >/dev/null
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
-- Create user
|
||||
CREATE USER ${IREDADMIN_DB_USER} WITH ENCRYPTED PASSWORD '${IREDADMIN_DB_PASSWD}' NOSUPERUSER NOCREATEDB NOCREATEROLE;
|
||||
|
||||
-- Create database
|
||||
CREATE DATABASE ${IREDADMIN_DB_NAME} WITH TEMPLATE template0 ENCODING 'UTF8';
|
||||
|
||||
-- Grant privilege
|
||||
ALTER DATABASE ${IREDADMIN_DB_NAME} OWNER TO ${IREDADMIN_DB_USER};
|
||||
EOF
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -U ${IREDADMIN_DB_USER} -d ${IREDADMIN_DB_NAME}" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
-- Import SQL template
|
||||
\i ${PGSQL_DATA_DIR}/iredadmin.pgsql;
|
||||
EOF
|
||||
rm -f ${PGSQL_DATA_DIR}/iredadmin.pgsql
|
||||
fi
|
||||
|
||||
echo 'export status_iredadmin_initialize_db="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredadmin_config() {
|
||||
ECHO_DEBUG "Configure iRedAdmin."
|
||||
|
||||
# Update iRedAdmin config file.
|
||||
ECHO_DEBUG "Configure general settings."
|
||||
perl -pi -e 's#^(webmaster =).*#${1} "$ENV{DOMAIN_ADMIN_EMAIL}"#' settings.py
|
||||
perl -pi -e 's#^(storage_base_directory =).*#${1} "$ENV{STORAGE_MAILBOX_DIR}"#' settings.py
|
||||
perl -pi -e 's#^(default_mta_transport =).*#${1} "$ENV{TRANSPORT}"#' settings.py
|
||||
|
||||
ECHO_DEBUG "Configure iredadmin database related settings."
|
||||
perl -pi -e 's#^(iredadmin_db_host =).*#${1} "$ENV{SQL_SERVER_ADDRESS}"#' settings.py
|
||||
perl -pi -e 's#^(iredadmin_db_port =).*#${1} "$ENV{SQL_SERVER_PORT}"#' settings.py
|
||||
perl -pi -e 's#^(iredadmin_db_name =).*#${1} "$ENV{IREDADMIN_DB_NAME}"#' settings.py
|
||||
perl -pi -e 's#^(iredadmin_db_user =).*#${1} "$ENV{IREDADMIN_DB_USER}"#' settings.py
|
||||
perl -pi -e 's#^(iredadmin_db_password =).*#${1} "$ENV{IREDADMIN_DB_PASSWD}"#' settings.py
|
||||
|
||||
# Backend related settings.
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
ECHO_DEBUG "Configure OpenLDAP backend related settings."
|
||||
perl -pi -e 's#^(ldap_uri =).*#${1} "ldap://$ENV{LDAP_SERVER_HOST}:$ENV{LDAP_SERVER_PORT}"#' settings.py
|
||||
perl -pi -e 's#^(ldap_basedn =).*#${1} "$ENV{LDAP_BASEDN}"#' settings.py
|
||||
perl -pi -e 's#^(ldap_domainadmin_dn =).*#${1} "$ENV{LDAP_ADMIN_BASEDN}"#' settings.py
|
||||
perl -pi -e 's#^(ldap_bind_dn =).*#${1} "$ENV{LDAP_ADMIN_DN}"#' settings.py
|
||||
perl -pi -e 's#^(ldap_bind_password =).*#${1} "$ENV{LDAP_ADMIN_PW}"#' settings.py
|
||||
|
||||
elif [ X"${BACKEND}" == X'MYSQL' -o X"${BACKEND}" == X'PGSQL' ]; then
|
||||
ECHO_DEBUG "Configure SQL mail accounts related settings."
|
||||
perl -pi -e 's#^(vmail_db_host =).*#${1} "$ENV{SQL_SERVER_ADDRESS}"#' settings.py
|
||||
perl -pi -e 's#^(vmail_db_port =).*#${1} "$ENV{SQL_SERVER_PORT}"#' settings.py
|
||||
perl -pi -e 's#^(vmail_db_name =).*#${1} "$ENV{VMAIL_DB_NAME}"#' settings.py
|
||||
perl -pi -e 's#^(vmail_db_user =).*#${1} "$ENV{VMAIL_DB_ADMIN_USER}"#' settings.py
|
||||
perl -pi -e 's#^(vmail_db_password =).*#${1} "$ENV{VMAIL_DB_ADMIN_PASSWD}"#' settings.py
|
||||
fi
|
||||
|
||||
# Disable Policyd/Cluebringer
|
||||
perl -pi -e 's#^(policyd_enabled =).*#${1} False#' settings.py
|
||||
|
||||
# Amavisd.
|
||||
ECHO_DEBUG "Configure Amavisd related settings."
|
||||
perl -pi -e 's#^(amavisd_db_host =).*#${1} "$ENV{SQL_SERVER_ADDRESS}"#' settings.py
|
||||
perl -pi -e 's#^(amavisd_db_port =).*#${1} "$ENV{SQL_SERVER_PORT}"#' settings.py
|
||||
perl -pi -e 's#^(amavisd_db_name =).*#${1} "$ENV{AMAVISD_DB_NAME}"#' settings.py
|
||||
perl -pi -e 's#^(amavisd_db_user =).*#${1} "$ENV{AMAVISD_DB_USER}"#' settings.py
|
||||
perl -pi -e 's#^(amavisd_db_password =).*#${1} "$ENV{AMAVISD_DB_PASSWD}"#' settings.py
|
||||
|
||||
perl -pi -e 's#^(amavisd_enable_logging =).*#${1} True#' settings.py
|
||||
perl -pi -e 's#^(amavisd_enable_quarantine =).*#${1} True#' settings.py
|
||||
perl -pi -e 's#^(amavisd_enable_policy_lookup=).*#${1} True#' settings.py
|
||||
perl -pi -e 's#^(amavisd_quarantine_port =).*#${1} "$ENV{AMAVISD_QUARANTINE_PORT}"#' settings.py
|
||||
|
||||
ECHO_DEBUG "Configure iRedAPD related settings."
|
||||
perl -pi -e 's#^(iredapd_enabled =).*#${1} True#' settings.py
|
||||
perl -pi -e 's#^(iredapd_db_host =).*#${1} "$ENV{SQL_SERVER_ADDRESS}"#' settings.py
|
||||
perl -pi -e 's#^(iredapd_db_port =).*#${1} "$ENV{SQL_SERVER_PORT}"#' settings.py
|
||||
perl -pi -e 's#^(iredapd_db_name =).*#${1} "$ENV{IREDAPD_DB_NAME}"#' settings.py
|
||||
perl -pi -e 's#^(iredapd_db_user =).*#${1} "$ENV{IREDAPD_DB_USER}"#' settings.py
|
||||
perl -pi -e 's#^(iredapd_db_password =).*#${1} "$ENV{IREDAPD_DB_PASSWD}"#' settings.py
|
||||
|
||||
echo "DEFAULT_PASSWORD_SCHEME = '${DEFAULT_PASSWORD_SCHEME}'" >> settings.py
|
||||
echo "mlmmjadmin_api_auth_token = '${MLMMJADMIN_API_AUTH_TOKEN}'" >> settings.py
|
||||
|
||||
if [ X"${USE_FAIL2BAN}" == X'YES' ]; then
|
||||
ECHO_DEBUG "Configure Fail2ban integration."
|
||||
|
||||
echo "fail2ban_enabled = True" >> settings.py
|
||||
echo "fail2ban_db_host = '${SQL_SERVER_ADDRESS}'" >> settings.py
|
||||
echo "fail2ban_db_port = '${SQL_SERVER_PORT}'" >> settings.py
|
||||
echo "fail2ban_db_name = '${FAIL2BAN_DB_NAME}'" >> settings.py
|
||||
echo "fail2ban_db_user = '${FAIL2BAN_DB_USER}'" >> settings.py
|
||||
echo "fail2ban_db_password = '${FAIL2BAN_DB_PASSWD}'" >> settings.py
|
||||
fi
|
||||
|
||||
# Add postfix alias for user: iredapd
|
||||
add_postfix_alias ${SYS_USER_IREDAPD} ${SYS_USER_ROOT}
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
iRedAdmin - official web-based admin panel:
|
||||
* Version: ${IREDADMIN_VERSION}
|
||||
* Root directory: ${IREDADMIN_HTTPD_ROOT}
|
||||
* Config file: ${IREDADMIN_HTTPD_ROOT}/settings.py
|
||||
* Web access:
|
||||
- URL: https://${HOSTNAME}/iredadmin/
|
||||
- Username: ${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}
|
||||
- Password: ${DOMAIN_ADMIN_PASSWD_PLAIN}
|
||||
* SQL database:
|
||||
- Database name: ${IREDADMIN_DB_NAME}
|
||||
- Username: ${IREDADMIN_DB_USER}
|
||||
- Password: ${IREDADMIN_DB_PASSWD}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_iredadmin_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredadmin_cron_setup()
|
||||
{
|
||||
cat >> ${CRON_FILE_ROOT} <<EOF
|
||||
# ${PROG_NAME}: Cleanup Amavisd database
|
||||
1 2 * * * ${CMD_PYTHON2} ${IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/tools/cleanup_amavisd_db.py >/dev/null
|
||||
|
||||
# iRedAdmin: Clean up sql database.
|
||||
1 * * * * ${CMD_PYTHON2} ${IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/tools/cleanup_db.py >/dev/null 2>&1
|
||||
|
||||
# iRedAdmin: Delete mailboxes on file system which belong to removed accounts.
|
||||
1 * * * * ${CMD_PYTHON2} ${IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/tools/delete_mailboxes.py
|
||||
EOF
|
||||
|
||||
# Disable cron jobs if we don't need to initialize database on this server.
|
||||
if [ X"${INITIALIZE_SQL_DATA}" != X'YES' ]; then
|
||||
perl -pi -e 's/(.*iredadmin.*tools.*cleanup_amavisd_db.py.*)/#${1}/g' ${CRON_FILE_ROOT}
|
||||
fi
|
||||
|
||||
echo 'export status_iredadmin_cron_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredadmin_rc_setup()
|
||||
{
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
# Fix path to uwsgi.
|
||||
perl -pi -e 's#/usr/sbin/uwsgi#$ENV{CMD_UWSGI}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/systemd/rhel.service
|
||||
# Disable plugins. They're all builtin.
|
||||
perl -pi -e 's/^(plugins.*)/#${1}/g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/uwsgi/rhel.ini
|
||||
fi
|
||||
|
||||
cp -f ${IREDADMIN_HTTPD_ROOT}/rc_scripts/systemd/rhel.service ${SYSTEMD_SERVICE_DIR}/iredadmin.service
|
||||
chmod 0644 ${SYSTEMD_SERVICE_DIR}/iredadmin.service
|
||||
|
||||
perl -pi -e 's#^(uwsgi-socket).*#${1} = $ENV{IREDADMIN_BIND_ADDRESS}:$ENV{IREDADMIN_LISTEN_PORT}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/uwsgi/rhel.ini
|
||||
perl -pi -e 's#^(chdir).*#${1} = $ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/uwsgi/rhel.ini
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ X"${DISTRO_CODENAME}" == X'focal' ]; then
|
||||
# Fix path to uwsgi.
|
||||
perl -pi -e 's#/usr/bin/uwsgi#$ENV{CMD_UWSGI}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/systemd/debian.service
|
||||
fi
|
||||
|
||||
perl -pi -e 's#^(uwsgi-socket).*#${1} = $ENV{IREDADMIN_BIND_ADDRESS}:$ENV{IREDADMIN_LISTEN_PORT}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/uwsgi/debian.ini
|
||||
perl -pi -e 's#^(chdir).*#${1} = $ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/uwsgi/debian.ini
|
||||
|
||||
cp -f ${IREDADMIN_HTTPD_ROOT}/rc_scripts/systemd/debian.service ${SYSTEMD_SERVICE_DIR}/iredadmin.service
|
||||
chmod 0644 ${SYSTEMD_SERVICE_DIR}/iredadmin.service
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
cp -f ${IREDADMIN_HTTPD_ROOT}/rc_scripts/iredadmin.freebsd ${DIR_RC_SCRIPTS}/iredadmin
|
||||
chmod 0755 ${DIR_RC_SCRIPTS}/iredadmin
|
||||
perl -pi -e 's#(.*)(/opt/www/iredadmin)(.*)#${1}$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}${3}#g' ${DIR_RC_SCRIPTS}/iredadmin
|
||||
|
||||
perl -pi -e 's#^(uwsgi-socket).*#${1} = $ENV{IREDADMIN_BIND_ADDRESS}:$ENV{IREDADMIN_LISTEN_PORT}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/uwsgi/freebsd.ini
|
||||
perl -pi -e 's#^(chdir).*#${1} = $ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/uwsgi/freebsd.ini
|
||||
|
||||
service_control enable 'iredadmin_enable' 'YES' >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
cp -f ${IREDADMIN_HTTPD_ROOT}/rc_scripts/iredadmin.openbsd ${DIR_RC_SCRIPTS}/iredadmin
|
||||
chmod 0755 ${DIR_RC_SCRIPTS}/iredadmin
|
||||
|
||||
perl -pi -e 's#^(uwsgi-socket).*#${1} = $ENV{IREDADMIN_BIND_ADDRESS}:$ENV{IREDADMIN_LISTEN_PORT}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/uwsgi/openbsd.ini
|
||||
perl -pi -e 's#^(chdir).*#${1} = $ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}#g' ${IREDADMIN_HTTPD_ROOT}/rc_scripts/uwsgi/openbsd.ini
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Make sure iredadmin starting after system startup."
|
||||
service_control enable iredadmin >> ${INSTALL_LOG} 2>&1
|
||||
export ENABLED_SERVICES="${ENABLED_SERVICES} iredadmin"
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
EOF
|
||||
|
||||
echo 'export status_iredadmin_rc_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredadmin_setup() {
|
||||
check_status_before_run iredadmin_install
|
||||
check_status_before_run iredadmin_web_config
|
||||
|
||||
if [ X"${INITIALIZE_SQL_DATA}" == X'YES' ]; then
|
||||
check_status_before_run iredadmin_initialize_db
|
||||
fi
|
||||
|
||||
check_status_before_run iredadmin_cron_setup
|
||||
check_status_before_run iredadmin_config
|
||||
check_status_before_run iredadmin_rc_setup
|
||||
|
||||
write_iredmail_kv "sql_user_${IREDADMIN_DB_USER}" "${IREDADMIN_DB_PASSWD}"
|
||||
echo 'export status_iredadmin_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
# Purpose: Install & config necessary packages for iRedAPD.
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
|
||||
iredapd_install()
|
||||
{
|
||||
ECHO_INFO "Configure iRedAPD (postfix policy daemon)."
|
||||
|
||||
# Extract source tarball.
|
||||
cd ${PKG_MISC_DIR}
|
||||
[ -d ${IREDAPD_PARENT_DIR} ] || mkdir -p ${IREDAPD_PARENT_DIR}
|
||||
extract_pkg ${IREDAPD_TARBALL} ${IREDAPD_PARENT_DIR}
|
||||
|
||||
ECHO_DEBUG "Configure iRedAPD."
|
||||
# Create symbol link.
|
||||
ln -s ${IREDAPD_ROOT_DIR} ${IREDAPD_ROOT_DIR_SYMBOL_LINK} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# Set file permission.
|
||||
chown -R ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${IREDAPD_ROOT_DIR}
|
||||
chmod -R 0500 ${IREDAPD_ROOT_DIR}
|
||||
|
||||
# Copy init rc script.
|
||||
if [ X"${USE_SYSTEMD}" == X'YES' ]; then
|
||||
ECHO_DEBUG "Create symbol link: ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/rc_scripts/iredapd.service -> ${SYSTEMD_SERVICE_DIR}/iredapd.service."
|
||||
cp -f ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/rc_scripts/iredapd.service ${SYSTEMD_SERVICE_DIR}/iredapd.service >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# To supress systemd warning.
|
||||
chmod 0644 ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/rc_scripts/iredapd.service ${SYSTEMD_SERVICE_DIR}/iredapd.service
|
||||
|
||||
systemctl daemon-reload >> ${INSTALL_LOG} 2>&1
|
||||
else
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
cp ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/rc_scripts/iredapd.rhel ${DIR_RC_SCRIPTS}/iredapd >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
cp ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/rc_scripts/iredapd.debian ${DIR_RC_SCRIPTS}/iredapd >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
cp ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/rc_scripts/iredapd.freebsd ${DIR_RC_SCRIPTS}/iredapd >> ${INSTALL_LOG} 2>&1
|
||||
service_control enable 'iredapd_enable' 'YES' >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
cp ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/rc_scripts/iredapd.openbsd ${DIR_RC_SCRIPTS}/iredapd >> ${INSTALL_LOG} 2>&1
|
||||
else
|
||||
cp ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/rc_scripts/iredapd.rhel ${DIR_RC_SCRIPTS}/iredapd >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
chmod 0755 ${DIR_RC_SCRIPTS}/iredapd >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Make iredapd starting after system startup."
|
||||
service_control enable iredapd >> ${INSTALL_LOG} 2>&1
|
||||
export ENABLED_SERVICES="${ENABLED_SERVICES} iredapd"
|
||||
|
||||
# Copy sample config file.
|
||||
cd ${IREDAPD_ROOT_DIR_SYMBOL_LINK}
|
||||
cp settings.py.sample settings.py
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} settings.py
|
||||
chmod -R 0400 settings.py
|
||||
|
||||
echo 'export status_iredapd_install="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredapd_initialize_db()
|
||||
{
|
||||
ECHO_DEBUG "Import iRedAPD database template."
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
${MYSQL_CLIENT_ROOT} <<EOF
|
||||
-- Create databases and user.
|
||||
CREATE DATABASE IF NOT EXISTS ${IREDAPD_DB_NAME} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
|
||||
-- Import SQL template.
|
||||
USE ${IREDAPD_DB_NAME};
|
||||
SOURCE ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/SQL/iredapd.mysql;
|
||||
GRANT ALL ON ${IREDAPD_DB_NAME}.* TO '${IREDAPD_DB_USER}'@'${MYSQL_GRANT_HOST}' IDENTIFIED BY '${IREDAPD_DB_PASSWD}';
|
||||
-- GRANT ALL ON ${IREDAPD_DB_NAME}.* TO '${IREDAPD_DB_USER}'@'${HOSTNAME}' IDENTIFIED BY '${IREDAPD_DB_PASSWD}';
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
-- Enable greylisting by default.
|
||||
SOURCE ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/SQL/enable_global_greylisting.sql;
|
||||
|
||||
-- Import greylisting whitelist domains.
|
||||
SOURCE ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/SQL/greylisting_whitelist_domains.sql;
|
||||
|
||||
-- Blacklist some rDNS names
|
||||
SOURCE ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/SQL/wblist_rdns.sql;
|
||||
EOF
|
||||
|
||||
# Generate .my.cnf file
|
||||
cat > /root/.my.cnf-${IREDAPD_DB_USER} <<EOF
|
||||
[client]
|
||||
host=${MYSQL_SERVER_ADDRESS}
|
||||
port=${MYSQL_SERVER_PORT}
|
||||
user=${IREDAPD_DB_USER}
|
||||
password="${IREDAPD_DB_PASSWD}"
|
||||
EOF
|
||||
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
mkdir ${PGSQL_DATA_DIR}/tmp 2>/dev/null
|
||||
cp ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/SQL/*sql ${PGSQL_DATA_DIR}/tmp/ >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0555 ${PGSQL_DATA_DIR}/tmp/*sql
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
-- Create user
|
||||
CREATE USER ${IREDAPD_DB_USER} WITH ENCRYPTED PASSWORD '${IREDAPD_DB_PASSWD}' NOSUPERUSER NOCREATEDB NOCREATEROLE;
|
||||
|
||||
-- Create database
|
||||
CREATE DATABASE ${IREDAPD_DB_NAME} WITH TEMPLATE template0 ENCODING 'UTF8';
|
||||
|
||||
ALTER DATABASE ${IREDAPD_DB_NAME} OWNER TO ${IREDAPD_DB_USER};
|
||||
EOF
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -U ${IREDAPD_DB_USER} -d ${IREDAPD_DB_NAME}" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
-- Import SQL template
|
||||
\i ${PGSQL_DATA_DIR}/tmp/iredapd.pgsql;
|
||||
|
||||
-- Enable greylisting by default.
|
||||
\i ${PGSQL_DATA_DIR}/tmp/enable_global_greylisting.sql;
|
||||
|
||||
-- Import greylisting whitelist domains.
|
||||
\i ${PGSQL_DATA_DIR}/tmp/greylisting_whitelist_domains.sql;
|
||||
|
||||
-- Blacklist some rDNS names
|
||||
\i ${PGSQL_DATA_DIR}/tmp/wblist_rdns.sql;
|
||||
|
||||
EOF
|
||||
|
||||
rm -rf ${PGSQL_DATA_DIR}/tmp >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
echo 'export status_iredapd_initialize_db="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredapd_config()
|
||||
{
|
||||
perl -pi -e 's#^(listen_address).*#${1} = "$ENV{IREDAPD_BIND_HOST}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(listen_port).*#${1} = "$ENV{IREDAPD_LISTEN_PORT}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(run_as_user).*#${1} = "$ENV{SYS_USER_IREDAPD}"#' ${IREDAPD_CONF}
|
||||
|
||||
# SRS
|
||||
perl -pi -e 's#^(srs_forward_port).*#${1} = "$ENV{IREDAPD_SRS_FORWARD_PORT}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(srs_reverse_port).*#${1} = "$ENV{IREDAPD_SRS_REVERSE_PORT}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(srs_domain).*#${1} = "$ENV{HOSTNAME}"#' ${IREDAPD_CONF}
|
||||
|
||||
_srs_secret="$(${RANDOM_STRING})"
|
||||
perl -pi -e 's#^(srs_secrets).*#${1} = ["$ENV{_srs_secret}"]#' ${IREDAPD_CONF}
|
||||
|
||||
# Log
|
||||
perl -pi -e 's#^(log_level).*#${1} = "info"#' ${IREDAPD_CONF}
|
||||
|
||||
# Create log directory and log file
|
||||
[ -d ${IREDAPD_LOG_DIR} ] || mkdir -p ${IREDAPD_LOG_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
touch ${IREDAPD_LOG_FILE} >> ${INSTALL_LOG} 2>&1
|
||||
chown -R ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${IREDAPD_LOG_DIR} ${IREDAPD_LOG_FILE} >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0750 ${IREDAPD_LOG_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0640 ${IREDAPD_LOG_FILE} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# Backend.
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && perl -pi -e 's#^(backend).*#${1} = "ldap"#' ${IREDAPD_CONF}
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && perl -pi -e 's#^(backend).*#${1} = "mysql"#' ${IREDAPD_CONF}
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && perl -pi -e 's#^(backend).*#${1} = "pgsql"#' ${IREDAPD_CONF}
|
||||
|
||||
# Backend related parameters.
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
perl -pi -e 's#^(ldap_uri).*#${1} = "ldap://$ENV{LDAP_SERVER_HOST}:$ENV{LDAP_SERVER_PORT}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(ldap_binddn).*#${1} = "$ENV{LDAP_BINDDN}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(ldap_bindpw).*#${1} = "$ENV{LDAP_BINDPW}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(ldap_basedn).*#${1} = "$ENV{LDAP_BASEDN}"#' ${IREDAPD_CONF}
|
||||
|
||||
perl -pi -e 's#^(plugins).*#${1} = ["reject_null_sender", "wblist_rdns", "reject_sender_login_mismatch", "greylisting", "throttle", "amavisd_wblist", "ldap_maillist_access_policy"]#' ${IREDAPD_CONF}
|
||||
|
||||
elif [ X"${BACKEND}" == X'MYSQL' -o X"${BACKEND}" == X'PGSQL' ]; then
|
||||
perl -pi -e 's#^(vmail_db_server).*#${1} = "$ENV{SQL_SERVER_ADDRESS}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(vmail_db_port).*#${1} = "$ENV{SQL_SERVER_PORT}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(vmail_db_name).*#${1} = "$ENV{VMAIL_DB_NAME}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(vmail_db_user).*#${1} = "$ENV{VMAIL_DB_BIND_USER}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(vmail_db_password).*#${1} = "$ENV{VMAIL_DB_BIND_PASSWD}"#' ${IREDAPD_CONF}
|
||||
|
||||
perl -pi -e 's#^(plugins).*#${1} = ["reject_null_sender", "wblist_rdns", "reject_sender_login_mismatch", "greylisting", "throttle", "amavisd_wblist", "sql_alias_access_policy"]#' ${IREDAPD_CONF}
|
||||
fi
|
||||
|
||||
# Amavisd database
|
||||
perl -pi -e 's#^(amavisd_db_server).*#${1} = "$ENV{SQL_SERVER_ADDRESS}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(amavisd_db_port).*#${1} = "$ENV{SQL_SERVER_PORT}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(amavisd_db_name).*#${1} = "$ENV{AMAVISD_DB_NAME}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(amavisd_db_user).*#${1} = "$ENV{AMAVISD_DB_USER}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(amavisd_db_password).*#${1} = "$ENV{AMAVISD_DB_PASSWD}"#' ${IREDAPD_CONF}
|
||||
|
||||
# iRedAdmin database
|
||||
perl -pi -e 's#^(iredadmin_db_server).*#${1} = "$ENV{SQL_SERVER_ADDRESS}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(iredadmin_db_port).*#${1} = "$ENV{SQL_SERVER_PORT}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(iredadmin_db_name).*#${1} = "$ENV{IREDADMIN_DB_NAME}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(iredadmin_db_user).*#${1} = "$ENV{IREDADMIN_DB_USER}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(iredadmin_db_password).*#${1} = "$ENV{IREDADMIN_DB_PASSWD}"#' ${IREDAPD_CONF}
|
||||
|
||||
# iRedAPD database
|
||||
perl -pi -e 's#^(iredapd_db_server).*#${1} = "$ENV{SQL_SERVER_ADDRESS}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(iredapd_db_port).*#${1} = "$ENV{SQL_SERVER_PORT}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(iredapd_db_name).*#${1} = "$ENV{IREDAPD_DB_NAME}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(iredapd_db_user).*#${1} = "$ENV{IREDAPD_DB_USER}"#' ${IREDAPD_CONF}
|
||||
perl -pi -e 's#^(iredapd_db_password).*#${1} = "$ENV{IREDAPD_DB_PASSWD}"#' ${IREDAPD_CONF}
|
||||
|
||||
# mlmmjadmin integration.
|
||||
perl -pi -e 's#^(mlmmjadmin_api_auth_token).*#${1} = "$ENV{MLMMJADMIN_API_AUTH_TOKEN}"#' ${IREDAPD_CONF}
|
||||
|
||||
# Use pymysql.
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
echo "SQL_DB_DRIVER = 'pymysql'" >> ${IREDAPD_CONF}
|
||||
fi
|
||||
|
||||
if [ X"${LOCAL_ADDRESS}" != X'127.0.0.1' ]; then
|
||||
echo "MYNETWORKS = ['${LOCAL_ADDRESS}']" >> ${IREDAPD_CONF}
|
||||
fi
|
||||
|
||||
# FreeBSD uses different path for syslog socket.
|
||||
if [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
echo "SYSLOG_SERVER = '${SYSLOG_SOCKET}'" >> ${IREDAPD_CONF}
|
||||
fi
|
||||
|
||||
echo 'export status_iredapd_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredapd_syslog_setup()
|
||||
{
|
||||
ECHO_DEBUG "Generate modular syslog and log rotate config files for iRedAPD."
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
cp ${SAMPLE_DIR}/rsyslog.d/1-iredmail-iredapd.conf ${SYSLOG_CONF_DIR}
|
||||
|
||||
perl -pi -e 's#PH_IREDMAIL_SYSLOG_FACILITY#$ENV{IREDMAIL_SYSLOG_FACILITY}#g' ${SYSLOG_CONF_DIR}/1-iredmail-iredapd.conf
|
||||
perl -pi -e 's#PH_IREDAPD_LOG_FILE#$ENV{IREDAPD_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/1-iredmail-iredapd.conf
|
||||
|
||||
#
|
||||
# modular logrotate config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/logrotate/iredapd ${IREDAPD_LOGROTATE_FILE}
|
||||
chmod 0644 ${IREDAPD_LOGROTATE_FILE}
|
||||
|
||||
perl -pi -e 's#PH_IREDAPD_LOG_DIR#$ENV{IREDAPD_LOG_DIR}#g' ${IREDAPD_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYSLOG_POSTROTATE_CMD#$ENV{SYSLOG_POSTROTATE_CMD}#g' ${IREDAPD_LOGROTATE_FILE}
|
||||
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/syslog.d/iredapd.conf ${SYSLOG_CONF_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_IREDMAIL_SYSLOG_FACILITY#$ENV{IREDMAIL_SYSLOG_FACILITY}#g' ${SYSLOG_CONF_DIR}/iredapd.conf
|
||||
perl -pi -e 's#PH_IREDAPD_LOG_FILE#$ENV{IREDAPD_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/iredapd.conf
|
||||
|
||||
#
|
||||
# modular newsyslog (log rotate) config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/newsyslog.conf.d/iredapd ${IREDAPD_LOGROTATE_FILE}
|
||||
|
||||
perl -pi -e 's#PH_IREDAPD_LOG_FILE#$ENV{IREDAPD_LOG_FILE}#g' ${IREDAPD_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_IREDAPD_PID_FILE#$ENV{IREDAPD_PID_FILE}#g' ${IREDAPD_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYS_USER_SYSLOG#$ENV{SYS_USER_SYSLOG}#g' ${IREDAPD_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYS_GROUP_SYSLOG#$ENV{SYS_GROUP_SYSLOG}#g' ${IREDAPD_LOGROTATE_FILE}
|
||||
|
||||
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
if ! grep "${IREDAPD_LOG_FILE}" ${SYSLOG_CONF} &>/dev/null; then
|
||||
# '!!' means abort further evaluation after first match
|
||||
echo '' >> ${SYSLOG_CONF}
|
||||
echo '!!iredapd' >> ${SYSLOG_CONF}
|
||||
echo "${IREDMAIL_SYSLOG_FACILITY}.* ${IREDAPD_LOG_FILE}" >> ${SYSLOG_CONF}
|
||||
fi
|
||||
|
||||
if ! grep "${IREDAPD_LOG_FILE}" /etc/newsyslog.conf &>/dev/null; then
|
||||
cat >> /etc/newsyslog.conf <<EOF
|
||||
${IREDAPD_LOG_FILE} ${SYS_USER_IREDAPD}:${SYS_GROUP_IREDAPD} 600 7 * 24 Z
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
echo 'export status_iredapd_syslog_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
|
||||
iredapd_cron_setup()
|
||||
{
|
||||
# Setup cron job to clean up expired throttle tracking records.
|
||||
# Note: use ${IREDAPD_ROOT_DIR_SYMBOL_LINK} instead of ${IREDAPD_ROOT_DIR}
|
||||
# here, so that we don't need to change cron job after upgrading iRedAPD.
|
||||
cat >> ${CRON_FILE_ROOT} <<EOF
|
||||
# iRedAPD: Clean up expired tracking records hourly.
|
||||
1 * * * * ${CMD_PYTHON3} ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/tools/cleanup_db.py >/dev/null
|
||||
|
||||
# iRedAPD: Convert SPF DNS record of specified domain names to IP
|
||||
# addresses/networks hourly.
|
||||
2 * * * * ${CMD_PYTHON3} ${IREDAPD_ROOT_DIR_SYMBOL_LINK}/tools/spf_to_greylist_whitelists.py >/dev/null
|
||||
|
||||
EOF
|
||||
|
||||
# Disable cron jobs if we don't need to initialize database on this server.
|
||||
if [ X"${INITIALIZE_SQL_DATA}" != X'YES' ]; then
|
||||
perl -pi -e 's/(.*iredapd.*tools.*cleanup_db.py.*)/#${1}/g' ${CRON_FILE_ROOT}
|
||||
perl -pi -e 's/(.*iredapd.*tools.*spf_to_greylist_whitelists.py.*)/#${1}/g' ${CRON_FILE_ROOT}
|
||||
fi
|
||||
|
||||
echo 'export status_iredapd_cron_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
iredapd_setup()
|
||||
{
|
||||
check_status_before_run iredapd_install
|
||||
|
||||
if [ X"${INITIALIZE_SQL_DATA}" == X'YES' ]; then
|
||||
check_status_before_run iredapd_initialize_db
|
||||
fi
|
||||
|
||||
check_status_before_run iredapd_cron_setup
|
||||
check_status_before_run iredapd_config
|
||||
check_status_before_run iredapd_syslog_setup
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
iRedAPD - Postfix Policy Server:
|
||||
* Version: ${IREDAPD_VERSION}
|
||||
* Listen address: ${IREDAPD_BIND_HOST}, port: ${IREDAPD_LISTEN_PORT}
|
||||
* SQL database account:
|
||||
- Database name: ${IREDAPD_DB_NAME}
|
||||
- Username: ${IREDAPD_DB_USER}
|
||||
- Password: ${IREDAPD_DB_PASSWD}
|
||||
* Configuration file:
|
||||
- ${IREDAPD_CONF}
|
||||
* Related files:
|
||||
- ${IREDAPD_ROOT_DIR}
|
||||
- ${IREDAPD_ROOT_DIR_SYMBOL_LINK} (symbol link to ${IREDAPD_ROOT_DIR}
|
||||
|
||||
EOF
|
||||
|
||||
write_iredmail_kv "sql_user_${IREDAPD_DB_USER}" "${IREDAPD_DB_PASSWD}"
|
||||
write_iredmail_kv iredapd_srs_secret "${IREDAPD_SRS_SECRET}"
|
||||
echo 'export status_iredapd_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
|
||||
ldap_generate_populate_ldif()
|
||||
{
|
||||
ECHO_DEBUG "Generate LDIF file used to populate LDAP tree."
|
||||
|
||||
export LDAP_SUFFIX_MAJOR="$(echo ${LDAP_SUFFIX} | sed -e 's/dc=//g' -e 's/,/./g' | awk -F'.' '{print $1}')"
|
||||
|
||||
cat > ${LDAP_INIT_LDIF} <<EOF
|
||||
dn: ${LDAP_SUFFIX}
|
||||
objectclass: dcObject
|
||||
objectclass: organization
|
||||
dc: ${LDAP_SUFFIX_MAJOR}
|
||||
o: ${LDAP_SUFFIX_MAJOR}
|
||||
|
||||
dn: ${LDAP_BINDDN}
|
||||
objectClass: person
|
||||
objectClass: shadowAccount
|
||||
objectClass: top
|
||||
cn: ${SYS_USER_VMAIL}
|
||||
sn: ${SYS_USER_VMAIL}
|
||||
uid: ${SYS_USER_VMAIL}
|
||||
userPassword: $(generate_password_hash SSHA "${LDAP_BINDPW}")
|
||||
|
||||
dn: ${LDAP_ADMIN_DN}
|
||||
objectClass: person
|
||||
objectClass: shadowAccount
|
||||
objectClass: top
|
||||
cn: ${VMAIL_DB_ADMIN_USER}
|
||||
sn: ${VMAIL_DB_ADMIN_USER}
|
||||
uid: ${VMAIL_DB_ADMIN_USER}
|
||||
userPassword: $(generate_password_hash SSHA "${LDAP_ADMIN_PW}")
|
||||
|
||||
dn: ${LDAP_BASEDN}
|
||||
objectClass: Organization
|
||||
o: ${LDAP_BASEDN_NAME}
|
||||
|
||||
dn: ${LDAP_ADMIN_BASEDN}
|
||||
objectClass: Organization
|
||||
o: ${LDAP_ATTR_DOMAINADMIN_DN_NAME}
|
||||
|
||||
dn: domainName=${FIRST_DOMAIN},${LDAP_BASEDN}
|
||||
objectClass: mailDomain
|
||||
domainName: ${FIRST_DOMAIN}
|
||||
mtaTransport: ${TRANSPORT}
|
||||
accountStatus: active
|
||||
accountSetting: minPasswordLength:8
|
||||
accountSetting: defaultQuota:1024
|
||||
enabledService: mail
|
||||
|
||||
dn: ou=Users,domainName=${FIRST_DOMAIN},${LDAP_BASEDN}
|
||||
objectClass: organizationalUnit
|
||||
objectClass: top
|
||||
ou: Users
|
||||
|
||||
dn: ou=Groups,domainName=${FIRST_DOMAIN},${LDAP_BASEDN}
|
||||
objectClass: organizationalUnit
|
||||
objectClass: top
|
||||
ou: Groups
|
||||
|
||||
dn: ou=Aliases,domainName=${FIRST_DOMAIN},${LDAP_BASEDN}
|
||||
objectClass: organizationalUnit
|
||||
objectClass: top
|
||||
ou: Aliases
|
||||
|
||||
dn: ou=Externals,domainName=${FIRST_DOMAIN},${LDAP_BASEDN}
|
||||
objectClass: organizationalUnit
|
||||
objectClass: top
|
||||
ou: Externals
|
||||
|
||||
dn: mail=${DOMAIN_ADMIN_EMAIL},${LDAP_ATTR_GROUP_RDN}=${LDAP_ATTR_GROUP_USERS},${LDAP_ATTR_DOMAIN_RDN}=${FIRST_DOMAIN},${LDAP_BASEDN}
|
||||
objectClass: inetOrgPerson
|
||||
objectClass: shadowAccount
|
||||
objectClass: amavisAccount
|
||||
objectClass: mailUser
|
||||
objectClass: top
|
||||
cn: ${DOMAIN_ADMIN_NAME}
|
||||
sn: ${DOMAIN_ADMIN_NAME}
|
||||
uid: ${DOMAIN_ADMIN_NAME}
|
||||
givenName: ${DOMAIN_ADMIN_NAME}
|
||||
mail: ${DOMAIN_ADMIN_EMAIL}
|
||||
accountStatus: active
|
||||
storageBaseDirectory: ${STORAGE_BASE_DIR}
|
||||
mailMessageStore: ${STORAGE_NODE}/${DOMAIN_ADMIN_MAILDIR_HASH_PART}
|
||||
homeDirectory: ${DOMAIN_ADMIN_MAILDIR_FULL_PATH}
|
||||
mailQuota: 104857600
|
||||
userPassword: ${DOMAIN_ADMIN_PASSWD_HASH}
|
||||
enabledService: mail
|
||||
enabledService: internal
|
||||
enabledService: doveadm
|
||||
enabledService: smtp
|
||||
enabledService: smtpsecured
|
||||
enabledService: smtptls
|
||||
enabledService: pop3
|
||||
enabledService: pop3secured
|
||||
enabledService: pop3tls
|
||||
enabledService: imap
|
||||
enabledService: imapsecured
|
||||
enabledService: imaptls
|
||||
enabledService: deliver
|
||||
enabledService: lda
|
||||
enabledService: lmtp
|
||||
enabledService: forward
|
||||
enabledService: senderbcc
|
||||
enabledService: recipientbcc
|
||||
enabledService: managesieve
|
||||
enabledService: managesievesecured
|
||||
enabledService: sieve
|
||||
enabledService: sievesecured
|
||||
enabledService: sievetls
|
||||
enabledService: displayedInGlobalAddressBook
|
||||
enabledService: shadowaddress
|
||||
enabledService: lib-storage
|
||||
enabledService: indexer-worker
|
||||
enabledService: dsync
|
||||
enabledService: domainadmin
|
||||
enabledService: sogo
|
||||
domainGlobalAdmin: yes
|
||||
EOF
|
||||
}
|
||||
|
||||
ldap_server_config()
|
||||
{
|
||||
ldap_generate_populate_ldif
|
||||
|
||||
# Always use SSHA for root dn so that ldap server can verify the password.
|
||||
# SSHA512, BCRYPT is not supported by OpenLDAP.
|
||||
export LDAP_ROOTPW_SSHA="$(generate_password_hash SSHA ${LDAP_ROOTPW})"
|
||||
|
||||
. ${FUNCTIONS_DIR}/openldap.sh
|
||||
|
||||
check_status_before_run openldap_config && \
|
||||
check_status_before_run openldap_data_initialize
|
||||
}
|
||||
|
||||
ldap_server_cron_backup()
|
||||
{
|
||||
ldap_backup_script="${BACKUP_DIR}/${BACKUP_SCRIPT_LDAP_NAME}"
|
||||
|
||||
ECHO_INFO "Setup daily cron job to backup LDAP data with ${ldap_backup_script}"
|
||||
|
||||
[ ! -d ${BACKUP_DIR} ] && mkdir -p ${BACKUP_DIR} &>/dev/null
|
||||
|
||||
backup_file ${ldap_backup_script}
|
||||
|
||||
cp ${TOOLS_DIR}/${BACKUP_SCRIPT_LDAP_NAME} ${ldap_backup_script}
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${ldap_backup_script}
|
||||
chmod 0500 ${ldap_backup_script}
|
||||
|
||||
perl -pi -e 's#^(export BACKUP_ROOTDIR=).*#${1}"$ENV{BACKUP_DIR}"#' ${ldap_backup_script}
|
||||
perl -pi -e 's#^(export MYSQL_USER=).*#${1}"$ENV{IREDADMIN_DB_USER}"#' ${ldap_backup_script}
|
||||
perl -pi -e 's#^(export MYSQL_PASSWD=).*#${1}"$ENV{IREDADMIN_DB_PASSWD}"#' ${ldap_backup_script}
|
||||
|
||||
# Add cron job
|
||||
cat >> ${CRON_FILE_ROOT} <<EOF
|
||||
# ${PROG_NAME}: Backup LDAP data (at 03:00 AM)
|
||||
0 3 * * * ${SHELL_BASH} ${ldap_backup_script}
|
||||
|
||||
EOF
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Backup LDAP data:
|
||||
* Script: ${ldap_backup_script}
|
||||
* See also:
|
||||
# crontab -l -u ${SYS_USER_ROOT}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_ldap_server_cron_backup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------
|
||||
# ------------------ mlmmj & mlmmjadmin ----------------
|
||||
# -------------------------------------------------------
|
||||
|
||||
mlmmj_config()
|
||||
{
|
||||
ECHO_INFO "Configure mlmmj (mailing list manager)."
|
||||
|
||||
ECHO_DEBUG "Generate script: ${CMD_MLMMJ_AMIME_RECEIVE}."
|
||||
cp -f ${SAMPLE_DIR}/mlmmj/mlmmj-amime-receive ${CMD_MLMMJ_AMIME_RECEIVE}
|
||||
chown ${SYS_USER_MLMMJ}:${SYS_GROUP_MLMMJ} ${CMD_MLMMJ_AMIME_RECEIVE}
|
||||
chmod 0550 ${CMD_MLMMJ_AMIME_RECEIVE}
|
||||
|
||||
perl -pi -e 's#PH_CMD_MLMMJ_RECEIVE#$ENV{CMD_MLMMJ_RECEIVE}#g' ${CMD_MLMMJ_AMIME_RECEIVE}
|
||||
perl -pi -e 's#PH_CMD_ALTERMIME#$ENV{CMD_ALTERMIME}#g' ${CMD_MLMMJ_AMIME_RECEIVE}
|
||||
|
||||
ECHO_DEBUG "Create required directories: ${MLMMJ_SPOOL_DIR}, ${MLMMJ_ARCHIVE_DIR}."
|
||||
mkdir -p ${MLMMJ_SPOOL_DIR} ${MLMMJ_ARCHIVE_DIR}
|
||||
chown ${SYS_USER_MLMMJ}:${SYS_GROUP_MLMMJ} ${MLMMJ_SPOOL_DIR} ${MLMMJ_ARCHIVE_DIR}
|
||||
chmod 0700 ${MLMMJ_SPOOL_DIR} ${MLMMJ_ARCHIVE_DIR}
|
||||
|
||||
ECHO_DEBUG "Setting cron job for mlmmj maintenance."
|
||||
cat >> ${CRON_FILE_MLMMJ} <<EOF
|
||||
${CONF_MSG}
|
||||
# mlmmj: mailing list maintenance
|
||||
10 */2 * * * find ${MLMMJ_SPOOL_DIR} -mindepth 1 -maxdepth 1 -type d -exec ${CMD_MLMMJ_MAINTD} -F -d {} \\;
|
||||
|
||||
EOF
|
||||
|
||||
chmod 0600 ${CRON_FILE_MLMMJ}
|
||||
ECHO_DEBUG "Enable mlmmj transport in postfix: ${POSTFIX_FILE_MAIN_CF}."
|
||||
cat ${SAMPLE_DIR}/postfix/main.cf.mlmmj >> ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
echo 'export status_mlmmj_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
mlmmjadmin_config()
|
||||
{
|
||||
ECHO_DEBUG "Configure mlmmjadmin (RESTful API server used to manage mlmmj)."
|
||||
|
||||
# Extract source tarball.
|
||||
cd ${PKG_MISC_DIR}
|
||||
[ -d ${MLMMJADMIN_PARENT_DIR} ] || mkdir -p ${MLMMJADMIN_PARENT_DIR}
|
||||
extract_pkg ${MLMMJADMIN_TARBALL} ${MLMMJADMIN_PARENT_DIR}
|
||||
|
||||
# Set file permission.
|
||||
chown -R ${SYS_USER_MLMMJ}:${SYS_GROUP_MLMMJ} ${MLMMJADMIN_ROOT_DIR}
|
||||
chmod -R 0755 ${MLMMJADMIN_ROOT_DIR}
|
||||
|
||||
# Create symbol link.
|
||||
ln -s ${MLMMJADMIN_ROOT_DIR} ${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# Generate main config file
|
||||
cp ${SAMPLE_DIR}/mlmmj/mlmmjadmin.settings.py ${MLMMJADMIN_CONF}
|
||||
chown -R ${SYS_USER_MLMMJ}:${SYS_GROUP_MLMMJ} ${MLMMJADMIN_CONF}
|
||||
chmod 0400 ${MLMMJADMIN_CONF}
|
||||
|
||||
perl -pi -e 's#PH_MLMMJADMIN_BIND_HOST#$ENV{MLMMJADMIN_BIND_HOST}#g' ${MLMMJADMIN_CONF}
|
||||
perl -pi -e 's#PH_MLMMJADMIN_LISTEN_PORT#$ENV{MLMMJADMIN_LISTEN_PORT}#g' ${MLMMJADMIN_CONF}
|
||||
perl -pi -e 's#PH_SYS_USER_MLMMJ#$ENV{SYS_USER_MLMMJ}#g' ${MLMMJADMIN_CONF}
|
||||
perl -pi -e 's#PH_SYS_GROUP_MLMMJ#$ENV{SYS_GROUP_MLMMJ}#g' ${MLMMJADMIN_CONF}
|
||||
perl -pi -e 's#PH_MLMMJADMIN_PID_FILE#$ENV{MLMMJADMIN_PID_FILE}#g' ${MLMMJADMIN_CONF}
|
||||
perl -pi -e 's#PH_MLMMJADMIN_API_AUTH_TOKEN#$ENV{MLMMJADMIN_API_AUTH_TOKEN}#g' ${MLMMJADMIN_CONF}
|
||||
perl -pi -e 's#PH_MLMMJ_SPOOL_DIR#$ENV{MLMMJ_SPOOL_DIR}#g' ${MLMMJADMIN_CONF}
|
||||
perl -pi -e 's#PH_MLMMJ_ARCHIVE_DIR#$ENV{MLMMJ_ARCHIVE_DIR}#g' ${MLMMJADMIN_CONF}
|
||||
perl -pi -e 's#PH_MLMMJ_SKEL_DIR#$ENV{MLMMJ_SKEL_DIR}#g' ${MLMMJADMIN_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_MLMMJ_PORT#$ENV{AMAVISD_MLMMJ_PORT}#g' ${MLMMJADMIN_CONF}
|
||||
|
||||
perl -pi -e 's#^(backend_api =)(.*)#${1} "bk_none"#g' ${MLMMJADMIN_CONF}
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
perl -pi -e 's#^(backend_cli =)(.*)#${1} "bk_iredmail_ldap"#g' ${MLMMJADMIN_CONF}
|
||||
|
||||
cat >> ${MLMMJADMIN_CONF} <<EOF
|
||||
# LDAP server info. Required by backend 'bk_iredmail_ldap'.
|
||||
iredmail_ldap_uri = 'ldap://${LDAP_SERVER_HOST}:${LDAP_SERVER_PORT}'
|
||||
iredmail_ldap_basedn = '${LDAP_BASEDN}'
|
||||
iredmail_ldap_bind_dn = '${LDAP_ADMIN_DN}'
|
||||
iredmail_ldap_bind_password = '${LDAP_ADMIN_PW}'
|
||||
EOF
|
||||
elif [ X"${BACKEND}" == X'MYSQL' -o X"${BACKEND}" == X'PGSQL' ]; then
|
||||
perl -pi -e 's#^(backend_cli =)(.*)#${1} "bk_iredmail_sql"#g' ${MLMMJADMIN_CONF}
|
||||
|
||||
cat >> ${MLMMJADMIN_CONF} <<EOF
|
||||
# SQL database which stores meta data of mailing list accounts.
|
||||
# Required by backend 'bk_iredmail_sql'.
|
||||
EOF
|
||||
|
||||
if [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
echo 'iredmail_sql_db_type = "mysql"' >> ${MLMMJADMIN_CONF}
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
echo 'iredmail_sql_db_type = "pgsql"' >> ${MLMMJADMIN_CONF}
|
||||
fi
|
||||
|
||||
cat >> ${MLMMJADMIN_CONF} <<EOF
|
||||
iredmail_sql_db_server = '${SQL_SERVER_ADDRESS}'
|
||||
iredmail_sql_db_port = ${SQL_SERVER_PORT}
|
||||
iredmail_sql_db_name = '${VMAIL_DB_NAME}'
|
||||
iredmail_sql_db_user = '${VMAIL_DB_ADMIN_USER}'
|
||||
iredmail_sql_db_password = '${VMAIL_DB_ADMIN_PASSWD}'
|
||||
EOF
|
||||
fi
|
||||
|
||||
# FreeBSD uses different path for syslog socket.
|
||||
if [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
echo "SYSLOG_SERVER = '${SYSLOG_SOCKET}'" >> ${MLMMJADMIN_CONF}
|
||||
fi
|
||||
|
||||
# Create log directory and empty log file
|
||||
mkdir -p ${MLMMJADMIN_LOG_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
touch ${MLMMJADMIN_LOG_FILE} >> ${INSTALL_LOG} 2>&1
|
||||
chown ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${MLMMJADMIN_LOG_DIR} ${MLMMJADMIN_LOG_FILE} >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0640 ${MLMMJADMIN_LOG_DIR} ${MLMMJADMIN_LOG_FILE} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Generate modular syslog and log rotate config files for mlmmjadmin."
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
cp ${SAMPLE_DIR}/rsyslog.d/1-iredmail-mlmmjadmin.conf ${SYSLOG_CONF_DIR}
|
||||
|
||||
perl -pi -e 's#PH_IREDMAIL_SYSLOG_FACILITY#$ENV{IREDMAIL_SYSLOG_FACILITY}#g' ${SYSLOG_CONF_DIR}/1-iredmail-mlmmjadmin.conf
|
||||
perl -pi -e 's#PH_MLMMJADMIN_LOG_FILE#$ENV{MLMMJADMIN_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/1-iredmail-mlmmjadmin.conf
|
||||
|
||||
#
|
||||
# modular logrotate config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/logrotate/mlmmjadmin ${MLMMJADMIN_LOGROTATE_FILE}
|
||||
chmod 0644 ${MLMMJADMIN_LOGROTATE_FILE}
|
||||
|
||||
perl -pi -e 's#PH_MLMMJADMIN_LOG_DIR#$ENV{MLMMJADMIN_LOG_DIR}#g' ${MLMMJADMIN_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYSLOG_POSTROTATE_CMD#$ENV{SYSLOG_POSTROTATE_CMD}#g' ${MLMMJADMIN_LOGROTATE_FILE}
|
||||
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/syslog.d/mlmmjadmin.conf ${SYSLOG_CONF_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_IREDMAIL_SYSLOG_FACILITY#$ENV{IREDMAIL_SYSLOG_FACILITY}#g' ${SYSLOG_CONF_DIR}/mlmmjadmin.conf
|
||||
perl -pi -e 's#PH_MLMMJADMIN_LOG_FILE#$ENV{MLMMJADMIN_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/mlmmjadmin.conf
|
||||
|
||||
#
|
||||
# modular newsyslog (log rotate) config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/newsyslog.conf.d/mlmmjadmin ${MLMMJADMIN_LOGROTATE_FILE}
|
||||
|
||||
perl -pi -e 's#PH_MLMMJADMIN_LOG_FILE#$ENV{MLMMJADMIN_LOG_FILE}#g' ${MLMMJADMIN_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_MLMMJADMIN_PID_FILE#$ENV{MLMMJADMIN_PID_FILE}#g' ${MLMMJADMIN_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYS_USER_SYSLOG#$ENV{SYS_USER_SYSLOG}#g' ${MLMMJADMIN_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYS_GROUP_SYSLOG#$ENV{SYS_GROUP_SYSLOG}#g' ${MLMMJADMIN_LOGROTATE_FILE}
|
||||
|
||||
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
|
||||
if ! grep "${MLMMJADMIN_LOG_FILE}" ${SYSLOG_CONF} &>/dev/null; then
|
||||
# '!!' means abort further evaluation after first match
|
||||
echo '' >> ${SYSLOG_CONF}
|
||||
echo '!!mlmmjadmin' >> ${SYSLOG_CONF}
|
||||
echo "${IREDMAIL_SYSLOG_FACILITY}.* ${MLMMJADMIN_LOG_FILE}" >> ${SYSLOG_CONF}
|
||||
fi
|
||||
|
||||
if ! grep "${MLMMJADMIN_LOG_FILE}" /etc/newsyslog.conf &>/dev/null; then
|
||||
cat >> /etc/newsyslog.conf <<EOF
|
||||
${MLMMJADMIN_LOG_FILE} ${SYS_USER_MLMMJ}:${SYS_GROUP_MLMMJ} 600 7 * 24 Z
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy rc script file
|
||||
if [ X"${USE_SYSTEMD}" == X'YES' ]; then
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
perl -pi -e 's#(^plugins.*)python,(.*)#${1}$ENV{UWSGI_PY3_PLUGIN_NAME},${2}#g' ${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/rc_scripts/uwsgi/rhel.ini
|
||||
elif [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
# Fix path to uwsgi.
|
||||
perl -pi -e 's#/usr/sbin/uwsgi#$ENV{CMD_UWSGI_PY3}#g' ${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/rc_scripts/systemd/rhel.service
|
||||
# Disable plugins. They're all builtin.
|
||||
perl -pi -e 's/^(plugins.*)/#${1}/g' ${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/rc_scripts/uwsgi/rhel.ini
|
||||
fi
|
||||
|
||||
cp -f ${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/rc_scripts/systemd/rhel.service ${SYSTEMD_SERVICE_DIR}/${MLMMJADMIN_RC_SCRIPT_NAME}.service >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0644 ${SYSTEMD_SERVICE_DIR}/${MLMMJADMIN_RC_SCRIPT_NAME}.service
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
perl -pi -e 's#(^plugins.*)python,(.*)#${1}$ENV{UWSGI_PY3_PLUGIN_NAME},${2}#g' ${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/rc_scripts/uwsgi/debian.ini
|
||||
cp -f ${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/rc_scripts/systemd/debian.service ${SYSTEMD_SERVICE_DIR}/${MLMMJADMIN_RC_SCRIPT_NAME}.service >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0644 ${SYSTEMD_SERVICE_DIR}/${MLMMJADMIN_RC_SCRIPT_NAME}.service
|
||||
fi
|
||||
|
||||
systemctl daemon-reload >> ${INSTALL_LOG} 2>&1
|
||||
else
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
cp ${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/rc_scripts/${MLMMJADMIN_RC_SCRIPT_NAME}.freebsd ${MLMMJADMIN_RC_SCRIPT_PATH} >> ${INSTALL_LOG} 2>&1
|
||||
service_control enable 'mlmmjadmin_enable' 'YES' >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
cp ${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/rc_scripts/mlmmjadmin.openbsd ${MLMMJADMIN_RC_SCRIPT_PATH} >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0755 ${MLMMJADMIN_RC_SCRIPT_PATH} >> ${INSTALL_LOG} 2>&1
|
||||
rcctl enable mlmmjadmin
|
||||
fi
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Enable mlmmjadmin service."
|
||||
service_control enable ${MLMMJADMIN_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
export ENABLED_SERVICES="${ENABLED_SERVICES} ${MLMMJADMIN_RC_SCRIPT_NAME}"
|
||||
|
||||
write_iredmail_kv mlmmjadmin_api_token "${MLMMJADMIN_API_AUTH_TOKEN}"
|
||||
echo 'export status_mlmmjadmin_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# Please refer another file: functions/backend.sh
|
||||
|
||||
# -------------------------------------------------------
|
||||
# -------------------- MySQL ----------------------------
|
||||
# -------------------------------------------------------
|
||||
mysql_initialize_db()
|
||||
{
|
||||
ECHO_DEBUG "Initialize MySQL server."
|
||||
|
||||
backup_file ${MYSQL_MY_CNF}
|
||||
|
||||
ECHO_DEBUG "Stop MySQL service before initializing database or updating my.cnf."
|
||||
service_control stop ${MYSQL_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
sleep 3
|
||||
|
||||
# Initial MySQL database first
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ECHO_DEBUG "Run mysql_install_db."
|
||||
/usr/local/bin/mysql_install_db >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# 'mysql_enable=YES' is required to start service immediately.
|
||||
ECHO_DEBUG "Enable mysql service when system start up."
|
||||
service_control enable 'mysql_enable' 'YES'
|
||||
|
||||
# rc script `mysql-server` doesn't create required directory.
|
||||
mkdir -p /var/run/mysql &>/dev/null
|
||||
chown mysql:mysql /var/run/mysql
|
||||
chmod 0755 /var/run/mysql
|
||||
fi
|
||||
|
||||
if [ ! -e ${MYSQL_MY_CNF} ]; then
|
||||
ECHO_DEBUG "Copy sample MySQL config file: ${MYSQL_MY_CNF_SAMPLE} -> ${MYSQL_MY_CNF}."
|
||||
mkdir -p $(dirname ${MYSQL_MY_CNF}) &>/dev/null >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
if [ -f ${MYSQL_MY_CNF_SAMPLE} ]; then
|
||||
cp ${MYSQL_MY_CNF_SAMPLE} ${MYSQL_MY_CNF} >> ${INSTALL_LOG} 2>&1
|
||||
else
|
||||
cp ${SAMPLE_DIR}/mysql/my.cnf ${MYSQL_MY_CNF} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Disable 'skip-networking' in my.cnf."
|
||||
perl -pi -e 's/^(skip-networking.*)/#${1}/' ${MYSQL_MY_CNF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Set max_connections to ${MYSQL_MAX_CONNECTIONS}."
|
||||
perl -pi -e 's#^(max_connections .*=)(.*)#${1} $ENV{MYSQL_MAX_CONNECTIONS}#' ${MYSQL_MY_CNF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# Enable innodb_file_per_table by default.
|
||||
grep '^innodb_file_per_table' ${MYSQL_MY_CNF} &>/dev/null
|
||||
if [ X"$?" != X'0' ]; then
|
||||
ECHO_DEBUG "Enable 'innodb_file_per_table' in my.cnf."
|
||||
perl -pi -e 's#^(\[mysqld\])#${1}\ninnodb_file_per_table#' ${MYSQL_MY_CNF} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
if [ X"${BACKEND}" == X'MYSQL' -o X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
if [ X"${LOCAL_ADDRESS}" != X'127.0.0.1' ]; then
|
||||
ECHO_DEBUG "Enable 'skip_grant_tables' option, so that we can reset password."
|
||||
perl -pi -e 's#^(\[mysqld\])#${1}\nskip_grant_tables#' ${MYSQL_MY_CNF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# inside Jail: listen on Jail IP address
|
||||
ECHO_DEBUG "Enable 'bind-address = ${LOCAL_ADDRESS}' in my.cnf."
|
||||
perl -pi -e 's#^(bind-address).*#${1} = $ENV{LOCAL_ADDRESS}#' ${MYSQL_MY_CNF} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# Bind to 127.0.0.1 on OpenBSD
|
||||
grep '^bind-address' ${MYSQL_MY_CNF} &>/dev/null
|
||||
if [ X"$?" != X'0' ]; then
|
||||
ECHO_DEBUG "Enable 'bind-address = 127.0.0.1' in my.cnf."
|
||||
perl -pi -e 's#^(\[mysqld\])#${1}\nbind-address = 127.0.0.1#' ${MYSQL_MY_CNF} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ X"${USE_SYSTEMD}" == X'YES' ]; then
|
||||
mkdir -p /etc/systemd/system/mariadb.service.d &>/dev/null
|
||||
cp -f ${SAMPLE_DIR}/systemd/mariadb.service.d/override.conf /etc/systemd/system/mariadb.service.d/
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Restart service: ${MYSQL_RC_SCRIPT_NAME}."
|
||||
service_control restart ${MYSQL_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Sleep 10 seconds for MySQL daemon initialization ..."
|
||||
sleep 10
|
||||
|
||||
if [ X"${USE_EXISTING_MYSQL}" != X'YES' ]; then
|
||||
if [ X"${DISTRO}" == X'FREEBSD' -a X"${LOCAL_ADDRESS}" != X'127.0.0.1' ]; then
|
||||
# Jail
|
||||
mysql -h ${MYSQL_SERVER_ADDRESS} -u${MYSQL_ROOT_USER} --connect-expired-password mysql -e "UPDATE user SET host='${LOCAL_ADDRESS}',Password=PASSWORD('${MYSQL_ROOT_PASSWD}'),password_expired='N' WHERE User='root' AND Host='localhost'; FLUSH PRIVILEGES;" >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Remove 'skip_grant_tables'."
|
||||
perl -pi -e 's#^(skip_grant_tables.*)##g' ${MYSQL_MY_CNF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Restart service: ${MYSQL_RC_SCRIPT_NAME}."
|
||||
service_control restart ${MYSQL_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Sleep 10 seconds for MySQL daemon initialization ..."
|
||||
sleep 10
|
||||
else
|
||||
# Try to access without password, set a password if it's empty.
|
||||
if [ X"${MYSQL_SERVER_ADDRESS}" == X'127.0.0.1' ]; then
|
||||
# Use local socket
|
||||
_mysql_cmd="mysql -u${MYSQL_ROOT_USER}"
|
||||
_mysqladmin_cmd="mysqladmin -u${MYSQL_ROOT_USER}"
|
||||
else
|
||||
_mysql_cmd="mysql -h ${MYSQL_SERVER_ADDRESS} -u${MYSQL_ROOT_USER}"
|
||||
_mysqladmin_cmd="mysqladmin -h ${MYSQL_SERVER_ADDRESS} -u${MYSQL_ROOT_USER}"
|
||||
fi
|
||||
|
||||
${_mysql_cmd} -e "show databases" >> ${INSTALL_LOG} 2>&1
|
||||
if [ X"$?" == X'0' ]; then
|
||||
ECHO_DEBUG "Setting password for MySQL root user: ${MYSQL_ROOT_USER}."
|
||||
${_mysqladmin_cmd} -u${MYSQL_ROOT_USER} password ${MYSQL_ROOT_PASSWD} >> ${INSTALL_LOG} 2>&1
|
||||
${_mysql_cmd} -e "FLUSH PRIVILEGES" &>/dev/null
|
||||
|
||||
#if ${_mysql_cmd} -e "DESC mysql.user" | grep '\<authentication_string\>' >> ${INSTALL_LOG} 2>&1; then
|
||||
# ${_mysql_cmd} -e "UPDATE mysql.user SET authentication_string = PASSWORD('${MYSQL_ROOT_PASSWD}') WHERE User='root' AND Host='localhost'; FLUSH PRIVILEGES;" >> ${INSTALL_LOG} 2>&1
|
||||
#fi
|
||||
|
||||
#if ${_mysql_cmd} -e "DESC mysql.user" | grep '\<Password\>' >> ${INSTALL_LOG} 2>&1; then
|
||||
# ${_mysqladmin_cmd} password ${MYSQL_ROOT_PASSWD} >> ${INSTALL_LOG} 2>&1
|
||||
#fi
|
||||
else
|
||||
ECHO_DEBUG "MySQL root password is not empty, not reset."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
MySQL:
|
||||
* Root user: ${MYSQL_ROOT_USER}, Password: "${MYSQL_ROOT_PASSWD}" (without quotes)
|
||||
* Bind account (read-only):
|
||||
- Username: ${VMAIL_DB_BIND_USER}, Password: ${VMAIL_DB_BIND_PASSWD}
|
||||
* Vmail admin account (read-write):
|
||||
- Username: ${VMAIL_DB_ADMIN_USER}, Password: ${VMAIL_DB_ADMIN_PASSWD}
|
||||
* Config file: ${MYSQL_MY_CNF}
|
||||
* RC script: ${MYSQLD_RC_SCRIPT}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_mysql_initialize_db="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
mysql_generate_defaults_file_root()
|
||||
{
|
||||
ECHO_DEBUG "Generate defauts file for MySQL client option --defaults-file: ${MYSQL_DEFAULTS_FILE_ROOT}."
|
||||
backup_file ${MYSQL_DEFAULTS_FILE_ROOT}
|
||||
|
||||
cat > ${MYSQL_DEFAULTS_FILE_ROOT} <<EOF
|
||||
[client]
|
||||
user=${MYSQL_ROOT_USER}
|
||||
password="${MYSQL_ROOT_PASSWD}"
|
||||
EOF
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' \
|
||||
-o X"${LOCAL_ADDRESS}" != X'127.0.0.1' \
|
||||
-o X"${MYSQL_SERVER_ADDRESS}" != X'127.0.0.1' ]; then
|
||||
cat >> ${MYSQL_DEFAULTS_FILE_ROOT} <<EOF
|
||||
host=${MYSQL_SERVER_ADDRESS}
|
||||
port=${MYSQL_SERVER_PORT}
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat > /root/.my.cnf-${VMAIL_DB_BIND_USER} <<EOF
|
||||
[client]
|
||||
host=${MYSQL_SERVER_ADDRESS}
|
||||
port=${MYSQL_SERVER_PORT}
|
||||
user=${VMAIL_DB_BIND_USER}
|
||||
password="${VMAIL_DB_BIND_PASSWD}"
|
||||
EOF
|
||||
|
||||
cat > /root/.my.cnf-${VMAIL_DB_ADMIN_USER} <<EOF
|
||||
[client]
|
||||
host=${MYSQL_SERVER_ADDRESS}
|
||||
port=${MYSQL_SERVER_PORT}
|
||||
user=${VMAIL_DB_ADMIN_USER}
|
||||
password="${VMAIL_DB_ADMIN_PASSWD}"
|
||||
EOF
|
||||
|
||||
chmod 0400 ${MYSQL_DEFAULTS_FILE_ROOT} /root/.my.cnf-{${VMAIL_DB_BIND_USER},${VMAIL_DB_ADMIN_USER}}
|
||||
|
||||
echo 'export status_mysql_generate_defaults_file_root="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
mysql_grant_permission_on_remote_server()
|
||||
{
|
||||
# If we're using a remote mysql server: grant access privilege first.
|
||||
if [ X"${USE_EXISTING_MYSQL}" == X'YES' -a X"${MYSQL_SERVER_ADDRESS}" != X'127.0.0.1' ]; then
|
||||
ECHO_DEBUG "Grant access privilege to ${MYSQL_ROOT_USER}@${MYSQL_GRANT_HOST} ..."
|
||||
|
||||
cp -f ${SAMPLE_DIR}/mysql/sql/remote_grant_permission.sql ${RUNTIME_DIR}/
|
||||
perl -pi -e 's#PH_MYSQL_ROOT_USER#$ENV{MYSQL_ROOT_USER}#g' ${RUNTIME_DIR}/remote_grant_permission.sql
|
||||
perl -pi -e 's#PH_MYSQL_GRANT_HOST#$ENV{MYSQL_GRANT_HOST}#g' ${RUNTIME_DIR}/remote_grant_permission.sql
|
||||
perl -pi -e 's#PH_HOSTNAME#$ENV{HOSTNAME}#g' ${RUNTIME_DIR}/remote_grant_permission.sql
|
||||
|
||||
${MYSQL_CLIENT_ROOT} -e "SOURCE ${RUNTIME_DIR}/remote_grant_permission.sql;"
|
||||
fi
|
||||
|
||||
echo 'export status_mysql_grant_permission_on_remote_server="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
mysql_remove_insecure_data()
|
||||
{
|
||||
ECHO_DEBUG "Delete anonymous database user."
|
||||
${MYSQL_CLIENT_ROOT} -e "SOURCE ${SAMPLE_DIR}/mysql/sql/delete_anonymous_user.sql;"
|
||||
|
||||
# Delete root accounts with empty passwords
|
||||
${MYSQL_CLIENT_ROOT} -e "DESC mysql.user" | grep '\<Password\>' &>/dev/null
|
||||
if [ X"$?" == X'0' ]; then
|
||||
ECHO_DEBUG "Delete root access with empty passwords."
|
||||
${MYSQL_CLIENT_ROOT} -e "DELETE FROM mysql.user WHERE User='root' AND Password=''"
|
||||
fi
|
||||
|
||||
${MYSQL_CLIENT_ROOT} -e "SHOW DATABASES" | grep '\<test\>' &>/dev/null
|
||||
if [ X"$?" == X'0' ]; then
|
||||
ECHO_DEBUG "Remove 'test' database."
|
||||
${MYSQL_CLIENT_ROOT} -e "DROP DATABASE test"
|
||||
fi
|
||||
|
||||
echo 'export status_mysql_remove_insecure_data="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
# It's used only when backend is MySQL.
|
||||
mysql_import_vmail_users()
|
||||
{
|
||||
ECHO_DEBUG "Generate sample SQL templates."
|
||||
cp -f ${SAMPLE_DIR}/mysql/sql/init_vmail_db.sql ${RUNTIME_DIR}/
|
||||
cp -f ${SAMPLE_DIR}/iredmail/iredmail.mysql ${RUNTIME_DIR}/iredmail.sql
|
||||
cp -f ${SAMPLE_DIR}/mysql/sql/add_first_domain_and_user.sql ${RUNTIME_DIR}/
|
||||
|
||||
perl -pi -e 's#PH_VMAIL_DB_NAME#$ENV{VMAIL_DB_NAME}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_USER#$ENV{VMAIL_DB_BIND_USER}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_PASSWD#$ENV{VMAIL_DB_BIND_PASSWD}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_VMAIL_DB_ADMIN_USER#$ENV{VMAIL_DB_ADMIN_USER}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_VMAIL_DB_ADMIN_PASSWD#$ENV{VMAIL_DB_ADMIN_PASSWD}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_MYSQL_GRANT_HOST#$ENV{MYSQL_GRANT_HOST}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_HOSTNAME#$ENV{HOSTNAME}#g' ${RUNTIME_DIR}/*.sql
|
||||
|
||||
perl -pi -e 's#PH_DOMAIN_ADMIN_EMAIL#$ENV{DOMAIN_ADMIN_EMAIL}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_FIRST_DOMAIN#$ENV{FIRST_DOMAIN}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_TRANSPORT#$ENV{TRANSPORT}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_DOMAIN_ADMIN_PASSWD_HASH#$ENV{DOMAIN_ADMIN_PASSWD_HASH}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_DOMAIN_ADMIN_MAILDIR_HASH_PART#$ENV{DOMAIN_ADMIN_MAILDIR_HASH_PART}#g' ${RUNTIME_DIR}/*.sql
|
||||
perl -pi -e 's#PH_DOMAIN_ADMIN_NAME#$ENV{DOMAIN_ADMIN_NAME}#g' ${RUNTIME_DIR}/*.sql
|
||||
|
||||
# Modify default SQL template
|
||||
perl -pi -e 's#^-- (USE.*)#${1}#g' ${RUNTIME_DIR}/iredmail.sql
|
||||
perl -pi -e 's#(.*storagebasedirectory.*DEFAULT).*#${1} "$ENV{STORAGE_BASE_DIR}",#' ${RUNTIME_DIR}/iredmail.sql
|
||||
perl -pi -e 's#(.*storagenode.*DEFAULT).*#${1} "$ENV{STORAGE_NODE}",#' ${RUNTIME_DIR}/iredmail.sql
|
||||
# Rename SQL table `vmail.used_quota`
|
||||
perl -pi -e 's#used_quota`#$ENV{DOVECOT_REALTIME_QUOTA_TABLE}`#g' ${RUNTIME_DIR}/iredmail.sql
|
||||
|
||||
ECHO_DEBUG "Create database: ${VMAIL_DB_NAME}."
|
||||
${MYSQL_CLIENT_ROOT} -e "SOURCE ${RUNTIME_DIR}/init_vmail_db.sql;"
|
||||
|
||||
ECHO_DEBUG "Initialize database: ${VMAIL_DB_NAME}."
|
||||
${MYSQL_CLIENT_ROOT} -e "SOURCE ${RUNTIME_DIR}/iredmail.sql;"
|
||||
|
||||
ECHO_DEBUG "Add first domain and postmaster@ user."
|
||||
${MYSQL_CLIENT_ROOT} -e "SOURCE ${RUNTIME_DIR}/add_first_domain_and_user.sql;"
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Virtual Users:
|
||||
- ${MYSQL_VMAIL_STRUCTURE_SAMPLE}
|
||||
- ${RUNTIME_DIR}/*.sql
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_mysql_import_vmail_users="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
mysql_cron_backup()
|
||||
{
|
||||
mysql_backup_script="${BACKUP_DIR}/${BACKUP_SCRIPT_MYSQL_NAME}"
|
||||
|
||||
ECHO_INFO "Setup daily cron job to backup SQL databases with ${mysql_backup_script}"
|
||||
|
||||
[ ! -d ${BACKUP_DIR} ] && mkdir -p ${BACKUP_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
backup_file ${mysql_backup_script}
|
||||
cp ${TOOLS_DIR}/${BACKUP_SCRIPT_MYSQL_NAME} ${mysql_backup_script}
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${mysql_backup_script}
|
||||
chmod 0500 ${mysql_backup_script}
|
||||
|
||||
export MYSQL_ROOT_PASSWD
|
||||
perl -pi -e 's#^(export BACKUP_ROOTDIR=).*#${1}"$ENV{BACKUP_DIR}"#' ${mysql_backup_script}
|
||||
perl -pi -e 's#^(export MYSQL_USER=).*#${1}"$ENV{MYSQL_ROOT_USER}"#' ${mysql_backup_script}
|
||||
perl -pi -e 's#^(export MYSQL_PASSWD=).*#${1}"$ENV{MYSQL_ROOT_PASSWD}"#' ${mysql_backup_script}
|
||||
|
||||
# Add cron job
|
||||
cat >> ${CRON_FILE_ROOT} <<EOF
|
||||
# ${PROG_NAME}: Backup MySQL databases on 03:30 AM
|
||||
30 3 * * * ${SHELL_BASH} ${mysql_backup_script}
|
||||
|
||||
EOF
|
||||
|
||||
if [ X"${INITIALIZE_SQL_DATA}" != X'YES' ]; then
|
||||
perl -pi -e 's/(.*bash.*backup_mysql.sh.*)/#${1}/g' ${CRON_FILE_ROOT}
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Backup MySQL database:
|
||||
* Script: ${mysql_backup_script}
|
||||
* See also:
|
||||
# crontab -l -u ${SYS_USER_ROOT}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_mysql_cron_backup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
mysql_setup()
|
||||
{
|
||||
ECHO_INFO "Configure MariaDB database server."
|
||||
|
||||
if [ X"${USE_EXISTING_MYSQL}" != X'YES' ]; then
|
||||
check_status_before_run mysql_initialize_db
|
||||
fi
|
||||
|
||||
check_status_before_run mysql_generate_defaults_file_root
|
||||
|
||||
if [ X"${INITIALIZE_SQL_DATA}" == X'YES' ]; then
|
||||
check_status_before_run mysql_grant_permission_on_remote_server
|
||||
check_status_before_run mysql_remove_insecure_data
|
||||
check_status_before_run mysql_import_vmail_users
|
||||
fi
|
||||
|
||||
check_status_before_run mysql_cron_backup
|
||||
|
||||
write_iredmail_kv "sql_user_${MYSQL_ROOT_USER}" "${MYSQL_ROOT_PASSWD}"
|
||||
|
||||
if [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
write_iredmail_kv "sql_user_${VMAIL_DB_BIND_USER}" "${VMAIL_DB_BIND_PASSWD}"
|
||||
write_iredmail_kv "sql_user_${VMAIL_DB_ADMIN_USER}" "${VMAIL_DB_ADMIN_PASSWD}"
|
||||
fi
|
||||
|
||||
echo 'export status_mysql_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
netdata_install()
|
||||
{
|
||||
#
|
||||
# NOTE: Install netdata on __LINUX__.
|
||||
#
|
||||
ECHO_DEBUG "Install netdata with package: ${NETDATA_PKG_NAME}."
|
||||
|
||||
cd ${PKG_MISC_DIR}
|
||||
chmod +x ${NETDATA_PKG_NAME}
|
||||
|
||||
# Note: netdata installer will generate rc/systemd script automatically.
|
||||
./${NETDATA_PKG_NAME} --accept > ${RUNTIME_DIR}/netdata-install.log 2>&1
|
||||
|
||||
ln -s ${NETDATA_CONF_DIR} /etc/netdata >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# netdata will handle logrotate config file automatically.
|
||||
if [[ ! -d /var/log/netdata ]]; then
|
||||
ln -s ${NETDATA_LOG_DIR} /var/log/netdata >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
echo 'export status_netdata_install="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
netdata_config()
|
||||
{
|
||||
ECHO_INFO "Configure netdata (system and application monitor)."
|
||||
|
||||
# Disable sending anonymouse statistics to netdata cloud.
|
||||
touch ${NETDATA_CONF_DIR}/.opt-out-from-anonymous-statistics
|
||||
|
||||
# Enable service.
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
service_control enable 'netdata_enable' 'YES' >> ${INSTALL_LOG} 2>&1
|
||||
else
|
||||
service_control enable ${NETDATA_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
backup_file ${NETDATA_CONF}
|
||||
|
||||
ECHO_DEBUG "Generate netdata config file: ${SAMPLE_DIR}/netdata/netdata.conf -> ${NETDATA_CONF}."
|
||||
cp -f ${SAMPLE_DIR}/netdata/netdata.conf ${NETDATA_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SAMPLE_DIR}/netdata/health_alarm_notify.conf ${NETDATA_HEALTH_ALARM_NOTIFY_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SAMPLE_DIR}/netdata/python.d.conf ${NETDATA_PYTHON_D_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SAMPLE_DIR}/netdata/go.d.conf ${NETDATA_GO_D_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
chown ${SYS_USER_NETDATA}:${SYS_GROUP_NETDATA} \
|
||||
${NETDATA_CONF} \
|
||||
${NETDATA_HEALTH_ALARM_NOTIFY_CONF} \
|
||||
${NETDATA_PYTHON_D_CONF} \
|
||||
${NETDATA_GO_D_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
perl -pi -e 's#( *memory mode =).*#${1} save#g' ${NETDATA_CONF}
|
||||
|
||||
# FreeBSD doesn't have Go plugins, have to use Python plugins instead.
|
||||
perl -pi -e 's/^(web_log: no)/#${1}/' ${NETDATA_PYTHON_D_CONF}
|
||||
perl -pi -e 's/^(nginx: no)/#${1}/' ${NETDATA_PYTHON_D_CONF}
|
||||
perl -pi -e 's/^(phpfpm: no)/#${1}/' ${NETDATA_PYTHON_D_CONF}
|
||||
perl -pi -e 's/^(mysql: no)/#${1}/' ${NETDATA_PYTHON_D_CONF}
|
||||
fi
|
||||
|
||||
perl -pi -e 's#PH_NETDATA_PORT#$ENV{NETDATA_PORT}#g' ${NETDATA_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_SYS_USER_NETDATA#$ENV{SYS_USER_NETDATA}#g' ${NETDATA_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Generate htpasswd file: ${NETDATA_HTTPD_AUTH_FILE}."
|
||||
touch ${NETDATA_HTTPD_AUTH_FILE}
|
||||
chown ${HTTPD_USER}:${HTTPD_GROUP} ${NETDATA_HTTPD_AUTH_FILE}
|
||||
chmod 0400 ${NETDATA_HTTPD_AUTH_FILE}
|
||||
|
||||
# Add postmaster@<first-domain> if not present.
|
||||
if ! grep "^${DOMAIN_ADMIN_EMAIL}:" ${NETDATA_HTTPD_AUTH_FILE} &>/dev/null; then
|
||||
_pw="$(generate_password_hash SSHA ${DOMAIN_ADMIN_PASSWD_PLAIN})"
|
||||
echo "${DOMAIN_ADMIN_EMAIL}:${_pw}" >> ${NETDATA_HTTPD_AUTH_FILE}
|
||||
fi
|
||||
|
||||
echo 'export status_netdata_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
netdata_module_config()
|
||||
{
|
||||
ECHO_DEBUG "Generate config files for plugins."
|
||||
|
||||
mkdir -p ${NETDATA_GO_D_CONF_DIR} ${NETDATA_PYTHON_D_CONF_DIR} &>/dev/null
|
||||
|
||||
# go.d modules: phpfpm, nginx.
|
||||
cp -f ${SAMPLE_DIR}/netdata/go.d/phpfpm.conf ${NETDATA_GO_D_CONF_PHPFPM} >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SAMPLE_DIR}/netdata/go.d/nginx.conf ${NETDATA_GO_D_CONF_NGINX} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# OpenLDAP
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
ECHO_DEBUG "Generate ${NETDATA_PYTHON_D_CONF_OPENLDAP}."
|
||||
|
||||
cp -f ${SAMPLE_DIR}/netdata/python.d/openldap.conf ${NETDATA_PYTHON_D_CONF_OPENLDAP} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_LDAP_BINDDN#$ENV{LDAP_BINDDN}#g' ${NETDATA_PYTHON_D_CONF_OPENLDAP} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_LDAP_BINDPW#$ENV{LDAP_BINDPW}#g' ${NETDATA_PYTHON_D_CONF_OPENLDAP} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
# MySQL & PostgreSQL
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
ECHO_DEBUG "Create MySQL user ${NETDATA_DB_USER} with minimal privilege: USAGE."
|
||||
${MYSQL_CLIENT_ROOT} >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
GRANT USAGE ON *.* TO ${NETDATA_DB_USER}@${MYSQL_GRANT_HOST} IDENTIFIED BY '${NETDATA_DB_PASSWD}';
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
|
||||
ECHO_DEBUG "Generate ${NETDATA_GO_D_CONF_MYSQL}."
|
||||
cp -f ${SAMPLE_DIR}/netdata/go.d/mysql.conf ${NETDATA_GO_D_CONF_MYSQL} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
perl -pi -e 's#PH_MYSQL_SERVER_ADDRESS#$ENV{MYSQL_SERVER_ADDRESS}#g' ${NETDATA_GO_D_CONF_MYSQL} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_MYSQL_SERVER_PORT#$ENV{MYSQL_SERVER_PORT}#g' ${NETDATA_GO_D_CONF_MYSQL} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_NETDATA_DB_USER#$ENV{NETDATA_DB_USER}#g' ${NETDATA_GO_D_CONF_MYSQL} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_NETDATA_DB_PASSWD#$ENV{NETDATA_DB_PASSWD}#g' ${NETDATA_GO_D_CONF_MYSQL} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
CREATE USER ${NETDATA_DB_USER} WITH ENCRYPTED PASSWORD '${NETDATA_DB_PASSWD}' NOSUPERUSER NOCREATEDB NOCREATEROLE;
|
||||
EOF
|
||||
|
||||
ECHO_DEBUG "Generate ${NETDATA_PYTHON_D_CONF_PGSQL}."
|
||||
backup_file ${NETDATA_PYTHON_D_CONF_PGSQL}
|
||||
cp -f ${SAMPLE_DIR}/netdata/python.d/postgres.conf ${NETDATA_PYTHON_D_CONF_PGSQL} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_NETDATA_DB_USER#$ENV{NETDATA_DB_USER}#g' ${NETDATA_PYTHON_D_CONF_PGSQL} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_NETDATA_DB_PASSWD#$ENV{NETDATA_DB_PASSWD}#g' ${NETDATA_PYTHON_D_CONF_PGSQL} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
chown -R ${SYS_USER_NETDATA}:${SYS_GROUP_NETDATA} ${NETDATA_GO_D_CONF_DIR} ${NETDATA_PYTHON_D_CONF_DIR}
|
||||
chmod 0755 ${NETDATA_GO_D_CONF_DIR} ${NETDATA_PYTHON_D_CONF_DIR}
|
||||
chmod 0400 ${NETDATA_GO_D_CONF_DIR}/*.conf &>/dev/null
|
||||
chmod 0400 ${NETDATA_PYTHON_D_CONF_DIR}/*.conf &>/dev/null
|
||||
|
||||
echo 'export status_netdata_module_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
netdata_system_tune()
|
||||
{
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
ECHO_DEBUG "Add sysctl parameters for better netdata performance."
|
||||
update_sysctl_param vm.dirty_expire_centisecs 60000
|
||||
update_sysctl_param vm.dirty_background_ratio 80
|
||||
update_sysctl_param vm.dirty_ratio 90
|
||||
|
||||
ECHO_DEBUG "Increase open files limit."
|
||||
if [ X"${USE_SYSTEMD}" == X'YES' ]; then
|
||||
mkdir /etc/systemd/system/netdata.service.d >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SAMPLE_DIR}/netdata/systemd-limits.conf /etc/systemd/system/netdata.service.d/limits.conf >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo 'export status_netdata_system_tune="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
netdata_setup()
|
||||
{
|
||||
if [ X"${DISTRO}" != X'OPENBSD' ]; then
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
check_status_before_run netdata_install
|
||||
fi
|
||||
|
||||
check_status_before_run netdata_config
|
||||
check_status_before_run netdata_module_config
|
||||
check_status_before_run netdata_system_tune
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
netdata (monitor):
|
||||
- Config files:
|
||||
- All config files: ${NETDATA_CONF_DIR}
|
||||
- Main config file: ${NETDATA_CONF}
|
||||
- Modified modular config files:
|
||||
- ${NETDATA_GO_D_CONF_DIR}
|
||||
- ${NETDATA_PYTHON_D_CONF_DIR}
|
||||
- HTTP auth file (if you need a new account to access netdata, please
|
||||
update this file with command like 'htpasswd' or edit manually):
|
||||
- ${NETDATA_HTTPD_AUTH_FILE}
|
||||
- Log directory: ${NETDATA_LOG_DIR}
|
||||
- SQL:
|
||||
- Username: ${NETDATA_DB_USER}
|
||||
- Password: ${NETDATA_DB_PASSWD}
|
||||
- NOTE: No database required by netdata.
|
||||
|
||||
EOF
|
||||
|
||||
write_iredmail_kv "sql_user_${NETDATA_DB_USER}" "${NETDATA_DB_PASSWD}"
|
||||
echo 'export status_netdata_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------
|
||||
# ------------------- Nginx -----------------------------
|
||||
# -------------------------------------------------------
|
||||
|
||||
nginx_config()
|
||||
{
|
||||
ECHO_INFO "Configure Nginx web server."
|
||||
|
||||
backup_file ${NGINX_CONF} ${NGINX_CONF_SITE_DEFAULT} ${PHP_FPM_POOL_WWW_CONF}
|
||||
|
||||
# Make sure we have an empty directory
|
||||
[ -d ${HTTPD_CONF_DIR_AVAILABLE_CONF} ] && mv ${HTTPD_CONF_DIR_AVAILABLE_CONF} ${HTTPD_CONF_DIR_AVAILABLE_CONF}.bak
|
||||
[ ! -d ${HTTPD_CONF_DIR_AVAILABLE_CONF} ] && mkdir -p ${HTTPD_CONF_DIR_AVAILABLE_CONF}
|
||||
|
||||
[ -d ${HTTPD_CONF_DIR_ENABLED_CONF} ] && mv ${HTTPD_CONF_DIR_ENABLED_CONF} ${HTTPD_CONF_DIR_ENABLED_CONF}.bak
|
||||
[ ! -d ${HTTPD_CONF_DIR_ENABLED_CONF} ] && mkdir -p ${HTTPD_CONF_DIR_ENABLED_CONF}
|
||||
|
||||
# Directory used to store virtual web hosts config files
|
||||
[ -d ${HTTPD_CONF_DIR_AVAILABLE_SITES} ] && mv ${HTTPD_CONF_DIR_AVAILABLE_SITES} ${HTTPD_CONF_DIR_AVAILABLE_SITES}.bak
|
||||
[ ! -d ${HTTPD_CONF_DIR_AVAILABLE_SITES} ] && mkdir -p ${HTTPD_CONF_DIR_AVAILABLE_SITES}
|
||||
|
||||
[ -d ${HTTPD_CONF_DIR_ENABLED_SITES} ] && mv ${HTTPD_CONF_DIR_ENABLED_SITES} ${HTTPD_CONF_DIR_ENABLED_SITES}.bak
|
||||
[ ! -d ${HTTPD_CONF_DIR_ENABLED_SITES} ] && mkdir -p ${HTTPD_CONF_DIR_ENABLED_SITES}
|
||||
|
||||
#
|
||||
# Modular config files
|
||||
#
|
||||
# Copy sample files
|
||||
cp ${SAMPLE_DIR}/nginx/nginx.conf ${NGINX_CONF}
|
||||
cp -f ${SAMPLE_DIR}/nginx/conf-available/*.conf ${HTTPD_CONF_DIR_AVAILABLE_CONF}
|
||||
|
||||
#
|
||||
# Enable modular config files
|
||||
#
|
||||
_modular_conf='0-general.conf
|
||||
cache.conf
|
||||
client_max_body_size.conf
|
||||
default_type.conf
|
||||
gzip.conf
|
||||
headers.conf
|
||||
log.conf
|
||||
mime_types.conf
|
||||
sendfile.conf
|
||||
server_tokens.conf
|
||||
types_hash_max_size.conf'
|
||||
|
||||
[ X"${IREDMAIL_USE_PHP}" == X'YES' ] && _modular_conf="${_modular_conf} php_fpm.conf"
|
||||
|
||||
for cf in ${_modular_conf}; do
|
||||
ln -s ${HTTPD_CONF_DIR_AVAILABLE_CONF}/${cf} ${HTTPD_CONF_DIR_ENABLED_CONF}/${cf} >> ${INSTALL_LOG} 2>&1
|
||||
done
|
||||
|
||||
#
|
||||
# Default sites
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/nginx/sites-available/00-default.conf ${NGINX_CONF_SITE_DEFAULT}
|
||||
cp -f ${SAMPLE_DIR}/nginx/sites-available/00-default-ssl.conf ${NGINX_CONF_SITE_DEFAULT_SSL}
|
||||
ln -s ${NGINX_CONF_SITE_DEFAULT} ${HTTPD_CONF_DIR_ENABLED_SITES} >> ${INSTALL_LOG} 2>&1
|
||||
ln -s ${NGINX_CONF_SITE_DEFAULT_SSL} ${HTTPD_CONF_DIR_ENABLED_SITES} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# Template configuration snippets.
|
||||
[ ! -d ${NGINX_CONF_TMPL_DIR} ] && mkdir -p ${NGINX_CONF_TMPL_DIR}
|
||||
cp ${SAMPLE_DIR}/nginx/templates/*.tmpl ${NGINX_CONF_TMPL_DIR}
|
||||
perl -pi -e 's#PH_NGINX_CONF_TMPL_DIR#$ENV{NGINX_CONF_TMPL_DIR}#g' \
|
||||
${HTTPD_CONF_DIR_AVAILABLE_SITES}/*.conf \
|
||||
${NGINX_CONF_TMPL_DIR}/*tmpl
|
||||
|
||||
# nginx.conf
|
||||
perl -pi -e 's#PH_HTTPD_USER#$ENV{HTTPD_USER}#g' ${NGINX_CONF}
|
||||
perl -pi -e 's#PH_NGINX_PID#$ENV{NGINX_PID}#g' ${NGINX_CONF}
|
||||
perl -pi -e 's#PH_HTTPD_CONF_DIR_ENABLED_SITES#$ENV{HTTPD_CONF_DIR_ENABLED_SITES}#g' ${NGINX_CONF}
|
||||
perl -pi -e 's#PH_HTTPD_CONF_DIR_ENABLED_CONF#$ENV{HTTPD_CONF_DIR_ENABLED_CONF}#g' ${NGINX_CONF}
|
||||
|
||||
#
|
||||
# conf-available/*.conf
|
||||
#
|
||||
perl -pi -e 's#PH_NGINX_LOG_ERRORLOG#$ENV{NGINX_LOG_ERRORLOG}#g' ${HTTPD_CONF_DIR_AVAILABLE_CONF}/log.conf
|
||||
perl -pi -e 's#PH_NGINX_LOG_ACCESSLOG#$ENV{NGINX_LOG_ACCESSLOG}#g' ${HTTPD_CONF_DIR_AVAILABLE_CONF}/log.conf
|
||||
perl -pi -e 's#PH_NGINX_MIME_TYPES#$ENV{NGINX_MIME_TYPES}#g' ${HTTPD_CONF_DIR_AVAILABLE_CONF}/mime_types.conf
|
||||
|
||||
perl -pi -e 's#PH_PHP_FPM_BIND_HOST#$ENV{PHP_FPM_BIND_HOST}#g' ${HTTPD_CONF_DIR_AVAILABLE_CONF}/php_fpm.conf
|
||||
perl -pi -e 's#PH_PHP_FPM_PORT#$ENV{PHP_FPM_PORT}#g' ${HTTPD_CONF_DIR_AVAILABLE_CONF}/php_fpm.conf
|
||||
|
||||
# Ports
|
||||
perl -pi -e 's#PH_HTTPS_PORT#$ENV{HTTPS_PORT}#g' ${HTTPD_CONF_DIR_AVAILABLE_SITES}/*.conf
|
||||
perl -pi -e 's#PH_PORT_HTTP#$ENV{PORT_HTTP}#g' ${HTTPD_CONF_DIR_AVAILABLE_SITES}/*.conf
|
||||
|
||||
# Enable IPv6.
|
||||
if [[ X"${IREDMAIL_HAS_IPV6}" == X'YES' ]]; then
|
||||
perl -pi -e 's/#(listen .*::.*)/${1}/g' ${HTTPD_CONF_DIR_AVAILABLE_SITES}/*.conf
|
||||
fi
|
||||
|
||||
#
|
||||
# web sites
|
||||
#
|
||||
perl -pi -e 's#PH_HTTPD_DOCUMENTROOT#$ENV{HTTPD_DOCUMENTROOT}#g' ${HTTPD_CONF_DIR_AVAILABLE_SITES}/*.conf
|
||||
|
||||
# ssl
|
||||
perl -pi -e 's#PH_SSL_CERT_FILE#$ENV{SSL_CERT_FILE}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
perl -pi -e 's#PH_SSL_KEY_FILE#$ENV{SSL_KEY_FILE}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
perl -pi -e 's#PH_SSL_CIPHERS#$ENV{SSL_CIPHERS}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
perl -pi -e 's#PH_SSL_DH1024_PARAM_FILE#$ENV{SSL_DH1024_PARAM_FILE}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
|
||||
# Roundcube
|
||||
perl -pi -e 's#PH_RCM_HTTPD_ROOT_SYMBOL_LINK#$ENV{RCM_HTTPD_ROOT_SYMBOL_LINK}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
|
||||
# iRedAdmin
|
||||
perl -pi -e 's#PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK#$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
perl -pi -e 's#PH_IREDADMIN_BIND_ADDRESS#$ENV{IREDADMIN_BIND_ADDRESS}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
perl -pi -e 's#PH_IREDADMIN_LISTEN_PORT#$ENV{IREDADMIN_LISTEN_PORT}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
|
||||
# SOGo
|
||||
perl -pi -e 's#PH_SOGO_BIND_ADDRESS#$ENV{SOGO_BIND_ADDRESS}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
perl -pi -e 's#PH_SOGO_BIND_PORT#$ENV{SOGO_BIND_PORT}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
perl -pi -e 's#PH_SOGO_GNUSTEP_DIR#$ENV{SOGO_GNUSTEP_DIR}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
perl -pi -e 's#PH_SOGO_PROXY_TIMEOUT#$ENV{SOGO_PROXY_TIMEOUT}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
|
||||
# netdata
|
||||
perl -pi -e 's#PH_NETDATA_HTTPD_AUTH_FILE#$ENV{NETDATA_HTTPD_AUTH_FILE}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
perl -pi -e 's#PH_NETDATA_PORT#$ENV{NETDATA_PORT}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
|
||||
# Adminer
|
||||
perl -pi -e 's#PH_HTTPD_SERVERROOT#$ENV{HTTPD_SERVERROOT}#g' ${NGINX_CONF_TMPL_DIR}/*.tmpl
|
||||
|
||||
# php-fpm
|
||||
if [ X"${IREDMAIL_USE_PHP}" == X'YES' ]; then
|
||||
# Update php-fpm config file.
|
||||
perl -pi -e 's#^(error_log)( =.*)#$1 = syslog#g' ${PHP_FPM_CONF}
|
||||
perl -pi -e 's#;(error_log)( =.*)#$1 = syslog#g' ${PHP_FPM_CONF}
|
||||
perl -pi -e 's#^(syslog.facility)( =.*)#$1 = $ENV{IREDMAIL_SYSLOG_FACILITY}#g' ${PHP_FPM_CONF}
|
||||
perl -pi -e 's#;(syslog.facility)( =.*)#$1 = $ENV{IREDMAIL_SYSLOG_FACILITY}#g' ${PHP_FPM_CONF}
|
||||
perl -pi -e 's#^(syslog.ident)( =.*)#$1 = php-fpm#g' ${PHP_FPM_CONF}
|
||||
perl -pi -e 's#;(syslog.ident)( =.*)#$1 = php-fpm#g' ${PHP_FPM_CONF}
|
||||
perl -pi -e 's#^(pid)( =.*)#$1 = $ENV{PHP_FPM_PID_FILE}#g' ${PHP_FPM_CONF}
|
||||
perl -pi -e 's#;(pid)( =.*)#$1 = $ENV{PHP_FPM_PID_FILE}#g' ${PHP_FPM_CONF}
|
||||
|
||||
# Create php-fpm conf directory
|
||||
mkdir -p ${PHP_FPM_POOL_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
cp ${SAMPLE_DIR}/php/fpm/pool.d/www.conf ${PHP_FPM_POOL_WWW_CONF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
perl -pi -e 's#PH_HTTPD_USER#$ENV{HTTPD_USER}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_HTTPD_GROUP#$ENV{HTTPD_GROUP}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_LOCAL_ADDRESS#$ENV{LOCAL_ADDRESS}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_PORT#$ENV{PHP_FPM_PORT}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_POOL_MAX_CHILDREN#$ENV{PHP_FPM_POOL_MAX_CHILDREN}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_POOL_START_SERVERS#$ENV{PHP_FPM_POOL_START_SERVERS}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_POOL_MIN_SPARE_SERVERS#$ENV{PHP_FPM_POOL_MIN_SPARE_SERVERS}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_POOL_MAX_SPARE_SERVERS#$ENV{PHP_FPM_POOL_MAX_SPARE_SERVERS}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_POOL_MAX_CHILDREN#$ENV{PHP_FPM_POOL_MAX_CHILDREN}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_URI_STATUS#$ENV{PHP_FPM_URI_STATUS}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_URI_PING#$ENV{PHP_FPM_URI_PING}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_POOL_REQUEST_TERMINATE_TIMEOUT#$ENV{PHP_FPM_POOL_REQUEST_TERMINATE_TIMEOUT}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_REQUEST_SLOWLOG_TIMEOUT#$ENV{PHP_FPM_REQUEST_SLOWLOG_TIMEOUT}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
|
||||
perl -pi -e 's#PH_PHP_FPM_LOG_MAIN#$ENV{PHP_FPM_LOG_MAIN}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_LOG_SLOW#$ENV{PHP_FPM_LOG_SLOW}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
|
||||
if [[ X"${LOCAL_ADDRESS}" != X'127.0.0.1' ]] && [[ X"${LOCAL_ADDRESS}" != X'localhost' ]]; then
|
||||
perl -pi -e 's#^(listen.allowed_clients = 127.0.0.1)$#${1},$ENV{LOCAL_ADDRESS}#g' ${PHP_FPM_POOL_WWW_CONF}
|
||||
fi
|
||||
|
||||
# Create log directory
|
||||
mkdir -p ${PHP_FPM_LOG_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
touch ${PHP_FPM_LOG_MAIN} ${PHP_FPM_LOG_SLOW}
|
||||
chown ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${PHP_FPM_LOG_MAIN} ${PHP_FPM_LOG_SLOW}
|
||||
chmod 0640 ${PHP_FPM_LOG_MAIN} ${PHP_FPM_LOG_SLOW}
|
||||
|
||||
# Create modular syslog config file
|
||||
if [[ X"${KERNEL_NAME}" == X'LINUX' ]]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
cp ${SAMPLE_DIR}/rsyslog.d/1-iredmail-phpfpm.conf ${SYSLOG_CONF_DIR}
|
||||
|
||||
perl -pi -e 's#PH_IREDMAIL_SYSLOG_FACILITY#$ENV{IREDMAIL_SYSLOG_FACILITY}#g' ${SYSLOG_CONF_DIR}/1-iredmail-phpfpm.conf
|
||||
perl -pi -e 's#PH_PHP_FPM_LOG_MAIN#$ENV{PHP_FPM_LOG_MAIN}#g' ${SYSLOG_CONF_DIR}/1-iredmail-phpfpm.conf
|
||||
|
||||
#
|
||||
# modular log rotate config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/logrotate/php-fpm ${PHP_FPM_LOGROTATE_CONF}
|
||||
chmod 0644 ${PHP_FPM_LOGROTATE_CONF}
|
||||
|
||||
perl -pi -e 's#PH_PHP_FPM_LOG_DIR#$ENV{PHP_FPM_LOG_DIR}#g' ${PHP_FPM_LOGROTATE_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_PID_FILE#$ENV{PHP_FPM_PID_FILE}#g' ${PHP_FPM_LOGROTATE_CONF}
|
||||
|
||||
# Remove unused log file to avoid confusion.
|
||||
rm -f /var/log/php*fpm.log 2>/dev/null
|
||||
|
||||
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/syslog.d/php-fpm.conf ${SYSLOG_CONF_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_PHP_FPM_LOG_MAIN#$ENV{PHP_FPM_LOG_MAIN}#g' ${SYSLOG_CONF_DIR}/php-fpm.conf
|
||||
|
||||
#
|
||||
# modular newsyslog (log rotate) config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/newsyslog.conf.d/php-fpm ${PHP_FPM_LOGROTATE_CONF}
|
||||
|
||||
perl -pi -e 's#PH_PHP_FPM_LOG_MAIN#$ENV{PHP_FPM_LOG_MAIN}#g' ${PHP_FPM_LOGROTATE_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_LOG_SLOW#$ENV{PHP_FPM_LOG_SLOW}#g' ${PHP_FPM_LOGROTATE_CONF}
|
||||
perl -pi -e 's#PH_PHP_FPM_PID_FILE#$ENV{PHP_FPM_PID_FILE}#g' ${PHP_FPM_LOGROTATE_CONF}
|
||||
|
||||
perl -pi -e 's#PH_SYS_USER_SYSLOG#$ENV{SYS_USER_SYSLOG}#g' ${PHP_FPM_LOGROTATE_CONF}
|
||||
perl -pi -e 's#PH_SYS_GROUP_SYSLOG#$ENV{SYS_GROUP_SYSLOG}#g' ${PHP_FPM_LOGROTATE_CONF}
|
||||
elif [[ X"${KERNEL_NAME}" == X'OPENBSD' ]]; then
|
||||
if ! grep "${PHP_FPM_LOG_MAIN}" ${SYSLOG_CONF} &>/dev/null; then
|
||||
# '!!' means abort further evaluation after first match
|
||||
echo '!!php-fpm' >> ${SYSLOG_CONF}
|
||||
echo "${IREDMAIL_SYSLOG_FACILITY}.* ${PHP_FPM_LOG_MAIN}" >> ${SYSLOG_CONF}
|
||||
fi
|
||||
|
||||
# Remove unused log file to avoid confusion.
|
||||
rm -f /var/log/php-fpm.log &>/dev/null
|
||||
|
||||
if ! grep "${PHP_FPM_LOG_MAIN}" /etc/newsyslog.conf &>/dev/null; then
|
||||
cat >> /etc/newsyslog.conf <<EOF
|
||||
${PHP_FPM_LOG_MAIN} ${HTTPD_USER}:${HTTPD_GROUP} 600 7 * 24 Z ${PHP_FPM_PID_FILE}
|
||||
EOF
|
||||
fi
|
||||
|
||||
if ! grep "${PHP_FPM_LOG_SLOW}" /etc/newsyslog.conf &>/dev/null; then
|
||||
cat >> /etc/newsyslog.conf <<EOF
|
||||
${PHP_FPM_LOG_SLOW} ${HTTPD_USER}:${HTTPD_GROUP} 600 7 * 24 Z ${PHP_FPM_PID_FILE}
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
mkdir -p /var/log/nginx >> ${INSTALL_LOG} 2>&1
|
||||
service_control enable 'nginx_enable' 'YES'
|
||||
service_control enable 'php_fpm_enable' 'YES'
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# Enable unchrooted Nginx
|
||||
echo 'nginx_flags="-u"' >> ${RC_CONF_LOCAL}
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Nginx:
|
||||
* Configuration files:
|
||||
- ${NGINX_CONF}
|
||||
- ${NGINX_CONF_SITE_DEFAULT}
|
||||
- ${NGINX_CONF_SITE_DEFAULT_SSL}
|
||||
* Directories:
|
||||
- ${HTTPD_CONF_ROOT}
|
||||
- ${HTTPD_DOCUMENTROOT}
|
||||
* See also:
|
||||
- ${HTTPD_DOCUMENTROOT}/index.html
|
||||
|
||||
php-fpm:
|
||||
* Configuration files: ${PHP_FPM_POOL_WWW_CONF}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_nginx_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------
|
||||
# ------------------- OpenLDAP --------------------------
|
||||
# -------------------------------------------------------
|
||||
|
||||
openldap_config()
|
||||
{
|
||||
ECHO_INFO "Configure LDAP server: OpenLDAP."
|
||||
|
||||
ECHO_DEBUG "Stoping OpenLDAP."
|
||||
service_control stop ${OPENLDAP_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
backup_file ${OPENLDAP_SLAPD_CONF} ${OPENLDAP_LDAP_CONF}
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
# Run slapd with `slapd.conf` instead of `slapd.d`.
|
||||
if [ X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
perl -pi -e 's/#(SLAPD_OPTIONS=).*/${1}"-f $ENV{OPENLDAP_SLAPD_CONF}"/' ${OPENLDAP_SYSCONFIG_CONF}
|
||||
|
||||
elif [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
perl -pi -e 's#PH_SYS_USER_LDAP#$ENV{SYS_USER_LDAP}#g' ${SAMPLE_DIR}/systemd/slapd.service.d/override.conf
|
||||
perl -pi -e 's#PH_LDAP_SERVER_HOST#$ENV{LDAP_SERVER_HOST}#g' ${SAMPLE_DIR}/systemd/slapd.service.d/override.conf
|
||||
perl -pi -e 's#PH_LDAP_SERVER_PORT#$ENV{LDAP_SERVER_PORT}#g' ${SAMPLE_DIR}/systemd/slapd.service.d/override.conf
|
||||
perl -pi -e 's#PH_OPENLDAP_SLAPD_CONF#$ENV{OPENLDAP_SLAPD_CONF}#g' ${SAMPLE_DIR}/systemd/slapd.service.d/override.conf
|
||||
|
||||
cp -rf ${SAMPLE_DIR}/systemd/slapd.service.d /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# Add openldap daemon user to 'ssl-cert' group, so that slapd can read SSL key.
|
||||
usermod -G ssl-cert ${SYS_USER_LDAP}
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Start service when system start up.
|
||||
# 'slapd_enable=YES' is required to start service immediately.
|
||||
service_control enable 'slapd_enable' 'YES'
|
||||
service_control enable 'slapd_flags' "-h 'ldapi://%2fvar%2frun%2fopenldap%2fldapi/ ldap://0.0.0.0/ ldaps://0.0.0.0/'"
|
||||
service_control enable 'slapd_sockets' '/var/run/openldap/ldapi'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# Enable TLS/SSL support
|
||||
cat >> ${RC_CONF_LOCAL} <<EOF
|
||||
slapd_flags="-u ${SYS_USER_LDAP} -f ${OPENLDAP_SLAPD_CONF} -h ldapi:///\ ldap://0.0.0.0/\ ldaps://0.0.0.0/"
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Copy extar LDAP schema files
|
||||
cp -f ${LDAP_IREDMAIL_SCHEMA} ${OPENLDAP_SCHEMA_DIR}
|
||||
cp -f ${SAMPLE_DIR}/openldap/*.schema ${OPENLDAP_SCHEMA_DIR}
|
||||
|
||||
# Copy amavisd schema.
|
||||
# - On OpenBSD: package amavisd-new will copy schema file to /etc/openldap/schema
|
||||
if [ X"${DISTRO}" == X'RHEL' -o X"${DISTRO}" == X'FREEBSD' -o X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
cp -f ${SAMPLE_DIR}/amavisd/amavisd.schema ${OPENLDAP_SCHEMA_DIR}/${AMAVISD_LDAP_SCHEMA_NAME}
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Generate new server configuration file: ${OPENLDAP_SLAPD_CONF}."
|
||||
cp -f ${SAMPLE_DIR}/openldap/slapd.conf ${OPENLDAP_SLAPD_CONF}
|
||||
chown ${SYS_USER_LDAP}:${SYS_GROUP_LDAP} ${OPENLDAP_SLAPD_CONF}
|
||||
chmod 0640 ${OPENLDAP_SLAPD_CONF}
|
||||
|
||||
export LDAP_SUFFIX
|
||||
perl -pi -e 's#PH_OPENLDAP_SCHEMA_DIR#$ENV{OPENLDAP_SCHEMA_DIR}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_AMAVISD_LDAP_SCHEMA_NAME#$ENV{AMAVISD_LDAP_SCHEMA_NAME}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_OPENLDAP_PID_FILE#$ENV{OPENLDAP_PID_FILE}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_OPENLDAP_ARGS_FILE#$ENV{OPENLDAP_ARGS_FILE}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_OPENLDAP_MODULE_PATH#$ENV{OPENLDAP_MODULE_PATH}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' -o X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
perl -pi -e 's/^#(modulepath.*)/${1}/g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's/^#(moduleload.*back.*)/${1}/g' ${OPENLDAP_SLAPD_CONF}
|
||||
fi
|
||||
|
||||
perl -pi -e 's#PH_SSL_CERT_FILE#$ENV{SSL_CERT_FILE}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_SSL_KEY_FILE#$ENV{SSL_KEY_FILE}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_LDAP_BINDDN#$ENV{LDAP_BINDDN}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_LDAP_ADMIN_DN#$ENV{LDAP_ADMIN_DN}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_LDAP_BASEDN#$ENV{LDAP_BASEDN}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_LDAP_ADMIN_BASEDN#$ENV{LDAP_ADMIN_BASEDN}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_LDAP_SUFFIX#$ENV{LDAP_SUFFIX}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
|
||||
perl -pi -e 's#PH_OPENLDAP_DEFAULT_DBTYPE#$ENV{OPENLDAP_DEFAULT_DBTYPE}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_LDAP_DATA_DIR#$ENV{LDAP_DATA_DIR}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_LDAP_ROOTDN#$ENV{LDAP_ROOTDN}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
perl -pi -e 's#PH_LDAP_ROOTPW_SSHA#$ENV{LDAP_ROOTPW_SSHA}#g' ${OPENLDAP_SLAPD_CONF}
|
||||
|
||||
if [ X"${OPENLDAP_DEFAULT_DBTYPE}" == X'mdb' ]; then
|
||||
# maxsize is required by mdb
|
||||
perl -pi -e 's/^#(maxsize.*)/${1}/g' ${OPENLDAP_SLAPD_CONF}
|
||||
elif [ X"${OPENLDAP_DEFAULT_DBTYPE}" == X'bdb' \
|
||||
-o X"${OPENLDAP_DEFAULT_DBTYPE}" == X'hdb' ]; then
|
||||
# cachesize is required by hdb and bdb.
|
||||
perl -pi -e 's/^#(cachesize.*)//g' ${OPENLDAP_SLAPD_CONF}
|
||||
fi
|
||||
|
||||
# use slapd.conf insteald of slapd.d
|
||||
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
perl -pi -e 's#^(SLAPD_CONF=).*#${1}"$ENV{OPENLDAP_SLAPD_CONF}"#' ${OPENLDAP_SYSCONFIG_CONF}
|
||||
perl -pi -e 's#^(SLAPD_PIDFILE=).*#${1}"$ENV{OPENLDAP_PID_FILE}"#' ${OPENLDAP_SYSCONFIG_CONF}
|
||||
fi
|
||||
|
||||
# Password verification with sha2.
|
||||
if [ X"${OPENLDAP_HAS_SHA2}" == X'YES' ]; then
|
||||
perl -pi -e 's/^#(moduleload.*)(pw_sha2)/${1}$ENV{OPENLDAP_MOD_PW_SHA2}/' ${OPENLDAP_SLAPD_CONF}
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Generate new client configuration file: ${OPENLDAP_LDAP_CONF}"
|
||||
cp ${SAMPLE_DIR}/openldap/ldap.conf ${OPENLDAP_LDAP_CONF}
|
||||
perl -pi -e 's#PH_LDAP_SUFFIX#$ENV{LDAP_SUFFIX}#g' ${OPENLDAP_LDAP_CONF}
|
||||
perl -pi -e 's#PH_LDAP_SERVER_HOST#$ENV{LDAP_SERVER_HOST}#g' ${OPENLDAP_LDAP_CONF}
|
||||
perl -pi -e 's#PH_LDAP_SERVER_PORT#$ENV{LDAP_SERVER_PORT}#g' ${OPENLDAP_LDAP_CONF}
|
||||
perl -pi -e 's#PH_SSL_CERT_FILE#$ENV{SSL_CERT_FILE}#g' ${OPENLDAP_LDAP_CONF}
|
||||
chown ${SYS_USER_LDAP}:${SYS_GROUP_LDAP} ${OPENLDAP_LDAP_CONF}
|
||||
|
||||
ECHO_DEBUG "Create directory used to store OpenLDAP log file: ${OPENLDAP_LOG_DIR}"
|
||||
mkdir -p ${OPENLDAP_LOG_DIR}
|
||||
chown ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${OPENLDAP_LOG_DIR}
|
||||
chmod 0750 ${OPENLDAP_LOG_DIR}
|
||||
|
||||
ECHO_DEBUG "Create empty log file: ${OPENLDAP_LOG_FILE}."
|
||||
touch ${OPENLDAP_LOG_FILE}
|
||||
chown ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} ${OPENLDAP_LOG_FILE}
|
||||
chmod 0640 ${OPENLDAP_LOG_FILE}
|
||||
|
||||
ECHO_DEBUG "Setting up syslog and logrotate config files for OpenLDAP."
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
cp ${SAMPLE_DIR}/rsyslog.d/1-iredmail-openldap.conf ${SYSLOG_CONF_DIR}
|
||||
perl -pi -e 's#PH_OPENLDAP_SYSLOG_FACILITY#$ENV{OPENLDAP_SYSLOG_FACILITY}#g' ${SYSLOG_CONF_DIR}/1-iredmail-openldap.conf
|
||||
perl -pi -e 's#PH_OPENLDAP_LOG_FILE#$ENV{OPENLDAP_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/1-iredmail-openldap.conf
|
||||
|
||||
#
|
||||
# modular newsyslog (log rotate) config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/logrotate/openldap ${OPENLDAP_LOGROTATE_FILE}
|
||||
|
||||
perl -pi -e 's#PH_OPENLDAP_LOG_FILE#$ENV{OPENLDAP_LOG_FILE}#g' ${OPENLDAP_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYS_USER_LDAP#$ENV{SYS_USER_LDAP}#g' ${OPENLDAP_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYS_GROUP_LDAP#$ENV{SYS_GROUP_LDAP}#g' ${OPENLDAP_LOGROTATE_FILE}
|
||||
perl -pi -e 's#PH_SYSLOG_POSTROTATE_CMD#$ENV{SYSLOG_POSTROTATE_CMD}#g' ${OPENLDAP_LOGROTATE_FILE}
|
||||
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
#
|
||||
# modular syslog config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/syslog.d/slapd.conf ${SYSLOG_CONF_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's#PH_OPENLDAP_LOG_FILE#$ENV{OPENLDAP_LOG_FILE}#g' ${SYSLOG_CONF_DIR}/slapd.conf
|
||||
|
||||
#
|
||||
# modular newsyslog (log rotate) config file
|
||||
#
|
||||
cp -f ${SAMPLE_DIR}/freebsd/newsyslog.conf.d/slapd ${LOGROTATE_DIR}
|
||||
perl -pi -e 's#PH_OPENLDAP_LOG_FILE#$ENV{OPENLDAP_LOG_FILE}#g' ${LOGROTATE_DIR}/slapd
|
||||
perl -pi -e 's#PH_SYS_USER_SYSLOG#$ENV{SYS_USER_SYSLOG}#g' ${LOGROTATE_DIR}/slapd
|
||||
perl -pi -e 's#PH_SYS_GROUP_SYSLOG#$ENV{SYS_GROUP_SYSLOG}#g' ${LOGROTATE_DIR}/slapd
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# '!!' means abort further evaluation after first match
|
||||
echo -e '!!slapd' >> ${SYSLOG_CONF}
|
||||
echo -e "*.*\t\t\t\t\t\t${OPENLDAP_LOG_FILE}" >> ${SYSLOG_CONF}
|
||||
|
||||
if ! grep "${OPENLDAP_LOG_FILE}" /etc/newsyslog.conf &>/dev/null; then
|
||||
cat >> /etc/newsyslog.conf <<EOF
|
||||
${OPENLDAP_LOG_FILE} ${SYS_USER_SYSLOG}:${SYS_GROUP_SYSLOG} 640 7 * 24 Z
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Restarting syslog."
|
||||
if [ X"${DISTRO}" == X'RHEL' \
|
||||
-o X"${DISTRO}" == X'DEBIAN' \
|
||||
-o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
service_control restart rsyslog >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
echo 'export status_openldap_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
openldap_data_initialize()
|
||||
{
|
||||
ECHO_DEBUG "Create instance directory for openldap tree: ${LDAP_DATA_DIR}."
|
||||
mkdir -p ${LDAP_DATA_DIR}
|
||||
|
||||
# Get DB_CONFIG.example.
|
||||
if [ X"${OPENLDAP_DEFAULT_DBTYPE}" == X'hdb' ]; then
|
||||
cp -f ${OPENLDAP_DB_CONFIG_SAMPLE} ${LDAP_DATA_DIR}/DB_CONFIG
|
||||
fi
|
||||
|
||||
chown -R ${SYS_USER_LDAP}:${SYS_GROUP_LDAP} ${OPENLDAP_DATA_DIR}
|
||||
chmod -R 0700 ${OPENLDAP_DATA_DIR}
|
||||
|
||||
ECHO_DEBUG "Starting OpenLDAP."
|
||||
service_control restart ${OPENLDAP_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Sleep 5 seconds for LDAP daemon initialization ..."
|
||||
sleep 5
|
||||
|
||||
ECHO_DEBUG "Populate LDAP tree."
|
||||
ldapadd -x -D "${LDAP_ROOTDN}" -w "${LDAP_ROOTPW}" -f ${LDAP_INIT_LDIF} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
OpenLDAP:
|
||||
* LDAP suffix: ${LDAP_SUFFIX}
|
||||
* LDAP root dn: ${LDAP_ROOTDN}, password: ${LDAP_ROOTPW}
|
||||
* LDAP bind dn (read-only): ${LDAP_BINDDN}, password: ${LDAP_BINDPW}
|
||||
* LDAP admin dn (read-write): ${LDAP_ADMIN_DN}, password: ${LDAP_ADMIN_PW}
|
||||
* LDAP base dn: ${LDAP_BASEDN}
|
||||
* LDAP admin base dn: ${LDAP_ADMIN_BASEDN}
|
||||
* Configuration files:
|
||||
- ${OPENLDAP_CONF_ROOT}
|
||||
- ${OPENLDAP_SLAPD_CONF}
|
||||
- ${OPENLDAP_LDAP_CONF}
|
||||
- ${OPENLDAP_SCHEMA_DIR}/${PROG_NAME_LOWERCASE}.schema
|
||||
* Log file related:
|
||||
- ${SYSLOG_CONF}
|
||||
- ${OPENLDAP_LOG_FILE}
|
||||
- ${OPENLDAP_LOGROTATE_FILE}
|
||||
* Data dir and files:
|
||||
- ${OPENLDAP_DATA_DIR}
|
||||
- ${LDAP_DATA_DIR}
|
||||
- ${LDAP_DATA_DIR}/DB_CONFIG (available if backend is bdb or hdb)
|
||||
* RC script:
|
||||
- ${OPENLDAP_RC_SCRIPT}
|
||||
* See also:
|
||||
- ${LDAP_INIT_LDIF}
|
||||
|
||||
EOF
|
||||
|
||||
write_iredmail_kv ldap_root_password "${LDAP_ROOTPW}"
|
||||
write_iredmail_kv ldap_vmail_password "${LDAP_BINDPW}"
|
||||
write_iredmail_kv ldap_vmailadmin_password "${LDAP_ADMIN_PW}"
|
||||
|
||||
echo 'export status_openldap_data_initialize="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
# -------------------------------------------
|
||||
# Install all optional components.
|
||||
# -------------------------------------------
|
||||
optional_components()
|
||||
{
|
||||
# iRedAPD.
|
||||
check_status_before_run iredapd_setup
|
||||
|
||||
# iRedAdmin.
|
||||
[ X"${USE_IREDADMIN}" == X'YES' ] && \
|
||||
check_status_before_run iredadmin_setup
|
||||
|
||||
# Roundcubemail.
|
||||
[ X"${USE_ROUNDCUBE}" == X'YES' ] && \
|
||||
check_status_before_run rcm_setup
|
||||
|
||||
# SOGo
|
||||
[ X"${USE_SOGO}" == X'YES' ] && \
|
||||
check_status_before_run sogo_setup
|
||||
|
||||
# Fail2ban.
|
||||
[ X"${USE_FAIL2BAN}" == X'YES' -a X"${DISTRO}" != X'FREEBSD' ] && \
|
||||
check_status_before_run fail2ban_setup
|
||||
|
||||
# netdata.
|
||||
[ X"${USE_NETDATA}" == X'YES' ] && \
|
||||
check_status_before_run netdata_setup
|
||||
}
|
||||
@@ -0,0 +1,785 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
install_all()
|
||||
{
|
||||
ALL_PKGS=''
|
||||
PIP2_MODULES=''
|
||||
PIP3_MODULES=''
|
||||
NABLED_SERVICES=''
|
||||
DISABLED_SERVICES=''
|
||||
|
||||
# Specify version numbers while installing Python modules with pip.
|
||||
PIP_VERSION_PYTHON_LDAP='>=3.3.0'
|
||||
PIP_VERSION_WEBPY='>=0.51'
|
||||
PIP_VERSION_UWSGI='>=2.0.18'
|
||||
PIP_VERSION_REQUESTS='>=2.23.0'
|
||||
PIP_VERSION_PYMYSQL='>=0.9.3'
|
||||
PIP_VERSION_PSYCOPG2='>=2.8.5'
|
||||
PIP_VERSION_PYCURL='>=7.43.0.5'
|
||||
# more-itertools-5.0.0 is the last version which supports Python-2.7.
|
||||
PIP2_VERSION_MORE_ITERTOOLS='==5.0.0'
|
||||
|
||||
# OpenBSD only
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
PKG_SCRIPTS=''
|
||||
|
||||
# OpenBSD-6.7
|
||||
OB_PKG_PHP_VER='%7.4'
|
||||
OB_PKG_OPENLDAP_SERVER_VER='-2.4.49'
|
||||
OB_PKG_OPENLDAP_CLIENT_VER='-2.4.49'
|
||||
fi
|
||||
|
||||
# Install PHP if there's a web server running -- php is too popular.
|
||||
if [ X"${WEB_SERVER}" == X'NGINX' ]; then
|
||||
export IREDMAIL_USE_PHP='YES'
|
||||
fi
|
||||
|
||||
# Enable rsyslog on Linux.
|
||||
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} rsyslog firewalld"
|
||||
DISABLED_SERVICES="${DISABLED_SERVICES} exim sendmail"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} rsyslog firewalld"
|
||||
PIP2_MODULES="${PIP2_MODULES} web.py${PIP_VERSION_WEBPY} more-itertools${PIP2_VERSION_MORE_ITERTOOLS}"
|
||||
elif [ X"${DISTRO}" == X'UBUNTU' -a X"${DISTRO_CODENAME}" == X'focal' ]; then
|
||||
# Ubuntu 20.04
|
||||
PIP2_MODULES="${PIP2_MODULES} web.py${PIP_VERSION_WEBPY} more-itertools${PIP2_VERSION_MORE_ITERTOOLS} uwsgi${PIP_VERSION_UWSGI}"
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
PIP2_MODULES="${PIP2_MODULES} uwsgi${PIP_VERSION_UWSGI}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Postfix.
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} ${POSTFIX_RC_SCRIPT_NAME}"
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} postfix"
|
||||
|
||||
# Exclude postfix package from iRedMail repo.
|
||||
# Postfix in iRedMail repo was rebuilt to support PostgreSQL.
|
||||
if [ X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ] || [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
if [ -f ${LOCAL_REPO_FILE} ]; then
|
||||
perl -pi -e 's/^#(exclude=postfix.*)/${1}/' ${LOCAL_REPO_FILE}
|
||||
fi
|
||||
fi
|
||||
elif [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
# pcre support is required and available in iRedMail yum repo.
|
||||
ALL_PKGS="${ALL_PKGS} postfix-pcre"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} postfix-ldap"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} postfix-mysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} postfix-pgsql"
|
||||
fi
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# libsasl2-modules is required for sasl auth (used by relay host which
|
||||
# requires sasl auth)
|
||||
ALL_PKGS="${ALL_PKGS} postfix postfix-pcre libsasl2-modules"
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} postfix--sasl2-ldap%stable"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} postfix--sasl2-mysql%stable"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} postfix--sasl2-pgsql%stable"
|
||||
fi
|
||||
|
||||
# Backend: OpenLDAP, MySQL, PGSQL and extra packages.
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
# OpenLDAP server & client.
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} ${OPENLDAP_RC_SCRIPT_NAME} ${MYSQL_RC_SCRIPT_NAME}"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} openldap openldap-clients openldap-servers mariadb-server mod_ldap"
|
||||
elif [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
# Install packages from Symas yum repo.
|
||||
ALL_PKGS="${ALL_PKGS} symas-openldap-servers symas-openldap-clients mariadb-server"
|
||||
PIP2_MODULES="${PIP2_MODULES} python-ldap${PIP_VERSION_PYTHON_LDAP}"
|
||||
|
||||
if [ ! -f ${YUM_REPOS_DIR}/symas-openldap.repo ]; then
|
||||
cp -f ${SAMPLE_DIR}/yum/symas-openldap.repo ${YUM_REPOS_DIR}/
|
||||
fi
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} slapd ldap-utils postfix-ldap libnet-ldap-perl libdbd-mysql-perl mariadb-server mariadb-client"
|
||||
|
||||
if [ X"${DISTRO_CODENAME}" != X'stretch' \
|
||||
-a X"${DISTRO_CODENAME}" != X'buster' \
|
||||
-a X"${DISTRO_CODENAME}" != X'bionic' ]; then
|
||||
# Ubuntu 20.04+
|
||||
ALL_PKGS="${ALL_PKGS} libldap2-dev libsasl2-dev"
|
||||
PIP2_MODULES="${PIP2_MODULES} python-ldap${PIP_VERSION_PYTHON_LDAP}"
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} openldap-server${OB_PKG_OPENLDAP_SERVER_VER}"
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} ${OPENLDAP_RC_SCRIPT_NAME}"
|
||||
|
||||
ALL_PKGS="${ALL_PKGS} mariadb-server mariadb-client p5-ldap p5-DBD-mysql"
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} ${MYSQL_RC_SCRIPT_NAME}"
|
||||
fi
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
# MySQL server & client.
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} ${MYSQL_RC_SCRIPT_NAME}"
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
# Install MySQL client
|
||||
ALL_PKGS="${ALL_PKGS} mariadb"
|
||||
|
||||
if [ X"${USE_EXISTING_MYSQL}" != X'YES' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} mariadb-server"
|
||||
fi
|
||||
|
||||
# Perl module
|
||||
ALL_PKGS="${ALL_PKGS} perl-DBD-MySQL"
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# MySQL server and client.
|
||||
ALL_PKGS="${ALL_PKGS} mariadb-client"
|
||||
|
||||
if [ X"${USE_EXISTING_MYSQL}" != X'YES' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} mariadb-server"
|
||||
fi
|
||||
|
||||
ALL_PKGS="${ALL_PKGS} postfix-mysql libdbd-mysql-perl"
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} mariadb-client"
|
||||
|
||||
if [ X"${USE_EXISTING_MYSQL}" != X'YES' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} mariadb-server p5-DBD-mysql"
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} ${MYSQL_RC_SCRIPT_NAME}"
|
||||
fi
|
||||
fi
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} ${PGSQL_RC_SCRIPT_NAME}"
|
||||
|
||||
# PGSQL server & client.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} postgresql-server postgresql-contrib perl-DBD-Pg"
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# postgresql-contrib provides extension 'dblink' used in Roundcube password plugin.
|
||||
ALL_PKGS="${ALL_PKGS} postgresql postgresql-client postgresql-contrib postfix-pgsql libdbd-pg-perl"
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} postgresql-client postgresql-server postgresql-contrib p5-DBD-Pg"
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} ${PGSQL_RC_SCRIPT_NAME}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# PHP
|
||||
if [ X"${IREDMAIL_USE_PHP}" == X'YES' ]; then
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
[[ X"${DISTRO_VERSION}" == X'7' ]] && ALL_PKGS="${ALL_PKGS} php-common php-fpm php-gd php-xml php-mysql php-ldap php-pgsql php-imap php-mbstring php-pecl-apc php-intl php-mcrypt"
|
||||
[[ X"${DISTRO_VERSION}" == X'8' ]] && ALL_PKGS="${ALL_PKGS} php-cli php-common php-fpm php-gd php-xml php-mysqlnd php-ldap php-pgsql php-mbstring php-pecl-apcu php-intl php-json"
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# Debian 9
|
||||
ALL_PKGS="${ALL_PKGS} php-cli php-fpm php-json php-gd php-curl mcrypt php-intl php-xml php-mbstring"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} php-ldap php-mysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} php-mysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} php-pgsql"
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} php${OB_PKG_PHP_VER} php-bz2${OB_PKG_PHP_VER} php-imap${OB_PKG_PHP_VER} php-gd${OB_PKG_PHP_VER} php-intl${OB_PKG_PHP_VER}"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} php-ldap${OB_PKG_PHP_VER} php-pdo_mysql${OB_PKG_PHP_VER}"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} php-pdo_mysql${OB_PKG_PHP_VER}"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} php-pdo_pgsql${OB_PKG_PHP_VER}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Nginx
|
||||
if [ X"${WEB_SERVER}" == X'NGINX' ]; then
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} nginx"
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} nginx-full"
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} nginx"
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} ${NGINX_RC_SCRIPT_NAME} ${PHP_FPM_RC_SCRIPT_NAME}"
|
||||
fi
|
||||
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} ${NGINX_RC_SCRIPT_NAME} ${PHP_FPM_RC_SCRIPT_NAME}"
|
||||
fi
|
||||
|
||||
# Dovecot.
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} ${DOVECOT_RC_SCRIPT_NAME}"
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot dovecot-pigeonhole"
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot-mysql"
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot-pgsql"
|
||||
fi
|
||||
|
||||
# We use Dovecot SASL auth instead of saslauthd
|
||||
DISABLED_SERVICES="${DISABLED_SERVICES} saslauthd"
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-managesieved dovecot-sieve"
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot-ldap dovecot-mysql"
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot-mysql"
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot-pgsql"
|
||||
fi
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot dovecot-pigeonhole"
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} ${DOVECOT_RC_SCRIPT_NAME}"
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot-ldap dovecot-mysql"
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot-mysql"
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} dovecot-postgresql"
|
||||
fi
|
||||
|
||||
DISABLED_SERVICES="${DISABLED_SERVICES} saslauthd"
|
||||
fi
|
||||
|
||||
# Amavisd-new, ClamAV, Altermime.
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} ${CLAMAV_CLAMD_SERVICE_NAME} ${AMAVISD_RC_SCRIPT_NAME}"
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} amavisd-new spamassassin altermime perl-Mail-SPF lz4 clamav clamav-update clamav-server clamav-server-systemd"
|
||||
[[ X"${DISTRO_VERSION}" == X'7' ]] && ALL_PKGS="${ALL_PKGS} unrar pax"
|
||||
|
||||
# RHEL uses service name 'clamd@amavisd' instead of clamd.
|
||||
DISABLED_SERVICES="${DISABLED_SERVICES} clamd spamassassin"
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} amavisd-new libcrypt-openssl-rsa-perl libmail-dkim-perl clamav-freshclam clamav-daemon spamassassin altermime arj nomarch cpio lzop cabextract p7zip-full rpm libmail-spf-perl unrar-free pax lrzip"
|
||||
|
||||
if [ X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ X"${DISTRO_CODENAME}" == X'bionic' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} libclamunrar7"
|
||||
else
|
||||
ALL_PKGS="${ALL_PKGS} libclamunrar9"
|
||||
fi
|
||||
fi
|
||||
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} ${CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME}"
|
||||
DISABLED_SERVICES="${DISABLED_SERVICES} spamassassin"
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} rpm2cpio amavisd-new amavisd-new-utils p5-Mail-SPF p5-Mail-SpamAssassin clamav unrar altermime"
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} ${CLAMAV_CLAMD_SERVICE_NAME} ${CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME} ${AMAVISD_RC_SCRIPT_NAME}"
|
||||
fi
|
||||
|
||||
# mlmmj: mailing list manager
|
||||
ALL_PKGS="${ALL_PKGS} mlmmj"
|
||||
|
||||
# mlmmjadmin: RESTful API server used to manage mlmmj.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
PIP3_MODULES="${PIP3_MODULES} web.py${PIP_VERSION_WEBPY}"
|
||||
|
||||
[ X"${DISTRO_VERSION}" == X'7' ] \
|
||||
&& ALL_PKGS="${ALL_PKGS} python36 python3-pip python36-requests uwsgi uwsgi-logger-syslog uwsgi-plugin-python36"
|
||||
|
||||
if [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python38 python3-requests python3-devel"
|
||||
PIP3_MODULES="${PIP3_MODULES} uwsgi${PIP_VERSION_UWSGI}"
|
||||
fi
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
if [[ X"${DISTRO_VERSION}" == X'7' ]]; then
|
||||
# `gcc`, `python3-devel`, `openldap-devel` are required to compile `python-ldap`.
|
||||
ALL_PKGS="${ALL_PKGS} python36-PyMySQL gcc python3-devel openldap-devel"
|
||||
PIP3_MODULES="${PIP3_MODULES} python-ldap${PIP_VERSION_PYTHON_LDAP}"
|
||||
fi
|
||||
|
||||
[[ X"${DISTRO_VERSION}" == X'8' ]] && ALL_PKGS="${ALL_PKGS} python3-ldap python3-PyMySQL"
|
||||
fi
|
||||
|
||||
if [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
[[ X"${DISTRO_VERSION}" == X'7' ]] && ALL_PKGS="${ALL_PKGS} python36-PyMySQL"
|
||||
[[ X"${DISTRO_VERSION}" == X'8' ]] && ALL_PKGS="${ALL_PKGS} python3-PyMySQL"
|
||||
fi
|
||||
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python3-psycopg2"
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python3-setuptools python3-pip python3-wheel python3-requests uwsgi uwsgi-plugin-python3"
|
||||
PIP3_MODULES="${PIP3_MODULES} web.py${PIP_VERSION_WEBPY}"
|
||||
|
||||
if [ X"${DISTRO}" == X'DEBIAN' ]; then
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
if [ X"${DISTRO_VERSION}" == X'9' ]; then
|
||||
# pyldap is a fork of python-ldap.
|
||||
ALL_PKGS="${ALL_PKGS} python3-pyldap python3-pymysql"
|
||||
else
|
||||
ALL_PKGS="${ALL_PKGS} python3-ldap python3-pymysql"
|
||||
fi
|
||||
fi
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} python3-pymysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python3-psycopg2"
|
||||
else
|
||||
if [ X"${DISTRO_CODENAME}" == X'bionic' ]; then
|
||||
# Ubuntu 18.04
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} python3-ldap python3-pymysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} python3-pymysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python3-psycopg2"
|
||||
else
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} python3-ldap python3-pymysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} python3-pymysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python3-psycopg2"
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} py3-sqlalchemy py3-dnspython py3-webpy py3-requests"
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} py3-ldap py3-mysqlclient"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} py3-mysqlclient"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} py3-psycopg2"
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} mlmmjadmin"
|
||||
fi
|
||||
|
||||
# Roundcube
|
||||
if [ X"${USE_ROUNDCUBE}" == X'YES' ]; then
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
[[ X"${DISTRO_VERSION}" == X'7' ]] && ALL_PKGS="${ALL_PKGS} php-pear-Net-IDNA2"
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
if [ X"${DISTRO_CODENAME}" == X"bionic" -o X"${DISTRO_CODENAME}" == X"stretch" ]; then
|
||||
ALL_PKGS="${ALL_PKGS} php-net-ldap3"
|
||||
else
|
||||
ALL_PKGS="${ALL_PKGS} php-ldap"
|
||||
fi
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} php-pspell${OB_PKG_PHP_VER} php-intl${OB_PKG_PHP_VER}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# SOGo
|
||||
if [ X"${USE_SOGO}" == X'YES' ]; then
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} ${SOGO_RC_SCRIPT_NAME} ${MEMCACHED_RC_SCRIPT_NAME}"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} sogo sogo-activesync libwbxml sogo-ealarms-notify sogo-tool"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} sope49-gdl1-mysql sope49-ldap"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} sope49-gdl1-mysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} sope49-gdl1-postgresql"
|
||||
|
||||
if [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} mysql-libs"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy yum repo file
|
||||
ECHO_INFO "Add yum repo for SOGo: ${YUM_REPOS_DIR}/sogo.repo."
|
||||
cat > ${YUM_REPOS_DIR}/sogo.repo <<EOF
|
||||
[SOGo]
|
||||
name=Inverse SOGo Repository
|
||||
enabled=1
|
||||
gpgcheck=0
|
||||
|
||||
# SOGo v3 stable release.
|
||||
# WARNING: A proper support contract from Inverse is required:
|
||||
# https://sogo.nu/support/index.html#support-plans
|
||||
#baseurl=${SOGO_PKG_MIRROR}/SOGo/release/${SOGO_VERSION}/rhel/${DISTRO_VERSION}/\$basearch
|
||||
|
||||
# SOGo v3 nightly builds
|
||||
baseurl=${SOGO_PKG_MIRROR}/SOGo/nightly/${SOGO_VERSION}/rhel/${DISTRO_VERSION}/\$basearch
|
||||
EOF
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} memcached sogo sogo-activesync"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} sope4.9-gdl1-mysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} sope4.9-gdl1-mysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} sope4.9-gdl1-postgresql"
|
||||
|
||||
ECHO_INFO "Add apt repo for SOGo: ${SOGO_PKG_MIRROR}"
|
||||
if [ X"${DISTRO}" == X'DEBIAN' ]; then
|
||||
echo "deb ${SOGO_PKG_MIRROR}/SOGo/nightly/${SOGO_VERSION}/debian ${DISTRO_CODENAME} ${DISTRO_CODENAME}" > /etc/apt/sources.list.d/sogo-nightly.list
|
||||
elif [ X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
echo "deb ${SOGO_PKG_MIRROR}/SOGo/nightly/${SOGO_VERSION}/ubuntu ${DISTRO_CODENAME} ${DISTRO_CODENAME}" > /etc/apt/sources.list.d/sogo-nightly.list
|
||||
fi
|
||||
|
||||
ECHO_INFO "Import apt key (${SOGO_PKG_MIRROR_APT_KEY}) for SOGo repo (${SOGO_PKG_MIRROR})."
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-key ${SOGO_PKG_MIRROR_APT_KEY}
|
||||
|
||||
# Try another PGP key server if `keyserver.ubuntu.com` failed
|
||||
if [ X"$?" != X'0' ]; then
|
||||
apt-key adv --keyserver pgp.mit.edu --recv-key ${SOGO_PKG_MIRROR_APT_KEY}
|
||||
fi
|
||||
|
||||
ECHO_INFO "Resynchronizing the package index files (apt update) ..."
|
||||
${APTGET} update
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} sogo memcached--"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} sope-mysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} sope-mysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} sope-postgres"
|
||||
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} ${MEMCACHED_RC_SCRIPT_NAME} ${SOGO_RC_SCRIPT_NAME}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install few Python modules with `pip` for Python-2.
|
||||
# We still have few Python applications not ported to Py3.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python2-pip"
|
||||
elif [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} gcc libcurl-devel openssl-devel python2-devel python2-pip"
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} openldap-devel"
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'UBUNTU' -a X"${DISTRO_CODENAME}" != X'bionic' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python2-dev curl libcurl4-openssl-dev python-setuptools"
|
||||
fi
|
||||
|
||||
# iRedAPD. Requires Python-3.
|
||||
# Don't append service name 'iredapd' to ${ENABLED_SERVICES} since we don't
|
||||
# have RC script ready in this stage.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
PIP3_MODULES="${PIP3_MODULES} web.py${PIP_VERSION_WEBPY}"
|
||||
|
||||
[ X"${DISTRO_VERSION}" == X'7' ] \
|
||||
&& ALL_PKGS="${ALL_PKGS} python36 python3-pip python36-sqlalchemy python36-setuptools python36-dns python36-requests python36-six"
|
||||
[ X"${DISTRO_VERSION}" == X'8' ] \
|
||||
&& ALL_PKGS="${ALL_PKGS} python36 python3-sqlalchemy python3-setuptools python3-dns python3-requests python3-six"
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
if [[ X"${DISTRO_VERSION}" == X'7' ]]; then
|
||||
# `gcc`, `python3-devel`, `openldap-devel` are required to compile `python-ldap`.
|
||||
ALL_PKGS="${ALL_PKGS} python36-PyMySQL gcc python3-devel openldap-devel"
|
||||
PIP3_MODULES="${PIP3_MODULES} python-ldap${PIP_VERSION_PYTHON_LDAP}"
|
||||
fi
|
||||
|
||||
[[ X"${DISTRO_VERSION}" == X'8' ]] && ALL_PKGS="${ALL_PKGS} python3-ldap python3-PyMySQL"
|
||||
fi
|
||||
|
||||
if [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
[[ X"${DISTRO_VERSION}" == X'7' ]] && ALL_PKGS="${ALL_PKGS} python36-PyMySQL"
|
||||
[[ X"${DISTRO_VERSION}" == X'8' ]] && ALL_PKGS="${ALL_PKGS} python3-PyMySQL"
|
||||
fi
|
||||
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python3-psycopg2"
|
||||
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python3-sqlalchemy python3-dnspython python3-requests python3-pip"
|
||||
PIP3_MODULES="${PIP3_MODULES} web.py${PIP_VERSION_WEBPY}"
|
||||
|
||||
if [ X"${DISTRO}" == X'DEBIAN' ]; then
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
if [ X"${DISTRO_VERSION}" == X'9' ]; then
|
||||
# pyldap is a fork of python-ldap.
|
||||
ALL_PKGS="${ALL_PKGS} python3-pyldap python3-pymysql"
|
||||
else
|
||||
ALL_PKGS="${ALL_PKGS} python3-ldap python3-pymysql"
|
||||
fi
|
||||
fi
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} python3-pymysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python3-psycopg2"
|
||||
|
||||
elif [ X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ X"${DISTRO_CODENAME}" == X'bionic' ]; then
|
||||
# Ubuntu 18.04
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} python3-ldap python3-pymysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} python3-pymysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python3-psycopg2"
|
||||
else
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} python3-ldap python3-pymysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} python3-pymysql"
|
||||
|
||||
if [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
# `postgresql-server-dev-12` is used to compile `psycopg2` for py2.
|
||||
ALL_PKGS="${ALL_PKGS} python3-psycopg2 postgresql-server-dev-12"
|
||||
PIP2_MODULES="${PIP2_MODULES} psycopg2${PIP_VERSION_PSYCOPG2}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} py3-sqlalchemy py3-dnspython py3-webpy"
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} py3-ldap py3-mysqlclient"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} py3-mysqlclient"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} py3-psycopg2"
|
||||
PKG_SCRIPTS="${PKG_SCRIPTS} iredapd"
|
||||
fi
|
||||
|
||||
# OpenBSD: List postfix as last startup script.
|
||||
export PKG_SCRIPTS="${PKG_SCRIPTS} ${POSTFIX_RC_SCRIPT_NAME}"
|
||||
|
||||
# iRedAdmin. Still runs with py2.
|
||||
# Force install all dependent packages to help customers install iRedAdmin-Pro.
|
||||
# web.py, dnspython, requests, jinja2, mysqldb or pymysql.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python-jinja2 python-netifaces python-pycurl python-requests py-bcrypt python2-PyMySQL uwsgi-plugin-python2 python-dns uwsgi-plugin-python uwsgi-plugin-syslog"
|
||||
PIP2_MODULES="${PIP2_MODULES} web.py${PIP_VERSION_WEBPY} more-itertools${PIP2_VERSION_MORE_ITERTOOLS}"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} python-ldap python2-pymysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} python2-pymysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python-psycopg2"
|
||||
|
||||
elif [ X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python2-jinja2 python2-PyMySQL python2-requests python2-dns"
|
||||
PIP2_MODULES="${PIP2_MODULES} web.py${PIP_VERSION_WEBPY} more-itertools${PIP2_VERSION_MORE_ITERTOOLS} uwsgi${PIP_VERSION_UWSGI} pycurl${PIP_VERSION_PYCURL}"
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
PIP2_MODULES="${PIP2_MODULES} python-ldap${PIP_VERSION_PYTHON_LDAP} PyMySQL${PIP_VERSION_PYMYSQL}"
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
PIP2_MODULES="${PIP2_MODULES} PyMySQL${PIP_VERSION_PYMYSQL}"
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python2-psycopg2"
|
||||
fi
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python-jinja2 python-netifaces python-pycurl python-bcrypt python-dnspython"
|
||||
|
||||
if [ X"${DISTRO_CODENAME}" == X"bionic" -o X"${DISTRO_CODENAME}" == X"stretch" ]; then
|
||||
# Ubuntu 18.04 and Debian 9.
|
||||
ALL_PKGS="${ALL_PKGS} python-webpy python-mysqldb python-requests uwsgi uwsgi-plugin-python"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} python-ldap python-mysqldb python-pymysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} python-mysqldb python-pymysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python-psycopg2"
|
||||
elif [ X"${DISTRO_CODENAME}" == X"buster" ]; then
|
||||
# Debian 10
|
||||
ALL_PKGS="${ALL_PKGS} python-pip python-requests uwsgi-plugin-python"
|
||||
PIP2_MODULES="${PIP2_MODULES} web.py${PIP_VERSION_WEBPY} more-itertools${PIP2_VERSION_MORE_ITERTOOLS}"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} python-ldap python-mysqldb python-pymysql"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} python-mysqldb python-pymysql"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} python-psycopg2"
|
||||
elif [ X"${DISTRO_CODENAME}" == X"focal" ]; then
|
||||
# Ubuntu 20.04
|
||||
PIP2_MODULES="${PIP2_MODULES} web.py${PIP_VERSION_WEBPY} more-itertools${PIP2_VERSION_MORE_ITERTOOLS} requests${PIP_VERSION_REQUESTS} uwsgi${PIP_VERSION_UWSGI}"
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python3-ldap python3-pymysql"
|
||||
PIP2_MODULES="${PIP2_MODULES} python-ldap${PIP_VERSION_PYTHON_LDAP}"
|
||||
elif [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} python3-pymysql"
|
||||
PIP2_MODULES="${PIP2_MODULES} PyMySQL${PIP_VERSION_PYMYSQL}"
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
# `postgresql-server-dev-12` is used to compile `psycopg2` for py2.
|
||||
ALL_PKGS="${ALL_PKGS} python3-psycopg2 postgresql-server-dev-12"
|
||||
PIP2_MODULES="${PIP2_MODULES} psycopg2${PIP_VERSION_PSYCOPG2}"
|
||||
fi
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} py-pip py-jinja2 py-webpy py-flup py-bcrypt py-curl py-requests py-netifaces py-dnspython"
|
||||
|
||||
[ X"${BACKEND}" == X'OPENLDAP' ] && ALL_PKGS="${ALL_PKGS} py-ldap py-mysqlclient"
|
||||
[ X"${BACKEND}" == X'MYSQL' ] && ALL_PKGS="${ALL_PKGS} py-mysqlclient"
|
||||
[ X"${BACKEND}" == X'PGSQL' ] && ALL_PKGS="${ALL_PKGS} py-psycopg2"
|
||||
fi
|
||||
|
||||
# Fail2ban. Install fail2ban and geoip.
|
||||
if [ X"${USE_FAIL2BAN}" == X'YES' ]; then
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} fail2ban"
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
[[ X"${DISTRO_VERSION}" == X'7' ]] && ALL_PKGS="${ALL_PKGS} fail2ban GeoIP GeoIP-data"
|
||||
[[ X"${DISTRO_VERSION}" == X'8' ]] && ALL_PKGS="${ALL_PKGS} fail2ban GeoIP GeoIP-GeoLite-data"
|
||||
|
||||
DISABLED_SERVICES="${DISABLED_SERVICES} shorewall gamin gamin-python"
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} fail2ban geoip-bin geoip-database"
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# No port for fail2ban. Install from source tarball with pip later.
|
||||
# rc script will be generated from sample file later.
|
||||
ALL_PKGS="${ALL_PKGS} py-pip py3-pip geolite2-country geolite2-city"
|
||||
fi
|
||||
fi
|
||||
|
||||
# netdata
|
||||
# Note: netdata installer will generate rc/systemd script and enable the
|
||||
# service automatically.
|
||||
if [ X"${USE_NETDATA}" == X'YES' ]; then
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} curl libmnl libuuid lm_sensors nc zlib iproute"
|
||||
|
||||
[[ X"${DISTRO_VERSION}" == X'7' ]] && ALL_PKGS="${ALL_PKGS} PyYAML"
|
||||
[[ X"${DISTRO_VERSION}" == X'8' ]] && ALL_PKGS="${ALL_PKGS} python2-pyyaml"
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} zlib1g libuuid1 libmnl0 curl lm-sensors netcat"
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# netdata doesn't work on OpenBSD
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
# Misc packages & services.
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} unzip bzip2 acl patch tmpwatch crontabs dos2unix logwatch lz4"
|
||||
[[ X"${DISTRO_VERSION}" == X'7' ]] && ALL_PKGS="${ALL_PKGS} lrzip"
|
||||
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} crond"
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} bzip2 acl patch cron tofrodos logwatch unzip bsdutils liblz4-tool"
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} cron"
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} bzip2 lz4"
|
||||
fi
|
||||
|
||||
# Firewall
|
||||
if [ X"${DISTRO}" == X'DEBIAN' ]; then
|
||||
if [ X"${DISTRO_CODENAME}" == X'buster' ]; then
|
||||
ALL_PKGS="${ALL_PKGS} nftables"
|
||||
ENABLED_SERVICES="${ENABLED_SERVICES} nftables"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Disable ufw service and use iptables init script and rule file
|
||||
# shipped in iRedMail instead.
|
||||
[ X"${DISTRO}" == X'UBUNTU' ] && export DISABLED_SERVICES="${DISABLED_SERVICES} ufw"
|
||||
|
||||
export ALL_PKGS ENABLED_SERVICES PKG_SCRIPTS
|
||||
|
||||
# Install all packages.
|
||||
install_all_pkgs()
|
||||
{
|
||||
eval ${install_pkg} ${ALL_PKGS} | tee ${PKG_INSTALL_LOG}
|
||||
|
||||
if [ -f ${RUNTIME_DIR}/.pkg_install_failed ]; then
|
||||
ECHO_ERROR "Installation failed, please check the terminal output."
|
||||
ECHO_ERROR "If you're not sure what the problem is, try to get help in iRedMail"
|
||||
ECHO_ERROR "forum: https://forum.iredmail.org/"
|
||||
exit 255
|
||||
fi
|
||||
}
|
||||
|
||||
# Enable/Disable services.
|
||||
enable_all_services()
|
||||
{
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ -f /usr/lib/systemd/system/clamd\@.service ]; then
|
||||
if ! grep '\[Install\]' /usr/lib/systemd/system/clamd\@.service &>/dev/null; then
|
||||
echo '[Install]' >> /usr/lib/systemd/system/clamd\@.service
|
||||
echo 'WantedBy=multi-user.target' >> /usr/lib/systemd/system/clamd\@.service
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Enable/Disable services.
|
||||
if [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
for srv in ${PKG_SCRIPTS}; do
|
||||
service_control enable ${srv} >> ${INSTALL_LOG} 2>&1
|
||||
done
|
||||
else
|
||||
service_control enable ${ENABLED_SERVICES} >> ${INSTALL_LOG} 2>&1
|
||||
service_control disable ${DISABLED_SERVICES} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
* Enabled services: ${ENABLED_SERVICES}
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
after_package_installation()
|
||||
{
|
||||
pip_args=''
|
||||
if [ X"${PIP_MIRROR_SITE}" != X'' -a X"${PIP_TRUSTED_HOST}" != X'' ]; then
|
||||
pip_args="-i ${PIP_MIRROR_SITE} --trusted-host ${PIP_TRUSTED_HOST}"
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ X"${PIP3_MODULES}" != X'' ]; then
|
||||
ECHO_INFO "Installing required Python-3 modules with pip3:${PIP3_MODULES}"
|
||||
${CMD_PIP3} install ${pip_args} -U ${PIP3_MODULES} 2>&1 | tee ${RUNTIME_DIR}/pip3.log
|
||||
fi
|
||||
|
||||
if [ X"${PIP2_MODULES}" != X'' ]; then
|
||||
ECHO_INFO "Installing required Python-2 modules with pip2:${PIP2_MODULES}"
|
||||
|
||||
# Install py2 modules.
|
||||
# pycurl requires specified ssl library.
|
||||
PYCURL_SSL_LIBRARY=openssl ${CMD_PIP2} install ${pip_args} -U ${PIP2_MODULES} 2>&1 | tee ${RUNTIME_DIR}/pip2.log
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ X"${PIP2_MODULES}" != X'' ]; then
|
||||
if [ X"${DISTRO_CODENAME}" == X'focal' ]; then
|
||||
ECHO_INFO "Installing pip for Python 2."
|
||||
cd /tmp
|
||||
${FETCH_CMD} ${URL_GET_PIP_PY}
|
||||
python2 get-pip.py ${pip_args}
|
||||
rm -f get-pip.py
|
||||
fi
|
||||
|
||||
ECHO_INFO "Installing required Python-2 modules with pip2:${PIP2_MODULES}"
|
||||
${CMD_PIP2} install ${pip_args} -U ${PIP2_MODULES} 2>&1 | tee ${RUNTIME_DIR}/pip2.log
|
||||
fi
|
||||
|
||||
if [ X"${PIP3_MODULES}" != X'' ]; then
|
||||
ECHO_INFO "Installing required Python-3 modules with pip3:${PIP3_MODULES}"
|
||||
${CMD_PIP3} install ${pip_args} -U ${PIP3_MODULES}
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# Create symbol links for php.
|
||||
if [ X"${IREDMAIL_USE_PHP}" == X'YES' ]; then
|
||||
ln -sf /usr/local/bin/php-${OB_PHP_VERSION} /usr/local/bin/php >> ${INSTALL_LOG} 2>&1
|
||||
ln -sf /usr/local/bin/php-config-${OB_PHP_VERSION} /usr/local/bin/php-config >> ${INSTALL_LOG} 2>&1
|
||||
ln -sf /usr/local/bin/phpize-${OB_PHP_VERSION} /usr/local/bin/phpize >> ${INSTALL_LOG} 2>&1
|
||||
ln -sf /usr/local/bin/php-fpm-${OB_PHP_VERSION} /usr/local/bin/php-fpm >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
for v in 3.9 3.8 3.7 3.6 3.5 3.4; do
|
||||
if [ -x /usr/local/bin/python${v} ]; then
|
||||
ECHO_DEBUG "Create symbol link: /usr/local/bin/python${v} -> /usr/local/bin/python3"
|
||||
ln -sf /usr/local/bin/python${v} /usr/local/bin/python3
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# uwsgi. Required by iRedAdmin.
|
||||
ECHO_INFO "Installing uWSGI from source tarball, please wait for a moment."
|
||||
${CMD_PIP2} install ${PKG_MISC_DIR}/uwsgi-*.tar.gz &> ${RUNTIME_DIR}/uwsgi_install.log
|
||||
|
||||
# Fail2ban.
|
||||
if [ X"${USE_FAIL2BAN}" == X'YES' ]; then
|
||||
ECHO_INFO "Installing Fail2ban from source tarball, please wait for a moment."
|
||||
${CMD_PIP3} install ${PKG_MISC_DIR}/fail2ban-*.tar.gz &> ${RUNTIME_DIR}/fail2ban_install.log
|
||||
fi
|
||||
|
||||
# Required by uwsgi applications.
|
||||
update_sysctl_param kern.seminfo.semmni 1024
|
||||
update_sysctl_param kern.seminfo.semmns 1200
|
||||
update_sysctl_param kern.seminfo.semmnu 60
|
||||
update_sysctl_param kern.seminfo.semmsl 120
|
||||
update_sysctl_param kern.seminfo.semopm 200
|
||||
fi
|
||||
|
||||
echo 'export status_after_package_installation="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
# Do not run them with 'check_status_before_run', so that we can always
|
||||
# install missed packages and enable/disable new services while re-run
|
||||
# iRedMail installer.
|
||||
install_all_pkgs
|
||||
enable_all_services
|
||||
|
||||
check_status_before_run after_package_installation
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
|
||||
# PHP Setting.
|
||||
php_config()
|
||||
{
|
||||
ECHO_INFO "Configure PHP."
|
||||
|
||||
backup_file ${PHP_INI}
|
||||
|
||||
# FreeBSD: Copy sample file.
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
cp -f /usr/local/etc/php.ini-production ${PHP_INI}
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# Enable PHP modules
|
||||
for i in $(ls -d /etc/php-${OB_PHP_VERSION}.sample/*); do
|
||||
ln -sf ${i} /etc/php-${OB_PHP_VERSION}/$(basename $i)
|
||||
done
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Hide PHP info from remote users requests: ${PHP_INI}."
|
||||
perl -pi -e 's#^(expose_php.*=).*#${1} Off;#' ${PHP_INI}
|
||||
|
||||
ECHO_DEBUG "Increase 'memory_limit' to 256M: ${PHP_INI}."
|
||||
perl -pi -e 's#^(memory_limit.*=).*#${1} 256M;#' ${PHP_INI}
|
||||
|
||||
ECHO_DEBUG "Increase 'upload_max_filesize', 'post_max_size' to 10/12M: ${PHP_INI}."
|
||||
perl -pi -e 's/^(upload_max_filesize.*=).*/${1} 10M;/' ${PHP_INI}
|
||||
perl -pi -e 's/^(post_max_size.*=).*/${1} 12M;/' ${PHP_INI}
|
||||
|
||||
ECHO_DEBUG "Disable php extension: suhosin. ${PHP_INI}."
|
||||
perl -pi -e 's/^(suhosin.session.encrypt.*=).*/${1} Off;/' ${PHP_INI}
|
||||
perl -pi -e 's/^;(suhosin.session.encrypt.*=).*/${1} Off;/' ${PHP_INI}
|
||||
|
||||
#perl -pi -e 's/^(allow_url_fopen.*=).*/${1} On/' ${PHP_INI}
|
||||
|
||||
# Add setting `disable_functions`
|
||||
perl -pi -e 's#^;(disable_functions.*)#${1}#g' ${PHP_INI}
|
||||
perl -pi -e 's#^(disable_functions).*#${1} = $ENV{PHP_DISABLE_FUNCTIONS}#g' ${PHP_INI}
|
||||
|
||||
# Create directory used to store session (session.save_path)
|
||||
perl -pi -e 's#^;(session.save_path).*#${1}#g' ${PHP_INI}
|
||||
perl -pi -e 's#^(session.save_path).*#session.save_path = "$ENV{PHP_SESSION_SAVE_PATH}"#g' ${PHP_INI}
|
||||
# Set correct owner and permission
|
||||
[ -d ${PHP_SESSION_SAVE_PATH} ] || mkdir -p ${PHP_SESSION_SAVE_PATH} >> ${INSTALL_LOG} 2>&1
|
||||
chown ${SYS_USER_ROOT}:${HTTPD_GROUP} ${PHP_SESSION_SAVE_PATH}
|
||||
chmod 0770 ${PHP_SESSION_SAVE_PATH}
|
||||
|
||||
# Set date.timezone. Required by PHP-5.3.
|
||||
grep '^date.timezone' ${PHP_INI} >/dev/null
|
||||
if [ X"$?" == X"0" ]; then
|
||||
perl -pi -e 's#^(date.timezone).*#${1} = GMT#' ${PHP_INI}
|
||||
else
|
||||
perl -pi -e 's#^;(date.timezone).*#${1} = GMT#' ${PHP_INI}
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# Enable mcrypt
|
||||
${PHPENMOD_BIN} mcrypt >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# `intl` is required by Roundcube.
|
||||
${PHPENMOD_BIN} intl >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
ECHO_DEBUG "Disable suhosin.session.encrypt -> Off."
|
||||
echo 'suhosin.session.encrypt = Off' >> ${PHP_INI}
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
PHP:
|
||||
* PHP config file for Nginx: ${NGINX_PHP_INI}
|
||||
* Disabled functions: ${PHP_DISABLE_FUNCTIONS}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_php_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------
|
||||
# ---------------------- Postfix ------------------------
|
||||
# -------------------------------------------------------
|
||||
|
||||
postfix_config_basic()
|
||||
{
|
||||
ECHO_INFO "Configure Postfix (MTA)."
|
||||
|
||||
# Reset `inet_interfaces` to avoid invalid value which may cause fatal
|
||||
# error while getting value with command `postconf <var>`.
|
||||
postconf -e inet_interfaces='all'
|
||||
|
||||
#
|
||||
# main.cf
|
||||
#
|
||||
# Get values with default main.cf before we modify it.
|
||||
export queue_directory="$(postconf queue_directory | awk '{print $NF}')"
|
||||
export command_directory="$(postconf command_directory | awk '{print $NF}')"
|
||||
export daemon_directory="$(postconf daemon_directory | awk '{print $NF}')"
|
||||
export data_directory="$(postconf data_directory | awk '{print $NF}')"
|
||||
|
||||
export sendmail_path="$(postconf sendmail_path | awk '{print $NF}')"
|
||||
export newaliases_path="$(postconf newaliases_path | awk '{print $NF}')"
|
||||
export mailq_path="$(postconf mailq_path | awk '{print $NF}')"
|
||||
export mail_owner="$(postconf mail_owner | awk '{print $NF}')"
|
||||
export setgid_group="$(postconf setgid_group | awk '{print $NF}')"
|
||||
|
||||
# Copy sample main.cf and update values.
|
||||
backup_file ${POSTFIX_FILE_MAIN_CF} ${POSTFIX_FILE_MASTER_CF}
|
||||
cp ${SAMPLE_DIR}/postfix/main.cf ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
perl -pi -e 's#PH_QUEUE_DIRECTORY#$ENV{queue_directory}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_COMMAND_DIRECTORY#$ENV{command_directory}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_DAEMON_DIRECTORY#$ENV{daemon_directory}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_DATA_DIRECTORY#$ENV{data_directory}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
perl -pi -e 's#PH_SENDMAIL_PATH#$ENV{sendmail_path}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_NEWALIASES_PATH#$ENV{newaliases_path}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_MAILQ_PATH#$ENV{mailq_path}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_MAIL_OWNER#$ENV{mail_owner}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_SETGID_GROUP#$ENV{setgid_group}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
unset queue_directory command_directory daemon_directory data_directory
|
||||
unset mail_owner sendmail_path newaliases_path mailq_path setgid_group
|
||||
|
||||
# Append LOCAL_ADDRESS in `mynetworks`
|
||||
if [ X"${LOCAL_ADDRESS}" != X'127.0.0.1' ]; then
|
||||
perl -pi -e 's#^(mynetworks.*)#${1} $ENV{LOCAL_ADDRESS}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
fi
|
||||
|
||||
if [ X"${IREDMAIL_HAS_IPV6}" == X'YES' ]; then
|
||||
# Append local IPv6 address in `mynetworks`
|
||||
perl -pi -e 's#^(mynetworks.*)#${1} [::1]#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
else
|
||||
# Disable ipv6 protocol
|
||||
perl -pi -e 's#^(inet_protocols.*=).*#${1} ipv4#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
fi
|
||||
|
||||
# Update normal settings.
|
||||
perl -pi -e 's#PH_HOSTNAME#$ENV{HOSTNAME}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_MESSAGE_SIZE_LIMIT_BYTES#$ENV{MESSAGE_SIZE_LIMIT_BYTES}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_STORAGE_BASE_DIR#$ENV{STORAGE_BASE_DIR}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_SYS_USER_VMAIL_UID#$ENV{SYS_USER_VMAIL_UID}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
perl -pi -e 's#PH_SYS_GROUP_VMAIL_GID#$ENV{SYS_GROUP_VMAIL_GID}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_SYS_USER_VMAIL_UID#$ENV{SYS_USER_VMAIL_UID}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
perl -pi -e 's#PH_SSL_DH512_PARAM_FILE#$ENV{SSL_DH512_PARAM_FILE}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_SSL_DH1024_PARAM_FILE#$ENV{SSL_DH1024_PARAM_FILE}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_SSL_CERT_FILE#$ENV{SSL_CERT_FILE}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_SSL_KEY_FILE#$ENV{SSL_KEY_FILE}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_SSL_CERT_DIR#$ENV{SSL_CERT_DIR}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' -o X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
perl -pi -e 's#^(smtpd_tls_CAfile =).*#${1} /etc/ssl/cert.pem#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#^(smtpd_tls_CApath=).*#${1}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
fi
|
||||
|
||||
perl -pi -e 's#PH_POSTFIX_FILE_ALIASES#$ENV{POSTFIX_FILE_ALIASES}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_POSTFIX_FILE_HELO_ACCESS#$ENV{POSTFIX_FILE_HELO_ACCESS}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_POSTFIX_FILE_HEADER_CHECKS#$ENV{POSTFIX_FILE_HEADER_CHECKS}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_POSTFIX_FILE_BODY_CHECKS#$ENV{POSTFIX_FILE_BODY_CHECKS}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_POSTFIX_FILE_SENDER_ACCESS#$ENV{POSTFIX_FILE_SENDER_ACCESS}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_POSTFIX_FILE_SMTPD_COMMAND_FILTER#$ENV{POSTFIX_FILE_SMTPD_COMMAND_FILTER}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
# Create required files and set correct owner + permission
|
||||
_files="${POSTFIX_FILE_HELO_ACCESS} ${POSTFIX_FILE_HEADER_CHECKS} ${POSTFIX_FILE_BODY_CHECKS} ${POSTFIX_FILE_SENDER_ACCESS}"
|
||||
touch ${_files}
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_POSTFIX} ${_files}
|
||||
chmod 0640 ${_files}
|
||||
unset _files
|
||||
|
||||
# iRedAPD
|
||||
perl -pi -e 's#PH_IREDAPD_SERVER_ADDRESS#$ENV{IREDAPD_SERVER_ADDRESS}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_IREDAPD_LISTEN_PORT#$ENV{IREDAPD_LISTEN_PORT}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_IREDAPD_SRS_FORWARD_PORT#$ENV{IREDAPD_SRS_FORWARD_PORT}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_IREDAPD_SRS_REVERSE_PORT#$ENV{IREDAPD_SRS_REVERSE_PORT}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
# Dovecot quota-status service
|
||||
perl -pi -e 's#PH_DOVECOT_SERVICE_QUOTA_STATUS_PORT#$ENV{DOVECOT_SERVICE_QUOTA_STATUS_PORT}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
#
|
||||
# master.cf
|
||||
#
|
||||
_postfix_version="$(postconf mail_version | awk '{print $NF}')"
|
||||
if echo ${_postfix_version} | grep '^3' &>/dev/null; then
|
||||
# Postfix v3
|
||||
postconf -e compatibility_level=2
|
||||
|
||||
# The master.cf chroot default value has changed from "y" (yes) to "n" (no).
|
||||
for i in $(postconf -Mf | grep '^[0-9a-zA-Z]' | awk '{print $1"/"$2"/chroot=n"}'); do
|
||||
postconf -F $i
|
||||
done
|
||||
|
||||
# Disable smtputf8 if EAI support is not compiled in.
|
||||
if postconf -m 2>&1 |grep 'warning: smtputf8_enable' &>/dev/null; then
|
||||
postconf -e smtputf8_enable=no
|
||||
fi
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Enable chroot."
|
||||
perl -pi -e 's/^(smtp.*inet)(.*)(n)(.*)(n)(.*smtpd)$/${1}${2}${3}${4}-${6}/' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
ECHO_DEBUG "Enable submission and additional transports required by Amavisd and Dovecot."
|
||||
cat ${SAMPLE_DIR}/postfix/master.cf >> ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
# set smtp server
|
||||
perl -pi -e 's#PH_SMTP_SERVER#$ENV{SMTP_SERVER}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
perl -pi -e 's#PH_AMAVISD_CONTENT_FILTER_ORIGINATING#$ENV{AMAVISD_CONTENT_FILTER_ORIGINATING}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
# set mailbox owner: user/group
|
||||
perl -pi -e 's#PH_SYS_USER_VMAIL#$ENV{SYS_USER_VMAIL}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
perl -pi -e 's#PH_SYS_GROUP_VMAIL#$ENV{SYS_GROUP_VMAIL}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
# Amavisd integration.
|
||||
perl -pi -e 's#PH_LOCAL_ADDRESS#$ENV{LOCAL_ADDRESS}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
perl -pi -e 's#PH_AMAVISD_MAX_SERVERS#$ENV{AMAVISD_MAX_SERVERS}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
perl -pi -e 's#PH_AMAVISD_MYNETWORKS#$ENV{AMAVISD_MYNETWORKS}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
perl -pi -e 's#PH_POSTFIX_MAIL_REINJECT_PORT#$ENV{POSTFIX_MAIL_REINJECT_PORT}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
perl -pi -e 's#PH_AMAVISD_ORIGINATING_PORT#$ENV{AMAVISD_ORIGINATING_PORT}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
# Enable `content_filter` for `pickup` transport:
|
||||
# - Treat all emails generated locally as outbound
|
||||
# - sign DKIM signature
|
||||
# - do spam/virus scanning
|
||||
_pickup_orig="$(postconf -M |grep '^pickup')"
|
||||
echo ${_pickup_orig} | grep 'content_filter=' &>/dev/null
|
||||
if [ X"$?" != X'0' ]; then
|
||||
if [ X"${DISTRO}" == X'RHEL' -a X"${DISTRO_VERSION}" == X'7' ]; then
|
||||
# CentOS 7 ships old Postfix which doesn't support `postconf -P`.
|
||||
perl -pi -e 's#^(pickup.*)#${1}\n -o content_filter=$ENV{AMAVISD_CONTENT_FILTER_ORIGINATING}#' ${POSTFIX_FILE_MASTER_CF}
|
||||
else
|
||||
postconf -M "pickup/unix=${_pickup_orig}"
|
||||
postconf -P "pickup/unix/content_filter=${AMAVISD_CONTENT_FILTER_ORIGINATING}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# mlmmj integration.
|
||||
perl -pi -e 's#PH_POSTFIX_MLMMJ_REINJECT_PORT#$ENV{POSTFIX_MLMMJ_REINJECT_PORT}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
# Dovecot LDA
|
||||
perl -pi -e 's#PH_DOVECOT_DELIVER_BIN#$ENV{DOVECOT_DELIVER_BIN}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
# mlmmj
|
||||
perl -pi -e 's#PH_SYS_USER_MLMMJ#$ENV{SYS_USER_MLMMJ}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
perl -pi -e 's#PH_SYS_GROUP_MLMMJ#$ENV{SYS_GROUP_MLMMJ}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
perl -pi -e 's#PH_CMD_MLMMJ_AMIME_RECEIVE#$ENV{CMD_MLMMJ_AMIME_RECEIVE}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
perl -pi -e 's#PH_MLMMJ_SPOOL_DIR#$ENV{MLMMJ_SPOOL_DIR}#g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
ECHO_DEBUG "Copy: /etc/{hosts,resolv.conf,localtime,services} -> ${POSTFIX_CHROOT_DIR}/etc/"
|
||||
mkdir -p ${POSTFIX_CHROOT_DIR}/etc/ >> ${INSTALL_LOG} 2>&1
|
||||
for i in /etc/hosts /etc/resolv.conf /etc/localtime /etc/services; do
|
||||
[ -f $i ] && cp ${i} ${POSTFIX_CHROOT_DIR}/etc/
|
||||
done
|
||||
|
||||
backup_file ${POSTFIX_FILE_HELO_ACCESS}
|
||||
cp -f ${SAMPLE_DIR}/postfix/helo_access.pcre ${POSTFIX_FILE_HELO_ACCESS}
|
||||
|
||||
backup_file ${POSTFIX_FILE_SMTPD_COMMAND_FILTER}
|
||||
cp -f ${SAMPLE_DIR}/postfix/command_filter.pcre ${POSTFIX_FILE_SMTPD_COMMAND_FILTER}
|
||||
|
||||
# Update Postfix aliases file.
|
||||
add_postfix_alias nobody ${SYS_USER_ROOT}
|
||||
add_postfix_alias ${SYS_USER_VMAIL} ${SYS_USER_ROOT}
|
||||
add_postfix_alias ${SYS_USER_ROOT} ${DOMAIN_ADMIN_EMAIL}
|
||||
|
||||
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# Since `mail.*` is logged to /var/log/mail.log, no need to log
|
||||
# `mail.err` to /var/log/mail.err separately.
|
||||
ECHO_DEBUG "Disable duplicate log entries (mail.{info,warn,err}) in syslog config file."
|
||||
|
||||
for f in ${SYSLOG_CONF} ${SYSLOG_CONF_DIR}/50-default.conf; do
|
||||
if [ -f ${f} ]; then
|
||||
perl -pi -e 's/^(mail.info.*mail.info)$/#${1}/' ${f}
|
||||
perl -pi -e 's/^(mail.warn.*mail.warn)$/#${1}/' ${f}
|
||||
perl -pi -e 's/^(mail.err.*mail.err)$/#${1}/' ${f}
|
||||
fi
|
||||
done
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# FreeBSD: Start postfix when system start up.
|
||||
backup_file /etc/mail/mailer.conf
|
||||
cp -f ${SAMPLE_DIR}/postfix/freebsd/mailer.conf /etc/mail/mailer.conf
|
||||
chmod +r /etc/mail/mailer.conf
|
||||
|
||||
# Start service when system start up.
|
||||
service_control enable 'postfix_enable' 'YES'
|
||||
service_control enable 'sendmail_enable' 'NO'
|
||||
service_control enable 'sendmail_submit_enable' 'NO'
|
||||
service_control enable 'sendmail_outbound_enable' 'NO'
|
||||
service_control enable 'sendmail_msp_queue_enable' 'NO'
|
||||
service_control enable 'daily_clean_hoststat_enable' 'NO'
|
||||
service_control enable 'daily_status_mail_rejects_enable' 'NO'
|
||||
service_control enable 'daily_status_include_submit_mailq' 'NO'
|
||||
service_control enable 'daily_submit_queuerun' 'NO'
|
||||
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
# Replace sendmail, opensmtpd by Postfix
|
||||
echo 'sendmail_flags=NO' >> ${RC_CONF_LOCAL}
|
||||
echo 'smtpd_flags=NO' >> ${RC_CONF_LOCAL}
|
||||
/usr/local/sbin/postfix-enable >> ${INSTALL_LOG} 2>&1
|
||||
perl -pi -e 's/(.*sendmail -L sm-msp-queue.*)/#${1}/' ${CRON_FILE_ROOT}
|
||||
fi
|
||||
|
||||
# Update /etc/host.conf to solve warning message in Postfix like this:
|
||||
# "warning: hostname xxx does not resolve to address 127.0.0.1"
|
||||
if [ -f /etc/host.conf ]; then
|
||||
if ! grep '^multi on$' /etc/host.conf &>/dev/null; then
|
||||
echo 'multi on' >> /etc/host.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create symbol link: /var/log/mail.log -> maillog
|
||||
# So that all linux/bsd distributions have the same maillog file.
|
||||
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ -f ${MAILLOG} -a ! -f /var/log/maillog ]; then
|
||||
ln -s ${MAILLOG} /var/log/maillog
|
||||
fi
|
||||
fi
|
||||
|
||||
echo 'export status_postfix_config_basic="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
postfix_config_vhost()
|
||||
{
|
||||
ECHO_DEBUG "Configure Postfix for SQL/LDAP lookup."
|
||||
|
||||
# Create directory which used to store sql/ldap lookup files.
|
||||
[ -d ${POSTFIX_LOOKUP_DIR} ] || mkdir -p ${POSTFIX_LOOKUP_DIR}
|
||||
|
||||
cat ${SAMPLE_DIR}/postfix/main.cf.${POSTFIX_LOOKUP_DB} >> ${POSTFIX_FILE_MAIN_CF}
|
||||
perl -pi -e 's#PH_POSTFIX_LOOKUP_DIR#$ENV{POSTFIX_LOOKUP_DIR}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
cp -f ${SAMPLE_DIR}/postfix/${POSTFIX_LOOKUP_DB}/*.cf ${POSTFIX_LOOKUP_DIR}
|
||||
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_POSTFIX} ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
chmod 0640 ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
# LDAP server and bind dn/password
|
||||
perl -pi -e 's#PH_LDAP_SERVER_HOST#$ENV{LDAP_SERVER_HOST}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_LDAP_SERVER_PORT#$ENV{LDAP_SERVER_PORT}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_LDAP_BIND_VERSION#$ENV{LDAP_BIND_VERSION}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_LDAP_BASEDN#$ENV{LDAP_BASEDN}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_LDAP_BINDDN#$ENV{LDAP_BINDDN}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_LDAP_BINDPW#$ENV{LDAP_BINDPW}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
|
||||
perl -pi -e 's#PH_LDAP_ATTR_GROUP_USERS#$ENV{LDAP_ATTR_GROUP_USERS}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_LDAP_ATTR_GROUP_GROUPS#$ENV{LDAP_ATTR_GROUP_GROUPS}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
elif [ X"${BACKEND}" == X'MYSQL' -o X"${BACKEND}" == X'PGSQL' ]; then
|
||||
# SQL server, port, bind username, password
|
||||
perl -pi -e 's#PH_SQL_SERVER_ADDRESS#$ENV{SQL_SERVER_ADDRESS}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_SQL_SERVER_PORT#$ENV{SQL_SERVER_PORT}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_USER#$ENV{VMAIL_DB_BIND_USER}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_PASSWD#$ENV{VMAIL_DB_BIND_PASSWD}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
perl -pi -e 's#PH_VMAIL_DB_NAME#$ENV{VMAIL_DB_NAME}#g' ${POSTFIX_LOOKUP_DIR}/*.cf
|
||||
fi
|
||||
|
||||
echo 'export status_postfix_config_vhost="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
postfix_config_postscreen()
|
||||
{
|
||||
ECHO_DEBUG "Enable postscreen service."
|
||||
|
||||
backup_file ${POSTSCREEN_FILE_ACCESS_CIDR} ${POSTSCREEN_FILE_DNSBL_REPLY}
|
||||
|
||||
export POSTFIX_VERSION="$(postconf mail_version 2>/dev/null | awk '{print $NF}')"
|
||||
if echo ${POSTFIX_VERSION} | grep '^2\.[01234567]\.' &>/dev/null; then
|
||||
ECHO_ERROR "postscreen requires Postfix 2.8 or later, you're running ${POSTFIX_VERSION}."
|
||||
ECHO_ERROR "postscreen service not enabled."
|
||||
else
|
||||
ECHO_DEBUG "Comment out 'smtp inet ... smtpd' service in ${POSTFIX_FILE_MASTER_CF}."
|
||||
perl -pi -e 's/^(smtp .*inet.*smtpd)$/#${1}/g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
ECHO_DEBUG "Uncomment the new 'smtpd pass ... smtpd' service in ${POSTFIX_FILE_MASTER_CF}."
|
||||
perl -pi -e 's/^#(smtpd.*pass.*smtpd)$/${1}/g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
ECHO_DEBUG "Uncomment the new "smtp inet ... postscreen" service in ${POSTFIX_FILE_MASTER_CF}."
|
||||
perl -pi -e 's/^#(smtp *.*inet.*postscreen)$/${1}/g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
ECHO_DEBUG "Uncomment the new 'tlsproxy unix ... tlsproxy' service in ${POSTFIX_FILE_MASTER_CF}."
|
||||
perl -pi -e 's/^#(tlsproxy.*unix.*tlsproxy)$/${1}/g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
ECHO_DEBUG "Uncomment the new 'dnsblog unix ... dnsblog' service in ${POSTFIX_FILE_MASTER_CF}."
|
||||
perl -pi -e 's/^#(dnsblog.*unix.*dnsblog)$/${1}/g' ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
#
|
||||
# main.cf
|
||||
#
|
||||
ECHO_DEBUG "Update ${POSTFIX_FILE_MAIN_CF} to enable postscreen."
|
||||
cat ${SAMPLE_DIR}/postfix/main.cf.postscreen >> ${POSTFIX_FILE_MAIN_CF}
|
||||
|
||||
perl -pi -e 's#PH_POSTSCREEN_FILE_DNSBL_REPLY#$ENV{POSTSCREEN_FILE_DNSBL_REPLY}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
touch ${POSTSCREEN_FILE_DNSBL_REPLY}
|
||||
|
||||
perl -pi -e 's#PH_POSTSCREEN_FILE_ACCESS_CIDR#$ENV{POSTSCREEN_FILE_ACCESS_CIDR}#g' ${POSTFIX_FILE_MAIN_CF}
|
||||
cp -f ${SAMPLE_DIR}/postfix/postscreen_access.cidr ${POSTSCREEN_FILE_ACCESS_CIDR}
|
||||
|
||||
# Require Postfix-2.11+
|
||||
if echo ${POSTFIX_VERSION} | egrep '(^3|^2\.[123456789][123456789])' &>/dev/null; then
|
||||
perl -pi -e 's/^#(postscreen_dnsbl_whitelist_threshold.*)/${1}/g' ${POSTFIX_FILE_MAIN_CF}
|
||||
fi
|
||||
|
||||
# Set a not existing directory as default value, if we cannot get
|
||||
# ${queue_directory} for some reason, it won't mistakenly reset owner
|
||||
# and permission on '/'
|
||||
export queue_directory="$(postconf queue_directory | awk '{print $NF}')"
|
||||
export data_directory="$(postconf data_directory | awk '{print $NF}')"
|
||||
_chrooted_data_directory="${queue_directory:=/tmp/not-exist}/${data_directory}"
|
||||
|
||||
unset queue_directory data_directory
|
||||
|
||||
ECHO_DEBUG "Create ${_chrooted_data_directory}/postscreen_cache.db."
|
||||
if [ ! -d ${_chrooted_data_directory} ]; then
|
||||
mkdir -p ${_chrooted_data_directory}
|
||||
chown ${SYS_USER_POSTFIX}:${SYS_GROUP_ROOT} ${_chrooted_data_directory}
|
||||
chmod 0700 ${_chrooted_data_directory}
|
||||
fi
|
||||
|
||||
# Create db file.
|
||||
cd ${_chrooted_data_directory}
|
||||
touch postscreen_cache
|
||||
postmap btree:postscreen_cache
|
||||
rm postscreen_cache
|
||||
chown ${SYS_USER_POSTFIX}:${SYS_GROUP_POSTFIX} postscreen_cache.db
|
||||
chmod 0700 postscreen_cache.db
|
||||
fi
|
||||
|
||||
echo 'export status_postfix_config_postscreen="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
postfix_setup()
|
||||
{
|
||||
# Include all sub-steps
|
||||
check_status_before_run postfix_config_basic && \
|
||||
check_status_before_run postfix_config_vhost && \
|
||||
check_status_before_run postfix_config_postscreen
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Postfix:
|
||||
* Configuration files:
|
||||
- ${POSTFIX_ROOTDIR}
|
||||
- ${POSTFIX_ROOTDIR}/aliases
|
||||
- ${POSTFIX_FILE_MAIN_CF}
|
||||
- ${POSTFIX_FILE_MASTER_CF}
|
||||
|
||||
* SQL/LDAP lookup config files:
|
||||
- ${POSTFIX_LOOKUP_DIR}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_postfix_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------
|
||||
# -------------------- PostgreSQL -----------------------
|
||||
# -------------------------------------------------------
|
||||
|
||||
# NOTE: iRedMail will force all clients to send encrypted password
|
||||
# after configuration completed and SQL data imported.
|
||||
# Reference: functions/cleanup.sh, function cleanup_pgsql_force_password().
|
||||
|
||||
pgsql_initialize()
|
||||
{
|
||||
ECHO_DEBUG "Initialize PostgreSQL databases."
|
||||
|
||||
# Init db
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
postgresql-setup initdb >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Start service when system start up.
|
||||
# 'postgresql_enable=YES' is required to start service immediately.
|
||||
service_control enable 'postgresql_enable' 'YES'
|
||||
|
||||
${PGSQL_RC_SCRIPT} initdb >> ${INSTALL_LOG} 2>&1
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
mkdir -p ${PGSQL_DATA_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
chown ${SYS_USER_PGSQL}:${SYS_GROUP_PGSQL} ${PGSQL_DATA_DIR}
|
||||
su - ${SYS_USER_PGSQL} -c "initdb -D ${PGSQL_DATA_DIR} -U ${SYS_USER_PGSQL} -A trust" >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
backup_file ${PGSQL_CONF_PG_HBA} ${PGSQL_CONF_POSTGRESQL}
|
||||
|
||||
if [ -f ${PGSQL_CONF_POSTGRESQL} ]; then
|
||||
ECHO_DEBUG "Make sure PostgreSQL binds to local address: ${SQL_SERVER_ADDRESS}."
|
||||
perl -pi -e 's#.*(listen_addresses.=.)(.).*#${1}${2}$ENV{LOCAL_ADDRESS}${2}#' ${PGSQL_CONF_POSTGRESQL}
|
||||
|
||||
ECHO_DEBUG "Set client_min_messages to ERROR."
|
||||
perl -pi -e 's#.*(client_min_messages =).*#${1} error#' ${PGSQL_CONF_POSTGRESQL}
|
||||
|
||||
# SSL is enabled by default on Ubuntu.
|
||||
[ X"${DISTRO}" == X'FREEBSD' ] && \
|
||||
perl -pi -e 's/^#(ssl.=.)off(.*)/${1}on${2}/' ${PGSQL_CONF_POSTGRESQL}
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Copy iRedMail SSL cert/key with strict permission."
|
||||
backup_file ${PGSQL_DATA_DIR}/server.{crt,key}
|
||||
rm -f ${PGSQL_DATA_DIR}/server.{crt,key} >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SSL_CERT_FILE} ${PGSQL_SSL_CERT} >> ${INSTALL_LOG} 2>&1
|
||||
cp -f ${SSL_KEY_FILE} ${PGSQL_SSL_KEY} >> ${INSTALL_LOG} 2>&1
|
||||
chown ${SYS_USER_PGSQL}:${SYS_GROUP_PGSQL} ${PGSQL_SSL_CERT} ${PGSQL_SSL_KEY} >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0600 ${PGSQL_SSL_CERT} ${PGSQL_SSL_KEY} >> ${INSTALL_LOG} 2>&1
|
||||
ln -s ${PGSQL_SSL_CERT} ${PGSQL_DATA_DIR}/server.crt >> ${INSTALL_LOG} 2>&1
|
||||
ln -s ${PGSQL_SSL_KEY} ${PGSQL_DATA_DIR}/server.key >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Start PostgreSQL server and sleep 5 seconds for initialization"
|
||||
service_control stop ${PGSQL_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
sleep 5
|
||||
service_control start ${PGSQL_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
sleep 5
|
||||
|
||||
# Note: we must reset `postgres` password first, otherwise all connections
|
||||
# will fail, because we cannot set/change passwords at all, so we're trying
|
||||
# to connect with a wrong password.
|
||||
ECHO_DEBUG "Setting password for PostgreSQL admin: (${PGSQL_ROOT_USER})."
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
ALTER USER ${PGSQL_ROOT_USER} WITH ENCRYPTED PASSWORD '${PGSQL_ROOT_PASSWD}';
|
||||
EOF
|
||||
|
||||
ECHO_DEBUG "Update pg_hba.conf to force local users to authenticate with md5."
|
||||
perl -pi -e 's/^(local.*)/#${1}/g' ${PGSQL_CONF_PG_HBA}
|
||||
perl -pi -e 's/^(host.*)/#${1}/g' ${PGSQL_CONF_PG_HBA}
|
||||
|
||||
if [ X"${PGSQL_VERSION}" == X'8' ]; then
|
||||
echo "local all ${SYS_USER_PGSQL} ident" >> ${PGSQL_CONF_PG_HBA}
|
||||
else
|
||||
echo "local all ${SYS_USER_PGSQL} peer" >> ${PGSQL_CONF_PG_HBA}
|
||||
fi
|
||||
echo 'local all all md5' >> ${PGSQL_CONF_PG_HBA}
|
||||
echo 'host all all 0.0.0.0/0 md5' >> ${PGSQL_CONF_PG_HBA}
|
||||
|
||||
ECHO_DEBUG "Restart PostgreSQL server and sleeping for 5 seconds."
|
||||
service_control stop ${PGSQL_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
sleep 5
|
||||
service_control start ${PGSQL_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
sleep 5
|
||||
|
||||
ECHO_DEBUG "Generate ${PGSQL_DOT_PGPASS}."
|
||||
cat > ${PGSQL_DOT_PGPASS} <<EOF
|
||||
*:*:*:${PGSQL_ROOT_USER}:${PGSQL_ROOT_PASSWD}
|
||||
*:*:*:${VMAIL_DB_BIND_USER}:${VMAIL_DB_BIND_PASSWD}
|
||||
*:*:*:${VMAIL_DB_ADMIN_USER}:${VMAIL_DB_ADMIN_PASSWD}
|
||||
*:*:*:${IREDAPD_DB_USER}:${IREDAPD_DB_PASSWD}
|
||||
*:*:*:${IREDADMIN_DB_USER}:${IREDADMIN_DB_PASSWD}
|
||||
*:*:*:${SOGO_DB_USER}:${SOGO_DB_PASSWD}
|
||||
*:*:*:${RCM_DB_USER}:${RCM_DB_PASSWD}
|
||||
*:*:*:${AMAVISD_DB_USER}:${AMAVISD_DB_PASSWD}
|
||||
*:*:*:${FAIL2BAN_DB_USER}:${FAIL2BAN_DB_PASSWD}
|
||||
EOF
|
||||
|
||||
chown ${SYS_USER_PGSQL}:${SYS_GROUP_PGSQL} ${PGSQL_DOT_PGPASS}
|
||||
chmod 0600 ${PGSQL_DOT_PGPASS} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
PostgreSQL:
|
||||
* Admin user: ${PGSQL_ROOT_USER}, Password: ${PGSQL_ROOT_PASSWD}
|
||||
* Bind account (read-only):
|
||||
- Name: ${VMAIL_DB_BIND_USER}, Password: ${VMAIL_DB_BIND_PASSWD}
|
||||
* Vmail admin account (read-write):
|
||||
- Name: ${VMAIL_DB_ADMIN_USER}, Password: ${VMAIL_DB_ADMIN_PASSWD}
|
||||
* Database stored in: ${PGSQL_DATA_DIR}
|
||||
* RC script: ${PGSQL_RC_SCRIPT}
|
||||
* Config files:
|
||||
* ${PGSQL_CONF_POSTGRESQL}
|
||||
* ${PGSQL_CONF_PG_HBA}
|
||||
* Log file: /var/log/postgresql/
|
||||
* See also:
|
||||
- ${PGSQL_INIT_SQL_SAMPLE}
|
||||
- ${PGSQL_DOT_PGPASS}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_pgsql_initialize="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
pgsql_import_vmail_users()
|
||||
{
|
||||
ECHO_DEBUG "Generate sample SQL templates."
|
||||
cp -f ${SAMPLE_DIR}/postgresql/sql/init_vmail_db.sql ${PGSQL_DATA_DIR}/
|
||||
cp -f ${SAMPLE_DIR}/iredmail/iredmail.pgsql ${PGSQL_DATA_DIR}/iredmail.sql
|
||||
cp -f ${SAMPLE_DIR}/postgresql/sql/add_first_domain_and_user.sql ${PGSQL_DATA_DIR}/
|
||||
cp -f ${SAMPLE_DIR}/postgresql/sql/grant_permissions.sql ${PGSQL_DATA_DIR}/
|
||||
|
||||
perl -pi -e 's#PH_VMAIL_DB_NAME#$ENV{VMAIL_DB_NAME}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_USER#$ENV{VMAIL_DB_BIND_USER}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
perl -pi -e 's#PH_VMAIL_DB_BIND_PASSWD#$ENV{VMAIL_DB_BIND_PASSWD}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
perl -pi -e 's#PH_VMAIL_DB_ADMIN_USER#$ENV{VMAIL_DB_ADMIN_USER}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
perl -pi -e 's#PH_VMAIL_DB_ADMIN_PASSWD#$ENV{VMAIL_DB_ADMIN_PASSWD}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
|
||||
perl -pi -e 's#PH_DOMAIN_ADMIN_EMAIL#$ENV{DOMAIN_ADMIN_EMAIL}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
perl -pi -e 's#PH_FIRST_DOMAIN#$ENV{FIRST_DOMAIN}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
perl -pi -e 's#PH_TRANSPORT#$ENV{TRANSPORT}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
perl -pi -e 's#PH_DOMAIN_ADMIN_PASSWD_HASH#$ENV{DOMAIN_ADMIN_PASSWD_HASH}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
perl -pi -e 's#PH_DOMAIN_ADMIN_MAILDIR_HASH_PART#$ENV{DOMAIN_ADMIN_MAILDIR_HASH_PART}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
perl -pi -e 's#PH_DOMAIN_ADMIN_NAME#$ENV{DOMAIN_ADMIN_NAME}#g' ${PGSQL_DATA_DIR}/*.sql
|
||||
|
||||
if [ X"${PGSQL_VERSION}" == X'8' ]; then
|
||||
perl -pi -e 's#^(-- )(CREATE LANGUAGE plpgsql)#${2}#g' ${PGSQL_DATA_DIR}/iredmail.sql
|
||||
fi
|
||||
|
||||
perl -pi -e 's#^-- \\c#\\c#g' ${PGSQL_DATA_DIR}/iredmail.sql
|
||||
|
||||
# Modify default SQL template, set storagebasedirectory, storagenode.
|
||||
perl -pi -e 's#(.*storagebasedirectory.*DEFAULT..)(.*)#${1}$ENV{STORAGE_BASE_DIR}${2}#' ${PGSQL_DATA_DIR}/iredmail.sql
|
||||
perl -pi -e 's#(.*storagenode.*DEFAULT..)(.*)#${1}$ENV{STORAGE_NODE}${2}#' ${PGSQL_DATA_DIR}/iredmail.sql
|
||||
|
||||
chmod 0755 ${PGSQL_DATA_DIR}/*sql
|
||||
|
||||
ECHO_DEBUG "Create roles (${VMAIL_DB_BIND_USER}, ${VMAIL_DB_ADMIN_USER}) and database: ${VMAIL_DB_NAME}."
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1 -f ${PGSQL_DATA_DIR}/init_vmail_db.sql" >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Create tables in ${VMAIL_DB_NAME} database."
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1 -f ${PGSQL_DATA_DIR}/iredmail.sql" >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Grant permissions."
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1 -f ${PGSQL_DATA_DIR}/grant_permissions.sql" >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Add first domain and postmaster@ user."
|
||||
su - ${SYS_USER_PGSQL} -c "psql -U ${VMAIL_DB_ADMIN_USER} -d template1 -f ${PGSQL_DATA_DIR}/add_first_domain_and_user.sql" >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
mv ${PGSQL_DATA_DIR}/*sql ${RUNTIME_DIR}
|
||||
chmod 0700 ${RUNTIME_DIR}/*sql
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
SQL commands used to initialize database and import mail accounts:
|
||||
- ${RUNTIME_DIR}/*.sql
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_pgsql_import_vmail_users="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
pgsql_cron_backup()
|
||||
{
|
||||
pgsql_backup_script="${BACKUP_DIR}/${BACKUP_SCRIPT_PGSQL_NAME}"
|
||||
ECHO_INFO "Setup daily cron job to backup PostgreSQL databases with ${pgsql_backup_script}"
|
||||
|
||||
[ ! -d ${BACKUP_DIR} ] && mkdir -p ${BACKUP_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
backup_file ${pgsql_backup_script}
|
||||
cp ${TOOLS_DIR}/${BACKUP_SCRIPT_PGSQL_NAME} ${pgsql_backup_script}
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${pgsql_backup_script}
|
||||
chmod 0500 ${pgsql_backup_script}
|
||||
|
||||
perl -pi -e 's#^(export SYS_USER_PGSQL=).*#${1}"$ENV{SYS_USER_PGSQL}"#' ${pgsql_backup_script}
|
||||
perl -pi -e 's#^(export BACKUP_ROOTDIR=).*#${1}"$ENV{BACKUP_DIR}"#' ${pgsql_backup_script}
|
||||
|
||||
# Add cron job
|
||||
cat >> ${CRON_FILE_ROOT} <<EOF
|
||||
# ${PROG_NAME}: Backup PostgreSQL databases on 03:01 AM
|
||||
1 3 * * * ${SHELL_BASH} ${pgsql_backup_script}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_pgsql_cron_backup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
pgsql_setup()
|
||||
{
|
||||
ECHO_INFO "Configure PostgreSQL database server."
|
||||
|
||||
check_status_before_run pgsql_initialize
|
||||
check_status_before_run pgsql_import_vmail_users
|
||||
check_status_before_run pgsql_cron_backup
|
||||
|
||||
write_iredmail_kv "sql_user_${PGSQL_ROOT_USER}" "${PGSQL_ROOT_PASSWD}"
|
||||
write_iredmail_kv "sql_user_${VMAIL_DB_BIND_USER}" "${VMAIL_DB_BIND_PASSWD}"
|
||||
write_iredmail_kv "sql_user_${VMAIL_DB_ADMIN_USER}" "${VMAIL_DB_ADMIN_PASSWD}"
|
||||
|
||||
echo 'export status_pgsql_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
# -----------------------
|
||||
# Roundcube.
|
||||
# -----------------------
|
||||
rcm_install()
|
||||
{
|
||||
ECHO_INFO "Configure Roundcube webmail."
|
||||
|
||||
if [ X"${RCM_USE_SOURCE}" == X'YES' ]; then
|
||||
cd ${PKG_MISC_DIR}
|
||||
|
||||
# Extract source tarball.
|
||||
extract_pkg ${RCM_TARBALL} ${HTTPD_SERVERROOT}
|
||||
|
||||
# Create symbol link, so that we don't need to modify web server config
|
||||
# file to set new version number after upgrading this software.
|
||||
ln -s ${RCM_HTTPD_ROOT} ${RCM_HTTPD_ROOT_SYMBOL_LINK} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
ECHO_DEBUG "Set correct permission for Roundcubemail: ${RCM_HTTPD_ROOT}."
|
||||
chown -R ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${RCM_HTTPD_ROOT}
|
||||
chown -R ${HTTPD_USER}:${HTTPD_GROUP} ${RCM_HTTPD_ROOT}/{temp,logs}
|
||||
chmod 0000 ${RCM_HTTPD_ROOT}/{CHANGELOG,INSTALL,LICENSE,README*,UPGRADING,installer,SQL}
|
||||
fi
|
||||
|
||||
# Copy sample config files.
|
||||
cp -f ${SAMPLE_DIR}/roundcubemail/config.inc.php ${RCM_CONF}
|
||||
chown ${HTTPD_USER}:${HTTPD_GROUP} ${RCM_CONF}
|
||||
chmod 0600 ${RCM_CONF}
|
||||
|
||||
echo 'export status_rcm_install="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
rcm_initialize_db()
|
||||
{
|
||||
ECHO_DEBUG "Import SQL database and privileges for Roundcubemail."
|
||||
|
||||
# Initial roundcube db.
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
${MYSQL_CLIENT_ROOT} <<EOF
|
||||
-- Create database and grant privileges
|
||||
CREATE DATABASE ${RCM_DB_NAME} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
GRANT ALL ON ${RCM_DB_NAME}.* TO "${RCM_DB_USER}"@"${MYSQL_GRANT_HOST}" IDENTIFIED BY '${RCM_DB_PASSWD}';
|
||||
-- GRANT ALL ON ${RCM_DB_NAME}.* TO "${RCM_DB_USER}"@"${HOSTNAME}" IDENTIFIED BY '${RCM_DB_PASSWD}';
|
||||
|
||||
-- Import Roundcubemail SQL template
|
||||
USE ${RCM_DB_NAME};
|
||||
SOURCE ${RCM_HTTPD_ROOT}/SQL/mysql.initial.sql;
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
|
||||
# Generate .my.cnf file
|
||||
cat > /root/.my.cnf-${RCM_DB_USER} <<EOF
|
||||
[client]
|
||||
host=${MYSQL_SERVER_ADDRESS}
|
||||
port=${MYSQL_SERVER_PORT}
|
||||
user=${RCM_DB_USER}
|
||||
password="${RCM_DB_PASSWD}"
|
||||
EOF
|
||||
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
cp -f ${RCM_HTTPD_ROOT}/SQL/postgres.initial.sql ${PGSQL_USER_HOMEDIR}/rcm.sql >> ${INSTALL_LOG} 2>&1
|
||||
chmod 0777 ${PGSQL_USER_HOMEDIR}/rcm.sql
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1 >/dev/null" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
-- Create database and role
|
||||
CREATE DATABASE ${RCM_DB_NAME} WITH TEMPLATE template0 ENCODING 'UTF8';
|
||||
CREATE ROLE ${RCM_DB_USER} WITH LOGIN ENCRYPTED PASSWORD '${RCM_DB_PASSWD}' NOSUPERUSER NOCREATEDB NOCREATEROLE;
|
||||
|
||||
-- Grant privilege
|
||||
ALTER DATABASE ${RCM_DB_NAME} OWNER TO ${RCM_DB_USER};
|
||||
EOF
|
||||
|
||||
# Import sql templte as roundcube user.
|
||||
su - ${SYS_USER_PGSQL} -c "psql -U ${RCM_DB_USER} -d ${RCM_DB_NAME}" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
-- Import Roundcubemail SQL template
|
||||
\i ${PGSQL_USER_HOMEDIR}/rcm.sql;
|
||||
|
||||
-- Grant privileges
|
||||
-- GRANT SELECT,INSERT,UPDATE,DELETE ON cache,cache_index,cache_messages,cache_shared,cache_thread,contactgroupmembers,contactgroups,contacts,dictionary,identities,searches,session,system,users TO ${RCM_DB_USER};
|
||||
-- GRANT SELECT,UPDATE,USAGE ON contacts_seq,contactgroups_seq,identities_seq,searches_seq,users_seq TO ${RCM_DB_USER};
|
||||
EOF
|
||||
|
||||
# Grant privilege to update password (vmail.mailbox) through roundcube webmail
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d ${VMAIL_DB_NAME} >/dev/null" >> ${INSTALL_LOG} 2>&1 <<EOF
|
||||
\c ${VMAIL_DB_NAME};
|
||||
GRANT UPDATE,SELECT ON mailbox TO ${RCM_DB_USER};
|
||||
EOF
|
||||
rm -f ${PGSQL_USER_HOMEDIR}/rcm.sql >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
# Grant privileges
|
||||
if [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
${MYSQL_CLIENT_ROOT} <<EOF
|
||||
-- Grant privileges for Roundcubemail, so that user can change
|
||||
-- their own password and setting mail forwarding.
|
||||
GRANT UPDATE,SELECT ON ${VMAIL_DB_NAME}.mailbox TO "${RCM_DB_USER}"@"${MYSQL_GRANT_HOST}";
|
||||
-- GRANT UPDATE,SELECT ON ${VMAIL_DB_NAME}.mailbox TO "${RCM_DB_USER}"@"${HOSTNAME}";
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo 'export status_rcm_initialize_db="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
rcm_config()
|
||||
{
|
||||
ECHO_DEBUG "Configure database for Roundcubemail: ${RCM_CONF_DIR}/*."
|
||||
|
||||
cd ${RCM_CONF_DIR}
|
||||
|
||||
perl -pi -e 's#PH_IMAP_SERVER#$ENV{IMAP_SERVER}#g' ${RCM_CONF}
|
||||
|
||||
perl -pi -e 's#PH_PHP_CONN_TYPE#$ENV{PHP_CONN_TYPE}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_RCM_DB_USER#$ENV{RCM_DB_USER}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_RCM_DB_PASSWD#$ENV{RCM_DB_PASSWD}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_RCM_DB_NAME#$ENV{RCM_DB_NAME}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_SQL_SERVER_ADDRESS#$ENV{SQL_SERVER_ADDRESS}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_SQL_SERVER_PORT#$ENV{SQL_SERVER_PORT}#g' ${RCM_CONF}
|
||||
|
||||
perl -pi -e 's#PH_SMTP_SERVER#$ENV{SMTP_SERVER}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_RCM_DES_KEY#$ENV{RCM_DES_KEY}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_MESSAGE_SIZE_LIMIT_MB#$ENV{MESSAGE_SIZE_LIMIT_MB}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_FIRST_DOMAIN#$ENV{FIRST_DOMAIN}#g' ${RCM_CONF}
|
||||
|
||||
# Enable mime.types on Linux
|
||||
if [ X"${KERNEL_NAME}" == X"LINUX" ]; then
|
||||
perl -pi -e 's#//(.*mime_types.*)#${1}#' ${RCM_CONF}
|
||||
fi
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
export LDAP_SERVER_HOST LDAP_SERVER_PORT LDAP_BIND_VERSION LDAP_BASEDN LDAP_ATTR_DOMAIN_RDN LDAP_ATTR_USER_RDN
|
||||
cd ${RCM_CONF_DIR}
|
||||
ECHO_DEBUG "Setting global LDAP address book in Roundcube."
|
||||
|
||||
cat ${SAMPLE_DIR}/roundcubemail/global_ldap_address_book.inc.php >> ${RCM_CONF}
|
||||
perl -pi -e 's#PH_LDAP_SERVER_HOST#$ENV{LDAP_SERVER_HOST}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_LDAP_SERVER_PORT#$ENV{LDAP_SERVER_PORT}#g' ${RCM_CONF}
|
||||
perl -pi -e 's#PH_LDAP_BASEDN#$ENV{LDAP_BASEDN}#g' ${RCM_CONF}
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Roundcube webmail: ${RCM_HTTPD_ROOT}
|
||||
* Config file: ${RCM_CONF_DIR}
|
||||
* Web access:
|
||||
- URL: http://${HOSTNAME}/mail/ (will be redirected to https:// site)
|
||||
- URL: https://${HOSTNAME}/mail/ (secure connection)
|
||||
- Username: ${DOMAIN_ADMIN_EMAIL}
|
||||
- Password: ${DOMAIN_ADMIN_PASSWD_PLAIN}
|
||||
* SQL database account:
|
||||
- Database name: ${RCM_DB_NAME}
|
||||
- Username: ${RCM_DB_USER}
|
||||
- Password: ${RCM_DB_PASSWD}
|
||||
* Cron job:
|
||||
- Command: "crontab -l -u ${SYS_USER_ROOT}"
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_rcm_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
rcm_cron_setup()
|
||||
{
|
||||
ECHO_DEBUG "Setup daily cron job to keep SQL database clean."
|
||||
cat >> ${CRON_FILE_ROOT} <<EOF
|
||||
# ${PROG_NAME}: Cleanup Roundcube SQL database
|
||||
2 2 * * * ${PHP_BIN} ${RCM_HTTPD_ROOT_SYMBOL_LINK}/bin/cleandb.sh >/dev/null
|
||||
|
||||
# ${PROG_NAME}: Cleanup Roundcube temporary files under 'temp/' directory
|
||||
2 2 * * * ${PHP_BIN} ${RCM_HTTPD_ROOT_SYMBOL_LINK}/bin/gc.sh >/dev/null
|
||||
EOF
|
||||
|
||||
echo 'export status_rcm_cron_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
rcm_plugin_managesieve()
|
||||
{
|
||||
ECHO_DEBUG "Config plugin: managesieve."
|
||||
cd ${RCM_CONF_DIR}
|
||||
|
||||
export MANAGESIEVE_SERVER MANAGESIEVE_PORT
|
||||
cd ${RCM_HTTPD_ROOT}/plugins/managesieve/ && \
|
||||
cp config.inc.php.dist config.inc.php && \
|
||||
perl -pi -e 's#(.*managesieve_host.*=).*#${1} "$ENV{MANAGESIEVE_SERVER}";#' config.inc.php
|
||||
perl -pi -e 's#(.*managesieve_auth_type.*=).*#${1} "LOGIN";#' config.inc.php
|
||||
perl -pi -e 's#(.*managesieve_port.*=).*#${1} $ENV{MANAGESIEVE_PORT};#' config.inc.php
|
||||
perl -pi -e 's#(.*managesieve_usetls.*=).*#${1} true;#' config.inc.php
|
||||
perl -pi -e 's#(.*managesieve_default.*=).*#${1} "";#' config.inc.php
|
||||
perl -pi -e 's#(.*managesieve_vacation.*=).*#${1} 1;#' config.inc.php
|
||||
|
||||
# Disable ssl peer verify
|
||||
perl -pi -e 's#(.*managesieve_conn_options.*=.*)(null.*)#${1}array("ssl" => array("verify_peer" => false, "verify_peer_name" => false));#' config.inc.php
|
||||
|
||||
echo 'export status_rcm_plugin_managesieve="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
rcm_plugin_password()
|
||||
{
|
||||
ECHO_DEBUG "Config plugin: password."
|
||||
cd ${RCM_CONF_DIR}
|
||||
|
||||
cd ${RCM_HTTPD_ROOT}/plugins/password/
|
||||
cp config.inc.php.dist config.inc.php
|
||||
chown ${HTTPD_USER}:${HTTPD_GROUP} config.inc.php
|
||||
chmod 0400 config.inc.php
|
||||
|
||||
# Determine whether current password is required to change password
|
||||
perl -pi -e 's#(.*password_confirm_current.*=).*#${1} true;#' config.inc.php
|
||||
|
||||
# Require the new password to be a certain length
|
||||
perl -pi -e 's#(.*password_minimum_length.*=).*#${1} 8;#' config.inc.php
|
||||
|
||||
# Require the new password to contain a letter and punctuation character
|
||||
perl -pi -e 's#(.*password_require_nonalpha.*=).*#${1} true;#' config.inc.php
|
||||
perl -pi -e 's#(.*password_log.*=).*#${1} true;#' config.inc.php
|
||||
|
||||
# Roundcube uses scheme name in lower cases
|
||||
export default_password_scheme="$(echo ${DEFAULT_PASSWORD_SCHEME} | tr '[A-Z]' '[a-z]')"
|
||||
|
||||
# Dovecot uses scheme name in upper cases
|
||||
export dovecotpw_method="${DEFAULT_PASSWORD_SCHEME}"
|
||||
|
||||
if [ X"${dovecotpw_method}" == X'BCRYPT' ]; then
|
||||
# Password scheme name used in Dovecot (doveadm pw).
|
||||
export default_password_scheme='blf-crypt'
|
||||
export dovecotpw_method='BLF-CRYPT'
|
||||
fi
|
||||
|
||||
# Roundcube supports ssha, but not ssha512.
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
export default_password_scheme='ssha'
|
||||
fi
|
||||
|
||||
perl -pi -e 's#(.*password_dovecotpw.*=.*for dovecot-1.*)#//${1}#' config.inc.php
|
||||
perl -pi -e 's#// (.*password_dovecotpw.*=).*for dovecot-2.*#${1} "$ENV{DOVECOT_DOVEADM_BIN} pw";#' config.inc.php
|
||||
|
||||
perl -pi -e 's#(.*password_dovecotpw_method.*=).*#${1} "$ENV{dovecotpw_method}";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_dovecotpw_with_method.*=).*#${1} true;#' config.inc.php
|
||||
|
||||
if [ X"${BACKEND}" == X'MYSQL' -o X"${BACKEND}" == X'PGSQL' ]; then
|
||||
perl -pi -e 's#(.*password_driver.*=).*#${1} "sql";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_db_dsn.*= )(.*)#${1}"$ENV{PHP_CONN_TYPE}://$ENV{RCM_DB_USER}:$ENV{RCM_DB_PASSWD}\@$ENV{SQL_SERVER_ADDRESS}/$ENV{VMAIL_DB_NAME}";#' config.inc.php
|
||||
|
||||
perl -pi -e 's#(.*password_query.*=).*#${1} "UPDATE mailbox SET password=%D,passwordlastchange=NOW() WHERE username=%u";#' config.inc.php
|
||||
|
||||
elif [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
perl -pi -e 's#(.*password_confirm_current.*=).*#${1} true;#' config.inc.php
|
||||
|
||||
perl -pi -e 's#(.*password_driver.*=).*#${1} "ldap_simple";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_host.*=).*#${1} "$ENV{LDAP_SERVER_HOST}";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_port.*=).*#${1} "$ENV{LDAP_SERVER_PORT}";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_starttls.*=).*#${1} false;#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_version.*=).*#${1} "3";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_basedn...=).*#${1} "$ENV{LDAP_BASEDN}";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_userDN_mask...=).*#${1} "$ENV{LDAP_ATTR_USER_RDN}=%login,$ENV{LDAP_ATTR_GROUP_RDN}=$ENV{LDAP_ATTR_GROUP_USERS},$ENV{LDAP_ATTR_DOMAIN_RDN}=%domain,$ENV{LDAP_BASEDN}";#' config.inc.php
|
||||
|
||||
perl -pi -e 's#(.*password_ldap_method.*=).*#${1} "user";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_adminDN.*=).*#${1} "null";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_adminPW.*=).*#${1} "null";#' config.inc.php
|
||||
|
||||
perl -pi -e 's#(.*password_ldap_encodage.*=).*#${1} "$ENV{default_password_scheme}";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_pwattr.*=).*#${1} "userPassword";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_lchattr.*=).*#${1} "shadowLastChange";#' config.inc.php
|
||||
perl -pi -e 's#(.*password_ldap_force_replace.*=).*#${1} true;#' config.inc.php
|
||||
fi
|
||||
|
||||
echo 'export status_rcm_plugin_password="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
rcm_plugin_enigma()
|
||||
{
|
||||
ECHO_DEBUG "Config plugin: enigma."
|
||||
|
||||
cd ${RCM_HTTPD_ROOT}/plugins/enigma/
|
||||
cp -f config.inc.php.dist config.inc.php
|
||||
perl -pi -e 's#(.*enigma_pgp_homedir.*=).*#${1} "$ENV{RCM_PLUGIN_ENIGMA_PGP_HOMEDIR}";#' config.inc.php
|
||||
|
||||
# Directory used to store pgp keys generated by enigma plugin.
|
||||
mkdir -p ${RCM_PLUGIN_ENIGMA_PGP_HOMEDIR} >> ${INSTALL_LOG} 2>&1
|
||||
chown ${HTTPD_USER}:${HTTPD_GROUP} ${RCM_PLUGIN_ENIGMA_PGP_HOMEDIR}
|
||||
chmod 0700 ${RCM_PLUGIN_ENIGMA_PGP_HOMEDIR}
|
||||
|
||||
echo 'export status_rcm_plugin_enigma="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
rcm_setup() {
|
||||
check_status_before_run rcm_install
|
||||
|
||||
if [ X"${INITIALIZE_SQL_DATA}" == X'YES' ]; then
|
||||
check_status_before_run rcm_initialize_db
|
||||
fi
|
||||
|
||||
check_status_before_run rcm_config
|
||||
check_status_before_run rcm_cron_setup
|
||||
check_status_before_run rcm_plugin_managesieve
|
||||
check_status_before_run rcm_plugin_password
|
||||
check_status_before_run rcm_plugin_enigma
|
||||
|
||||
write_iredmail_kv "sql_user_${RCM_DB_USER}" "${RCM_DB_PASSWD}"
|
||||
write_iredmail_kv roundcube_des_key "${RCM_DES_KEY}"
|
||||
echo 'export status_rcm_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
sogo_initialize_db()
|
||||
{
|
||||
ECHO_DEBUG "Initialize SOGo database."
|
||||
|
||||
# Create log directory
|
||||
mkdir -p $(dirname ${SOGO_LOG_FILE}) >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
|
||||
tmp_sql="${ROOTDIR}/sogo_init.sql"
|
||||
|
||||
cat > ${tmp_sql} <<EOF
|
||||
CREATE DATABASE ${SOGO_DB_NAME} CHARSET='UTF8';
|
||||
EOF
|
||||
|
||||
cat >> ${tmp_sql} <<EOF
|
||||
GRANT ALL ON ${SOGO_DB_NAME}.* TO ${SOGO_DB_USER}@"${MYSQL_GRANT_HOST}" IDENTIFIED BY "${SOGO_DB_PASSWD}";
|
||||
-- GRANT ALL ON ${SOGO_DB_NAME}.* TO ${SOGO_DB_USER}@"${HOSTNAME}" IDENTIFIED BY "${SOGO_DB_PASSWD}";
|
||||
EOF
|
||||
|
||||
if [ X"${BACKEND}" == X'MYSQL' ]; then
|
||||
cat >> ${tmp_sql} <<EOF
|
||||
GRANT SELECT ON ${VMAIL_DB_NAME}.mailbox TO ${SOGO_DB_USER}@"${MYSQL_GRANT_HOST}";
|
||||
-- GRANT SELECT ON ${VMAIL_DB_NAME}.mailbox TO ${SOGO_DB_USER}@"${HOSTNAME}";
|
||||
CREATE VIEW ${SOGO_DB_NAME}.${SOGO_DB_VIEW_AUTH} (c_uid, c_name, c_password, c_cn, mail, domain) AS SELECT username, username, password, name, username, domain FROM ${VMAIL_DB_NAME}.mailbox WHERE enablesogo=1 AND active=1;
|
||||
EOF
|
||||
fi
|
||||
|
||||
${MYSQL_CLIENT_ROOT} -e "SOURCE ${tmp_sql}"
|
||||
|
||||
# Generate .my.cnf file
|
||||
cat > /root/.my.cnf-${SOGO_DB_USER} <<EOF
|
||||
[client]
|
||||
host=${MYSQL_SERVER_ADDRESS}
|
||||
port=${MYSQL_SERVER_PORT}
|
||||
user=${SOGO_DB_USER}
|
||||
password="${SOGO_DB_PASSWD}"
|
||||
EOF
|
||||
|
||||
elif [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
tmp_sql="${PGSQL_DATA_DIR}/create_db.sql"
|
||||
|
||||
# Create db, user/role, set ownership
|
||||
cat > ${tmp_sql} <<EOF
|
||||
CREATE DATABASE ${SOGO_DB_NAME} WITH TEMPLATE template0 ENCODING 'UTF8';
|
||||
CREATE USER ${SOGO_DB_USER} WITH ENCRYPTED PASSWORD '${SOGO_DB_PASSWD}' NOSUPERUSER NOCREATEDB NOCREATEROLE;
|
||||
ALTER DATABASE ${SOGO_DB_NAME} OWNER TO ${SOGO_DB_USER};
|
||||
\c ${SOGO_DB_NAME};
|
||||
CREATE EXTENSION dblink;
|
||||
EOF
|
||||
|
||||
# Create view for user authentication
|
||||
cat >> ${tmp_sql} <<EOF
|
||||
CREATE VIEW ${SOGO_DB_VIEW_AUTH} AS
|
||||
SELECT * FROM dblink('host=${SQL_SERVER_ADDRESS}
|
||||
port=${SQL_SERVER_PORT}
|
||||
dbname=${VMAIL_DB_NAME}
|
||||
user=${VMAIL_DB_BIND_USER}
|
||||
password=${VMAIL_DB_BIND_PASSWD}',
|
||||
'SELECT username AS c_uid,
|
||||
username AS c_name,
|
||||
password AS c_password,
|
||||
name AS c_cn,
|
||||
username AS mail,
|
||||
domain AS domain
|
||||
FROM mailbox
|
||||
WHERE enablesogo=1 AND active=1')
|
||||
AS ${SOGO_DB_VIEW_AUTH} (c_uid VARCHAR(255),
|
||||
c_name VARCHAR(255),
|
||||
c_password VARCHAR(255),
|
||||
c_cn VARCHAR(255),
|
||||
mail VARCHAR(255),
|
||||
domain VARCHAR(255));
|
||||
|
||||
ALTER TABLE ${SOGO_DB_VIEW_AUTH} OWNER TO ${SOGO_DB_USER};
|
||||
EOF
|
||||
|
||||
su - ${SYS_USER_PGSQL} -c "psql -d template1 -f ${tmp_sql} >/dev/null" >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
rm -f ${tmp_sql} &>/dev/null
|
||||
|
||||
echo 'export status_sogo_initialize_db="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
sogo_config() {
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Start services when system start up.
|
||||
service_control enable 'memcached_enable' 'YES'
|
||||
service_control enable 'memcached_flags' "-l ${MEMCACHED_BIND_ADDRESS}"
|
||||
service_control enable 'sogod_enable' 'YES'
|
||||
fi
|
||||
|
||||
# Configure SOGo config file
|
||||
backup_file ${SOGO_CONF}
|
||||
|
||||
# Create /etc/timezone required by sogo
|
||||
if [ ! -f /etc/timezone ]; then
|
||||
echo 'America/New_York' > /etc/timezone
|
||||
fi
|
||||
|
||||
# Create directory to store config files
|
||||
[ ! -d ${SOGO_CONF_DIR} ] && mkdir -p ${SOGO_CONF_DIR}
|
||||
|
||||
cp -f ${SAMPLE_DIR}/sogo/sogo.conf ${SOGO_CONF}
|
||||
chown ${SYS_USER_SOGO}:${SYS_GROUP_SOGO} ${SOGO_CONF}
|
||||
chmod 0400 ${SOGO_CONF}
|
||||
|
||||
perl -pi -e 's#PH_SOGO_BIND_ADDRESS#$ENV{SOGO_BIND_ADDRESS}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_BIND_PORT#$ENV{SOGO_BIND_PORT}#g' ${SOGO_CONF}
|
||||
|
||||
# PID, log file
|
||||
perl -pi -e 's#PH_SOGO_PID_FILE#$ENV{SOGO_PID_FILE}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_LOG_FILE#$ENV{SOGO_LOG_FILE}#g' ${SOGO_CONF}
|
||||
|
||||
perl -pi -e 's#PH_MESSAGE_SIZE_LIMIT_KB#$ENV{MESSAGE_SIZE_LIMIT_KB}#g' ${SOGO_CONF}
|
||||
|
||||
# Proxy timeout
|
||||
perl -pi -e 's#PH_SOGO_PROXY_TIMEOUT#$ENV{SOGO_PROXY_TIMEOUT}#g' ${SOGO_CONF}
|
||||
# WatchDog timeout
|
||||
export watchdog_request_timeout="$((SOGO_PROXY_TIMEOUT / 60 + 2 ))"
|
||||
perl -pi -e 's#PH_SOGO_WATCHDOG_REQUEST_TIMEOUT#$ENV{watchdog_request_timeout}#g' ${SOGO_CONF}
|
||||
|
||||
perl -pi -e 's#PH_IMAP_SERVER#$ENV{IMAP_SERVER}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_MANAGESIEVE_SERVER#$ENV{MANAGESIEVE_SERVER}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_MANAGESIEVE_PORT#$ENV{MANAGESIEVE_PORT}#g' ${SOGO_CONF}
|
||||
|
||||
# SMTP server
|
||||
perl -pi -e 's#PH_SMTP_SERVER#$ENV{SMTP_SERVER}#g' ${SOGO_CONF}
|
||||
|
||||
# Memcached server
|
||||
perl -pi -e 's#PH_MEMCACHED_BIND_ADDRESS#$ENV{MEMCACHED_BIND_ADDRESS}#g' ${SOGO_CONF}
|
||||
|
||||
perl -pi -e 's#PH_SOGO_DB_TYPE#$ENV{SOGO_DB_TYPE}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_USER#$ENV{SOGO_DB_USER}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_PASSWD#$ENV{SOGO_DB_PASSWD}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_NAME#$ENV{SOGO_DB_NAME}#g' ${SOGO_CONF}
|
||||
|
||||
perl -pi -e 's#PH_SOGO_DB_VIEW_AUTH#$ENV{SOGO_DB_VIEW_AUTH}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_VIEW_ALIASES#$ENV{SOGO_DB_VIEW_ALIASES}#g' ${SOGO_CONF}
|
||||
|
||||
perl -pi -e 's#PH_SOGO_DB_TABLE_USER_PROFILE#$ENV{SOGO_DB_TABLE_USER_PROFILE}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_TABLE_FOLDER_INFO#$ENV{SOGO_DB_TABLE_FOLDER_INFO}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_TABLE_SESSIONS_FOLDER#$ENV{SOGO_DB_TABLE_SESSIONS_FOLDER}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_TABLE_ALARMS#$ENV{SOGO_DB_TABLE_ALARMS}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_TABLE_STORE#$ENV{SOGO_DB_TABLE_STORE}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_TABLE_ACL#$ENV{SOGO_DB_TABLE_ACL}#g' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_SOGO_DB_TABLE_CACHE_FOLDER#$ENV{SOGO_DB_TABLE_CACHE_FOLDER}#g' ${SOGO_CONF}
|
||||
|
||||
perl -pi -e 's#PH_SQL_SERVER_PORT#$ENV{SQL_SERVER_PORT}#g' ${SOGO_CONF}
|
||||
if [ X"${SQL_SERVER_ADDRESS_IS_IPV6}" == X'YES' ]; then
|
||||
# [ipv6]
|
||||
perl -pi -e 's#PH_SQL_SERVER_ADDRESS#[$ENV{SQL_SERVER_ADDRESS}]#g' ${SOGO_CONF}
|
||||
else
|
||||
perl -pi -e 's#PH_SQL_SERVER_ADDRESS#$ENV{SQL_SERVER_ADDRESS}#g' ${SOGO_CONF}
|
||||
fi
|
||||
|
||||
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
|
||||
# Enable LDAP as SOGoUserSources
|
||||
perl -pi -e 's#/\* LDAP backend##' ${SOGO_CONF}
|
||||
perl -pi -e 's#LDAP backend \*/##' ${SOGO_CONF}
|
||||
|
||||
perl -pi -e 's#PH_LDAP_URI#ldap://$ENV{LDAP_SERVER_HOST}:$ENV{LDAP_SERVER_PORT}#' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_LDAP_BASEDN#$ENV{LDAP_BASEDN}#' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_LDAP_BINDDN#$ENV{LDAP_BINDDN}#' ${SOGO_CONF}
|
||||
perl -pi -e 's#PH_LDAP_BINDPW#$ENV{LDAP_BINDPW}#' ${SOGO_CONF}
|
||||
|
||||
if [ X"${DEFAULT_PASSWORD_SCHEME}" == X'SSHA' ]; then
|
||||
perl -pi -e 's#= ssha512#= ssha#' ${SOGO_CONF}
|
||||
fi
|
||||
else
|
||||
# Enable LDAP as SOGoUserSources
|
||||
perl -pi -e 's#/\* SQL backend##' ${SOGO_CONF}
|
||||
perl -pi -e 's#SQL backend \*/##' ${SOGO_CONF}
|
||||
|
||||
# Enable password change in MySQL backend
|
||||
if [ X"${BACKEND}" == X'PGSQL' ]; then
|
||||
perl -pi -e 's#(.*SOGoPasswordChangeEnabled = )YES;#${1}NO;#g' ${SOGO_CONF}
|
||||
fi
|
||||
fi
|
||||
|
||||
# SOGo reads some additional config file for certain parameters.
|
||||
# Increase WOWorkerCount.
|
||||
if [ X"${DISTRO}" == X'RHEL' \
|
||||
-o X"${DISTRO}" == X'DEBIAN' \
|
||||
-o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ -f ${ETC_SYSCONFIG_DIR}/sogo ]; then
|
||||
perl -pi -e 's/^# (PREFORK=).*/${1}10/g' ${ETC_SYSCONFIG_DIR}/sogo
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add Dovecot Master User, for vacation message expiration
|
||||
cat >> ${DOVECOT_MASTER_USER_PASSWORD_FILE} <<EOF
|
||||
${SOGO_SIEVE_MASTER_USER}@${DOVECOT_MASTER_USER_DOMAIN}:$(generate_password_hash ${DEFAULT_PASSWORD_SCHEME} "${SOGO_SIEVE_MASTER_PASSWD}")
|
||||
EOF
|
||||
|
||||
cat >> ${SOGO_SIEVE_CREDENTIAL_FILE} <<EOF
|
||||
${SOGO_SIEVE_MASTER_USER}@${DOVECOT_MASTER_USER_DOMAIN}:${SOGO_SIEVE_MASTER_PASSWD}
|
||||
EOF
|
||||
|
||||
chown ${SYS_USER_SOGO}:${SYS_GROUP_SOGO} ${SOGO_SIEVE_CREDENTIAL_FILE}
|
||||
chmod 0400 ${SOGO_SIEVE_CREDENTIAL_FILE}
|
||||
|
||||
# Start SOGo service to avoid cron job error.
|
||||
service_control restart ${SOGO_RC_SCRIPT_NAME} >> ${INSTALL_LOG} 2>&1
|
||||
sleep 3
|
||||
|
||||
add_postfix_alias ${SYS_USER_SOGO} ${SYS_USER_ROOT}
|
||||
|
||||
# Enable sieve support if Roundcube is not installed
|
||||
# WARNING: Do not enable sieve support in both Roundcube and SOGo, because
|
||||
# the sieve rules generated by them are not compatible.
|
||||
if [ X"${USE_ROUNDCUBE}" != X'YES' ]; then
|
||||
perl -pi -e 's#(//)(SOGoSieveServer.*)#${2}#' ${SOGO_CONF}
|
||||
perl -pi -e 's#(//)(SOGoSieveScriptsEnabled.*)#${2}#' ${SOGO_CONF}
|
||||
perl -pi -e 's#(//)(SOGoSieveFolderEncoding*)#${2}#' ${SOGO_CONF}
|
||||
perl -pi -e 's#(//)(SOGoVacationEnabled.*)#${2}#' ${SOGO_CONF}
|
||||
perl -pi -e 's#(//)(SOGoForwardEnabled.*)#${2}#' ${SOGO_CONF}
|
||||
|
||||
# Disable Roundcube in Nginx, redirect '/mail' to SOGo.
|
||||
if [ X"${WEB_SERVER}" == X'NGINX' ]; then
|
||||
perl -pi -e 's/^#(location.*mail.*SOGo.*)/${1}/g' ${NGINX_CONF_TMPL_DIR}/sogo.tmpl
|
||||
fi
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
SOGo Groupware:
|
||||
* Web access: httpS://${HOSTNAME}/SOGo/
|
||||
* Main config file: ${SOGO_CONF}
|
||||
* Nginx template file: ${NGINX_CONF_TMPL_DIR}/sogo.tmpl
|
||||
* Database:
|
||||
- Database name: ${SOGO_DB_NAME}
|
||||
- Database user: ${SOGO_DB_USER}
|
||||
- Database password: ${SOGO_DB_PASSWD}
|
||||
* SOGo sieve account (Warning: it's a Dovecot Master User):
|
||||
- file: ${SOGO_SIEVE_CREDENTIAL_FILE}
|
||||
- username: ${SOGO_SIEVE_MASTER_USER}@${DOVECOT_MASTER_USER_DOMAIN}
|
||||
- password: ${SOGO_SIEVE_MASTER_PASSWD}
|
||||
* See also:
|
||||
- cron job of system user: ${SYS_USER_SOGO}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_sogo_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
sogo_cron_setup()
|
||||
{
|
||||
# Add cron jobs
|
||||
cp -f ${SAMPLE_DIR}/sogo/sogo.cron ${CRON_FILE_SOGO} &>/dev/null
|
||||
chmod 0600 ${CRON_FILE_SOGO}
|
||||
perl -pi -e 's#PH_SOGO_CMD_TOOL#$ENV{SOGO_CMD_TOOL}#g' ${CRON_FILE_SOGO}
|
||||
perl -pi -e 's#PH_SOGO_CMD_EALARMS_NOTIFY#$ENV{SOGO_CMD_EALARMS_NOTIFY}#g' ${CRON_FILE_SOGO}
|
||||
perl -pi -e 's#PH_SOGO_SIEVE_CREDENTIAL_FILE#$ENV{SOGO_SIEVE_CREDENTIAL_FILE}#g' ${CRON_FILE_SOGO}
|
||||
|
||||
# backup script
|
||||
cp -f ${TOOLS_DIR}/backup_sogo.sh ${BACKUP_SCRIPT_SOGO}
|
||||
chmod 0400 ${BACKUP_SCRIPT_SOGO}
|
||||
perl -pi -e 's#^(export BACKUP_ROOTDIR=).*#${1}"$ENV{BACKUP_DIR}"#g' ${BACKUP_SCRIPT_SOGO}
|
||||
|
||||
# Add cron job for root user
|
||||
cat >> ${CRON_FILE_ROOT} <<EOF
|
||||
# ${PROG_NAME}: Backup SOGo data databases on 04:01AM
|
||||
1 4 * * * ${SHELL_BASH} ${BACKUP_SCRIPT_SOGO}
|
||||
|
||||
EOF
|
||||
|
||||
# Disable cron jobs if we don't need to initialize database on this server.
|
||||
if [ X"${INITIALIZE_SQL_DATA}" != X'YES' ]; then
|
||||
perl -pi -e 's/(.*sogo-tool.*)/#${1}/g' ${CRON_FILE_SOGO}
|
||||
fi
|
||||
|
||||
echo 'export status_sogo_cron_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
memcached_setup()
|
||||
{
|
||||
# Listen on localhost by default
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ -f ${ETC_SYSCONFIG_DIR}/memcached ]; then
|
||||
perl -pi -e 's#^(OPTIONS=).*#${1}"-l $ENV{MEMCACHED_BIND_ADDRESS}"#g' ${ETC_SYSCONFIG_DIR}/memcached
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if grep -- '^-l' ${MEMCACHED_CONF} &>/dev/null; then
|
||||
perl -pi -e 's#^(-l).*#${1} $ENV{MEMCACHED_BIND_ADDRESS}#g' ${MEMCACHED_CONF}
|
||||
else
|
||||
echo "-l ${MEMCACHED_BIND_ADDRESS}" >> ${MEMCACHED_CONF}
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
echo "memcached_flags='-u ${MEMCACHED_DAEMIN_USER} -l ${MEMCACHED_BIND_ADDRESS}'" >> ${RC_CONF_LOCAL}
|
||||
fi
|
||||
|
||||
echo 'export status_memcached_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
sogo_setup()
|
||||
{
|
||||
ECHO_INFO "Configure SOGo Groupware (Webmail, Calendar, Address Book, ActiveSync)."
|
||||
|
||||
if [ X"${INITIALIZE_SQL_DATA}" == X'YES' ]; then
|
||||
check_status_before_run sogo_initialize_db
|
||||
fi
|
||||
|
||||
check_status_before_run sogo_config
|
||||
check_status_before_run memcached_setup
|
||||
check_status_before_run sogo_cron_setup
|
||||
|
||||
write_iredmail_kv "sql_user_${SOGO_DB_USER}" "${SOGO_DB_PASSWD}"
|
||||
write_iredmail_kv sogo_sieve_master_password "${SOGO_SIEVE_MASTER_PASSWD}"
|
||||
echo 'export status_sogo_setup="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# SpamAssassin.
|
||||
# ---------------------------------------------------------
|
||||
sa_config()
|
||||
{
|
||||
ECHO_INFO "Configure SpamAssassin (content-based spam filter)."
|
||||
|
||||
backup_file ${SA_LOCAL_CF}
|
||||
|
||||
ECHO_DEBUG "Copy sample SpamAssassin config file: ${SAMPLE_DIR}/spamassassin/local.cf -> ${SA_LOCAL_CF}."
|
||||
cp -f ${SAMPLE_DIR}/spamassassin/local.cf ${SA_LOCAL_CF}
|
||||
cp -f ${SAMPLE_DIR}/spamassassin/razor.conf ${SA_PLUGIN_RAZOR_CONF}
|
||||
|
||||
perl -pi -e 's#PH_SA_PLUGIN_RAZOR_CONF#$ENV{SA_PLUGIN_RAZOR_CONF}#g' ${SA_LOCAL_CF}
|
||||
|
||||
ECHO_DEBUG "Enable crontabs for SpamAssassin update."
|
||||
if [ X"${DISTRO}" == X'RHEL' ]; then
|
||||
if [ -f ${ETC_SYSCONFIG_DIR}/sa-update ]; then
|
||||
perl -pi -e 's/^#(SAUPDATE=yes)/${1}/' ${ETC_SYSCONFIG_DIR}/sa-update
|
||||
fi
|
||||
|
||||
# CentOS 7.
|
||||
if [ -f /etc/cron.d/sa-update ]; then
|
||||
chmod 0644 /etc/cron.d/sa-update
|
||||
perl -pi -e 's/#(10.*)/${1}/' /etc/cron.d/sa-update
|
||||
fi
|
||||
elif [ X"${DISTRO}" == X'UBUNTU' -o X"${DISTRO}" == X'DEBIAN' ]; then
|
||||
perl -pi -e 's#^(CRON=)0#${1}1#' /etc/default/spamassassin
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
ECHO_DEBUG "Compile SpamAssassin ruleset into native code."
|
||||
sa-compile >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
SpamAssassin:
|
||||
* Configuration files and rules:
|
||||
- ${SA_CONF_DIR}
|
||||
- ${SA_CONF_DIR}/local.cf
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_sa_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
|
||||
|
||||
# Add required system accounts
|
||||
|
||||
add_user_vmail()
|
||||
{
|
||||
ECHO_DEBUG "Create system account: ${SYS_USER_VMAIL}:${SYS_GROUP_VMAIL} (${SYS_USER_VMAIL_UID}:${SYS_GROUP_VMAIL_GID})."
|
||||
|
||||
# Create STORAGE_BASE_DIR and set correct owner and permission.
|
||||
if [ ! -d ${STORAGE_BASE_DIR} ]; then
|
||||
mkdir -p ${STORAGE_BASE_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${STORAGE_BASE_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
chmod -R 0755 ${STORAGE_BASE_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
fi
|
||||
|
||||
[ -d ${STORAGE_MAILBOX_DIR} ] || mkdir -p ${STORAGE_MAILBOX_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
[ -d ${PUBLIC_MAILBOX_DIR} ] || mkdir -p ${PUBLIC_MAILBOX_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# vmail/vmail must has the same UID/GID on all supported Linux/BSD
|
||||
# distributions, required by cluster environment. e.g. GlusterFS.
|
||||
add_sys_user_group \
|
||||
${SYS_USER_VMAIL} \
|
||||
${SYS_GROUP_VMAIL} \
|
||||
${SYS_USER_VMAIL_UID} \
|
||||
${SYS_GROUP_VMAIL_GID} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
if [ -n "${MAILBOX_INDEX_DIR}" ]; then
|
||||
if [ ! -d ${MAILBOX_INDEX_DIR} ]; then
|
||||
ECHO_DEBUG "Create directory used to store mailbox indexes: ${MAILBOX_INDEX_DIR}."
|
||||
mkdir -p ${MAILBOX_INDEX_DIR} >> ${INSTALL_LOG} 2>&1
|
||||
chown -R ${SYS_USER_VMAIL}:${SYS_GROUP_VMAIL} ${MAILBOX_INDEX_DIR}
|
||||
chmod -R 0700 ${MAILBOX_INDEX_DIR}
|
||||
fi
|
||||
fi
|
||||
|
||||
ECHO_DEBUG "Create directory used to store global sieve filters: ${SIEVE_DIR}."
|
||||
mkdir -p ${SIEVE_DIR} &>/dev/null
|
||||
|
||||
export DOMAIN_ADMIN_MAILDIR_HASH_PART="${FIRST_DOMAIN}/$(hash_maildir --no-timestamp ${DOMAIN_ADMIN_NAME})"
|
||||
export DOMAIN_ADMIN_MAILDIR_FULL_PATH="${STORAGE_MAILBOX_DIR}/${DOMAIN_ADMIN_MAILDIR_HASH_PART}"
|
||||
|
||||
# Create maildir.
|
||||
# We will deliver emails with sensitive info of iRedMail installation
|
||||
# to postmaster immediately after installation completed.
|
||||
# NOTE: 'Maildir/' is appended by Dovecot (defined in dovecot.conf).
|
||||
export DOMAIN_ADMIN_MAILDIR_INBOX="${DOMAIN_ADMIN_MAILDIR_FULL_PATH}/Maildir/new"
|
||||
mkdir -p ${DOMAIN_ADMIN_MAILDIR_INBOX} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
# set owner/group and permission.
|
||||
chown -R ${SYS_USER_VMAIL}:${SYS_GROUP_VMAIL} ${STORAGE_MAILBOX_DIR} ${PUBLIC_MAILBOX_DIR} ${SIEVE_DIR}
|
||||
chmod -R 0700 ${STORAGE_MAILBOX_DIR} ${PUBLIC_MAILBOX_DIR} ${SIEVE_DIR}
|
||||
|
||||
# backup directory
|
||||
[ -d ${BACKUP_DIR} ] || mkdir -p ${BACKUP_DIR} &>/dev/null
|
||||
chown ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${BACKUP_DIR}
|
||||
chmod 0700 ${BACKUP_DIR}
|
||||
|
||||
cat >> ${TIP_FILE} <<EOF
|
||||
Mail Storage:
|
||||
- Mailboxes: ${STORAGE_MAILBOX_DIR}
|
||||
- Mailbox indexes: ${MAILBOX_INDEX_DIR}
|
||||
- Global sieve filters: ${SIEVE_DIR}
|
||||
- Backup scripts and backup copies: ${BACKUP_DIR}
|
||||
|
||||
EOF
|
||||
|
||||
echo 'export status_add_user_vmail="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
add_user_iredadmin()
|
||||
{
|
||||
add_sys_user_group \
|
||||
${SYS_USER_IREDADMIN} \
|
||||
${SYS_GROUP_IREDADMIN} \
|
||||
${SYS_USER_IREDADMIN_UID} \
|
||||
${SYS_GROUP_IREDADMIN_GID}
|
||||
|
||||
echo 'export status_add_user_iredadmin="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
add_user_mlmmj()
|
||||
{
|
||||
add_sys_user_group \
|
||||
${SYS_USER_MLMMJ} \
|
||||
${SYS_GROUP_MLMMJ} \
|
||||
${SYS_USER_MLMMJ_UID} \
|
||||
${SYS_GROUP_MLMMJ_GID} \
|
||||
${MLMMJ_HOME_DIR}
|
||||
|
||||
echo 'export status_add_user_mlmmj="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
add_user_iredapd()
|
||||
{
|
||||
add_sys_user_group \
|
||||
${SYS_USER_IREDAPD} \
|
||||
${SYS_GROUP_IREDAPD} \
|
||||
${SYS_USER_IREDAPD_UID} \
|
||||
${SYS_GROUP_IREDAPD_GID}
|
||||
|
||||
echo 'export status_add_user_iredapd="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
add_user_netdata()
|
||||
{
|
||||
add_sys_user_group \
|
||||
${SYS_USER_NETDATA} \
|
||||
${SYS_GROUP_NETDATA} \
|
||||
${SYS_USER_NETDATA_UID} \
|
||||
${SYS_GROUP_NETDATA_GID}
|
||||
|
||||
echo 'export status_add_user_netdata="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
|
||||
add_required_users()
|
||||
{
|
||||
ECHO_INFO "Create required system accounts."
|
||||
|
||||
check_status_before_run add_user_vmail
|
||||
check_status_before_run add_user_mlmmj
|
||||
check_status_before_run add_user_iredadmin
|
||||
check_status_before_run add_user_iredapd
|
||||
|
||||
[ X"${USE_NETDATA}" == X'YES' ] && check_status_before_run add_user_netdata
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
web_server_extra()
|
||||
{
|
||||
# Create robots.txt.
|
||||
if [ ! -e ${HTTPD_DOCUMENTROOT}/robots.txt ]; then
|
||||
cat >> ${HTTPD_DOCUMENTROOT}/robots.txt <<EOF
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Redirect home page to webmail by default
|
||||
if [ ! -e ${HTTPD_DOCUMENTROOT}/index.html ]; then
|
||||
if [ X"${USE_ROUNDCUBE}" == X'YES' ]; then
|
||||
echo '<html><head><meta HTTP-EQUIV="REFRESH" content="0; url=/mail/"></head></html>' > ${HTTPD_DOCUMENTROOT}/index.html
|
||||
elif [ X"${USE_SOGO}" == X'YES' ]; then
|
||||
echo '<html><head><meta HTTP-EQUIV="REFRESH" content="0; url=/SOGo/"></head></html>' > ${HTTPD_DOCUMENTROOT}/index.html
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add alias for web server daemon user
|
||||
add_postfix_alias ${HTTPD_USER} ${SYS_USER_ROOT}
|
||||
|
||||
echo 'export status_web_server_extra="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
web_server_config()
|
||||
{
|
||||
# Create required directories
|
||||
[ -d ${HTTPD_SERVERROOT} ] || mkdir -p ${HTTPD_SERVERROOT} >> ${INSTALL_LOG} 2>&1
|
||||
[ -d ${HTTPD_DOCUMENTROOT} ] || mkdir -p ${HTTPD_DOCUMENTROOT} >> ${INSTALL_LOG} 2>&1
|
||||
|
||||
if [ X"${WEB_SERVER}" == X'NGINX' ]; then
|
||||
. ${FUNCTIONS_DIR}/nginx.sh
|
||||
check_status_before_run nginx_config
|
||||
check_status_before_run web_server_extra
|
||||
fi
|
||||
|
||||
if [ X"${IREDMAIL_USE_PHP}" == X'YES' ]; then
|
||||
. ${FUNCTIONS_DIR}/php.sh
|
||||
check_status_before_run php_config
|
||||
fi
|
||||
|
||||
echo 'export status_web_server_config="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb@iredmail.org)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
# ------------------------------
|
||||
# Define some global variables.
|
||||
# ------------------------------
|
||||
tmprootdir="$(dirname $0)"
|
||||
echo ${tmprootdir} | grep '^/' >/dev/null 2>&1
|
||||
if [ X"$?" == X"0" ]; then
|
||||
export ROOTDIR="${tmprootdir}"
|
||||
else
|
||||
export ROOTDIR="$(pwd)"
|
||||
fi
|
||||
|
||||
cd ${ROOTDIR}
|
||||
|
||||
export CONF_DIR="${ROOTDIR}/conf"
|
||||
export FUNCTIONS_DIR="${ROOTDIR}/functions"
|
||||
export DIALOG_DIR="${ROOTDIR}/dialog"
|
||||
export PKG_DIR="${ROOTDIR}/pkgs/pkgs"
|
||||
export PKG_MISC_DIR="${ROOTDIR}/pkgs/misc"
|
||||
export SAMPLE_DIR="${ROOTDIR}/samples"
|
||||
export PATCH_DIR="${ROOTDIR}/patches"
|
||||
export TOOLS_DIR="${ROOTDIR}/tools"
|
||||
export RUNTIME_DIR="${ROOTDIR}/runtime"
|
||||
|
||||
[[ -d ${RUNTIME_DIR} ]] || mkdir -p ${RUNTIME_DIR}
|
||||
|
||||
. ${CONF_DIR}/global
|
||||
. ${CONF_DIR}/core
|
||||
|
||||
# Check downloaded packages, pkg repository.
|
||||
[ -f ${STATUS_FILE} ] && . ${STATUS_FILE}
|
||||
if [ X"${status_get_all}" != X"DONE" ]; then
|
||||
cd ${ROOTDIR}/pkgs/ && bash get_all.sh
|
||||
if [ X"$?" == X'0' ]; then
|
||||
cd ${ROOTDIR}
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
fi
|
||||
|
||||
# --------------------------------------
|
||||
# Check target platform and environment.
|
||||
# --------------------------------------
|
||||
# Required by OpenVZ:
|
||||
# Make sure others can read-write /dev/null and /dev/*random, so that it won't
|
||||
# interrupt iRedMail installation.
|
||||
chmod go+rx /dev/null /dev/*random &>/dev/null
|
||||
|
||||
check_env
|
||||
|
||||
# Define paths of some directories
|
||||
# Directory used to store mailboxes
|
||||
export STORAGE_MAILBOX_DIR="${STORAGE_MAILBOX_DIR:=${STORAGE_BASE_DIR}/${STORAGE_NODE}}"
|
||||
# Directory used to store sieve filters
|
||||
export SIEVE_DIR="${SIEVE_DIR:=${STORAGE_BASE_DIR}/sieve}"
|
||||
# Directory used to store daily SQL/LDAP backup files
|
||||
export BACKUP_DIR="${BACKUP_DIR:=${STORAGE_BASE_DIR}/backup}"
|
||||
# Directory used to store public IMAP folders
|
||||
export PUBLIC_MAILBOX_DIR="${PUBLIC_MAILBOX_DIR:=${STORAGE_BASE_DIR}/public}"
|
||||
|
||||
# Domain admin email address
|
||||
export DOMAIN_ADMIN_EMAIL="${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}"
|
||||
|
||||
# Import global variables in specified order.
|
||||
. ${CONF_DIR}/web_server
|
||||
. ${CONF_DIR}/openldap
|
||||
. ${CONF_DIR}/mysql
|
||||
. ${CONF_DIR}/postgresql
|
||||
. ${CONF_DIR}/dovecot
|
||||
. ${CONF_DIR}/postfix
|
||||
. ${CONF_DIR}/mlmmj
|
||||
. ${CONF_DIR}/amavisd
|
||||
. ${CONF_DIR}/iredapd
|
||||
. ${CONF_DIR}/memcached
|
||||
. ${CONF_DIR}/sogo
|
||||
. ${CONF_DIR}/clamav
|
||||
. ${CONF_DIR}/spamassassin
|
||||
. ${CONF_DIR}/roundcube
|
||||
. ${CONF_DIR}/netdata
|
||||
. ${CONF_DIR}/fail2ban
|
||||
. ${CONF_DIR}/iredadmin
|
||||
|
||||
# Import functions in specified order.
|
||||
if [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
# Install packages from freebsd ports tree.
|
||||
. ${FUNCTIONS_DIR}/packages_freebsd.sh
|
||||
else
|
||||
. ${FUNCTIONS_DIR}/packages.sh
|
||||
fi
|
||||
|
||||
. ${FUNCTIONS_DIR}/system_accounts.sh
|
||||
. ${FUNCTIONS_DIR}/web_server.sh
|
||||
. ${FUNCTIONS_DIR}/ldap_server.sh
|
||||
. ${FUNCTIONS_DIR}/mysql.sh
|
||||
. ${FUNCTIONS_DIR}/postgresql.sh
|
||||
|
||||
# Switch backend
|
||||
. ${FUNCTIONS_DIR}/backend.sh
|
||||
|
||||
. ${FUNCTIONS_DIR}/postfix.sh
|
||||
. ${FUNCTIONS_DIR}/dovecot.sh
|
||||
. ${FUNCTIONS_DIR}/mlmmj.sh
|
||||
. ${FUNCTIONS_DIR}/amavisd.sh
|
||||
. ${FUNCTIONS_DIR}/iredapd.sh
|
||||
. ${FUNCTIONS_DIR}/clamav.sh
|
||||
. ${FUNCTIONS_DIR}/spamassassin.sh
|
||||
. ${FUNCTIONS_DIR}/roundcubemail.sh
|
||||
. ${FUNCTIONS_DIR}/sogo.sh
|
||||
. ${FUNCTIONS_DIR}/fail2ban.sh
|
||||
. ${FUNCTIONS_DIR}/iredadmin.sh
|
||||
. ${FUNCTIONS_DIR}/netdata.sh
|
||||
. ${FUNCTIONS_DIR}/optional_components.sh
|
||||
. ${FUNCTIONS_DIR}/cleanup.sh
|
||||
|
||||
# ************************************************************************
|
||||
# *************************** Script Main ********************************
|
||||
# ************************************************************************
|
||||
|
||||
# Install all required packages.
|
||||
check_status_before_run install_all || (ECHO_ERROR "Package installation error, please check the output log.\n\n" && exit 255)
|
||||
|
||||
cat <<EOF
|
||||
|
||||
********************************************************************
|
||||
* Start iRedMail Configurations
|
||||
********************************************************************
|
||||
EOF
|
||||
|
||||
|
||||
check_status_before_run generate_ssl_keys
|
||||
check_status_before_run add_required_users
|
||||
check_status_before_run backend_install
|
||||
check_status_before_run postfix_setup
|
||||
check_status_before_run dovecot_setup
|
||||
check_status_before_run web_server_config
|
||||
check_status_before_run mlmmj_config
|
||||
check_status_before_run mlmmjadmin_config
|
||||
check_status_before_run clamav_config
|
||||
check_status_before_run amavisd_config
|
||||
check_status_before_run sa_config
|
||||
optional_components
|
||||
check_status_before_run cleanup
|
||||
@@ -0,0 +1,311 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
|
||||
# Purpose: Fetch all extra packages we need to build mail server.
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# This file is part of iRedMail, which is an open source mail server
|
||||
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
|
||||
#
|
||||
# iRedMail is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iRedMail is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
_ROOTDIR="$(pwd)"
|
||||
CONF_DIR="${_ROOTDIR}/../conf"
|
||||
|
||||
. ${CONF_DIR}/global
|
||||
. ${CONF_DIR}/core
|
||||
. ${CONF_DIR}/iredadmin
|
||||
|
||||
# Re-define @STATUS_FILE, so that iRedMail.sh can read it.
|
||||
#export STATUS_FILE="${_ROOTDIR}/../.status"
|
||||
|
||||
check_user root
|
||||
check_hostname
|
||||
check_runtime_dir
|
||||
|
||||
export PKG_DIR="${_ROOTDIR}/pkgs"
|
||||
export PKG_MISC_DIR="${_ROOTDIR}/misc"
|
||||
|
||||
# Verify downloaded source tarballs
|
||||
export SHASUM_CHECK_FILE='pkgs.sha256'
|
||||
# Linux/FreeBSD use 'shasum -c'
|
||||
export CMD_SHASUM_CHECK='sha256sum -c'
|
||||
|
||||
# Special package.
|
||||
# command: which.
|
||||
export BIN_WHICH='which'
|
||||
export PKG_WHICH='which'
|
||||
# command: wget.
|
||||
export BIN_WGET='wget'
|
||||
export PKG_WGET='wget'
|
||||
# command: perl
|
||||
export BIN_PERL='perl'
|
||||
export PKG_PERL='perl'
|
||||
|
||||
if [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
|
||||
export PKG_WHICH="debianutils"
|
||||
|
||||
export PKG_APT_TRANSPORT_HTTPS="apt-transport-https"
|
||||
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
|
||||
export SHASUM_CHECK_FILE='pkgs.freebsd.sha256'
|
||||
export CMD_SHASUM_CHECK='shasum -c'
|
||||
export CMD_SHASUM='sha256'
|
||||
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
export SHASUM_CHECK_FILE='pkgs.openbsd.sha256'
|
||||
export CMD_SHASUM_CHECK='cksum -c'
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'FREEBSD' -o X"${DISTRO}" == X'OPENBSD' ]; then
|
||||
MISCLIST="$(cat ${_ROOTDIR}/${SHASUM_CHECK_FILE} | awk -F'[(/)]' '{print $3}')"
|
||||
else
|
||||
MISCLIST="$(cat ${_ROOTDIR}/${SHASUM_CHECK_FILE} | awk -F'misc/' '{print $2}')"
|
||||
fi
|
||||
|
||||
prepare_dirs()
|
||||
{
|
||||
ECHO_DEBUG "Creating necessary directories ..."
|
||||
for i in ${PKG_DIR} ${PKG_MISC_DIR}; do
|
||||
[ -d "${i}" ] || mkdir -p "${i}"
|
||||
done
|
||||
}
|
||||
|
||||
fetch_misc()
|
||||
{
|
||||
# Fetch all misc packages.
|
||||
cd ${PKG_MISC_DIR}
|
||||
|
||||
misc_total=$(( $(echo ${MISCLIST} | wc -w | awk '{print $1}') ))
|
||||
misc_count=1
|
||||
|
||||
ECHO_INFO "Fetching source tarballs ..."
|
||||
|
||||
for i in ${MISCLIST}; do
|
||||
url="${IREDMAIL_MIRROR}/yum/misc/${i}"
|
||||
ECHO_INFO "+ ${misc_count} of ${misc_total}: ${url}"
|
||||
|
||||
${FETCH_CMD} "${url}"
|
||||
|
||||
misc_count=$((misc_count + 1))
|
||||
done
|
||||
}
|
||||
|
||||
verify_downloaded_packages()
|
||||
{
|
||||
ECHO_INFO "Validate downloaded source tarballs ..."
|
||||
|
||||
cd ${_ROOTDIR}
|
||||
if [ X"${DISTRO}" == X"FREEBSD" ]; then
|
||||
# Get package names.
|
||||
pkg_names="$(cat ${SHASUM_CHECK_FILE} | awk -F'(' '{print $2}' | awk -F')' '{print $1}')"
|
||||
|
||||
# Create a temp file to store shasum
|
||||
${CMD_SHASUM} ${pkg_names} > _tmp_pkg_names
|
||||
#cat _tmp_pkg_names
|
||||
|
||||
# Compare the shasum
|
||||
diff _tmp_pkg_names ${SHASUM_CHECK_FILE}
|
||||
RETVAL="$?"
|
||||
rm -f _tmp_pkg_names &>/dev/null
|
||||
else
|
||||
${CMD_SHASUM_CHECK} ${SHASUM_CHECK_FILE}
|
||||
RETVAL="$?"
|
||||
fi
|
||||
|
||||
if [ X"${RETVAL}" == X"0" ]; then
|
||||
echo -e "\t[ OK ]"
|
||||
echo 'export status_fetch_misc="DONE"' >> ${STATUS_FILE}
|
||||
echo 'export status_verify_downloaded_packages="DONE"' >> ${STATUS_FILE}
|
||||
else
|
||||
echo -e "\t[ FAILED ]"
|
||||
ECHO_ERROR "Package verification failed. Script exit ...\n"
|
||||
exit 255
|
||||
fi
|
||||
}
|
||||
|
||||
create_repo_rhel()
|
||||
{
|
||||
ECHO_INFO "Preparing yum repositories ..."
|
||||
|
||||
_required_pkgs="epel-release"
|
||||
if [ X"${DISTRO}" == X"RHEL" -a X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
# required by command `yum config-manager --enable <repo>`.
|
||||
_required_pkgs="${_required_pkgs} dnf-plugins-core"
|
||||
fi
|
||||
|
||||
eval ${install_pkg} ${_required_pkgs}
|
||||
|
||||
# Backup old repo file.
|
||||
backup_file ${LOCAL_REPO_FILE}
|
||||
|
||||
# Generate iRedMail repo file.
|
||||
cat > ${LOCAL_REPO_FILE} <<EOF
|
||||
[${LOCAL_REPO_NAME}]
|
||||
name=${LOCAL_REPO_NAME}
|
||||
baseurl=${IREDMAIL_MIRROR}/yum/rpms/\$releasever/
|
||||
enabled=1
|
||||
gpgcheck=0
|
||||
#exclude=postfix*
|
||||
priority=99
|
||||
module_hotfixes=1
|
||||
EOF
|
||||
|
||||
# RHEL/CentOS 8.
|
||||
if [ X"${DISTRO}" == X"RHEL" -a X"${DISTRO_VERSION}" == X'8' ]; then
|
||||
# repo PowerTools is required.
|
||||
for repo in AppStream PowerTools; do
|
||||
if [ ! -f "${YUM_REPOS_DIR}/CentOS-${repo}.repo" ]; then
|
||||
cp -f "${SAMPLE_DIR}/yum/CentOS-${repo}.repo" ${YUM_REPOS_DIR}/CentOS-${repo}.repo
|
||||
fi
|
||||
|
||||
# Although repo file exists, still need to make sure it is enabled.
|
||||
ECHO_INFO "Enable yum repo: ${repo}"
|
||||
yum config-manager --enable ${repo}
|
||||
done
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO_CODENAME}" == X'rhel' ]; then
|
||||
rm -f ${YUM_REPOS_DIR}/tmp_epel.repo
|
||||
fi
|
||||
|
||||
echo 'export status_create_repo_rhel="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
check_new_iredmail()
|
||||
{
|
||||
# Check new version and track basic information,
|
||||
# Used to help iRedMail team understand which Linux/BSD distribution
|
||||
# we should take more care of.
|
||||
#
|
||||
# - PROG_VERSION: iRedMail version number
|
||||
# - OS_ARCH: arch (i386, x86_64)
|
||||
# - DISTRO: OS distribution
|
||||
# - DISTRO_VERSION: distribution release number
|
||||
# - DISTRO_CODENAME: code name
|
||||
ECHO_INFO "Checking new version of iRedMail ..."
|
||||
${FETCH_CMD} "https://lic.iredmail.org/check_version/iredmail_os?iredmail_version=${PROG_VERSION}&arch=${OS_ARCH}&distro=${DISTRO}&distro_version=${DISTRO_VERSION}&distro_code_name=${DISTRO_CODENAME}" &>/dev/null
|
||||
|
||||
UPDATE_AVAILABLE='NO'
|
||||
if ls iredmail_os* &>/dev/null; then
|
||||
info="$(cat iredmail_os*)"
|
||||
if [ X"${info}" == X'UPDATE_AVAILABLE' ]; then
|
||||
UPDATE_AVAILABLE='YES'
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f iredmail_os* &>/dev/null
|
||||
|
||||
if [ X"${UPDATE_AVAILABLE}" == X'YES' ]; then
|
||||
echo ''
|
||||
ECHO_ERROR "Your iRedMail version (${PROG_VERSION}) is out of date, please"
|
||||
ECHO_ERROR "download the latest version and try again:"
|
||||
ECHO_ERROR "http://www.iredmail.org/download.html"
|
||||
echo ''
|
||||
exit 255
|
||||
fi
|
||||
|
||||
echo 'export status_check_new_iredmail="DONE"' >> ${STATUS_FILE}
|
||||
}
|
||||
|
||||
echo_end_msg()
|
||||
{
|
||||
if [ X"$(basename $0)" != X'get_all.sh' ]; then
|
||||
cat <<EOF
|
||||
********************************************************
|
||||
* All tasks had been finished successfully. Next step:
|
||||
*
|
||||
* # cd ..
|
||||
* # bash ${PROG_NAME}.sh
|
||||
*
|
||||
********************************************************
|
||||
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -e ${STATUS_FILE} ]; then
|
||||
. ${STATUS_FILE}
|
||||
else
|
||||
echo '' > ${STATUS_FILE}
|
||||
fi
|
||||
|
||||
# Check latest version
|
||||
[ X"${CHECK_NEW_IREDMAIL}" != X'NO' ] && \
|
||||
check_status_before_run check_new_iredmail
|
||||
|
||||
prepare_dirs
|
||||
|
||||
if [ X"${DISTRO}" == X"RHEL" ]; then
|
||||
# Check required commands, install related package if command doesn't exist.
|
||||
check_pkg ${BIN_WHICH} ${PKG_WHICH}
|
||||
check_pkg ${BIN_WGET} ${PKG_WGET}
|
||||
check_pkg ${BIN_PERL} ${PKG_PERL}
|
||||
|
||||
# Create yum repository.
|
||||
check_status_before_run create_repo_rhel
|
||||
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
# Some required packages are in `universe` and `multiverse` apt repos.
|
||||
[ -x /usr/bin/apt-add-repository ] || ${APTGET} install -y software-properties-common
|
||||
|
||||
for repo in multiverse universe; do
|
||||
if [ X"${UBUNTU_MIRROR_SITE}" != X'' ]; then
|
||||
apt-add-repository -n "deb ${UBUNTU_MIRROR_SITE} ${DISTRO_CODENAME} $repo"
|
||||
apt-add-repository -n "deb ${UBUNTU_MIRROR_SITE} ${DISTRO_CODENAME}-security $repo"
|
||||
apt-add-repository -n "deb ${UBUNTU_MIRROR_SITE} ${DISTRO_CODENAME}-updates $repo"
|
||||
else
|
||||
apt-add-repository -n $repo
|
||||
fi
|
||||
done
|
||||
apt-get update
|
||||
fi
|
||||
|
||||
_missing_pkgs=''
|
||||
|
||||
if [ ! -e /usr/sbin/update-ca-certificates ]; then
|
||||
_missing_pkgs="${_missing_pkgs} ca-certificates"
|
||||
fi
|
||||
|
||||
if [ ! -e /usr/lib/apt/methods/https ]; then
|
||||
_missing_pkgs="${_missing_pkgs} ${PKG_APT_TRANSPORT_HTTPS}"
|
||||
fi
|
||||
|
||||
# dirmngr is required by apt-key
|
||||
if [ ! -e /usr/bin/dirmngr ]; then
|
||||
_missing_pkgs="${_missing_pkgs} dirmngr"
|
||||
fi
|
||||
|
||||
if [ X"${DISTRO}" == X'UBUNTU' ]; then
|
||||
if [ ! -e /usr/bin/apt-add-repository ]; then
|
||||
_missing_pkgs="${_missing_pkgs} software-properties-common"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ X"${_missing_pkgs}" != X'' ]; then
|
||||
eval ${install_pkg} ${_missing_pkgs}
|
||||
fi
|
||||
|
||||
# Force update.
|
||||
ECHO_INFO "apt update ..."
|
||||
${APTGET} update
|
||||
|
||||
check_pkg ${BIN_PERL} ${PKG_PERL}
|
||||
check_pkg ${BIN_WGET} ${PKG_WGET}
|
||||
fi
|
||||
|
||||
check_status_before_run fetch_misc && \
|
||||
check_status_before_run verify_downloaded_packages && \
|
||||
check_pkg ${BIN_DIALOG} ${PKG_DIALOG} && \
|
||||
echo_end_msg && \
|
||||
echo 'export status_get_all="DONE"' >> ${STATUS_FILE}
|
||||
@@ -0,0 +1,3 @@
|
||||
SHA256 (misc/iRedAdmin-1.0.tar.bz2) = 84b8eea9472aac3ab6d4cfc914a0277b484f99ec1ed32914b144449c218d3da1
|
||||
SHA256 (misc/mlmmjadmin-3.0.tar.gz) = 8f82d0c77ecbe9c0a37530e8228fb6daa994bd41ca4f8012d22c9ced1ae9a842
|
||||
SHA256 (misc/iRedAPD-4.3.tar.gz) = b1a8552337a175fd8fe7bc771e752af7393bc72640189e9f55a09611a5280646
|
||||
@@ -0,0 +1,6 @@
|
||||
SHA256 (misc/uwsgi-2.0.18.tar.gz) = 4972ac538800fb2d421027f49b4a1869b66048839507ccf0aa2fda792d99f583
|
||||
SHA256 (misc/iRedAdmin-1.0.tar.bz2) = 84b8eea9472aac3ab6d4cfc914a0277b484f99ec1ed32914b144449c218d3da1
|
||||
SHA256 (misc/mlmmjadmin-3.0.tar.gz) = 8f82d0c77ecbe9c0a37530e8228fb6daa994bd41ca4f8012d22c9ced1ae9a842
|
||||
SHA256 (misc/iRedAPD-4.3.tar.gz) = b1a8552337a175fd8fe7bc771e752af7393bc72640189e9f55a09611a5280646
|
||||
SHA256 (misc/roundcubemail-1.4.7-complete.tar.gz) = 26d85d27ff7ef491de09168a27df74a5574b7dd4127e6c2822c90a108c6aacc9
|
||||
SHA256 (misc/fail2ban-0.11.1.tar.gz) = 71d2a52b66bb0f87ac3812246bdd3819ec561913cd44afd39130a342f043aa6d
|
||||
@@ -0,0 +1,6 @@
|
||||
84b8eea9472aac3ab6d4cfc914a0277b484f99ec1ed32914b144449c218d3da1 misc/iRedAdmin-1.0.tar.bz2
|
||||
8f82d0c77ecbe9c0a37530e8228fb6daa994bd41ca4f8012d22c9ced1ae9a842 misc/mlmmjadmin-3.0.tar.gz
|
||||
b1a8552337a175fd8fe7bc771e752af7393bc72640189e9f55a09611a5280646 misc/iRedAPD-4.3.tar.gz
|
||||
ad395acb01a28197c1c8275d4e9cf73022f66c55e8026408a9e50ce9da9dee96 misc/netdata-v1.23.1.gz.run
|
||||
26d85d27ff7ef491de09168a27df74a5574b7dd4127e6c2822c90a108c6aacc9 misc/roundcubemail-1.4.7-complete.tar.gz
|
||||
550ed5fb18c7626c578cc2119fd45a9a898b7815fc81a4ac85ae2ed383a0ec5f misc/webpy-0.51.tar.gz
|
||||
@@ -0,0 +1,663 @@
|
||||
use strict;
|
||||
|
||||
# controls running of anti-virus/spam code: 0 -> enabled, 1 -> disabled.
|
||||
@bypass_virus_checks_maps = (0);
|
||||
@bypass_spam_checks_maps = (0);
|
||||
# $bypass_decode_parts = 1; # controls running of decoders&dearchivers
|
||||
|
||||
$daemon_user = 'PH_SYS_USER_AMAVISD';
|
||||
$daemon_group = 'PH_SYS_GROUP_AMAVISD';
|
||||
|
||||
# Set hostname.
|
||||
$myhostname = 'PH_HOSTNAME';
|
||||
$mydomain = $myhostname;
|
||||
$localhost_name = $myhostname;
|
||||
|
||||
#
|
||||
# NOTE: $MYHOME/{tmp,var,db} must be created manually
|
||||
#
|
||||
$MYHOME = 'PH_AMAVISD_SPOOL_DIR';
|
||||
$TEMPBASE = 'PH_AMAVISD_TEMP_DIR'; # working directory, needs to exist, -T
|
||||
$ENV{TMPDIR} = $TEMPBASE; # environment variable TMPDIR, used by SA, etc.
|
||||
$db_home = 'PH_AMAVISD_DB_DIR'; # dir for bdb nanny/cache/snmp databases, -D
|
||||
$QUARANTINEDIR = 'PH_AMAVISD_QUARANTINE_DIR'; # -Q
|
||||
$quarantine_subdir_levels = 2; # add level of subdirs to disperse quarantine
|
||||
# $release_format = 'resend'; # 'attach', 'plain', 'resend'
|
||||
# $report_format = 'arf'; # 'attach', 'plain', 'resend', 'arf'
|
||||
# $daemon_chroot_dir = $MYHOME; # chroot directory or undef, -R
|
||||
# $helpers_home = "$MYHOME/var"; # working directory for SpamAssassin, -S
|
||||
|
||||
$lock_file = 'PH_AMAVISD_LOCK_FILE'; # -L
|
||||
$pid_file = 'PH_AMAVISD_PID_FILE'; # -P
|
||||
|
||||
@local_domains_maps = 1;
|
||||
@mynetworks = qw( 127.0.0.0/8 [::1] PH_LOCAL_ADDRESS );
|
||||
|
||||
# Socket file, used by amavisd-release or amavis-milter.
|
||||
$unix_socketname = 'PH_AMAVISD_SOCKET_FILE';
|
||||
|
||||
#
|
||||
# BDB
|
||||
#
|
||||
$enable_db = 0; # enable use of BerkeleyDB/libdb (SNMP and nanny)
|
||||
$nanny_details_level = 2; # nanny verbosity: 1: traditional, 2: detailed
|
||||
|
||||
$inet_socket_port = [PH_AMAVISD_SMTP_PORT, PH_AMAVISD_ORIGINATING_PORT, PH_AMAVISD_MLMMJ_PORT, PH_AMAVISD_QUARANTINE_PORT];
|
||||
|
||||
$policy_bank{'MYNETS'} = { # mail originating from @mynetworks
|
||||
originating => 1, # is true in MYNETS by default, but let's make it explicit
|
||||
os_fingerprint_method => undef, # don't query p0f for internal clients
|
||||
allow_disclaimers => 1, # enables disclaimer insertion if available
|
||||
enable_dkim_signing => 1,
|
||||
};
|
||||
|
||||
# Postfix will re-route mail from authenticated users to this port.
|
||||
$interface_policy{'PH_AMAVISD_ORIGINATING_PORT'} = 'ORIGINATING';
|
||||
$policy_bank{'ORIGINATING'} = {
|
||||
originating => 1, # declare that mail was submitted by our smtp client
|
||||
allow_disclaimers => 1, # enables disclaimer insertion if available
|
||||
enable_dkim_signing => 1,
|
||||
|
||||
# notify administrator of locally originating malware
|
||||
spam_admin_maps => ["root\@$mydomain"],
|
||||
# notify administrator of locally originating malware
|
||||
virus_admin_maps => ["root\@$mydomain"],
|
||||
spam_admin_maps => ["root\@$mydomain"],
|
||||
bad_header_admin_maps => ["root\@$mydomain"],
|
||||
banned_admin_maps => ["root\@$mydomain"],
|
||||
warnbadhsender => 0,
|
||||
warnbannedsender => 0,
|
||||
|
||||
# force MTA conversion to 7-bit (e.g. before DKIM signing)
|
||||
smtpd_discard_ehlo_keywords => ['8BITMIME'],
|
||||
terminate_dsn_on_notify_success => 0, # don't remove NOTIFY=SUCCESS option
|
||||
|
||||
# Bypass checks
|
||||
#bypass_spam_checks_maps => [1], # don't check spam
|
||||
#bypass_virus_checks_maps => [1], # don't check virus
|
||||
#bypass_banned_checks_maps => [1], # don't check banned file names and types
|
||||
#bypass_header_checks_maps => [1], # don't check bad header
|
||||
};
|
||||
|
||||
$interface_policy{'PH_AMAVISD_MLMMJ_PORT'} = 'MLMMJ';
|
||||
$policy_bank{'MLMMJ'} = {
|
||||
originating => 1, # declare that mail was submitted by our smtp client
|
||||
allow_disclaimers => 0, # we use 'mlmmj-amime-receive' program to handle disclaimer/footer
|
||||
enable_dkim_signing => 1, # enable DKIM signing for outbound
|
||||
virus_admin_maps => ["root\@$mydomain"],
|
||||
spam_admin_maps => ["root\@$mydomain"],
|
||||
smtpd_discard_ehlo_keywords => ['8BITMIME'],
|
||||
terminate_dsn_on_notify_success => 0, # don't remove NOTIFY=SUCCESS option
|
||||
# re-inject processed email to Postfix, with address mapping enabled.
|
||||
forward_method => 'smtp:[PH_LOCAL_ADDRESS]:PH_POSTFIX_MLMMJ_REINJECT_PORT',
|
||||
# Amavisd performs the checks for email sent to mailing list, so no need to
|
||||
# check again for outbound.
|
||||
bypass_spam_checks_maps => [1], # don't check spam
|
||||
bypass_virus_checks_maps => [1], # don't check virus
|
||||
bypass_banned_checks_maps => [1], # don't check banned file names and types
|
||||
bypass_header_checks_maps => [1], # don't check bad header
|
||||
};
|
||||
|
||||
$interface_policy{'SOCK'} = 'AM.PDP-SOCK'; # only applies with $unix_socketname
|
||||
|
||||
# Use with amavis-release over a socket or with Petr Rehor's amavis-milter.c
|
||||
# (with amavis-milter.c from this package or old amavis.c client use 'AM.CL'):
|
||||
$policy_bank{'AM.PDP-SOCK'} = {
|
||||
protocol => 'AM.PDP',
|
||||
auth_required_release => 0, # do not require secret_id for amavisd-release
|
||||
};
|
||||
|
||||
$sa_tag_level_deflt = 2.0; # add spam info headers if at, or above that level
|
||||
$sa_tag2_level_deflt = 6.2; # add 'spam detected' headers at that level
|
||||
$sa_kill_level_deflt = 6.9; # triggers spam evasive actions (e.g. blocks mail)
|
||||
$sa_dsn_cutoff_level = 10; # spam level beyond which a DSN is not sent
|
||||
$sa_crediblefrom_dsn_cutoff_level = 18; # likewise, but for a likely valid From
|
||||
#$sa_quarantine_cutoff_level = 25; # spam level beyond which quarantine is off
|
||||
|
||||
$sa_mail_body_size_limit = 400*1024; # don't waste time on SA if mail is larger
|
||||
$sa_local_tests_only = 0; # only tests which do not require internet access?
|
||||
|
||||
$virus_admin = undef; # notifications recip.
|
||||
|
||||
$mailfrom_notify_admin = undef; # notifications sender
|
||||
$mailfrom_notify_recip = undef; # notifications sender
|
||||
$mailfrom_notify_spamadmin = undef; # notifications sender
|
||||
$mailfrom_to_quarantine = ''; # null return path; uses original sender if undef
|
||||
|
||||
@addr_extension_virus_maps = ('virus');
|
||||
@addr_extension_banned_maps = ('banned');
|
||||
@addr_extension_spam_maps = ('spam');
|
||||
@addr_extension_bad_header_maps = ('badh');
|
||||
# $recipient_delimiter = '+'; # undef disables address extensions altogether
|
||||
# when enabling addr extensions do also Postfix/main.cf: recipient_delimiter=+
|
||||
|
||||
$path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin';
|
||||
# $dspam = 'dspam';
|
||||
|
||||
$MAXLEVELS = 14;
|
||||
$MAXFILES = 3000;
|
||||
$MIN_EXPANSION_QUOTA = 100*1024; # bytes (default undef, not enforced)
|
||||
$MAX_EXPANSION_QUOTA = 500*1024*1024; # bytes (default undef, not enforced)
|
||||
|
||||
# Prepend '[SPAM] ' to subject of spam message.
|
||||
$sa_spam_modifies_subj = 1;
|
||||
$sa_spam_subject_tag = '[SPAM] ';
|
||||
|
||||
$defang_virus = 1; # MIME-wrap passed infected mail
|
||||
$defang_banned = 0; # MIME-wrap passed mail containing banned name
|
||||
# for defanging bad headers only turn on certain minor contents categories:
|
||||
$defang_by_ccat{CC_BADH.",3"} = 1; # NUL or CR character in header
|
||||
$defang_by_ccat{CC_BADH.",5"} = 1; # header line longer than 998 characters
|
||||
$defang_by_ccat{CC_BADH.",6"} = 1; # header field syntax error
|
||||
|
||||
@keep_decoded_original_maps = (new_RE(
|
||||
# let virus scanner (clamav) see full original message (can be slow)
|
||||
# this setting is required if we're going to use third-party clamav
|
||||
# signatures. for example, Sanesecurity signatures.
|
||||
# FYI: http://sanesecurity.com/support/signature-testing/
|
||||
#qr'^MAIL$',
|
||||
|
||||
qr'^MAIL-UNDECIPHERABLE$', # same as ^MAIL$ if mail is undecipherable
|
||||
qr'^(ASCII(?! cpio)|text|uuencoded|xxencoded|binhex)'i,
|
||||
#qr'^Zip archive data', # don't trust Archive::Zip
|
||||
));
|
||||
|
||||
$banned_filename_re = new_RE(
|
||||
|
||||
### BLOCKED ANYWHERE
|
||||
# qr'^UNDECIPHERABLE$', # is or contains any undecipherable components
|
||||
qr'^\.(exe-ms|dll)$', # banned file(1) types, rudimentary
|
||||
# qr'^\.(exe|lha|cab|dll)$', # banned file(1) types
|
||||
|
||||
### BLOCK THE FOLLOWING, EXCEPT WITHIN UNIX ARCHIVES:
|
||||
# [ qr'^\.(gz|bz2)$' => 0 ], # allow any in gzip or bzip2
|
||||
[ qr'^\.(rpm|cpio|tar)$' => 0 ], # allow any in Unix-type archives
|
||||
|
||||
qr'.\.(pif|scr)$'i, # banned extensions - rudimentary
|
||||
# qr'^\.zip$', # block zip type
|
||||
|
||||
### BLOCK THE FOLLOWING, EXCEPT WITHIN ARCHIVES:
|
||||
# [ qr'^\.(zip|rar|arc|arj|zoo)$'=> 0 ], # allow any within these archives
|
||||
|
||||
qr'^application/x-msdownload$'i, # block these MIME types
|
||||
qr'^application/x-msdos-program$'i,
|
||||
qr'^application/hta$'i,
|
||||
|
||||
# qr'^message/partial$'i, # rfc2046 MIME type
|
||||
# qr'^message/external-body$'i, # rfc2046 MIME type
|
||||
|
||||
# qr'^(application/x-msmetafile|image/x-wmf)$'i, # Windows Metafile MIME type
|
||||
# qr'^\.wmf$', # Windows Metafile file(1) type
|
||||
|
||||
# block certain double extensions in filenames
|
||||
qr'^(?!cid:).*\.[^./]*[A-Za-z][^./]*\.\s*(exe|vbs|pif|scr|bat|cmd|com|cpl|dll)[.\s]*$'i,
|
||||
|
||||
# qr'\{[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}\}?'i, # Class ID CLSID, strict
|
||||
# qr'\{[0-9a-z]{4,}(-[0-9a-z]{4,}){0,7}\}?'i, # Class ID extension CLSID, loose
|
||||
|
||||
qr'.\.(exe|vbs|pif|scr|cpl)$'i, # banned extension - basic
|
||||
# qr'.\.(exe|vbs|pif|scr|cpl|bat|cmd|com)$'i, # banned extension - basic+cmd
|
||||
# qr'.\.(ade|adp|app|bas|bat|chm|cmd|com|cpl|crt|emf|exe|fxp|grp|hlp|hta|
|
||||
# inf|ini|ins|isp|js|jse|lib|lnk|mda|mdb|mde|mdt|mdw|mdz|msc|msi|
|
||||
# msp|mst|ocx|ops|pcd|pif|prg|reg|scr|sct|shb|shs|sys|vb|vbe|vbs|vxd|
|
||||
# wmf|wsc|wsf|wsh)$'ix, # banned extensions - long
|
||||
# qr'.\.(asd|asf|asx|url|vcs|wmd|wmz)$'i, # consider also
|
||||
# qr'.\.(ani|cur|ico)$'i, # banned cursors and icons filename
|
||||
# qr'^\.ani$', # banned animated cursor file(1) type
|
||||
# qr'.\.(mim|b64|bhx|hqx|xxe|uu|uue)$'i, # banned extension - WinZip vulnerab.
|
||||
);
|
||||
# See http://support.microsoft.com/default.aspx?scid=kb;EN-US;q262631
|
||||
# and http://www.cknow.com/vtutor/vtextensions.htm
|
||||
|
||||
|
||||
# ENVELOPE SENDER SOFT-WHITELISTING / SOFT-BLACKLISTING
|
||||
|
||||
@score_sender_maps = ({ # a by-recipient hash lookup table,
|
||||
# results from all matching recipient tables are summed
|
||||
|
||||
# ## per-recipient personal tables (NOTE: positive: black, negative: white)
|
||||
# 'user1@example.com' => [{'bla-mobile.press@example.com' => 10.0}],
|
||||
# 'user3@example.com' => [{'.ebay.com' => -3.0}],
|
||||
# 'user4@example.com' => [{'cleargreen@cleargreen.com' => -7.0,
|
||||
# '.cleargreen.com' => -5.0}],
|
||||
|
||||
## site-wide opinions about senders (the '.' matches any recipient)
|
||||
'.' => [ # the _first_ matching sender determines the score boost
|
||||
|
||||
new_RE( # regexp-type lookup table, just happens to be all soft-blacklist
|
||||
[qr'^(bulkmail|offers|cheapbenefits|earnmoney|foryou)@'i => 5.0],
|
||||
[qr'^(greatcasino|investments|lose_weight_today|market\.alert)@'i=> 5.0],
|
||||
[qr'^(money2you|MyGreenCard|new\.tld\.registry|opt-out|opt-in)@'i=> 5.0],
|
||||
[qr'^(optin|saveonlsmoking2002k|specialoffer|specialoffers)@'i => 5.0],
|
||||
[qr'^(stockalert|stopsnoring|wantsome|workathome|yesitsfree)@'i => 5.0],
|
||||
[qr'^(your_friend|greatoffers)@'i => 5.0],
|
||||
[qr'^(inkjetplanet|marketopt|MakeMoney)\d*@'i => 5.0],
|
||||
),
|
||||
|
||||
#read_hash("/var/amavis/sender_scores_sitewide"),
|
||||
|
||||
{ # a hash-type lookup table (associative array)
|
||||
'nobody@cert.org' => -3.0,
|
||||
'cert-advisory@us-cert.gov' => -3.0,
|
||||
'owner-alert@iss.net' => -3.0,
|
||||
'slashdot@slashdot.org' => -3.0,
|
||||
'securityfocus.com' => -3.0,
|
||||
'ntbugtraq@listserv.ntbugtraq.com' => -3.0,
|
||||
'security-alerts@linuxsecurity.com' => -3.0,
|
||||
'mailman-announce-admin@python.org' => -3.0,
|
||||
'amavis-user-admin@lists.sourceforge.net'=> -3.0,
|
||||
'amavis-user-bounces@lists.sourceforge.net' => -3.0,
|
||||
'spamassassin.apache.org' => -3.0,
|
||||
'notification-return@lists.sophos.com' => -3.0,
|
||||
'owner-postfix-users@postfix.org' => -3.0,
|
||||
'owner-postfix-announce@postfix.org' => -3.0,
|
||||
'owner-sendmail-announce@lists.sendmail.org' => -3.0,
|
||||
'sendmail-announce-request@lists.sendmail.org' => -3.0,
|
||||
'donotreply@sendmail.org' => -3.0,
|
||||
'ca+envelope@sendmail.org' => -3.0,
|
||||
'noreply@freshmeat.net' => -3.0,
|
||||
'owner-technews@postel.acm.org' => -3.0,
|
||||
'ietf-123-owner@loki.ietf.org' => -3.0,
|
||||
'cvs-commits-list-admin@gnome.org' => -3.0,
|
||||
'rt-users-admin@lists.fsck.com' => -3.0,
|
||||
'clp-request@comp.nus.edu.sg' => -3.0,
|
||||
'surveys-errors@lists.nua.ie' => -3.0,
|
||||
'emailnews@genomeweb.com' => -5.0,
|
||||
'yahoo-dev-null@yahoo-inc.com' => -3.0,
|
||||
'returns.groups.yahoo.com' => -3.0,
|
||||
'clusternews@linuxnetworx.com' => -3.0,
|
||||
lc('lvs-users-admin@LinuxVirtualServer.org') => -3.0,
|
||||
lc('owner-textbreakingnews@CNNIMAIL12.CNN.COM') => -5.0,
|
||||
|
||||
# soft-blacklisting (positive score)
|
||||
'sender@example.net' => 3.0,
|
||||
'.example.net' => 1.0,
|
||||
|
||||
},
|
||||
], # end of site-wide tables
|
||||
});
|
||||
|
||||
|
||||
@decoders = (
|
||||
['mail', \&do_mime_decode],
|
||||
# [[qw(asc uue hqx ync)], \&do_ascii], # not safe
|
||||
['F', \&do_uncompress, ['unfreeze', 'freeze -d', 'melt', 'fcat'] ],
|
||||
['Z', \&do_uncompress, ['uncompress', 'gzip -d', 'zcat'] ],
|
||||
['gz', \&do_uncompress, 'gzip -d'],
|
||||
['gz', \&do_gunzip],
|
||||
['bz2', \&do_uncompress, 'bzip2 -d'],
|
||||
['xz', \&do_uncompress,
|
||||
['xzdec', 'xz -dc', 'unxz -c', 'xzcat'] ],
|
||||
['lzma', \&do_uncompress,
|
||||
['lzmadec', 'xz -dc --format=lzma',
|
||||
'lzma -dc', 'unlzma -c', 'lzcat', 'lzmadec'] ],
|
||||
['lrz', \&do_uncompress,
|
||||
['lrzip -q -k -d -o -', 'lrzcat -q -k'] ],
|
||||
['lzo', \&do_uncompress, 'lzop -d'],
|
||||
['lz4', \&do_uncompress, ['lz4c -d'] ],
|
||||
['rpm', \&do_uncompress, ['rpm2cpio.pl', 'rpm2cpio'] ],
|
||||
[['cpio','tar'], \&do_pax_cpio, ['pax', 'gcpio', 'cpio'] ],
|
||||
# ['/usr/local/heirloom/usr/5bin/pax', 'pax', 'gcpio', 'cpio']
|
||||
['deb', \&do_ar, 'ar'],
|
||||
# ['a', \&do_ar, 'ar'], # unpacking .a seems an overkill
|
||||
['rar', \&do_unrar, ['unrar', 'rar'] ],
|
||||
['arj', \&do_unarj, ['unarj', 'arj'] ],
|
||||
['arc', \&do_arc, ['nomarch', 'arc'] ],
|
||||
['zoo', \&do_zoo, ['zoo', 'unzoo'] ],
|
||||
# ['doc', \&do_ole, 'ripole'], # no ripole package so far
|
||||
['cab', \&do_cabextract, 'cabextract'],
|
||||
# ['tnef', \&do_tnef_ext, 'tnef'], # use internal do_tnef() instead
|
||||
['tnef', \&do_tnef],
|
||||
# ['lha', \&do_lha, 'lha'], # not safe, use 7z instead
|
||||
# ['sit', \&do_unstuff, 'unstuff'], # not safe
|
||||
[['zip','kmz'], \&do_7zip, ['7za', '7z'] ],
|
||||
[['zip','kmz'], \&do_unzip],
|
||||
['7z', \&do_7zip, ['7zr', '7za', '7z'] ],
|
||||
[[qw(gz bz2 Z tar)],
|
||||
\&do_7zip, ['7za', '7z'] ],
|
||||
[[qw(xz lzma jar cpio arj rar swf lha iso cab deb rpm)],
|
||||
\&do_7zip, '7z' ],
|
||||
['exe', \&do_executable, ['unrar','rar'], 'lha', ['unarj','arj'] ],
|
||||
);
|
||||
|
||||
$notify_method = 'smtp:[PH_LOCAL_ADDRESS]:PH_POSTFIX_MAIL_REINJECT_PORT';
|
||||
$forward_method = 'smtp:[PH_LOCAL_ADDRESS]:PH_POSTFIX_MAIL_REINJECT_PORT';
|
||||
|
||||
# Mark Spam/Virus with third-party clamav signatures: SaneSecurity.
|
||||
# *) The order matters, first match wins. Set to 'undef' to keep as infected
|
||||
# *) Anything declared as undefined will be marked as a virus
|
||||
@virus_name_to_spam_score_maps =(new_RE(
|
||||
# SaneSecurity + Foxhole
|
||||
[ qr'^Sanesecurity\.(Malware|Badmacro|Foxhole|Rogue|Trojan)\.' => undef ],
|
||||
[ qr'^Sanesecurity\.MalwareHash\.' => undef ],
|
||||
[ qr'^Sanesecurity.TestSig_' => undef ],
|
||||
[ qr'^Sanesecurity\.' => 0.1 ],
|
||||
|
||||
# winnow
|
||||
[ qr'^winnow\.(Exploit|Trojan|malware)\.' => undef ],
|
||||
[ qr'^winnow\.(botnet|compromised|trojan)' => undef ],
|
||||
[ qr'^winnow\.(exe|ms|JS)\.' => undef ],
|
||||
[ qr'^winnow\.phish\.' => 3.0 ],
|
||||
[ qr'^winnow\.' => 0.1 ],
|
||||
|
||||
# bofhland
|
||||
[ qr'^Bofhland\.Malware\.' => undef ],
|
||||
[ qr'^BofhlandMWFile' => undef ],
|
||||
[ qr'^Bofhland\.Phishing\.' => 3.0 ],
|
||||
[ qr'^Bofhland\.' => 0.1 ],
|
||||
|
||||
# porcupine.ndb
|
||||
[ qr'^Porcupine\.(Malware|Trojan)\.' => undef ],
|
||||
[ qr'^Porcupine\.(Junk|Spammer)\.' => 3.0 ],
|
||||
[ qr'^Porcupine\.Phishing\.' => 3.0 ],
|
||||
[ qr'^Porcupine\.' => 0.01 ],
|
||||
|
||||
# phishtank.ndb
|
||||
[ qr'^PhishTank\.Phishing\.' => 3.0 ],
|
||||
|
||||
# SecuriteInfo
|
||||
[ qr'^SecuriteInfo\.com\.Spammer\.' => 3.0 ],
|
||||
|
||||
# Others
|
||||
[ qr'^Structured\.(SSN|CreditCardNumber)\b' => 0.1 ],
|
||||
[ qr'^(Heuristics\.)?Phishing\.' => 0.1 ],
|
||||
[ qr'^(Email|HTML)\.Phishing\.(?!.*Sanesecurity)' => 0.1 ],
|
||||
[ qr'^Email\.Spam\.Bounce(\.[^., ]*)*\.Sanesecurity\.' => 0 ],
|
||||
[ qr'^Email\.Spammail\b' => 0.1 ],
|
||||
[ qr'^MSRBL-(Images|SPAM)\b' => 0.1 ],
|
||||
[ qr'^VX\.Honeypot-SecuriteInfo\.com\.Joke' => 0.1 ],
|
||||
[ qr'^VX\.not-virus_(Hoax|Joke)\..*-SecuriteInfo\.com(\.|\z)' => 0.1 ],
|
||||
[ qr'^Email\.Spam.*-SecuriteInfo\.com(\.|\z)' => 0.1 ],
|
||||
[ qr'^Safebrowsing\.' => 0.1 ],
|
||||
[ qr'^INetMsg\.SpamDomain' => 0.1 ],
|
||||
[ qr'^Doppelstern\.(Spam|Scam|Phishing|Junk|Lott|Loan)'=> 0.1 ],
|
||||
[ qr'^ScamNailer\.' => 0.1 ],
|
||||
[ qr'^HTML/Bankish' => 0.1 ],
|
||||
[ qr'(-)?SecuriteInfo\.com(\.|\z)' => undef ],
|
||||
[ qr'^MBL_NA\.UNOFFICIAL' => 0.1 ],
|
||||
[ qr'^MBL_' => undef ],
|
||||
));
|
||||
|
||||
@av_scanners = (
|
||||
['clamav-socket',
|
||||
\&ask_daemon, ["CONTSCAN {}\n", 'PH_CLAMD_LOCAL_SOCKET'],
|
||||
qr/\bOK$/, qr/\bFOUND$/,
|
||||
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
|
||||
);
|
||||
|
||||
@av_scanners_backup = (
|
||||
['clamav-clamscan', 'clamscan',
|
||||
"--stdout --disable-summary -r --tempdir=$TEMPBASE {}", [0], [1],
|
||||
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
|
||||
);
|
||||
|
||||
#
|
||||
# Port used to release quarantined mails.
|
||||
#
|
||||
$interface_policy{'PH_AMAVISD_QUARANTINE_PORT'} = 'AM.PDP-INET';
|
||||
$policy_bank{'AM.PDP-INET'} = {
|
||||
protocol => 'AM.PDP', # select Amavis policy delegation protocol
|
||||
auth_required_release => 1, # 0 - don't require secret_id for amavisd-release
|
||||
#log_level => 4,
|
||||
#always_bcc_by_ccat => {CC_CLEAN, 'admin@example.com'},
|
||||
};
|
||||
|
||||
#########################
|
||||
# Default action applied to detected spam/virus/banned/bad-header, and how to
|
||||
# quarantine them
|
||||
#
|
||||
# Available actions:
|
||||
#
|
||||
# - D_PASS: Mail will pass to recipients, regardless of bad contents.
|
||||
# If a quarantine is configured, a copy of the mail will go there.
|
||||
# Note that including a recipient in a @*_lovers_maps is
|
||||
# functionally equivalent to setting '*_destiny = D_PASS;'
|
||||
# for that recipient.
|
||||
#
|
||||
# - D_BOUNCE: Mail will not be delivered to its recipients. A non-delivery
|
||||
# notification (bounce) will be created and sent to the sender.
|
||||
#
|
||||
# - D_REJECT: Mail will not be delivered to its recipients. Amavisd will
|
||||
# send the typical 55x reject response to the upstream MTA and
|
||||
# that MTA may create a reject notice (bounce) and return it to
|
||||
# the sender.
|
||||
# This notice is not as informative as the one created using
|
||||
# D_BOUNCE, so usually D_BOUNCE is preferred over D_REJECT.
|
||||
# If a quarantine is configured, a copy of the mail will go
|
||||
# there, if not mail message will be lost, but the sender should
|
||||
# be notified their message was rejected.
|
||||
#
|
||||
# - D_DISCARD: Mail will not be delivered to its recipients and the sender
|
||||
# normally will NOT be notified.
|
||||
# If a quarantine is configured, a copy of the mail will go
|
||||
# there, if not mail message will be lost. Note that there are
|
||||
# additional settings available that can send notifications to
|
||||
# persons that normally may not be notified when an undesirable
|
||||
# message is found, so it is possible to notify the sender even
|
||||
# when using D_DISCARD.
|
||||
#
|
||||
# Where to store quarantined mail message:
|
||||
#
|
||||
# - 'local:spam-%i-%m', quarantine mail on local file system.
|
||||
# - 'sql:', quarantine mail in SQL server specified in @storage_sql_dsn.
|
||||
# - undef, do not quarantine mail.
|
||||
|
||||
# SPAM.
|
||||
$final_spam_destiny = D_DISCARD;
|
||||
$spam_quarantine_method = 'sql:';
|
||||
$spam_quarantine_to = 'spam-quarantine';
|
||||
|
||||
# Virus
|
||||
$final_virus_destiny = D_DISCARD;
|
||||
$virus_quarantine_method = 'sql:';
|
||||
$virus_quarantine_to = 'virus-quarantine';
|
||||
|
||||
# Banned
|
||||
$final_banned_destiny = D_DISCARD;
|
||||
$banned_files_quarantine_method = 'sql:';
|
||||
$banned_quarantine_to = 'banned-quarantine';
|
||||
|
||||
# Bad header.
|
||||
$final_bad_header_destiny = D_DISCARD;
|
||||
$bad_header_quarantine_method = 'sql:';
|
||||
$bad_header_quarantine_to = 'bad-header-quarantine';
|
||||
|
||||
#########################
|
||||
# Quarantine CLEAN mails.
|
||||
# Don't forget to enable clean quarantine in policy bank 'MYUSERS'.
|
||||
#
|
||||
#$clean_quarantine_method = 'sql:';
|
||||
#$clean_quarantine_to = 'clean-quarantine';
|
||||
|
||||
# a string to prepend to Subject (for local recipients only) if mail could
|
||||
# not be decoded or checked entirely, e.g. due to password-protected archives
|
||||
#$undecipherable_subject_tag = '***UNCHECKED*** '; # undef disables it
|
||||
$undecipherable_subject_tag = undef;
|
||||
|
||||
# Hope to fix 'nested MAIL command' issue on high load server.
|
||||
$smtp_connection_cache_enable = 0;
|
||||
|
||||
# The default set of header fields to be signed can be controlled
|
||||
# by setting %signed_header_fields elements to true (to sign) or
|
||||
# to false (not to sign). Keys must be in lowercase, e.g.:
|
||||
# 0 -> off
|
||||
# 1 -> on
|
||||
$signed_header_fields{'received'} = 0;
|
||||
$signed_header_fields{'to'} = 1;
|
||||
$signed_header_fields{'from'} = 1;
|
||||
$signed_header_fields{'subject'} = 1;
|
||||
$signed_header_fields{'message-id'} = 1;
|
||||
$signed_header_fields{'content-type'} = 1;
|
||||
$signed_header_fields{'date'} = 1;
|
||||
$signed_header_fields{'mime-version'} = 1;
|
||||
|
||||
#
|
||||
# DKIM
|
||||
#
|
||||
# Enable DKIM verification globally.
|
||||
$enable_dkim_verification = 1;
|
||||
|
||||
# Disable DKIM signing globally, because it's controlled per policy bank.
|
||||
#$enable_dkim_signing = 1;
|
||||
|
||||
# Add dkim_key here.
|
||||
dkim_key('PH_FIRST_DOMAIN', 'dkim', 'PH_AMAVISD_FIRST_DOMAIN_DKIM_KEY');
|
||||
|
||||
@dkim_signature_options_bysender_maps = ({
|
||||
# 'd' defaults to a domain of an author/sender address,
|
||||
# 's' defaults to whatever selector is offered by a matching key
|
||||
|
||||
# Per-domain dkim key
|
||||
#"domain.com" => { d => "domain.com", a => 'rsa-sha256', ttl => 10*24*3600 },
|
||||
|
||||
# catch-all (one dkim key for all domains)
|
||||
'.' => {d => 'PH_FIRST_DOMAIN',
|
||||
a => 'rsa-sha256',
|
||||
c => 'relaxed/simple',
|
||||
ttl => 30*24*3600 },
|
||||
});
|
||||
|
||||
#
|
||||
# Disclaimer settings
|
||||
#
|
||||
# Uncomment below line to enable singing disclaimer in outgoing mails.
|
||||
#$defang_maps_by_ccat{+CC_CATCHALL} = [ 'disclaimer' ];
|
||||
|
||||
# Program used to signing disclaimer in outgoing mails.
|
||||
$altermime = 'PH_CMD_ALTERMIME';
|
||||
|
||||
# Disclaimer in plain text formart.
|
||||
@altermime_args_disclaimer = qw(--disclaimer=/etc/postfix/disclaimer/_OPTION_.txt --disclaimer-html=/etc/postfix/disclaimer/_OPTION_.txt --force-for-bad-html);
|
||||
|
||||
@disclaimer_options_bysender_maps = ({
|
||||
# Per-domain, per-user disclaimer setting:
|
||||
# '<domain>' => /path/to/disclaimer.txt,
|
||||
# '<email>' => /path/to/disclaimer.txt,
|
||||
|
||||
# Catch-all disclaimer setting: /etc/postfix/disclaimer/default.txt
|
||||
'.' => 'default',
|
||||
},);
|
||||
|
||||
$sql_allow_8bit_address = 1;
|
||||
$timestamp_fmt_mysql = 1; # if using MySQL *and* msgs.time_iso is TIMESTAMP;
|
||||
|
||||
# Reporting and quarantining.
|
||||
@storage_sql_dsn = (['DBI:PH_AMAVISD_PERL_SQL_DBI:database=PH_AMAVISD_DB_NAME;host=PH_SQL_SERVER_ADDRESS;port=PH_SQL_SERVER_PORT', 'PH_AMAVISD_DB_USER', 'PH_AMAVISD_DB_PASSWD']);
|
||||
|
||||
# Lookup for per-recipient, per-domain and global policy.
|
||||
@lookup_sql_dsn = @storage_sql_dsn;
|
||||
|
||||
# Don't send email with subject "UNCHECKED contents in mail FROM xxx".
|
||||
delete $admin_maps_by_ccat{&CC_UNCHECKED};
|
||||
|
||||
# Do not notify administrator about SPAM/VIRUS from remote servers.
|
||||
$virus_admin = undef;
|
||||
$spam_admin = undef;
|
||||
$banned_admin = undef;
|
||||
$bad_header_admin = undef;
|
||||
|
||||
#
|
||||
# Pre-define some policy banks.
|
||||
#
|
||||
# You can assign certain policy banks to clients/senders you want to whitelist
|
||||
# with parameter `@client_ipaddr_policy` and @author_to_policy_bank_maps.
|
||||
$policy_bank{'FULL_WHITELIST'} = {
|
||||
bypass_spam_checks_maps => [1],
|
||||
spam_lovers_maps => [1],
|
||||
bypass_decode_parts => 1,
|
||||
bypass_virus_checks_maps => [1],
|
||||
virus_lovers_maps => [1],
|
||||
bypass_banned_checks_maps => [1],
|
||||
banned_files_lovers_maps => [1],
|
||||
bypass_header_checks_maps => [1],
|
||||
bad_header_lovers_maps => [1],
|
||||
};
|
||||
|
||||
$policy_bank{'NO_SPAM_CHECK'} = {
|
||||
bypass_spam_checks_maps => [1],
|
||||
spam_lovers_maps => [1],
|
||||
};
|
||||
|
||||
$policy_bank{'NO_VIRUS_CHECK'} = {
|
||||
bypass_decode_parts => 1,
|
||||
bypass_virus_checks_maps => [1],
|
||||
virus_lovers_maps => [1],
|
||||
};
|
||||
|
||||
$policy_bank{'NO_BANNED_CHECK'} = {
|
||||
bypass_banned_checks_maps => [1],
|
||||
banned_files_lovers_maps => [1],
|
||||
};
|
||||
|
||||
$policy_bank{'NO_BAD_HEADER_CHECK'} = {
|
||||
bypass_header_checks_maps => [1],
|
||||
bad_header_lovers_maps => [1],
|
||||
};
|
||||
|
||||
#$policy_bank{'MILD_WHITELIST'} = {
|
||||
# score_sender_maps => [ { '.' => [-1.8] } ],
|
||||
#};
|
||||
|
||||
#
|
||||
# Logging
|
||||
#
|
||||
$do_syslog = 1; # log via syslogd (preferred)
|
||||
$syslog_facility = 'mail'; # Syslog facility as a string
|
||||
$log_level = 0; # Amavisd log level.
|
||||
# Verbosity: 0, 1, 2, 3, 4, 5.
|
||||
$sa_debug = 0; # SpamAssassin debugging (require $log_level).
|
||||
# Default if off (0).
|
||||
|
||||
# Amavisd on some Linux/BSD distribution use $banned_namepath_re instead of
|
||||
# $banned_filename_re, so we define some blocked file types here.
|
||||
#
|
||||
# Sample input for $banned_namepath_re:
|
||||
#
|
||||
# P=p003\tL=1\tM=multipart/mixed\nP=p002\tL=1/2\tM=application/octet-stream\tT=dat\tN=my_docum.zip
|
||||
# P=p003,L=1,M=multipart/mixed | P=p002,L=1/2,M=application/zip,T=zip,N=FedEx_00628727.zip | P=p005,L=1/2/2,T=asc,N=FedEx_00628727.doc.wsf
|
||||
#
|
||||
# What it means:
|
||||
# - T: type. e.g. zip archive.
|
||||
# - M: MIME type. e.g. application/octet-stream.
|
||||
# - N: suggested (MIME) name. e.g. my_docum.zip.
|
||||
|
||||
$banned_namepath_re = new_RE(
|
||||
#[qr'T=(rar|arc|arj|zoo|gz|bz2)(,|\t)'xmi => 'DISCARD'], # Compressed file types
|
||||
[qr'T=x-(msdownload|msdos-program|msmetafile)(,|\t)'xmi => 'DISCARD'],
|
||||
[qr'T=(hta)(,|\t)'xmi => 'DISCARD'],
|
||||
|
||||
# Dangerous mime types
|
||||
[qr'T=(9|386|LeChiffre|aaa|abc|aepl|ani|aru|atm|aut|b64|bat|bhx|bkd|blf|bll|bmw|boo|bps|bqf|breaking_bad|buk|bup|bxz|cc|ccc|ce0|ceo|cfxxe|chm|cih|cla|class|cmd|com|cpl|crinf|crjoker|crypt|cryptolocker|cryptowall|ctbl|cxq|cyw|dbd|delf|dev|dlb|dli|dll|dllx|dom|drv|dx|dxz|dyv|dyz|ecc|exe|exe-ms|exe1|exe_renamed|exx|ezt|ezz|fag|fjl|fnr|fuj|good|gzquar|hlp|hlw|hqx|hsq|hts|iva|iws|jar|js|kcd|keybtc@inbox_com|let|lik|lkh|lnk|locky|lok|lol!|lpaq5|magic|mfu|micro|mim|mjg|mjz|nls|oar|ocx|osa|ozd|pcx|pgm|php2|php3|pid|pif|plc|pr|pzdc|qit|qrn|r5a|rhk|rna|rsc_tmp|s7p|scr|shs|ska|smm|smtmp|sop|spam|ssy|swf|sys|tko|tps|tsa|tti|ttt|txs|upa|uu|uue|uzy|vb|vba|vbe|vbs|vbx|vexe|vxd|vzr|wlpginstall|ws|wsc|wsf|wsh|wss|xdu|xir|xlm|xlv|xnt|xnxx|xtbl|xxe|xxx|xyz|zix|zvz|zzz)(,|\t)'xmi => 'DISCARD'],
|
||||
|
||||
# Dangerous file name extensions
|
||||
[qr'N=.*\.(9|386|LeChiffre|aaa|abc|aepl|ani|aru|atm|aut|b64|bat|bhx|bkd|blf|bll|bmw|boo|bps|bqf|breaking_bad|buk|bup|bxz|cc|ccc|ce0|ceo|cfxxe|chm|cih|cla|class|cmd|com|cpl|crinf|crjoker|crypt|cryptolocker|cryptowall|ctbl|cxq|cyw|dbd|delf|dev|dlb|dli|dll|dllx|dom|drv|dx|dxz|dyv|dyz|ecc|exe|exe-ms|exe1|exe_renamed|exx|ezt|ezz|fag|fjl|fnr|fuj|good|gzquar|hlp|hlw|hqx|hsq|hts|iva|iws|jar|js|kcd|keybtc@inbox_com|let|lik|lkh|lnk|locky|lok|lol!|lpaq5|magic|mfu|micro|mim|mjg|mjz|nls|oar|ocx|osa|ozd|pcx|pgm|php2|php3|pid|pif|plc|pr|pzdc|qit|qrn|r5a|rhk|rna|rsc_tmp|s7p|scr|shs|ska|smm|smtmp|sop|spam|ssy|swf|sys|tko|tps|tsa|tti|ttt|txs|upa|uu|uue|uzy|vb|vba|vbe|vbs|vbx|vexe|vxd|vzr|wlpginstall|ws|wsc|wsf|wsh|wss|xdu|xir|xlm|xlv|xnt|xnxx|xtbl|xxe|xxx|xyz|zix|zvz|zzz)$'xmi => 'DISCARD'],
|
||||
);
|
||||
|
||||
# Log verbose.
|
||||
$log_templ = $log_verbose_templ;
|
||||
|
||||
# $bounce_killer_score defaults to 100, it will cause quota exceed notification
|
||||
# email sent by Dovecot quarantined by Amavisd.
|
||||
$penpals_bonus_score = undef;
|
||||
$bounce_killer_score = 0;
|
||||
|
||||
# Selectively disable some of the header checks
|
||||
#
|
||||
# Duplicate or multiple occurrence of a header field
|
||||
$allowed_header_tests{'multiple'} = 0;
|
||||
|
||||
# Missing some headers. e.g. 'Date:'
|
||||
$allowed_header_tests{'missing'} = 0;
|
||||
|
||||
# Listen on specified addresses.
|
||||
$inet_socket_bind = ['PH_LOCAL_ADDRESS'];
|
||||
|
||||
# Set ACL
|
||||
@inet_acl = qw(127.0.0.1 [::1] PH_LOCAL_ADDRESS);
|
||||
|
||||
# Num of pre-forked children.
|
||||
# WARNING: it must match (equal to or larger than) the number set in
|
||||
# `maxproc` column in Postfix master.cf for the `smtp-amavis` transport.
|
||||
$max_servers = PH_AMAVISD_MAX_SERVERS;
|
||||
|
||||
1; # insure a defined return
|
||||
@@ -0,0 +1,278 @@
|
||||
-- MySQL template for Amavisd-new-2.7.0 and later releases.
|
||||
-- Extracted from Amavisd docs/README.sql-mysql.
|
||||
|
||||
-- used in @lookup_sql_dsn
|
||||
-- local users
|
||||
CREATE TABLE users (
|
||||
id int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, -- unique id
|
||||
priority integer NOT NULL DEFAULT '7', -- sort field, 0 is low prior.
|
||||
policy_id integer unsigned NOT NULL DEFAULT '1', -- JOINs with policy.id
|
||||
email varbinary(255) NOT NULL UNIQUE,
|
||||
fullname varchar(255) DEFAULT NULL -- not used by amavisd-new
|
||||
-- local char(1) -- Y/N (optional field, see note further down)
|
||||
);
|
||||
|
||||
-- used in @lookup_sql_dsn
|
||||
-- any e-mail address (non- rfc2822-quoted), external or local,
|
||||
-- used as senders in wblist
|
||||
CREATE TABLE mailaddr (
|
||||
id int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
priority integer NOT NULL DEFAULT '7', -- 0 is low priority
|
||||
email varbinary(255) NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
-- used in @lookup_sql_dsn
|
||||
-- per-recipient whitelist and/or blacklist,
|
||||
-- puts sender and recipient in relation wb (white or blacklisted sender)
|
||||
-- White/blacklist for inbound message
|
||||
CREATE TABLE wblist (
|
||||
rid integer unsigned NOT NULL, -- recipient: users.id
|
||||
sid integer unsigned NOT NULL, -- sender: mailaddr.id
|
||||
wb varchar(10) NOT NULL, -- W or Y / B or N / space=neutral / score
|
||||
PRIMARY KEY (rid,sid)
|
||||
);
|
||||
|
||||
-- White/blacklist for outbound message
|
||||
-- Note: it's used by iRedAPD plugin `amavisd_wblist`, not by Amavisd.
|
||||
CREATE TABLE outbound_wblist (
|
||||
rid integer unsigned NOT NULL, -- recipient: mailaddr.id
|
||||
sid integer unsigned NOT NULL, -- sender: users.id
|
||||
wb varchar(10) NOT NULL, -- W or Y / B or N / space=neutral / score
|
||||
PRIMARY KEY (rid,sid)
|
||||
);
|
||||
|
||||
-- used in @lookup_sql_dsn
|
||||
CREATE TABLE policy (
|
||||
id int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
-- 'id' this is the _only_ required field
|
||||
policy_name varchar(32), -- not used by amavisd-new, a comment
|
||||
|
||||
virus_lover char(1) default NULL, -- Y/N
|
||||
spam_lover char(1) default NULL, -- Y/N
|
||||
unchecked_lover char(1) default NULL, -- Y/N
|
||||
banned_files_lover char(1) default NULL, -- Y/N
|
||||
bad_header_lover char(1) default NULL, -- Y/N
|
||||
|
||||
bypass_virus_checks char(1) default NULL, -- Y/N
|
||||
bypass_spam_checks char(1) default NULL, -- Y/N
|
||||
bypass_banned_checks char(1) default NULL, -- Y/N
|
||||
bypass_header_checks char(1) default NULL, -- Y/N
|
||||
|
||||
virus_quarantine_to varchar(64) default NULL,
|
||||
spam_quarantine_to varchar(64) default NULL,
|
||||
banned_quarantine_to varchar(64) default NULL,
|
||||
unchecked_quarantine_to varchar(64) default NULL,
|
||||
bad_header_quarantine_to varchar(64) default NULL,
|
||||
clean_quarantine_to varchar(64) default NULL,
|
||||
archive_quarantine_to varchar(64) default NULL,
|
||||
|
||||
spam_tag_level float default NULL, -- higher score inserts spam info headers
|
||||
spam_tag2_level float default NULL, -- inserts 'declared spam' header fields
|
||||
spam_tag3_level float default NULL, -- inserts 'blatant spam' header fields
|
||||
spam_kill_level float default NULL, -- higher score triggers evasive actions
|
||||
-- e.g. reject/drop, quarantine, ...
|
||||
-- (subject to final_spam_destiny setting)
|
||||
spam_dsn_cutoff_level float default NULL,
|
||||
spam_quarantine_cutoff_level float default NULL,
|
||||
|
||||
addr_extension_virus varchar(64) default NULL,
|
||||
addr_extension_spam varchar(64) default NULL,
|
||||
addr_extension_banned varchar(64) default NULL,
|
||||
addr_extension_bad_header varchar(64) default NULL,
|
||||
|
||||
warnvirusrecip char(1) default NULL, -- Y/N
|
||||
warnbannedrecip char(1) default NULL, -- Y/N
|
||||
warnbadhrecip char(1) default NULL, -- Y/N
|
||||
newvirus_admin varchar(64) default NULL,
|
||||
virus_admin varchar(64) default NULL,
|
||||
banned_admin varchar(64) default NULL,
|
||||
bad_header_admin varchar(64) default NULL,
|
||||
spam_admin varchar(64) default NULL,
|
||||
spam_subject_tag varchar(64) default NULL,
|
||||
spam_subject_tag2 varchar(64) default NULL,
|
||||
spam_subject_tag3 varchar(64) default NULL,
|
||||
message_size_limit integer default NULL, -- max size in bytes, 0 disable
|
||||
banned_rulenames varchar(64) default NULL, -- comma-separated list of ...
|
||||
-- names mapped through %banned_rules to actual banned_filename tables
|
||||
disclaimer_options varchar(64) default NULL,
|
||||
forward_method varchar(64) default NULL,
|
||||
sa_userconf varchar(64) default NULL,
|
||||
sa_username varchar(64) default NULL
|
||||
);
|
||||
|
||||
-- Required by iRedMail
|
||||
ALTER TABLE policy MODIFY COLUMN policy_name VARCHAR(255) NOT NULL DEFAULT '';
|
||||
CREATE UNIQUE INDEX policy_idx_policy_name ON policy (policy_name);
|
||||
|
||||
-- Read-write part of the dataset (optional) - @storage_sql_dsn.
|
||||
-- May reside in the same or in a separate database as lookups database;
|
||||
-- REQUIRES SUPPORT FOR TRANSACTIONS; specified in @storage_sql_dsn
|
||||
--
|
||||
-- MySQL note ( http://dev.mysql.com/doc/mysql/en/storage-engines.html ):
|
||||
-- ENGINE is the preferred term, but cannot be used before MySQL 4.0.18.
|
||||
-- TYPE is available beginning with MySQL 3.23.0, the first version of
|
||||
-- MySQL for which multiple storage engines were available. If you omit
|
||||
-- the ENGINE or TYPE option, the default storage engine is used.
|
||||
-- By default this is MyISAM.
|
||||
--
|
||||
-- Please create additional indexes on keys when needed, or drop suggested
|
||||
-- ones as appropriate to optimize queries needed by a management application.
|
||||
-- See your database documentation for further optimization hints. With MySQL
|
||||
-- see Chapter 15 of the reference manual. For example the chapter 15.17 says:
|
||||
-- InnoDB does not keep an internal count of rows in a table. To process a
|
||||
-- SELECT COUNT(*) FROM T statement, InnoDB must scan an index of the table,
|
||||
-- which takes some time if the index is not entirely in the buffer pool.
|
||||
--
|
||||
-- Wayne Smith adds: When using MySQL with InnoDB one might want to
|
||||
-- increase buffer size for both pool and log, and might also want
|
||||
-- to change flush settings for a little better performance. Example:
|
||||
-- innodb_buffer_pool_size = 384M
|
||||
-- innodb_log_buffer_size = 8M
|
||||
-- innodb_flush_log_at_trx_commit = 0
|
||||
-- The big performance increase is the first two, the third just helps with
|
||||
-- lowering disk activity. Consider also adjusting the key_buffer_size.
|
||||
|
||||
-- used in @storage_sql_dsn
|
||||
-- provide unique id for each e-mail address, avoids storing copies
|
||||
CREATE TABLE maddr (
|
||||
partition_tag integer DEFAULT 0, -- see $partition_tag
|
||||
id bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
email varbinary(255) NOT NULL, -- full mail address
|
||||
-- mail address without address extension: user+abc@domain.com -> user@domain.com
|
||||
email_raw varbinary(255) NOT NULL DEFAULT '',
|
||||
domain varchar(255) NOT NULL, -- only domain part of the email address
|
||||
-- with subdomain fields in reverse
|
||||
CONSTRAINT part_email UNIQUE (partition_tag,email)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE INDEX maddr_idx_email ON maddr (email);
|
||||
CREATE INDEX maddr_idx_email_raw ON maddr (email_raw);
|
||||
CREATE INDEX maddr_idx_domain ON maddr (domain);
|
||||
|
||||
-- Create trigger to save email address withou address extension
|
||||
-- user+abc@domain.com -> user@domain.com
|
||||
DELIMITER //
|
||||
CREATE TRIGGER `maddr_email_raw`
|
||||
BEFORE INSERT
|
||||
ON `maddr`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF (NEW.email LIKE '%+%') THEN
|
||||
SET NEW.email_raw = CONCAT(SUBSTRING_INDEX(NEW.email, '+', 1), '@', SUBSTRING_INDEX(new.email, '@', -1));
|
||||
ELSE
|
||||
SET NEW.email_raw = NEW.email;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
DELIMITER ;
|
||||
|
||||
-- used in @storage_sql_dsn
|
||||
-- information pertaining to each processed message as a whole;
|
||||
-- NOTE: records with NULL msgs.content should be ignored by utilities,
|
||||
-- as such records correspond to messages just being processes, or were lost
|
||||
-- NOTE: instead of a character field time_iso, one might prefer:
|
||||
-- time_iso TIMESTAMP NOT NULL DEFAULT 0,
|
||||
-- but the following MUST then be set in amavisd.conf: $timestamp_fmt_mysql=1
|
||||
CREATE TABLE msgs (
|
||||
partition_tag integer DEFAULT 0, -- see $partition_tag
|
||||
mail_id varbinary(16) NOT NULL, -- long-term unique mail id, dflt 12 ch
|
||||
secret_id varbinary(16) DEFAULT '', -- authorizes release of mail_id, 12 ch
|
||||
am_id varchar(20) NOT NULL, -- id used in the log
|
||||
time_num integer unsigned NOT NULL, -- rx_time: seconds since Unix epoch
|
||||
time_iso char(16) NOT NULL, -- rx_time: ISO8601 UTC ascii time
|
||||
sid bigint unsigned NOT NULL, -- sender: maddr.id
|
||||
policy varchar(255) DEFAULT '', -- policy bank path (like macro %p)
|
||||
client_addr varchar(255) DEFAULT '', -- SMTP client IP address (IPv4 or v6)
|
||||
size integer unsigned NOT NULL, -- message size in bytes
|
||||
originating char(1) DEFAULT ' ' NOT NULL, -- sender from inside or auth'd
|
||||
content char(1),
|
||||
-- V: virus
|
||||
-- B: banned
|
||||
-- U: unchecked
|
||||
-- S: spam(kill)
|
||||
-- Y: spammy(tag2)
|
||||
-- M: bad-mime
|
||||
-- H: bad-header
|
||||
-- O: oversized
|
||||
-- O: mta-err
|
||||
-- C: clean
|
||||
-- is NULL on partially processed mail
|
||||
-- (prior to 2.7.0 the CC_SPAMMY was logged as 's', now 'Y' is used;
|
||||
-- to avoid a need for case-insenstivity in queries)
|
||||
quar_type char(1), -- quarantined as: ' '/F/Z/B/Q/M/L
|
||||
-- none/file/zipfile/bsmtp/sql/
|
||||
-- /mailbox(smtp)/mailbox(lmtp)
|
||||
quar_loc varbinary(255) DEFAULT '', -- quarantine location (e.g. file)
|
||||
dsn_sent char(1), -- was DSN sent? Y/N/q (q=quenched)
|
||||
spam_level float, -- SA spam level (no boosts)
|
||||
message_id varchar(255) DEFAULT '', -- mail Message-ID header field
|
||||
from_addr varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '',
|
||||
-- mail From header field, UTF8
|
||||
subject VARBINARY(255) NOT NULL DEFAULT '',
|
||||
-- mail Subject header field, UTF8
|
||||
host varchar(255) NOT NULL, -- hostname where amavisd is running
|
||||
PRIMARY KEY (partition_tag,mail_id)
|
||||
-- FOREIGN KEY (sid) REFERENCES maddr(id) ON DELETE RESTRICT
|
||||
) ENGINE=InnoDB;
|
||||
CREATE INDEX msgs_idx_sid ON msgs (sid);
|
||||
CREATE INDEX msgs_idx_mess_id ON msgs (message_id); -- useful with pen pals
|
||||
CREATE INDEX msgs_idx_time_num ON msgs (time_num);
|
||||
|
||||
CREATE INDEX msgs_idx_mail_id ON msgs (mail_id);
|
||||
CREATE INDEX msgs_idx_content ON msgs (content);
|
||||
CREATE INDEX msgs_idx_quar_type ON msgs (quar_type);
|
||||
CREATE INDEX msgs_idx_content_time_num ON msgs (content, time_num);
|
||||
CREATE INDEX msgs_idx_spam_level ON msgs (spam_level);
|
||||
|
||||
-- alternatively when purging based on time_iso (instead of msgs_idx_time_num):
|
||||
CREATE INDEX msgs_idx_time_iso ON msgs (time_iso);
|
||||
|
||||
-- used in @storage_sql_dsn
|
||||
-- per-recipient information related to each processed message;
|
||||
-- NOTE: records in msgrcpt without corresponding msgs.mail_id record are
|
||||
-- orphaned and should be ignored and eventually deleted by external utilities
|
||||
CREATE TABLE msgrcpt (
|
||||
partition_tag integer DEFAULT 0, -- see $partition_tag
|
||||
mail_id varbinary(16) NOT NULL, -- (must allow duplicates)
|
||||
rseqnum integer DEFAULT 0 NOT NULL, -- recip's enumeration within msg
|
||||
rid bigint unsigned NOT NULL, -- recipient: maddr.id (dupl. allowed)
|
||||
is_local char(1) DEFAULT ' ' NOT NULL, -- recip is: Y=local, N=foreign
|
||||
content char(1) DEFAULT ' ' NOT NULL, -- content type V/B/U/S/Y/M/H/O/T/C
|
||||
ds char(1) NOT NULL, -- delivery status: P/R/B/D/T
|
||||
-- pass/reject/bounce/discard/tempfail
|
||||
rs char(1) NOT NULL, -- release status: initialized to ' '
|
||||
bl char(1) DEFAULT ' ', -- sender blacklisted by this recip
|
||||
wl char(1) DEFAULT ' ', -- sender whitelisted by this recip
|
||||
bspam_level float, -- per-recipient (total) spam level
|
||||
smtp_resp varchar(255) DEFAULT '', -- SMTP response given to MTA
|
||||
PRIMARY KEY (partition_tag,mail_id,rseqnum)
|
||||
-- FOREIGN KEY (rid) REFERENCES maddr(id) ON DELETE RESTRICT,
|
||||
-- FOREIGN KEY (mail_id) REFERENCES msgs(mail_id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
CREATE INDEX msgrcpt_idx_mail_id ON msgrcpt (mail_id);
|
||||
CREATE INDEX msgrcpt_idx_rid ON msgrcpt (rid);
|
||||
|
||||
-- used in @storage_sql_dsn
|
||||
-- mail quarantine in SQL, enabled by $*_quarantine_method='sql:'
|
||||
-- NOTE: records in quarantine without corresponding msgs.mail_id record are
|
||||
-- orphaned and should be ignored and eventually deleted by external utilities
|
||||
CREATE TABLE quarantine (
|
||||
partition_tag integer DEFAULT 0, -- see $partition_tag
|
||||
mail_id varbinary(16) NOT NULL, -- long-term unique mail id
|
||||
chunk_ind integer unsigned NOT NULL, -- chunk number, starting with 1
|
||||
mail_text blob NOT NULL, -- store mail as chunks of octets
|
||||
PRIMARY KEY (partition_tag,mail_id,chunk_ind)
|
||||
-- FOREIGN KEY (mail_id) REFERENCES msgs(mail_id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE INDEX quar_idx_mail_id ON quarantine (mail_id);
|
||||
|
||||
-- field msgrcpt.rs is primarily intended for use by quarantine management
|
||||
-- software; the value assigned by amavisd is a space;
|
||||
-- a short _preliminary_ list of possible values:
|
||||
-- 'V' => viewed (marked as read)
|
||||
-- 'R' => released (delivered) to this recipient
|
||||
-- 'p' => pending (a status given to messages when the admin received the
|
||||
-- request but not yet released; targeted to banned parts)
|
||||
-- 'D' => marked for deletion; a cleanup script may delete it
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
-- MySQL template for Amavisd-new-2.7.0 and later releases.
|
||||
-- Read-only part of the dataset (@lookup_sql_dsn)
|
||||
|
||||
-- used in @lookup_sql_dsn
|
||||
-- local users
|
||||
CREATE TABLE users (
|
||||
id serial PRIMARY KEY, -- unique id
|
||||
priority integer NOT NULL DEFAULT '7', -- sort field, 0 is low prior.
|
||||
policy_id integer NOT NULL DEFAULT '1' CHECK (policy_id >= 0),
|
||||
-- JOINs with policy.id
|
||||
email bytea NOT NULL UNIQUE, -- email address, non-rfc2822-quoted
|
||||
fullname varchar(255) DEFAULT NULL -- not used by amavisd-new
|
||||
-- local char(1) -- Y/N (optional field, see note further down)
|
||||
);
|
||||
|
||||
-- used in @lookup_sql_dsn
|
||||
-- any e-mail address (non- rfc2822-quoted), external or local,
|
||||
-- used as senders in wblist
|
||||
CREATE TABLE mailaddr (
|
||||
id serial PRIMARY KEY,
|
||||
priority integer NOT NULL DEFAULT '7', -- 0 is low priority
|
||||
email bytea NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
-- used in @lookup_sql_dsn
|
||||
-- per-recipient whitelist and/or blacklist,
|
||||
-- puts sender and recipient in relation wb (white or blacklisted sender)
|
||||
-- White/blacklist for inbound message
|
||||
CREATE TABLE wblist (
|
||||
rid integer NOT NULL CHECK (rid >= 0), -- recipient: users.id
|
||||
sid integer NOT NULL CHECK (sid >= 0), -- sender: mailaddr.id
|
||||
wb varchar(10) NOT NULL, -- W or Y / B or N / space=neutral / score
|
||||
PRIMARY KEY (rid,sid)
|
||||
);
|
||||
|
||||
-- White/blacklist for outbound message
|
||||
-- Note: it's used by iRedAPD plugin `amavisd_wblist`, not by Amavisd.
|
||||
CREATE TABLE outbound_wblist (
|
||||
rid integer NOT NULL CHECK (rid >= 0), -- recipient: mailaddr.id
|
||||
sid integer NOT NULL CHECK (sid >= 0), -- sender: users.id
|
||||
wb varchar(10) NOT NULL, -- W or Y / B or N / space=neutral / score
|
||||
PRIMARY KEY (rid,sid)
|
||||
);
|
||||
|
||||
-- used in @lookup_sql_dsn
|
||||
CREATE TABLE policy (
|
||||
id serial PRIMARY KEY, -- 'id' this is the _only_ required field
|
||||
policy_name varchar(32), -- not used by amavisd-new, a comment
|
||||
|
||||
virus_lover char(1) default NULL, -- Y/N
|
||||
spam_lover char(1) default NULL, -- Y/N
|
||||
unchecked_lover char(1) default NULL, -- Y/N
|
||||
banned_files_lover char(1) default NULL, -- Y/N
|
||||
bad_header_lover char(1) default NULL, -- Y/N
|
||||
|
||||
bypass_virus_checks char(1) default NULL, -- Y/N
|
||||
bypass_spam_checks char(1) default NULL, -- Y/N
|
||||
bypass_banned_checks char(1) default NULL, -- Y/N
|
||||
bypass_header_checks char(1) default NULL, -- Y/N
|
||||
|
||||
virus_quarantine_to varchar(64) default NULL,
|
||||
spam_quarantine_to varchar(64) default NULL,
|
||||
banned_quarantine_to varchar(64) default NULL,
|
||||
unchecked_quarantine_to varchar(64) default NULL,
|
||||
bad_header_quarantine_to varchar(64) default NULL,
|
||||
clean_quarantine_to varchar(64) default NULL,
|
||||
archive_quarantine_to varchar(64) default NULL,
|
||||
|
||||
spam_tag_level real default NULL, -- higher score inserts spam info headers
|
||||
spam_tag2_level real default NULL, -- inserts 'declared spam' header fields
|
||||
spam_tag3_level real default NULL, -- inserts 'blatant spam' header fields
|
||||
spam_kill_level real default NULL, -- higher score triggers evasive actions
|
||||
-- e.g. reject/drop, quarantine, ...
|
||||
-- (subject to final_spam_destiny setting)
|
||||
spam_dsn_cutoff_level real default NULL,
|
||||
spam_quarantine_cutoff_level real default NULL,
|
||||
|
||||
addr_extension_virus varchar(64) default NULL,
|
||||
addr_extension_spam varchar(64) default NULL,
|
||||
addr_extension_banned varchar(64) default NULL,
|
||||
addr_extension_bad_header varchar(64) default NULL,
|
||||
|
||||
warnvirusrecip char(1) default NULL, -- Y/N
|
||||
warnbannedrecip char(1) default NULL, -- Y/N
|
||||
warnbadhrecip char(1) default NULL, -- Y/N
|
||||
newvirus_admin varchar(64) default NULL,
|
||||
virus_admin varchar(64) default NULL,
|
||||
banned_admin varchar(64) default NULL,
|
||||
bad_header_admin varchar(64) default NULL,
|
||||
spam_admin varchar(64) default NULL,
|
||||
spam_subject_tag varchar(64) default NULL,
|
||||
spam_subject_tag2 varchar(64) default NULL,
|
||||
spam_subject_tag3 varchar(64) default NULL,
|
||||
message_size_limit integer default NULL, -- max size in bytes, 0 disable
|
||||
banned_rulenames varchar(64) default NULL, -- comma-separated list of ...
|
||||
-- names mapped through %banned_rules to actual banned_filename tables
|
||||
disclaimer_options varchar(64) default NULL,
|
||||
forward_method varchar(64) default NULL,
|
||||
sa_userconf varchar(64) default NULL,
|
||||
sa_username varchar(64) default NULL
|
||||
);
|
||||
|
||||
-- Required by iRedMail
|
||||
ALTER TABLE policy ALTER COLUMN policy_name TYPE varchar(255);
|
||||
CREATE UNIQUE INDEX policy_idx_policy_name ON policy (policy_name);
|
||||
|
||||
-- Read-write part of the dataset (optional) - @storage_sql_dsn.
|
||||
-- May reside in the same or in a separate database as lookups database;
|
||||
-- REQUIRES SUPPORT FOR TRANSACTIONS; specified in @storage_sql_dsn
|
||||
--
|
||||
-- Please create additional indexes on keys when needed, or drop suggested
|
||||
-- ones as appropriate to optimize queries needed by a management application.
|
||||
-- See your database documentation for further optimization hints.
|
||||
|
||||
-- used in @storage_sql_dsn
|
||||
-- provide unique id for each e-mail address, avoids storing copies
|
||||
CREATE TABLE maddr (
|
||||
partition_tag integer DEFAULT 0, -- see $partition_tag
|
||||
id serial PRIMARY KEY,
|
||||
-- full e-mail address
|
||||
email bytea NOT NULL, -- long-term unique mail id, dflt 12 ch
|
||||
-- mail address without address extension: user+abc@domain.com -> user@domain.com
|
||||
email_raw VARCHAR(255) NOT NULL DEFAULT '',
|
||||
domain bytea NOT NULL, -- only domain part of the email address
|
||||
-- with subdomain fields in reverse
|
||||
CONSTRAINT part_email UNIQUE (partition_tag,email)
|
||||
);
|
||||
|
||||
CREATE INDEX maddr_idx_email ON maddr (email);
|
||||
CREATE INDEX maddr_idx_email_raw ON maddr (email_raw);
|
||||
CREATE INDEX maddr_idx_domain ON maddr (domain);
|
||||
|
||||
-- Create trigger to save email address withou address extension
|
||||
-- user+abc@domain.com -> user@domain.com
|
||||
-- CREATE OR REPLACE FUNCTION strip_addr_extension(bytea, varchar, integer) RETURNS TRIGGER AS $$
|
||||
CREATE OR REPLACE FUNCTION strip_addr_extension()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
IF (NEW.email LIKE '%+%') THEN
|
||||
NEW.email_raw := split_part(convert_from(NEW.email, 'UTF8'), '+', 1) || '@' || split_part(convert_from(NEW.email, 'UTF8'), '@', 2);
|
||||
ELSE
|
||||
NEW.email_raw := convert_from(NEW.email, 'UTF8');
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER maddr_email_raw
|
||||
BEFORE INSERT ON maddr
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE strip_addr_extension();
|
||||
|
||||
-- used in @storage_sql_dsn
|
||||
-- information pertaining to each processed message as a whole;
|
||||
-- NOTE: records with NULL msgs.content should be ignored by utilities,
|
||||
-- as such records correspond to messages just being processes, or were lost
|
||||
CREATE TABLE msgs (
|
||||
partition_tag integer DEFAULT 0, -- see $partition_tag
|
||||
mail_id bytea NOT NULL, -- long-term unique mail id, dflt 12 ch
|
||||
secret_id bytea DEFAULT '', -- authorizes release of mail_id, 12 ch
|
||||
am_id varchar(20) NOT NULL, -- id used in the log
|
||||
time_num integer NOT NULL CHECK (time_num >= 0),
|
||||
-- rx_time: seconds since Unix epoch
|
||||
time_iso timestamp WITH TIME ZONE NOT NULL,-- rx_time: ISO8601 UTC ascii time
|
||||
sid integer NOT NULL CHECK (sid >= 0), -- sender: maddr.id
|
||||
policy varchar(255) DEFAULT '', -- policy bank path (like macro %p)
|
||||
client_addr varchar(255) DEFAULT '', -- SMTP client IP address (IPv4 or v6)
|
||||
size integer NOT NULL CHECK (size >= 0), -- message size in bytes
|
||||
originating char(1) DEFAULT ' ' NOT NULL, -- sender from inside or auth'd
|
||||
content char(1),
|
||||
-- V: virus
|
||||
-- B: banned
|
||||
-- U: unchecked
|
||||
-- S: spam(kill)
|
||||
-- Y: spammy(tag2)
|
||||
-- M: bad-mime
|
||||
-- H: bad-header
|
||||
-- O: oversized
|
||||
-- O: mta-err
|
||||
-- C: clean
|
||||
-- is NULL on partially processed mail
|
||||
-- (prior to 2.7.0 the CC_SPAMMY was logged as 's', now 'Y' is used;
|
||||
-- to avoid a need for case-insenstivity in queries)
|
||||
quar_type char(1), -- quarantined as: ' '/F/Z/B/Q/M/L
|
||||
-- none/file/zipfile/bsmtp/sql/
|
||||
-- /mailbox(smtp)/mailbox(lmtp)
|
||||
quar_loc varchar(255) DEFAULT '', -- quarantine location (e.g. file)
|
||||
dsn_sent char(1), -- was DSN sent? Y/N/q (q=quenched)
|
||||
spam_level real, -- SA spam level (no boosts)
|
||||
message_id varchar(255) DEFAULT '', -- mail Message-ID header field
|
||||
from_addr bytea DEFAULT '', -- mail From header field, UTF8
|
||||
subject bytea DEFAULT '', -- mail Subject header field, UTF8
|
||||
host varchar(255) NOT NULL, -- hostname where amavisd is running
|
||||
PRIMARY KEY (partition_tag,mail_id)
|
||||
--FOREIGN KEY (sid) REFERENCES maddr(id) ON DELETE RESTRICT
|
||||
);
|
||||
CREATE INDEX msgs_idx_sid ON msgs (sid);
|
||||
CREATE INDEX msgs_idx_mess_id ON msgs (message_id); -- useful with pen pals
|
||||
CREATE INDEX msgs_idx_time_iso ON msgs (time_iso);
|
||||
CREATE INDEX msgs_idx_time_num ON msgs (time_num); -- optional
|
||||
|
||||
CREATE INDEX msgs_idx_mail_id ON msgs (mail_id);
|
||||
CREATE INDEX msgs_idx_content ON msgs (content);
|
||||
CREATE INDEX msgs_idx_quar_type ON msgs (quar_type);
|
||||
-- CREATE INDEX msgs_idx_content_time_num ON msgs (content, time_num);
|
||||
CREATE INDEX msgs_idx_spam_level ON msgs (spam_level);
|
||||
|
||||
-- used in @storage_sql_dsn
|
||||
-- per-recipient information related to each processed message;
|
||||
-- NOTE: records in msgrcpt without corresponding msgs.mail_id record are
|
||||
-- orphaned and should be ignored and eventually deleted by external utilities
|
||||
CREATE TABLE msgrcpt (
|
||||
partition_tag integer DEFAULT 0, -- see $partition_tag
|
||||
mail_id bytea NOT NULL, -- (must allow duplicates)
|
||||
rseqnum integer DEFAULT 0 NOT NULL, -- recip's enumeration within msg
|
||||
rid integer NOT NULL, -- recipient: maddr.id (duplicates allowed)
|
||||
is_local char(1) DEFAULT ' ' NOT NULL, -- recip is: Y=local, N=foreign
|
||||
content char(1) DEFAULT ' ' NOT NULL, -- content type V/B/U/S/Y/M/H/O/T/C
|
||||
ds char(1) NOT NULL, -- delivery status: P/R/B/D/T
|
||||
-- pass/reject/bounce/discard/tempfail
|
||||
rs char(1) NOT NULL, -- release status: initialized to ' '
|
||||
bl char(1) DEFAULT ' ', -- sender blacklisted by this recip
|
||||
wl char(1) DEFAULT ' ', -- sender whitelisted by this recip
|
||||
bspam_level real, -- per-recipient (total) spam level
|
||||
smtp_resp varchar(255) DEFAULT '', -- SMTP response given to MTA
|
||||
PRIMARY KEY (partition_tag,mail_id,rseqnum)
|
||||
--FOREIGN KEY (rid) REFERENCES maddr(id) ON DELETE RESTRICT,
|
||||
--FOREIGN KEY (mail_id) REFERENCES msgs(mail_id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE INDEX msgrcpt_idx_mail_id ON msgrcpt (mail_id);
|
||||
CREATE INDEX msgrcpt_idx_rid ON msgrcpt (rid);
|
||||
|
||||
-- used in @storage_sql_dsn
|
||||
-- mail quarantine in SQL, enabled by $*_quarantine_method='sql:'
|
||||
-- NOTE: records in quarantine without corresponding msgs.mail_id record are
|
||||
-- orphaned and should be ignored and eventually deleted by external utilities
|
||||
CREATE TABLE quarantine (
|
||||
partition_tag integer DEFAULT 0, -- see $partition_tag
|
||||
mail_id bytea NOT NULL, -- long-term unique mail id
|
||||
chunk_ind integer NOT NULL CHECK (chunk_ind >= 0), -- chunk number, 1..
|
||||
mail_text bytea NOT NULL, -- store mail as chunks of octects
|
||||
PRIMARY KEY (partition_tag,mail_id,chunk_ind)
|
||||
--FOREIGN KEY (mail_id) REFERENCES msgs(mail_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- field msgrcpt.rs is primarily intended for use by quarantine management
|
||||
-- software; the value assigned by amavisd is a space;
|
||||
-- a short _preliminary_ list of possible values:
|
||||
-- 'V' => viewed (marked as read)
|
||||
-- 'R' => released (delivered) to this recipient
|
||||
-- 'p' => pending (a status given to messages when the admin received the
|
||||
-- request but not yet released; targeted to banned parts)
|
||||
-- 'D' => marked for deletion; a cleanup script may delete it
|
||||
@@ -0,0 +1,942 @@
|
||||
#--------------------------------------------------------------------------
|
||||
# LDAP Schema for amavisd-new Jacques Supcik, PhD
|
||||
#----------------------------- IP-Plus Internet Services
|
||||
# Release 1.2.2 Swisscom Enterprise Solutions Ltd
|
||||
# 30 May 2004 3050 Bern - Switzerland
|
||||
#--------------------------------------------------------------------------
|
||||
# Copyright (c) 2004 Jacques Supcik, Swisscom Enterprise Solutions Ltd.
|
||||
# Permission is granted to copy, distribute and/or modify this document
|
||||
# under the terms of the GNU Free Documentation License, Version 1.2
|
||||
# or any later version published by the Free Software Foundation;
|
||||
# with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
# A copy of the license is included in the section entitled "GNU
|
||||
# Free Documentation License".
|
||||
#--------------------------------------------------------------------------
|
||||
# Changes made to LDAP Schema to make it import and play nicely with
|
||||
# Novell NDS - Michael Tracey, SONOPRESS USA, LLC April 07 2005
|
||||
# ( uncomment each dn:, changetype:, add:, add X-NDS-NAME attribute, replace
|
||||
# "attributetype" by "attributetypes:" and "objectclasse" by "objectclasses:"
|
||||
# (plural,colon), and unwrap each attributetypes: and objectclasses: )
|
||||
#--------------------------------------------------------------------------
|
||||
# 1.3.6.1.4.1.15312 Jozef Stefan Institute's OID
|
||||
# 1.3.6.1.4.1.15312.2 amavisd-new
|
||||
# 1.3.6.1.4.1.15312.2.2 amavisd-new LDAP Elements
|
||||
# 1.3.6.1.4.1.15312.2.2.1 AttributeTypes
|
||||
# 1.3.6.1.4.1.15312.2.2.2 ObjectClasses
|
||||
# 1.3.6.1.4.1.15312.2.2.3 Syntax Definitions
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
# Attribute Types
|
||||
#-----------------
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.1
|
||||
NAME 'amavisVirusLover'
|
||||
DESC 'Virus Lover'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.2
|
||||
NAME 'amavisBannedFilesLover'
|
||||
DESC 'Banned Files Lover'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.3
|
||||
NAME 'amavisBypassVirusChecks'
|
||||
DESC 'Bypass Virus Check'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.4
|
||||
NAME 'amavisBypassSpamChecks'
|
||||
DESC 'Bypass Spam Check'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.5
|
||||
NAME 'amavisSpamTagLevel'
|
||||
DESC 'Spam Tag Level'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.6
|
||||
NAME 'amavisSpamTag2Level'
|
||||
DESC 'Spam Tag2 Level'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.7
|
||||
NAME 'amavisSpamKillLevel'
|
||||
DESC 'Spam Kill Level'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.8
|
||||
NAME 'amavisSpamModifiesSubj'
|
||||
DESC 'Modifies Subject on spam - no longer in use since 2.7.0'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.9
|
||||
NAME 'amavisWhitelistSender'
|
||||
DESC 'White List Sender'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.10
|
||||
NAME 'amavisBlacklistSender'
|
||||
DESC 'Black List Sender'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.11
|
||||
NAME 'amavisSpamQuarantineTo'
|
||||
DESC 'Spam Quarantine to'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.12
|
||||
NAME 'amavisSpamLover'
|
||||
DESC 'Spam Lover'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.13
|
||||
NAME 'amavisBadHeaderLover'
|
||||
DESC 'Bad Header Lover'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.14
|
||||
NAME 'amavisBypassBannedChecks'
|
||||
DESC 'Bypass Banned Files Check'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.15
|
||||
NAME 'amavisBypassHeaderChecks'
|
||||
DESC 'Bypass Header Check'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.16
|
||||
NAME 'amavisVirusQuarantineTo'
|
||||
DESC 'Virus quarantine location'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.17
|
||||
NAME 'amavisBannedQuarantineTo'
|
||||
DESC 'Banned Files quarantine location'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.18
|
||||
NAME 'amavisBadHeaderQuarantineTo'
|
||||
DESC 'Bad Header quarantine location'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.19
|
||||
NAME 'amavisLocal'
|
||||
DESC 'Is user considered local'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.20
|
||||
NAME 'amavisMessageSizeLimit'
|
||||
DESC 'Message size limit'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.21
|
||||
NAME 'amavisWarnVirusRecip'
|
||||
DESC 'Notify virus recipients'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.22
|
||||
NAME 'amavisWarnBannedRecip'
|
||||
DESC 'Notify banned file recipients'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.23
|
||||
NAME 'amavisWarnBadHeaderRecip'
|
||||
DESC 'Notify bad header recipients'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.24
|
||||
NAME 'amavisVirusAdmin'
|
||||
DESC 'Virus admin'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.25
|
||||
NAME 'amavisNewVirusAdmin'
|
||||
DESC 'New virus admin'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.26
|
||||
NAME 'amavisSpamAdmin'
|
||||
DESC 'Spam admin'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.27
|
||||
NAME 'amavisBannedAdmin'
|
||||
DESC 'Banned file admin'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.28
|
||||
NAME 'amavisBadHeaderAdmin'
|
||||
DESC 'Bad header admin'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.29
|
||||
NAME 'amavisBannedRuleNames'
|
||||
DESC 'Banned rule names'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.30
|
||||
NAME 'amavisSpamDsnCutoffLevel'
|
||||
DESC 'Spam DSN Cutoff Level'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.31
|
||||
NAME 'amavisSpamQuarantineCutoffLevel'
|
||||
DESC 'Spam Quarantine Cutoff Level'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.32
|
||||
NAME 'amavisSpamSubjectTag'
|
||||
DESC 'Spam Subject Tag'
|
||||
EQUALITY caseExactIA5Match
|
||||
SUBSTR caseExactSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.33
|
||||
NAME 'amavisSpamSubjectTag2'
|
||||
DESC 'Spam Subject Tag2'
|
||||
EQUALITY caseExactIA5Match
|
||||
SUBSTR caseExactSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.34
|
||||
NAME 'amavisArchiveQuarantineTo'
|
||||
DESC 'Archive quarantine location'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.35
|
||||
NAME 'amavisAddrExtensionVirus'
|
||||
DESC 'Address Extension for Virus'
|
||||
EQUALITY caseExactIA5Match
|
||||
SUBSTR caseExactSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.36
|
||||
NAME 'amavisAddrExtensionSpam'
|
||||
DESC 'Address Extension for Spam'
|
||||
EQUALITY caseExactIA5Match
|
||||
SUBSTR caseExactSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.37
|
||||
NAME 'amavisAddrExtensionBanned'
|
||||
DESC 'Address Extension for Banned'
|
||||
EQUALITY caseExactIA5Match
|
||||
SUBSTR caseExactSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.38
|
||||
NAME 'amavisAddrExtensionBadHeader'
|
||||
DESC 'Address Extension for Bad Header'
|
||||
EQUALITY caseExactIA5Match
|
||||
SUBSTR caseExactSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
# NEW since 2.7.0:
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.39
|
||||
NAME 'amavisSpamTag3Level'
|
||||
DESC 'Spam Tag3 Level'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.40
|
||||
NAME 'amavisSpamSubjectTag3'
|
||||
DESC 'Spam Subject Tag3'
|
||||
EQUALITY caseExactIA5Match
|
||||
SUBSTR caseExactSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.41
|
||||
NAME 'amavisUncheckedQuarantineTo'
|
||||
DESC 'Virus quarantine location'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.42
|
||||
NAME 'amavisCleanQuarantineTo'
|
||||
DESC 'Clean quarantine location'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.43
|
||||
NAME 'amavisUncheckedLover'
|
||||
DESC 'Unchecked Files Lover'
|
||||
EQUALITY booleanMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.44
|
||||
NAME 'amavisForwardMethod'
|
||||
DESC 'Forward / next hop destination'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.45
|
||||
NAME 'amavisSaUserConf'
|
||||
DESC 'SpamAssassin user preferences configuration filename'
|
||||
EQUALITY caseExactIA5Match
|
||||
SUBSTR caseExactSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.46
|
||||
NAME 'amavisSaUserName'
|
||||
DESC 'SpamAssassin username (for Bayes and AWL lookups)'
|
||||
EQUALITY caseExactIA5Match
|
||||
SUBSTR caseExactSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: attributetypes
|
||||
attributetype ( 1.3.6.1.4.1.15312.2.2.1.47
|
||||
NAME 'amavisDisclaimerOptions'
|
||||
DESC 'Altermime disclaimer map data'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SUBSTR caseIgnoreIA5SubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256}
|
||||
SINGLE-VALUE )
|
||||
|
||||
|
||||
# Classes
|
||||
#---------
|
||||
|
||||
# amavisAccount
|
||||
# This class is an auxiliary class, this mean that the class will be added
|
||||
# to a structural class. Usually, the structural class is the class that
|
||||
# represent the mail account itself (e.g. an inetOrgPerson)
|
||||
|
||||
#dn: cn=schema
|
||||
#changetype: modify
|
||||
#add: objectclasses
|
||||
objectclass ( 1.3.6.1.4.1.15312.2.2.2.1
|
||||
NAME 'amavisAccount' AUXILIARY
|
||||
DESC 'Amavisd Account'
|
||||
SUP top
|
||||
MAY ( amavisVirusLover $ amavisBypassVirusChecks $
|
||||
amavisSpamLover $ amavisBypassSpamChecks $
|
||||
amavisBannedFilesLover $ amavisBypassBannedChecks $
|
||||
amavisBadHeaderLover $ amavisBypassHeaderChecks $
|
||||
amavisSpamTagLevel $ amavisSpamTag2Level $ amavisSpamKillLevel $
|
||||
amavisWhitelistSender $ amavisBlacklistSender $
|
||||
amavisSpamQuarantineTo $ amavisVirusQuarantineTo $
|
||||
amavisBannedQuarantineTo $ amavisBadHeaderQuarantineTo $
|
||||
amavisArchiveQuarantineTo $
|
||||
amavisSpamModifiesSubj $ amavisLocal $ amavisMessageSizeLimit $
|
||||
amavisWarnVirusRecip $ amavisWarnBannedRecip $
|
||||
amavisWarnBadHeaderRecip $ amavisVirusAdmin $ amavisNewVirusAdmin $
|
||||
amavisSpamAdmin $ amavisBannedAdmin $ amavisBadHeaderAdmin $
|
||||
amavisBannedRuleNames $
|
||||
amavisSpamDsnCutoffLevel $ amavisSpamQuarantineCutoffLevel $
|
||||
amavisSpamSubjectTag $ amavisSpamSubjectTag2 $
|
||||
amavisAddrExtensionVirus $ amavisAddrExtensionSpam $
|
||||
amavisAddrExtensionBanned $ amavisAddrExtensionBadHeader $
|
||||
amavisSpamTag3Level $ amavisSpamSubjectTag3 $
|
||||
amavisUncheckedQuarantineTo $ amavisCleanQuarantineTo $
|
||||
amavisUncheckedLover $ amavisForwardMethod $
|
||||
amavisSaUserConf $ amavisSaUserName $ amavisDisclaimerOptions $
|
||||
cn $ description ) )
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
#
|
||||
# GNU Free Documentation License
|
||||
# Version 1.2, November 2002
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
# Everyone is permitted to copy and distribute verbatim copies
|
||||
# of this license document, but changing it is not allowed.
|
||||
#
|
||||
#
|
||||
# 0. PREAMBLE
|
||||
#
|
||||
# The purpose of this License is to make a manual, textbook, or other
|
||||
# functional and useful document "free" in the sense of freedom: to
|
||||
# assure everyone the effective freedom to copy and redistribute it,
|
||||
# with or without modifying it, either commercially or noncommercially.
|
||||
# Secondarily, this License preserves for the author and publisher a way
|
||||
# to get credit for their work, while not being considered responsible
|
||||
# for modifications made by others.
|
||||
#
|
||||
# This License is a kind of "copyleft", which means that derivative
|
||||
# works of the document must themselves be free in the same sense. It
|
||||
# complements the GNU General Public License, which is a copyleft
|
||||
# license designed for free software.
|
||||
#
|
||||
# We have designed this License in order to use it for manuals for free
|
||||
# software, because free software needs free documentation: a free
|
||||
# program should come with manuals providing the same freedoms that the
|
||||
# software does. But this License is not limited to software manuals;
|
||||
# it can be used for any textual work, regardless of subject matter or
|
||||
# whether it is published as a printed book. We recommend this License
|
||||
# principally for works whose purpose is instruction or reference.
|
||||
#
|
||||
#
|
||||
# 1. APPLICABILITY AND DEFINITIONS
|
||||
#
|
||||
# This License applies to any manual or other work, in any medium, that
|
||||
# contains a notice placed by the copyright holder saying it can be
|
||||
# distributed under the terms of this License. Such a notice grants a
|
||||
# world-wide, royalty-free license, unlimited in duration, to use that
|
||||
# work under the conditions stated herein. The "Document", below,
|
||||
# refers to any such manual or work. Any member of the public is a
|
||||
# licensee, and is addressed as "you". You accept the license if you
|
||||
# copy, modify or distribute the work in a way requiring permission
|
||||
# under copyright law.
|
||||
#
|
||||
# A "Modified Version" of the Document means any work containing the
|
||||
# Document or a portion of it, either copied verbatim, or with
|
||||
# modifications and/or translated into another language.
|
||||
#
|
||||
# A "Secondary Section" is a named appendix or a front-matter section of
|
||||
# the Document that deals exclusively with the relationship of the
|
||||
# publishers or authors of the Document to the Document's overall subject
|
||||
# (or to related matters) and contains nothing that could fall directly
|
||||
# within that overall subject. (Thus, if the Document is in part a
|
||||
# textbook of mathematics, a Secondary Section may not explain any
|
||||
# mathematics.) The relationship could be a matter of historical
|
||||
# connection with the subject or with related matters, or of legal,
|
||||
# commercial, philosophical, ethical or political position regarding
|
||||
# them.
|
||||
#
|
||||
# The "Invariant Sections" are certain Secondary Sections whose titles
|
||||
# are designated, as being those of Invariant Sections, in the notice
|
||||
# that says that the Document is released under this License. If a
|
||||
# section does not fit the above definition of Secondary then it is not
|
||||
# allowed to be designated as Invariant. The Document may contain zero
|
||||
# Invariant Sections. If the Document does not identify any Invariant
|
||||
# Sections then there are none.
|
||||
#
|
||||
# The "Cover Texts" are certain short passages of text that are listed,
|
||||
# as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
||||
# the Document is released under this License. A Front-Cover Text may
|
||||
# be at most 5 words, and a Back-Cover Text may be at most 25 words.
|
||||
#
|
||||
# A "Transparent" copy of the Document means a machine-readable copy,
|
||||
# represented in a format whose specification is available to the
|
||||
# general public, that is suitable for revising the document
|
||||
# straightforwardly with generic text editors or (for images composed of
|
||||
# pixels) generic paint programs or (for drawings) some widely available
|
||||
# drawing editor, and that is suitable for input to text formatters or
|
||||
# for automatic translation to a variety of formats suitable for input
|
||||
# to text formatters. A copy made in an otherwise Transparent file
|
||||
# format whose markup, or absence of markup, has been arranged to thwart
|
||||
# or discourage subsequent modification by readers is not Transparent.
|
||||
# An image format is not Transparent if used for any substantial amount
|
||||
# of text. A copy that is not "Transparent" is called "Opaque".
|
||||
#
|
||||
# Examples of suitable formats for Transparent copies include plain
|
||||
# ASCII without markup, Texinfo input format, LaTeX input format, SGML
|
||||
# or XML using a publicly available DTD, and standard-conforming simple
|
||||
# HTML, PostScript or PDF designed for human modification. Examples of
|
||||
# transparent image formats include PNG, XCF and JPG. Opaque formats
|
||||
# include proprietary formats that can be read and edited only by
|
||||
# proprietary word processors, SGML or XML for which the DTD and/or
|
||||
# processing tools are not generally available, and the
|
||||
# machine-generated HTML, PostScript or PDF produced by some word
|
||||
# processors for output purposes only.
|
||||
#
|
||||
# The "Title Page" means, for a printed book, the title page itself,
|
||||
# plus such following pages as are needed to hold, legibly, the material
|
||||
# this License requires to appear in the title page. For works in
|
||||
# formats which do not have any title page as such, "Title Page" means
|
||||
# the text near the most prominent appearance of the work's title,
|
||||
# preceding the beginning of the body of the text.
|
||||
#
|
||||
# A section "Entitled XYZ" means a named subunit of the Document whose
|
||||
# title either is precisely XYZ or contains XYZ in parentheses following
|
||||
# text that translates XYZ in another language. (Here XYZ stands for a
|
||||
# specific section name mentioned below, such as "Acknowledgements",
|
||||
# "Dedications", "Endorsements", or "History".) To "Preserve the Title"
|
||||
# of such a section when you modify the Document means that it remains a
|
||||
# section "Entitled XYZ" according to this definition.
|
||||
#
|
||||
# The Document may include Warranty Disclaimers next to the notice which
|
||||
# states that this License applies to the Document. These Warranty
|
||||
# Disclaimers are considered to be included by reference in this
|
||||
# License, but only as regards disclaiming warranties: any other
|
||||
# implication that these Warranty Disclaimers may have is void and has
|
||||
# no effect on the meaning of this License.
|
||||
#
|
||||
#
|
||||
# 2. VERBATIM COPYING
|
||||
#
|
||||
# You may copy and distribute the Document in any medium, either
|
||||
# commercially or noncommercially, provided that this License, the
|
||||
# copyright notices, and the license notice saying this License applies
|
||||
# to the Document are reproduced in all copies, and that you add no other
|
||||
# conditions whatsoever to those of this License. You may not use
|
||||
# technical measures to obstruct or control the reading or further
|
||||
# copying of the copies you make or distribute. However, you may accept
|
||||
# compensation in exchange for copies. If you distribute a large enough
|
||||
# number of copies you must also follow the conditions in section 3.
|
||||
#
|
||||
# You may also lend copies, under the same conditions stated above, and
|
||||
# you may publicly display copies.
|
||||
#
|
||||
#
|
||||
# 3. COPYING IN QUANTITY
|
||||
#
|
||||
# If you publish printed copies (or copies in media that commonly have
|
||||
# printed covers) of the Document, numbering more than 100, and the
|
||||
# Document's license notice requires Cover Texts, you must enclose the
|
||||
# copies in covers that carry, clearly and legibly, all these Cover
|
||||
# Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
||||
# the back cover. Both covers must also clearly and legibly identify
|
||||
# you as the publisher of these copies. The front cover must present
|
||||
# the full title with all words of the title equally prominent and
|
||||
# visible. You may add other material on the covers in addition.
|
||||
# Copying with changes limited to the covers, as long as they preserve
|
||||
# the title of the Document and satisfy these conditions, can be treated
|
||||
# as verbatim copying in other respects.
|
||||
#
|
||||
# If the required texts for either cover are too voluminous to fit
|
||||
# legibly, you should put the first ones listed (as many as fit
|
||||
# reasonably) on the actual cover, and continue the rest onto adjacent
|
||||
# pages.
|
||||
#
|
||||
# If you publish or distribute Opaque copies of the Document numbering
|
||||
# more than 100, you must either include a machine-readable Transparent
|
||||
# copy along with each Opaque copy, or state in or with each Opaque copy
|
||||
# a computer-network location from which the general network-using
|
||||
# public has access to download using public-standard network protocols
|
||||
# a complete Transparent copy of the Document, free of added material.
|
||||
# If you use the latter option, you must take reasonably prudent steps,
|
||||
# when you begin distribution of Opaque copies in quantity, to ensure
|
||||
# that this Transparent copy will remain thus accessible at the stated
|
||||
# location until at least one year after the last time you distribute an
|
||||
# Opaque copy (directly or through your agents or retailers) of that
|
||||
# edition to the public.
|
||||
#
|
||||
# It is requested, but not required, that you contact the authors of the
|
||||
# Document well before redistributing any large number of copies, to give
|
||||
# them a chance to provide you with an updated version of the Document.
|
||||
#
|
||||
#
|
||||
# 4. MODIFICATIONS
|
||||
#
|
||||
# You may copy and distribute a Modified Version of the Document under
|
||||
# the conditions of sections 2 and 3 above, provided that you release
|
||||
# the Modified Version under precisely this License, with the Modified
|
||||
# Version filling the role of the Document, thus licensing distribution
|
||||
# and modification of the Modified Version to whoever possesses a copy
|
||||
# of it. In addition, you must do these things in the Modified Version:
|
||||
#
|
||||
# A. Use in the Title Page (and on the covers, if any) a title distinct
|
||||
# from that of the Document, and from those of previous versions
|
||||
# (which should, if there were any, be listed in the History section
|
||||
# of the Document). You may use the same title as a previous version
|
||||
# if the original publisher of that version gives permission.
|
||||
# B. List on the Title Page, as authors, one or more persons or entities
|
||||
# responsible for authorship of the modifications in the Modified
|
||||
# Version, together with at least five of the principal authors of the
|
||||
# Document (all of its principal authors, if it has fewer than five),
|
||||
# unless they release you from this requirement.
|
||||
# C. State on the Title page the name of the publisher of the
|
||||
# Modified Version, as the publisher.
|
||||
# D. Preserve all the copyright notices of the Document.
|
||||
# E. Add an appropriate copyright notice for your modifications
|
||||
# adjacent to the other copyright notices.
|
||||
# F. Include, immediately after the copyright notices, a license notice
|
||||
# giving the public permission to use the Modified Version under the
|
||||
# terms of this License, in the form shown in the Addendum below.
|
||||
# G. Preserve in that license notice the full lists of Invariant Sections
|
||||
# and required Cover Texts given in the Document's license notice.
|
||||
# H. Include an unaltered copy of this License.
|
||||
# I. Preserve the section Entitled "History", Preserve its Title, and add
|
||||
# to it an item stating at least the title, year, new authors, and
|
||||
# publisher of the Modified Version as given on the Title Page. If
|
||||
# there is no section Entitled "History" in the Document, create one
|
||||
# stating the title, year, authors, and publisher of the Document as
|
||||
# given on its Title Page, then add an item describing the Modified
|
||||
# Version as stated in the previous sentence.
|
||||
# J. Preserve the network location, if any, given in the Document for
|
||||
# public access to a Transparent copy of the Document, and likewise
|
||||
# the network locations given in the Document for previous versions
|
||||
# it was based on. These may be placed in the "History" section.
|
||||
# You may omit a network location for a work that was published at
|
||||
# least four years before the Document itself, or if the original
|
||||
# publisher of the version it refers to gives permission.
|
||||
# K. For any section Entitled "Acknowledgements" or "Dedications",
|
||||
# Preserve the Title of the section, and preserve in the section all
|
||||
# the substance and tone of each of the contributor acknowledgements
|
||||
# and/or dedications given therein.
|
||||
# L. Preserve all the Invariant Sections of the Document,
|
||||
# unaltered in their text and in their titles. Section numbers
|
||||
# or the equivalent are not considered part of the section titles.
|
||||
# M. Delete any section Entitled "Endorsements". Such a section
|
||||
# may not be included in the Modified Version.
|
||||
# N. Do not retitle any existing section to be Entitled "Endorsements"
|
||||
# or to conflict in title with any Invariant Section.
|
||||
# O. Preserve any Warranty Disclaimers.
|
||||
#
|
||||
# If the Modified Version includes new front-matter sections or
|
||||
# appendices that qualify as Secondary Sections and contain no material
|
||||
# copied from the Document, you may at your option designate some or all
|
||||
# of these sections as invariant. To do this, add their titles to the
|
||||
# list of Invariant Sections in the Modified Version's license notice.
|
||||
# These titles must be distinct from any other section titles.
|
||||
#
|
||||
# You may add a section Entitled "Endorsements", provided it contains
|
||||
# nothing but endorsements of your Modified Version by various
|
||||
# parties--for example, statements of peer review or that the text has
|
||||
# been approved by an organization as the authoritative definition of a
|
||||
# standard.
|
||||
#
|
||||
# You may add a passage of up to five words as a Front-Cover Text, and a
|
||||
# passage of up to 25 words as a Back-Cover Text, to the end of the list
|
||||
# of Cover Texts in the Modified Version. Only one passage of
|
||||
# Front-Cover Text and one of Back-Cover Text may be added by (or
|
||||
# through arrangements made by) any one entity. If the Document already
|
||||
# includes a cover text for the same cover, previously added by you or
|
||||
# by arrangement made by the same entity you are acting on behalf of,
|
||||
# you may not add another; but you may replace the old one, on explicit
|
||||
# permission from the previous publisher that added the old one.
|
||||
#
|
||||
# The author(s) and publisher(s) of the Document do not by this License
|
||||
# give permission to use their names for publicity for or to assert or
|
||||
# imply endorsement of any Modified Version.
|
||||
#
|
||||
#
|
||||
# 5. COMBINING DOCUMENTS
|
||||
#
|
||||
# You may combine the Document with other documents released under this
|
||||
# License, under the terms defined in section 4 above for modified
|
||||
# versions, provided that you include in the combination all of the
|
||||
# Invariant Sections of all of the original documents, unmodified, and
|
||||
# list them all as Invariant Sections of your combined work in its
|
||||
# license notice, and that you preserve all their Warranty Disclaimers.
|
||||
#
|
||||
# The combined work need only contain one copy of this License, and
|
||||
# multiple identical Invariant Sections may be replaced with a single
|
||||
# copy. If there are multiple Invariant Sections with the same name but
|
||||
# different contents, make the title of each such section unique by
|
||||
# adding at the end of it, in parentheses, the name of the original
|
||||
# author or publisher of that section if known, or else a unique number.
|
||||
# Make the same adjustment to the section titles in the list of
|
||||
# Invariant Sections in the license notice of the combined work.
|
||||
#
|
||||
# In the combination, you must combine any sections Entitled "History"
|
||||
# in the various original documents, forming one section Entitled
|
||||
# "History"; likewise combine any sections Entitled "Acknowledgements",
|
||||
# and any sections Entitled "Dedications". You must delete all sections
|
||||
# Entitled "Endorsements".
|
||||
#
|
||||
#
|
||||
# 6. COLLECTIONS OF DOCUMENTS
|
||||
#
|
||||
# You may make a collection consisting of the Document and other documents
|
||||
# released under this License, and replace the individual copies of this
|
||||
# License in the various documents with a single copy that is included in
|
||||
# the collection, provided that you follow the rules of this License for
|
||||
# verbatim copying of each of the documents in all other respects.
|
||||
#
|
||||
# You may extract a single document from such a collection, and distribute
|
||||
# it individually under this License, provided you insert a copy of this
|
||||
# License into the extracted document, and follow this License in all
|
||||
# other respects regarding verbatim copying of that document.
|
||||
#
|
||||
#
|
||||
# 7. AGGREGATION WITH INDEPENDENT WORKS
|
||||
#
|
||||
# A compilation of the Document or its derivatives with other separate
|
||||
# and independent documents or works, in or on a volume of a storage or
|
||||
# distribution medium, is called an "aggregate" if the copyright
|
||||
# resulting from the compilation is not used to limit the legal rights
|
||||
# of the compilation's users beyond what the individual works permit.
|
||||
# When the Document is included in an aggregate, this License does not
|
||||
# apply to the other works in the aggregate which are not themselves
|
||||
# derivative works of the Document.
|
||||
#
|
||||
# If the Cover Text requirement of section 3 is applicable to these
|
||||
# copies of the Document, then if the Document is less than one half of
|
||||
# the entire aggregate, the Document's Cover Texts may be placed on
|
||||
# covers that bracket the Document within the aggregate, or the
|
||||
# electronic equivalent of covers if the Document is in electronic form.
|
||||
# Otherwise they must appear on printed covers that bracket the whole
|
||||
# aggregate.
|
||||
#
|
||||
#
|
||||
# 8. TRANSLATION
|
||||
#
|
||||
# Translation is considered a kind of modification, so you may
|
||||
# distribute translations of the Document under the terms of section 4.
|
||||
# Replacing Invariant Sections with translations requires special
|
||||
# permission from their copyright holders, but you may include
|
||||
# translations of some or all Invariant Sections in addition to the
|
||||
# original versions of these Invariant Sections. You may include a
|
||||
# translation of this License, and all the license notices in the
|
||||
# Document, and any Warranty Disclaimers, provided that you also include
|
||||
# the original English version of this License and the original versions
|
||||
# of those notices and disclaimers. In case of a disagreement between
|
||||
# the translation and the original version of this License or a notice
|
||||
# or disclaimer, the original version will prevail.
|
||||
#
|
||||
# If a section in the Document is Entitled "Acknowledgements",
|
||||
# "Dedications", or "History", the requirement (section 4) to Preserve
|
||||
# its Title (section 1) will typically require changing the actual
|
||||
# title.
|
||||
#
|
||||
#
|
||||
# 9. TERMINATION
|
||||
#
|
||||
# You may not copy, modify, sublicense, or distribute the Document except
|
||||
# as expressly provided for under this License. Any other attempt to
|
||||
# copy, modify, sublicense or distribute the Document is void, and will
|
||||
# automatically terminate your rights under this License. However,
|
||||
# parties who have received copies, or rights, from you under this
|
||||
# License will not have their licenses terminated so long as such
|
||||
# parties remain in full compliance.
|
||||
#
|
||||
#
|
||||
# 10. FUTURE REVISIONS OF THIS LICENSE
|
||||
#
|
||||
# The Free Software Foundation may publish new, revised versions
|
||||
# of the GNU Free Documentation License from time to time. Such new
|
||||
# versions will be similar in spirit to the present version, but may
|
||||
# differ in detail to address new problems or concerns. See
|
||||
# http://www.gnu.org/copyleft/.
|
||||
#
|
||||
# Each version of the License is given a distinguishing version number.
|
||||
# If the Document specifies that a particular numbered version of this
|
||||
# License "or any later version" applies to it, you have the option of
|
||||
# following the terms and conditions either of that specified version or
|
||||
# of any later version that has been published (not as a draft) by the
|
||||
# Free Software Foundation. If the Document does not specify a version
|
||||
# number of this License, you may choose any version ever published (not
|
||||
# as a draft) by the Free Software Foundation.
|
||||
@@ -0,0 +1,46 @@
|
||||
-- Default server-wide spam policy
|
||||
--
|
||||
-- *) with 'spam_lover=Y' and:
|
||||
--
|
||||
-- - with 'spam_quarantine_to=spam-quarantine', spam will be delivered
|
||||
-- to mailbox and a copy will be quarantined
|
||||
-- - with 'spam_quarantine_to=' (empty value), spam will be delivered to
|
||||
-- mailbox, no copy will be quarantined
|
||||
--
|
||||
-- *) with 'spam_lover=N' and
|
||||
--
|
||||
-- - with 'spam_quarantine_to=spam-quarantine', spam will be quarantined,
|
||||
-- no copy will be delivered to mailbox.
|
||||
-- - with 'spam_quarantine_to=' (empty value), spam won't be quarantined,
|
||||
-- a copy will be delivered to mailbox.
|
||||
--
|
||||
|
||||
INSERT INTO policy (policy_name,
|
||||
spam_lover,
|
||||
virus_lover,
|
||||
banned_files_lover,
|
||||
bad_header_lover,
|
||||
bypass_spam_checks,
|
||||
bypass_virus_checks,
|
||||
bypass_banned_checks,
|
||||
bypass_header_checks,
|
||||
spam_quarantine_to,
|
||||
virus_quarantine_to,
|
||||
banned_quarantine_to,
|
||||
bad_header_quarantine_to)
|
||||
VALUES ('@.',
|
||||
'Y',
|
||||
'N',
|
||||
'N',
|
||||
'Y',
|
||||
'N',
|
||||
'N',
|
||||
'N',
|
||||
'N',
|
||||
'',
|
||||
'virus-quarantine',
|
||||
'banned-quarantine',
|
||||
'');
|
||||
|
||||
INSERT INTO users (priority, email) VALUES (0, '@.');
|
||||
UPDATE users SET policy_id = (SELECT id FROM policy WHERE policy.policy_name='@.' LIMIT 1);
|
||||
@@ -0,0 +1,50 @@
|
||||
connect = host=PH_SQL_SERVER_ADDRESS port=PH_SQL_SERVER_PORT dbname=PH_REALTIME_QUOTA_DB_NAME user=PH_REALTIME_QUOTA_DB_USER password=PH_REALTIME_QUOTA_DB_PASSWORD
|
||||
|
||||
map {
|
||||
pattern = shared/last-login/imap/$user/$domain
|
||||
table = last_login
|
||||
value_field = imap
|
||||
value_type = uint
|
||||
|
||||
fields {
|
||||
username = $user
|
||||
domain = $domain
|
||||
}
|
||||
}
|
||||
|
||||
map {
|
||||
pattern = shared/last-login/pop3/$user/$domain
|
||||
table = last_login
|
||||
value_field = pop3
|
||||
value_type = uint
|
||||
|
||||
fields {
|
||||
username = $user
|
||||
domain = $domain
|
||||
}
|
||||
}
|
||||
|
||||
map {
|
||||
pattern = shared/last-login/lda/$user/$domain
|
||||
table = last_login
|
||||
value_field = lda
|
||||
value_type = uint
|
||||
|
||||
fields {
|
||||
username = $user
|
||||
domain = $domain
|
||||
}
|
||||
}
|
||||
|
||||
# Treat lmtp as lda.
|
||||
map {
|
||||
pattern = shared/last-login/lmtp/$user/$domain
|
||||
table = last_login
|
||||
value_field = lda
|
||||
value_type = uint
|
||||
|
||||
fields {
|
||||
username = $user
|
||||
domain = $domain
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
hosts = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT
|
||||
ldap_version = PH_LDAP_BIND_VERSION
|
||||
auth_bind = yes
|
||||
dn = PH_LDAP_BINDDN
|
||||
dnpass = PH_LDAP_BINDPW
|
||||
base = PH_LDAP_BASEDN
|
||||
scope = subtree
|
||||
deref = never
|
||||
|
||||
# Below two are required by command 'doveadm mailbox ...'
|
||||
#iterate_attrs = mail=user
|
||||
#iterate_filter = (&(objectClass=mailUser)(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail))
|
||||
|
||||
user_filter = (&(objectClass=mailUser)(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)(enabledService=%Ls%Lc)(|(mail=%u)(&(enabledService=shadowaddress)(shadowAddress=%u))))
|
||||
user_attrs = mail=master_user,mail=user,=home=%L{ldap:homeDirectory},=mail=%{ldap:mailboxFormat:maildir}:~/%{ldap:mailboxFolder:Maildir}/,mailQuota=quota_rule=*:bytes=%$
|
||||
|
||||
# Used for dn lookup
|
||||
pass_filter = (&(objectClass=mailUser)(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)(enabledService=%Ls%Lc)(|(mail=%u)(&(enabledService=shadowaddress)(shadowAddress=%u))))
|
||||
pass_attrs = mail=user,userPassword=password,allowNets=allow_nets
|
||||
default_pass_scheme = CRYPT
|
||||
@@ -0,0 +1,22 @@
|
||||
connect = host=PH_SQL_SERVER_ADDRESS port=PH_SQL_SERVER_PORT dbname=PH_DOVECOT_SHARE_FOLDER_DB_NAME user=PH_DOVECOT_SHARE_FOLDER_DB_USER password=PH_DOVECOT_SHARE_FOLDER_DB_PASSWORD
|
||||
map {
|
||||
pattern = shared/shared-boxes/user/$to/$from
|
||||
table = PH_DOVECOT_SHARE_FOLDER_DB_TABLE
|
||||
value_field = dummy
|
||||
|
||||
fields {
|
||||
from_user = $from
|
||||
to_user = $to
|
||||
}
|
||||
}
|
||||
|
||||
# To share mailbox to anyone, please uncomment 'acl_anyone = allow' in
|
||||
# dovecot.conf
|
||||
map {
|
||||
pattern = shared/shared-boxes/anyone/$from
|
||||
table = PH_DOVECOT_SHARE_FOLDER_ANYONE_DB_TABLE
|
||||
value_field = dummy
|
||||
fields {
|
||||
from_user = $from
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
driver = PH_SQL_DRIVER
|
||||
default_pass_scheme = CRYPT
|
||||
connect = host=PH_SQL_SERVER_ADDRESS port=PH_SQL_SERVER_PORT dbname=PH_VMAIL_DB_NAME user=PH_VMAIL_DB_BIND_USER password=PH_VMAIL_DB_BIND_PASSWD
|
||||
|
||||
# Required by doveadm tools which require to list all mail users.
|
||||
iterate_query = SELECT username AS user FROM mailbox
|
||||
|
||||
password_query = SELECT mailbox.password, mailbox.allow_nets \
|
||||
FROM mailbox,domain \
|
||||
WHERE mailbox.username='%u' \
|
||||
AND mailbox.enable%Ls%Lc=1 \
|
||||
AND mailbox.active=1 \
|
||||
AND mailbox.domain=domain.domain \
|
||||
AND domain.backupmx=0 \
|
||||
AND domain.active=1
|
||||
|
||||
user_query = SELECT \
|
||||
LOWER('%u') AS master_user, \
|
||||
LOWER(CONCAT(mailbox.storagebasedirectory, '/', mailbox.storagenode, '/', mailbox.maildir)) AS home, \
|
||||
CONCAT(mailbox.mailboxformat, ':~/', mailbox.mailboxfolder) AS mail, \
|
||||
CONCAT('*:bytes=', mailbox.quota*1048576) AS quota_rule \
|
||||
FROM mailbox,domain \
|
||||
WHERE mailbox.username='%u' \
|
||||
AND mailbox.enable%Ls%Lc=1 \
|
||||
AND mailbox.active=1 \
|
||||
AND mailbox.domain=domain.domain \
|
||||
AND domain.backupmx=0 \
|
||||
AND domain.active=1
|
||||
@@ -0,0 +1,13 @@
|
||||
connect = host=PH_SQL_SERVER_ADDRESS port=PH_SQL_SERVER_PORT dbname=PH_REALTIME_QUOTA_DB_NAME user=PH_REALTIME_QUOTA_DB_USER password=PH_REALTIME_QUOTA_DB_PASSWORD
|
||||
map {
|
||||
pattern = priv/quota/storage
|
||||
table = PH_DOVECOT_REALTIME_QUOTA_TABLE
|
||||
username_field = username
|
||||
value_field = bytes
|
||||
}
|
||||
map {
|
||||
pattern = priv/quota/messages
|
||||
table = PH_DOVECOT_REALTIME_QUOTA_TABLE
|
||||
username_field = username
|
||||
value_field = messages
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
require ["fileinto"];
|
||||
|
||||
# rule:[Move Spam to Junk Folder]
|
||||
if header :is "X-Spam-Flag" "YES"
|
||||
{
|
||||
fileinto "Junk";
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Purpose: Mail to user when his/her quota exceeds specified percentage.
|
||||
# Reference: http://wiki2.dovecot.org/Quota/Configuration#Quota_warnings
|
||||
|
||||
PERCENT=${1}
|
||||
USER=${2}
|
||||
|
||||
# Use "plugin/quota=maildir:User quota:noenforcing" for maildir quota.
|
||||
cat << EOF | PH_DOVECOT_DELIVER_BIN -d ${USER} -o "plugin/quota=dict:User quota::noenforcing:proxy::quotadict"
|
||||
From: no-reply@$(hostname -f)
|
||||
Subject: Warning: Your mailbox is now ${PERCENT}% full.
|
||||
|
||||
Your mailbox is now ${PERCENT}% full, please clean up some mails for further incoming mails.
|
||||
EOF
|
||||
|
||||
# Send a copy to postmaster@ if mailbox is greater than or equal to 95% full.
|
||||
if [ ${PERCENT} -ge 95 ]; then
|
||||
DOMAIN="$(echo ${USER} | awk -F'@' '{print $2}')"
|
||||
cat << EOF | PH_DOVECOT_DELIVER_BIN -d postmaster@${DOMAIN} -o "plugin/quota=dict:User quota::noenforcing:proxy::quotadict"
|
||||
From: no-reply@$(hostname -f)
|
||||
Subject: Mailbox Quota Warning: ${PERCENT}% full, ${USER}
|
||||
|
||||
Mailbox (${USER}) is now ${PERCENT}% full, please clean up some mails for
|
||||
further incoming mails.
|
||||
EOF
|
||||
fi
|
||||
@@ -0,0 +1,506 @@
|
||||
# More details about Dovecot settings:
|
||||
# - http://wiki2.dovecot.org/
|
||||
# - http://wiki2.dovecot.org/Variables
|
||||
|
||||
# Listen addresses.
|
||||
# - '*' means all available IPv4 addresses.
|
||||
# - '[::]' means all available IPv6 addresses.
|
||||
# Listen on all available addresses by default
|
||||
listen = * [::]
|
||||
|
||||
#base_dir = PH_BASE_DIR
|
||||
mail_plugins = quota mailbox_alias acl mail_log notify stats
|
||||
|
||||
# Enabled mail protocols.
|
||||
protocols = PH_PROTOCOLS
|
||||
|
||||
# User/group who owns the message files:
|
||||
mail_uid = PH_MAIL_UID
|
||||
mail_gid = PH_MAIL_GID
|
||||
|
||||
# Assign uid to virtual users.
|
||||
first_valid_uid = PH_FIRST_VALID_UID
|
||||
last_valid_uid = PH_LAST_VALID_UID
|
||||
|
||||
# Logging. Reference: http://wiki2.dovecot.org/Logging
|
||||
#
|
||||
# Use syslog
|
||||
syslog_facility = PH_IREDMAIL_SYSLOG_FACILITY
|
||||
# Log file path if we use internal log system
|
||||
#log_path = PH_LOG_PATH
|
||||
|
||||
# Debug
|
||||
#mail_debug = yes
|
||||
#auth_verbose = yes
|
||||
#auth_debug = yes
|
||||
#auth_debug_passwords = yes
|
||||
# Possible values: no, plain, sha1.
|
||||
#auth_verbose_passwords = no
|
||||
|
||||
# SSL: Global settings.
|
||||
# Refer to wiki site for per protocol, ip, server name SSL settings:
|
||||
# http://wiki.dovecot.org/SSL/DovecotConfiguration
|
||||
ssl_protocols = !SSLv2 !SSLv3 !TLSv1 !TLSv1.1
|
||||
ssl = required
|
||||
verbose_ssl = no
|
||||
#ssl_ca = </path/to/ca
|
||||
ssl_cert = <PH_SSL_CERT
|
||||
ssl_key = <PH_SSL_KEY
|
||||
|
||||
# Fix 'The Logjam Attack'
|
||||
ssl_cipher_list = PH_SSL_CIPHERS
|
||||
ssl_prefer_server_ciphers = yes
|
||||
|
||||
# With disable_plaintext_auth=yes AND ssl=required, STARTTLS is mandatory.
|
||||
# Set disable_plaintext_auth=no AND ssl=yes to allow plain password transmitted
|
||||
# insecurely.
|
||||
disable_plaintext_auth = yes
|
||||
|
||||
# Allow plain text password per IP address/net
|
||||
#remote 192.168.0.0/24 {
|
||||
# disable_plaintext_auth = no
|
||||
#}
|
||||
|
||||
# Mail location and mailbox format.
|
||||
mail_location = maildir:%Lh/Maildir/:INDEX=%Lh/Maildir/
|
||||
|
||||
# Authentication related settings.
|
||||
# Append this domain name if client gives empty realm.
|
||||
#auth_default_realm = PH_AUTH_DEFAULT_REALM
|
||||
|
||||
# Authentication mechanisms.
|
||||
auth_mechanisms = PLAIN LOGIN
|
||||
|
||||
# Limits the number of users that can be logging in at the same time.
|
||||
# Default is 100. This can be overridden by `process_limit =` in
|
||||
# `service [protocol]` block.
|
||||
# e.g.
|
||||
# protocol imap-login {
|
||||
# ...
|
||||
# process_limit = 500
|
||||
# }
|
||||
#default_process_limit = 100
|
||||
|
||||
# Login log elements.
|
||||
# Add '%k' for detailed SSL protocol and cipher information.
|
||||
# e.g. "TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)"
|
||||
login_log_format_elements = user=<%u> method=%m rip=%r lip=%l mpid=%e %c %k session=<%{session}>
|
||||
|
||||
# Mail delivery log format
|
||||
deliver_log_format = from=%{from}, envelope_sender=%{from_envelope}, subject=%{subject}, msgid=%m, size=%{size}, delivery_time=%{delivery_time}ms, %$
|
||||
|
||||
service auth {
|
||||
unix_listener PH_POSTFIX_CHROOT_DIR/private/dovecot-auth {
|
||||
user = PH_DOVECOT_AUTH_USER
|
||||
group = PH_DOVECOT_AUTH_GROUP
|
||||
mode = 0666
|
||||
}
|
||||
unix_listener auth-master {
|
||||
user = PH_AUTH_MASTER_USER
|
||||
group = PH_AUTH_MASTER_GROUP
|
||||
mode = 0666
|
||||
}
|
||||
unix_listener auth-userdb {
|
||||
user = PH_AUTH_MASTER_USER
|
||||
group = PH_AUTH_MASTER_GROUP
|
||||
mode = 0660
|
||||
}
|
||||
}
|
||||
|
||||
# LMTP server (Local Mail Transfer Protocol).
|
||||
# Reference: http://wiki2.dovecot.org/LMTP
|
||||
service lmtp {
|
||||
user = PH_AUTH_MASTER_USER
|
||||
|
||||
# For higher volume sites, it may be desirable to increase the number of
|
||||
# active listener processes. A range of 5 to 20 is probably good for most
|
||||
# sites.
|
||||
process_min_avail = 5
|
||||
|
||||
# Logging.
|
||||
# Require 'log_path =' in 'protocol lmtp {}' block.
|
||||
executable = lmtp -L
|
||||
|
||||
# Listening on socket file and TCP
|
||||
unix_listener PH_POSTFIX_CHROOT_DIR/private/dovecot-lmtp {
|
||||
user = PH_DOVECOT_AUTH_USER
|
||||
group = PH_DOVECOT_AUTH_GROUP
|
||||
mode = 0600
|
||||
}
|
||||
|
||||
inet_listener lmtp {
|
||||
# Listen on localhost (ipv4)
|
||||
address = PH_LMTP_BIND_ADDRESS
|
||||
port = PH_LMTP_BIND_PORT
|
||||
}
|
||||
}
|
||||
|
||||
# Virtual mail accounts.
|
||||
userdb {
|
||||
args = PH_USERDB_ARGS
|
||||
driver = PH_USERDB_DRIVER
|
||||
}
|
||||
passdb {
|
||||
args = PH_PASSDB_ARGS
|
||||
driver = PH_PASSDB_DRIVER
|
||||
}
|
||||
|
||||
# Master user.
|
||||
# Master users are able to log in as other users. It's also possible to
|
||||
# directly log in as any user using a master password, although this isn't
|
||||
# recommended.
|
||||
# Reference: http://wiki2.dovecot.org/Authentication/MasterUsers
|
||||
auth_master_user_separator = *
|
||||
passdb {
|
||||
driver = passwd-file
|
||||
args = PH_DOVECOT_MASTER_USER_PASSWORD_FILE
|
||||
master = yes
|
||||
}
|
||||
|
||||
plugin {
|
||||
# Quota configuration.
|
||||
# Reference: http://wiki2.dovecot.org/Quota/Configuration
|
||||
quota = PH_QUOTA_TYPE
|
||||
|
||||
# Set default quota rule if no quota returned from SQL/LDAP query.
|
||||
#quota_rule = *:storage=1G
|
||||
#quota_rule2 = *:messages=0
|
||||
#quota_rule3 = Trash:storage=1G
|
||||
#quota_rule4 = Junk:ignore
|
||||
|
||||
# Quota warning.
|
||||
#
|
||||
# If user suddenly receives a huge mail and the quota jumps from
|
||||
# 85% to 95%, only the 95% script is executed.
|
||||
#
|
||||
# Only the command for the first exceeded limit is executed, so configure
|
||||
# the highest limit first.
|
||||
quota_warning = storage=100%% quota-warning 100 %u
|
||||
quota_warning2 = storage=95%% quota-warning 95 %u
|
||||
quota_warning3 = storage=90%% quota-warning 90 %u
|
||||
quota_warning4 = storage=85%% quota-warning 85 %u
|
||||
|
||||
# allow user to become max 10% (or 50 MB) over quota
|
||||
quota_grace = 10%%
|
||||
#quota_grace = 50 M
|
||||
|
||||
# Custom Quota Exceeded Message.
|
||||
# You can specify the message directly or read the message from a file.
|
||||
#quota_exceeded_message = Quota exceeded, please try again later.
|
||||
#quota_exceeded_message = </path/to/quota_exceeded_message.txt
|
||||
|
||||
# Used by quota-status service.
|
||||
quota_status_success = DUNNO
|
||||
quota_status_nouser = DUNNO
|
||||
quota_status_overquota = "552 5.2.2 Mailbox is full"
|
||||
|
||||
# Plugin: expire.
|
||||
#expire = Trash 7 Trash/* 7 Junk 30
|
||||
#expire_dict = proxy::expire
|
||||
|
||||
# ACL and share folder
|
||||
acl = vfile
|
||||
acl_shared_dict = proxy::acl
|
||||
|
||||
# By default Dovecot doesn't allow using the IMAP "anyone" or
|
||||
# "authenticated" identifier, because it would be an easy way to spam
|
||||
# other users in the system. If you wish to allow it,
|
||||
#acl_anyone = allow
|
||||
|
||||
# Pigeonhole managesieve service.
|
||||
# Reference: http://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration
|
||||
# Per-user sieve settings.
|
||||
sieve_dir = ~/sieve
|
||||
sieve = ~/sieve/PH_SIEVE_RULE_FILENAME
|
||||
|
||||
# Global sieve settings.
|
||||
sieve_global_dir = PH_SIEVE_DIR
|
||||
# Note: if user has personal sieve script, global sieve rules defined in
|
||||
# sieve_default will be ignored. Please use sieve_before or
|
||||
# sieve_after instead.
|
||||
#sieve_default =
|
||||
|
||||
sieve_before = PH_GLOBAL_SIEVE_FILE
|
||||
#sieve_after =
|
||||
|
||||
# The maximum number of redirect actions that can be performed during a
|
||||
# single script execution.
|
||||
# The meaning of 0 differs based on your version. For pigeonhole-0.3.0 and
|
||||
# beyond this means that redirect is prohibited. For older versions,
|
||||
# however, this means that the number of redirects is unlimited.
|
||||
sieve_max_redirects = 30
|
||||
|
||||
# Use recipient as vacation message sender instead of null sender (<>).
|
||||
sieve_vacation_send_from_recipient = yes
|
||||
|
||||
# Reference: http://wiki2.dovecot.org/Plugins/MailboxAlias
|
||||
mailbox_alias_old = Sent
|
||||
mailbox_alias_new = Sent Messages
|
||||
mailbox_alias_old2 = Sent
|
||||
mailbox_alias_new2 = Sent Items
|
||||
|
||||
# Events to log. `autoexpunge` is included in `expunge`
|
||||
# Defined in https://github.com/dovecot/core/blob/master/src/plugins/mail-log/mail-log-plugin.c
|
||||
mail_log_events = delete undelete expunge copy mailbox_create mailbox_delete mailbox_rename
|
||||
mail_log_fields = uid box msgid size from subject flags
|
||||
|
||||
# stats
|
||||
#
|
||||
# how often to session statistics (must be set)
|
||||
stats_refresh = 30 secs
|
||||
# track per-IMAP command statistics (optional)
|
||||
stats_track_cmds = yes
|
||||
|
||||
# Track user last login
|
||||
last_login_dict = proxy::lastlogin
|
||||
last_login_key = last-login/%s/%u/%d
|
||||
}
|
||||
|
||||
service stats {
|
||||
fifo_listener stats-mail {
|
||||
user = PH_DOVECOT_SERVICE_STATS_USER
|
||||
group = PH_DOVECOT_SERVICE_STATS_GROUP
|
||||
mode = 0644
|
||||
}
|
||||
|
||||
unix_listener stats-writer {
|
||||
user = PH_DOVECOT_SERVICE_STATS_USER
|
||||
group = PH_DOVECOT_SERVICE_STATS_GROUP
|
||||
mode = 0660
|
||||
}
|
||||
|
||||
inet_listener {
|
||||
address = 127.0.0.1
|
||||
port = PH_DOVECOT_SERVICE_STATS_PORT
|
||||
}
|
||||
}
|
||||
|
||||
service quota-warning {
|
||||
executable = script PH_QUOTA_WARNING_SCRIPT
|
||||
unix_listener quota-warning {
|
||||
user = PH_QUOTA_WARNING_USER
|
||||
group = PH_QUOTA_WARNING_GROUP
|
||||
mode = 0660
|
||||
}
|
||||
}
|
||||
|
||||
service quota-status {
|
||||
# '-p <protocol>'. Currently only 'postfix' protocol is supported.
|
||||
executable = quota-status -p postfix
|
||||
client_limit = 1
|
||||
inet_listener {
|
||||
address = PH_DOVECOT_SERVICE_QUOTA_STATUS_BIND_ADDRESS
|
||||
port = PH_DOVECOT_SERVICE_QUOTA_STATUS_PORT
|
||||
}
|
||||
}
|
||||
|
||||
service dict {
|
||||
unix_listener dict {
|
||||
mode = 0660
|
||||
user = PH_SERVICE_DICT_USER
|
||||
group = PH_SERVICE_DICT_GROUP
|
||||
}
|
||||
}
|
||||
|
||||
dict {
|
||||
#expire = db:/var/lib/dovecot/expire/expire.db
|
||||
quotadict = PH_DOVECOT_SQL_DBN:PH_DOVECOT_REALTIME_QUOTA_CONF
|
||||
acl = PH_DOVECOT_SQL_DBN:PH_DOVECOT_SHARE_FOLDER_CONF
|
||||
lastlogin = PH_DOVECOT_SQL_DBN:PH_DOVECOT_LAST_LOGIN_CONF
|
||||
}
|
||||
|
||||
protocol lda {
|
||||
# Reference: http://wiki2.dovecot.org/LDA
|
||||
mail_plugins = $mail_plugins sieve
|
||||
lda_mailbox_autocreate = yes
|
||||
lda_mailbox_autosubscribe = yes
|
||||
|
||||
# Log file path if we use internal log system
|
||||
#log_path = PH_DOVECOT_SIEVE_LOG_FILE
|
||||
}
|
||||
|
||||
protocol lmtp {
|
||||
# Log file path if we use internal log system
|
||||
#log_path = PH_DOVECOT_LMTP_LOG_FILE
|
||||
|
||||
# Plugins
|
||||
mail_plugins = $mail_plugins sieve
|
||||
|
||||
# Address extension delivery
|
||||
lmtp_save_to_detail_mailbox = yes
|
||||
recipient_delimiter = +
|
||||
}
|
||||
|
||||
protocol imap {
|
||||
mail_plugins = $mail_plugins imap_quota imap_acl imap_stats last_login
|
||||
imap_client_workarounds = tb-extra-mailbox-sep
|
||||
|
||||
# Maximum number of IMAP connections allowed for a user from each IP address.
|
||||
# NOTE: The username is compared case-sensitively.
|
||||
# Default is 10.
|
||||
# Increase it to avoid issue like below:
|
||||
# "Maximum number of concurrent IMAP connections exceeded"
|
||||
mail_max_userip_connections = 30
|
||||
}
|
||||
|
||||
protocol pop3 {
|
||||
mail_plugins = $mail_plugins last_login
|
||||
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
|
||||
pop3_uidl_format = %08Xu%08Xv
|
||||
|
||||
# Maximum number of IMAP connections allowed for a user from each IP address.
|
||||
# NOTE: The username is compared case-sensitively.
|
||||
# Default is 10.
|
||||
mail_max_userip_connections = 30
|
||||
|
||||
# POP3 logout format string:
|
||||
# %i - total number of bytes read from client
|
||||
# %o - total number of bytes sent to client
|
||||
# %t - number of TOP commands
|
||||
# %p - number of bytes sent to client as a result of TOP command
|
||||
# %r - number of RETR commands
|
||||
# %b - number of bytes sent to client as a result of RETR command
|
||||
# %d - number of deleted messages
|
||||
# %m - number of messages (before deletion)
|
||||
# %s - mailbox size in bytes (before deletion)
|
||||
# Default format doesn't have 'in=%i, out=%o'.
|
||||
#pop3_logout_format = top=%t/%p, retr=%r/%b, del=%d/%m, size=%s, in=%i, out=%o
|
||||
}
|
||||
|
||||
# Login processes. Refer to Dovecot wiki for more details:
|
||||
# http://wiki2.dovecot.org/LoginProcess
|
||||
service imap-login {
|
||||
#inet_listener imap {
|
||||
# port = 143
|
||||
#}
|
||||
#inet_listener imaps {
|
||||
# port = 993
|
||||
# ssl = yes
|
||||
#}
|
||||
|
||||
service_count = 1
|
||||
|
||||
# To avoid startup latency for new client connections, set process_min_avail
|
||||
# to higher than zero. That many idling processes are always kept around
|
||||
# waiting for new connections.
|
||||
#process_min_avail = 0
|
||||
|
||||
# number of simultaneous IMAP connections
|
||||
process_limit = 500
|
||||
|
||||
# vsz_limit should be fine at its default 64MB value
|
||||
#vsz_limit = 64M
|
||||
}
|
||||
|
||||
service pop3-login {
|
||||
#inet_listener pop3 {
|
||||
# port = 110
|
||||
#}
|
||||
#inet_listener pop3s {
|
||||
# port = 995
|
||||
# ssl = yes
|
||||
#}
|
||||
|
||||
service_count = 1
|
||||
|
||||
# number of simultaneous POP3 connections
|
||||
#process_limit = 500
|
||||
}
|
||||
|
||||
service managesieve-login {
|
||||
inet_listener sieve {
|
||||
# Listen on localhost (ipv4)
|
||||
address = PH_MANAGESIEVE_BIND_HOST
|
||||
port = PH_MANAGESIEVE_BIND_PORT
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
type = private
|
||||
separator = /
|
||||
prefix =
|
||||
inbox = yes
|
||||
|
||||
# Refer to document for more details about alias mailbox:
|
||||
# http://wiki2.dovecot.org/MailboxSettings
|
||||
#
|
||||
# Sent
|
||||
mailbox Sent {
|
||||
auto = subscribe
|
||||
special_use = \Sent
|
||||
}
|
||||
mailbox "Sent Messages" {
|
||||
auto = no
|
||||
special_use = \Sent
|
||||
}
|
||||
mailbox "Sent Items" {
|
||||
auto = no
|
||||
special_use = \Sent
|
||||
}
|
||||
|
||||
mailbox Drafts {
|
||||
auto = subscribe
|
||||
special_use = \Drafts
|
||||
}
|
||||
|
||||
# Trash
|
||||
mailbox Trash {
|
||||
auto = subscribe
|
||||
special_use = \Trash
|
||||
}
|
||||
|
||||
mailbox "Deleted Messages" {
|
||||
auto = no
|
||||
special_use = \Trash
|
||||
}
|
||||
|
||||
# Junk
|
||||
mailbox Junk {
|
||||
auto = subscribe
|
||||
special_use = \Junk
|
||||
}
|
||||
mailbox Spam {
|
||||
auto = no
|
||||
special_use = \Junk
|
||||
}
|
||||
mailbox "Junk E-mail" {
|
||||
auto = no
|
||||
special_use = \Junk
|
||||
}
|
||||
|
||||
# Archive
|
||||
mailbox Archive {
|
||||
auto = no
|
||||
special_use = \Archive
|
||||
}
|
||||
mailbox Archives {
|
||||
auto = no
|
||||
special_use = \Archive
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
type = shared
|
||||
separator = /
|
||||
prefix = Shared/%%u/
|
||||
location = maildir:%%Lh/Maildir/:INDEX=%%Lh/Maildir/Shared/%%Ld/%%Ln
|
||||
|
||||
# this namespace should handle its own subscriptions or not.
|
||||
subscriptions = yes
|
||||
list = children
|
||||
}
|
||||
|
||||
# Public mailboxes.
|
||||
# Refer to Dovecot wiki page for more details:
|
||||
# http://wiki2.dovecot.org/SharedMailboxes/Public
|
||||
#namespace {
|
||||
# type = public
|
||||
# separator = /
|
||||
# prefix = Public/
|
||||
# location = maildir:PH_PUBLIC_MAILBOX_DIR:CONTROL=%Lh/Maildir/public:INDEXPVT=%Lh/Maildir/public
|
||||
#
|
||||
# # Allow users to subscribe to the public folders.
|
||||
# subscriptions = yes
|
||||
#}
|
||||
|
||||
!include_try PH_DOVECOT_CONF_INCLUDE_DIR/*.conf
|
||||
@@ -0,0 +1,496 @@
|
||||
# More details about Dovecot settings:
|
||||
# - http://wiki2.dovecot.org/
|
||||
# - http://wiki2.dovecot.org/Variables
|
||||
|
||||
# Listen addresses.
|
||||
# - '*' means all available IPv4 addresses.
|
||||
# - '[::]' means all available IPv6 addresses.
|
||||
# Listen on all available addresses by default
|
||||
listen = * [::]
|
||||
|
||||
#base_dir = PH_BASE_DIR
|
||||
mail_plugins = quota mailbox_alias acl mail_log notify
|
||||
|
||||
# Enabled mail protocols.
|
||||
protocols = PH_PROTOCOLS
|
||||
|
||||
# User/group who owns the message files:
|
||||
mail_uid = PH_MAIL_UID
|
||||
mail_gid = PH_MAIL_GID
|
||||
|
||||
# Assign uid to virtual users.
|
||||
first_valid_uid = PH_FIRST_VALID_UID
|
||||
last_valid_uid = PH_LAST_VALID_UID
|
||||
|
||||
# Logging. Reference: http://wiki2.dovecot.org/Logging
|
||||
#
|
||||
# Use syslog
|
||||
syslog_facility = PH_IREDMAIL_SYSLOG_FACILITY
|
||||
# Log file path if we use internal log system
|
||||
#log_path = PH_LOG_PATH
|
||||
|
||||
# Debug
|
||||
#mail_debug = yes
|
||||
#auth_verbose = yes
|
||||
#auth_debug = yes
|
||||
#auth_debug_passwords = yes
|
||||
# Possible values: no, plain, sha1.
|
||||
#auth_verbose_passwords = no
|
||||
|
||||
# SSL: Global settings.
|
||||
# Refer to wiki site for per protocol, ip, server name SSL settings:
|
||||
# http://wiki2.dovecot.org/SSL/DovecotConfiguration
|
||||
ssl_min_protocol = TLSv1.2
|
||||
ssl = required
|
||||
verbose_ssl = no
|
||||
#ssl_ca = </path/to/ca
|
||||
ssl_cert = <PH_SSL_CERT
|
||||
ssl_key = <PH_SSL_KEY
|
||||
ssl_dh = <PH_SSL_DH1024_PARAM_FILE
|
||||
|
||||
# Fix 'The Logjam Attack'
|
||||
ssl_cipher_list = PH_SSL_CIPHERS
|
||||
ssl_prefer_server_ciphers = yes
|
||||
|
||||
# With disable_plaintext_auth=yes AND ssl=required, STARTTLS is mandatory.
|
||||
# Set disable_plaintext_auth=no AND ssl=yes to allow plain password transmitted
|
||||
# insecurely.
|
||||
disable_plaintext_auth = yes
|
||||
|
||||
# Allow plain text password per IP address/net
|
||||
#remote 192.168.0.0/24 {
|
||||
# disable_plaintext_auth = no
|
||||
#}
|
||||
|
||||
# Mail location and mailbox format.
|
||||
mail_location = maildir:%Lh/Maildir/:INDEX=%Lh/Maildir/
|
||||
|
||||
# Authentication related settings.
|
||||
# Append this domain name if client gives empty realm.
|
||||
#auth_default_realm = PH_AUTH_DEFAULT_REALM
|
||||
|
||||
# Authentication mechanisms.
|
||||
auth_mechanisms = PLAIN LOGIN
|
||||
|
||||
# Limits the number of users that can be logging in at the same time.
|
||||
# Default is 100. This can be overridden by `process_limit =` in
|
||||
# `service [protocol]` block.
|
||||
# e.g.
|
||||
# protocol imap-login {
|
||||
# ...
|
||||
# process_limit = 500
|
||||
# }
|
||||
#default_process_limit = 100
|
||||
|
||||
# Login log elements.
|
||||
# Add '%k' for detailed SSL protocol and cipher information.
|
||||
# e.g. "TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)"
|
||||
login_log_format_elements = user=<%u> method=%m rip=%r lip=%l mpid=%e %c %k session=<%{session}>
|
||||
|
||||
# Mail delivery log format
|
||||
deliver_log_format = from=%{from}, envelope_sender=%{from_envelope}, subject=%{subject}, msgid=%m, size=%{size}, delivery_time=%{delivery_time}ms, %$
|
||||
|
||||
service auth {
|
||||
unix_listener PH_POSTFIX_CHROOT_DIR/private/dovecot-auth {
|
||||
user = PH_DOVECOT_AUTH_USER
|
||||
group = PH_DOVECOT_AUTH_GROUP
|
||||
mode = 0666
|
||||
}
|
||||
unix_listener auth-master {
|
||||
user = PH_AUTH_MASTER_USER
|
||||
group = PH_AUTH_MASTER_GROUP
|
||||
mode = 0666
|
||||
}
|
||||
unix_listener auth-userdb {
|
||||
user = PH_AUTH_MASTER_USER
|
||||
group = PH_AUTH_MASTER_GROUP
|
||||
mode = 0660
|
||||
}
|
||||
}
|
||||
|
||||
# LMTP server (Local Mail Transfer Protocol).
|
||||
# Reference: http://wiki2.dovecot.org/LMTP
|
||||
service lmtp {
|
||||
user = PH_AUTH_MASTER_USER
|
||||
|
||||
# For higher volume sites, it may be desirable to increase the number of
|
||||
# active listener processes. A range of 5 to 20 is probably good for most
|
||||
# sites.
|
||||
process_min_avail = 5
|
||||
|
||||
# Logging.
|
||||
# Require 'log_path =' in 'protocol lmtp {}' block.
|
||||
executable = lmtp -L
|
||||
|
||||
# Listening on socket file and TCP
|
||||
unix_listener PH_POSTFIX_CHROOT_DIR/private/dovecot-lmtp {
|
||||
user = PH_DOVECOT_AUTH_USER
|
||||
group = PH_DOVECOT_AUTH_GROUP
|
||||
mode = 0600
|
||||
}
|
||||
|
||||
inet_listener lmtp {
|
||||
# Listen on localhost (ipv4)
|
||||
address = PH_LMTP_BIND_ADDRESS
|
||||
port = PH_LMTP_BIND_PORT
|
||||
}
|
||||
}
|
||||
|
||||
# Virtual mail accounts.
|
||||
userdb {
|
||||
args = PH_USERDB_ARGS
|
||||
driver = PH_USERDB_DRIVER
|
||||
}
|
||||
passdb {
|
||||
args = PH_PASSDB_ARGS
|
||||
driver = PH_PASSDB_DRIVER
|
||||
}
|
||||
|
||||
# Master user.
|
||||
# Master users are able to log in as other users. It's also possible to
|
||||
# directly log in as any user using a master password, although this isn't
|
||||
# recommended.
|
||||
# Reference: http://wiki2.dovecot.org/Authentication/MasterUsers
|
||||
auth_master_user_separator = *
|
||||
passdb {
|
||||
driver = passwd-file
|
||||
args = PH_DOVECOT_MASTER_USER_PASSWORD_FILE
|
||||
master = yes
|
||||
}
|
||||
|
||||
plugin {
|
||||
# Quota configuration.
|
||||
# Reference: http://wiki2.dovecot.org/Quota/Configuration
|
||||
quota = PH_QUOTA_TYPE
|
||||
|
||||
# Set default quota rule if no quota returned from SQL/LDAP query.
|
||||
#quota_rule = *:storage=1G
|
||||
#quota_rule2 = *:messages=0
|
||||
#quota_rule3 = Trash:storage=1G
|
||||
#quota_rule4 = Junk:ignore
|
||||
|
||||
# Quota warning.
|
||||
#
|
||||
# If user suddenly receives a huge mail and the quota jumps from
|
||||
# 85% to 95%, only the 95% script is executed.
|
||||
#
|
||||
# Only the command for the first exceeded limit is executed, so configure
|
||||
# the highest limit first.
|
||||
quota_warning = storage=100%% quota-warning 100 %u
|
||||
quota_warning2 = storage=95%% quota-warning 95 %u
|
||||
quota_warning3 = storage=90%% quota-warning 90 %u
|
||||
quota_warning4 = storage=85%% quota-warning 85 %u
|
||||
|
||||
# allow user to become max 10% (or 50 MB) over quota
|
||||
quota_grace = 10%%
|
||||
#quota_grace = 50 M
|
||||
|
||||
# Custom Quota Exceeded Message.
|
||||
# You can specify the message directly or read the message from a file.
|
||||
#quota_exceeded_message = Quota exceeded, please try again later.
|
||||
#quota_exceeded_message = </path/to/quota_exceeded_message.txt
|
||||
|
||||
# Used by quota-status service.
|
||||
quota_status_success = DUNNO
|
||||
quota_status_nouser = DUNNO
|
||||
quota_status_overquota = "552 5.2.2 Mailbox is full"
|
||||
|
||||
# Plugin: expire.
|
||||
#expire = Trash 7 Trash/* 7 Junk 30
|
||||
#expire_dict = proxy::expire
|
||||
|
||||
# ACL and share folder
|
||||
acl = vfile
|
||||
acl_shared_dict = proxy::acl
|
||||
|
||||
# By default Dovecot doesn't allow using the IMAP "anyone" or
|
||||
# "authenticated" identifier, because it would be an easy way to spam
|
||||
# other users in the system. If you wish to allow it,
|
||||
#acl_anyone = allow
|
||||
|
||||
# Pigeonhole managesieve service.
|
||||
# Reference: http://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration
|
||||
# Per-user sieve settings.
|
||||
sieve_dir = ~/sieve
|
||||
sieve = ~/sieve/PH_SIEVE_RULE_FILENAME
|
||||
|
||||
# Global sieve settings.
|
||||
sieve_global_dir = PH_SIEVE_DIR
|
||||
# Note: if user has personal sieve script, global sieve rules defined in
|
||||
# sieve_default will be ignored. Please use sieve_before or
|
||||
# sieve_after instead.
|
||||
#sieve_default =
|
||||
|
||||
sieve_before = PH_GLOBAL_SIEVE_FILE
|
||||
#sieve_after =
|
||||
|
||||
# The maximum number of redirect actions that can be performed during a
|
||||
# single script execution.
|
||||
# The meaning of 0 differs based on your version. For pigeonhole-0.3.0 and
|
||||
# beyond this means that redirect is prohibited. For older versions,
|
||||
# however, this means that the number of redirects is unlimited.
|
||||
sieve_max_redirects = 30
|
||||
|
||||
# Use recipient as vacation message sender instead of null sender (<>).
|
||||
sieve_vacation_send_from_recipient = yes
|
||||
|
||||
# Reference: http://wiki2.dovecot.org/Plugins/MailboxAlias
|
||||
mailbox_alias_old = Sent
|
||||
mailbox_alias_new = Sent Messages
|
||||
mailbox_alias_old2 = Sent
|
||||
mailbox_alias_new2 = Sent Items
|
||||
|
||||
# Events to log. `autoexpunge` is included in `expunge`
|
||||
# Defined in https://github.com/dovecot/core/blob/master/src/plugins/mail-log/mail-log-plugin.c
|
||||
mail_log_events = delete undelete expunge copy mailbox_create mailbox_delete mailbox_rename
|
||||
mail_log_fields = uid box msgid size from subject flags
|
||||
|
||||
# Track user last login
|
||||
last_login_dict = proxy::lastlogin
|
||||
last_login_key = last-login/%s/%u/%d
|
||||
}
|
||||
|
||||
service stats {
|
||||
fifo_listener stats-mail {
|
||||
user = PH_DOVECOT_SERVICE_STATS_USER
|
||||
mode = 0644
|
||||
}
|
||||
|
||||
unix_listener stats-writer {
|
||||
user = PH_DOVECOT_SERVICE_STATS_USER
|
||||
group = PH_DOVECOT_SERVICE_STATS_GROUP
|
||||
mode = 0660
|
||||
}
|
||||
|
||||
inet_listener {
|
||||
address = 127.0.0.1
|
||||
port = PH_DOVECOT_SERVICE_STATS_PORT
|
||||
}
|
||||
}
|
||||
|
||||
service quota-warning {
|
||||
executable = script PH_QUOTA_WARNING_SCRIPT
|
||||
unix_listener quota-warning {
|
||||
user = PH_QUOTA_WARNING_USER
|
||||
group = PH_QUOTA_WARNING_GROUP
|
||||
mode = 0660
|
||||
}
|
||||
}
|
||||
|
||||
service quota-status {
|
||||
# '-p <protocol>'. Currently only 'postfix' protocol is supported.
|
||||
executable = quota-status -p postfix
|
||||
client_limit = 1
|
||||
inet_listener {
|
||||
address = PH_DOVECOT_SERVICE_QUOTA_STATUS_BIND_ADDRESS
|
||||
port = PH_DOVECOT_SERVICE_QUOTA_STATUS_PORT
|
||||
}
|
||||
}
|
||||
|
||||
service dict {
|
||||
unix_listener dict {
|
||||
mode = 0660
|
||||
user = PH_SERVICE_DICT_USER
|
||||
group = PH_SERVICE_DICT_GROUP
|
||||
}
|
||||
}
|
||||
|
||||
dict {
|
||||
#expire = db:/var/lib/dovecot/expire/expire.db
|
||||
quotadict = PH_DOVECOT_SQL_DBN:PH_DOVECOT_REALTIME_QUOTA_CONF
|
||||
acl = PH_DOVECOT_SQL_DBN:PH_DOVECOT_SHARE_FOLDER_CONF
|
||||
lastlogin = PH_DOVECOT_SQL_DBN:PH_DOVECOT_LAST_LOGIN_CONF
|
||||
}
|
||||
|
||||
protocol lda {
|
||||
mail_plugins = $mail_plugins sieve
|
||||
lda_mailbox_autocreate = yes
|
||||
lda_mailbox_autosubscribe = yes
|
||||
}
|
||||
|
||||
protocol lmtp {
|
||||
# Plugins
|
||||
mail_plugins = $mail_plugins sieve
|
||||
|
||||
# Address extension delivery
|
||||
lmtp_save_to_detail_mailbox = yes
|
||||
recipient_delimiter = +
|
||||
}
|
||||
|
||||
protocol imap {
|
||||
mail_plugins = $mail_plugins imap_quota imap_acl last_login
|
||||
imap_client_workarounds = tb-extra-mailbox-sep
|
||||
|
||||
# Maximum number of IMAP connections allowed for a user from each IP address.
|
||||
# NOTE: The username is compared case-sensitively.
|
||||
# Default is 10.
|
||||
# Increase it to avoid issue like below:
|
||||
# "Maximum number of concurrent IMAP connections exceeded"
|
||||
mail_max_userip_connections = 30
|
||||
}
|
||||
|
||||
protocol pop3 {
|
||||
mail_plugins = $mail_plugins last_login
|
||||
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
|
||||
pop3_uidl_format = %08Xu%08Xv
|
||||
|
||||
# Maximum number of IMAP connections allowed for a user from each IP address.
|
||||
# NOTE: The username is compared case-sensitively.
|
||||
# Default is 10.
|
||||
mail_max_userip_connections = 30
|
||||
|
||||
# POP3 logout format string:
|
||||
# %i - total number of bytes read from client
|
||||
# %o - total number of bytes sent to client
|
||||
# %t - number of TOP commands
|
||||
# %p - number of bytes sent to client as a result of TOP command
|
||||
# %r - number of RETR commands
|
||||
# %b - number of bytes sent to client as a result of RETR command
|
||||
# %d - number of deleted messages
|
||||
# %m - number of messages (before deletion)
|
||||
# %s - mailbox size in bytes (before deletion)
|
||||
# Default format doesn't have 'in=%i, out=%o'.
|
||||
#pop3_logout_format = top=%t/%p, retr=%r/%b, del=%d/%m, size=%s, in=%i, out=%o
|
||||
}
|
||||
|
||||
# Login processes. Refer to Dovecot wiki for more details:
|
||||
# http://wiki2.dovecot.org/LoginProcess
|
||||
service imap-login {
|
||||
#inet_listener imap {
|
||||
# port = 143
|
||||
#}
|
||||
#inet_listener imaps {
|
||||
# port = 993
|
||||
# ssl = yes
|
||||
#}
|
||||
|
||||
service_count = 1
|
||||
|
||||
# To avoid startup latency for new client connections, set process_min_avail
|
||||
# to higher than zero. That many idling processes are always kept around
|
||||
# waiting for new connections.
|
||||
#process_min_avail = 0
|
||||
|
||||
# number of simultaneous IMAP connections
|
||||
process_limit = 500
|
||||
|
||||
# vsz_limit should be fine at its default 64MB value
|
||||
#vsz_limit = 64M
|
||||
}
|
||||
|
||||
service pop3-login {
|
||||
#inet_listener pop3 {
|
||||
# port = 110
|
||||
#}
|
||||
#inet_listener pop3s {
|
||||
# port = 995
|
||||
# ssl = yes
|
||||
#}
|
||||
|
||||
service_count = 1
|
||||
|
||||
# number of simultaneous POP3 connections
|
||||
#process_limit = 500
|
||||
}
|
||||
|
||||
service managesieve-login {
|
||||
inet_listener sieve {
|
||||
# Listen on localhost (ipv4)
|
||||
address = PH_MANAGESIEVE_BIND_HOST
|
||||
port = PH_MANAGESIEVE_BIND_PORT
|
||||
}
|
||||
}
|
||||
|
||||
metric imap_command_finished {
|
||||
event_name = imap_command_finished
|
||||
}
|
||||
|
||||
namespace {
|
||||
type = private
|
||||
separator = /
|
||||
prefix =
|
||||
inbox = yes
|
||||
|
||||
# Refer to document for more details about alias mailbox:
|
||||
# http://wiki2.dovecot.org/MailboxSettings
|
||||
#
|
||||
# Sent
|
||||
mailbox Sent {
|
||||
auto = subscribe
|
||||
special_use = \Sent
|
||||
}
|
||||
mailbox "Sent Messages" {
|
||||
auto = no
|
||||
special_use = \Sent
|
||||
}
|
||||
mailbox "Sent Items" {
|
||||
auto = no
|
||||
special_use = \Sent
|
||||
}
|
||||
|
||||
mailbox Drafts {
|
||||
auto = subscribe
|
||||
special_use = \Drafts
|
||||
}
|
||||
|
||||
# Trash
|
||||
mailbox Trash {
|
||||
auto = subscribe
|
||||
special_use = \Trash
|
||||
}
|
||||
|
||||
mailbox "Deleted Messages" {
|
||||
auto = no
|
||||
special_use = \Trash
|
||||
}
|
||||
|
||||
# Junk
|
||||
mailbox Junk {
|
||||
auto = subscribe
|
||||
special_use = \Junk
|
||||
}
|
||||
mailbox Spam {
|
||||
auto = no
|
||||
special_use = \Junk
|
||||
}
|
||||
mailbox "Junk E-mail" {
|
||||
auto = no
|
||||
special_use = \Junk
|
||||
}
|
||||
|
||||
# Archive
|
||||
mailbox Archive {
|
||||
auto = no
|
||||
special_use = \Archive
|
||||
}
|
||||
mailbox Archives {
|
||||
auto = no
|
||||
special_use = \Archive
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
type = shared
|
||||
separator = /
|
||||
prefix = Shared/%%u/
|
||||
location = maildir:%%Lh/Maildir/:INDEX=%%Lh/Maildir/Shared/%%Ld/%%Ln
|
||||
|
||||
# this namespace should handle its own subscriptions or not.
|
||||
subscriptions = yes
|
||||
list = children
|
||||
}
|
||||
|
||||
# Public mailboxes.
|
||||
# Refer to Dovecot wiki page for more details:
|
||||
# http://wiki2.dovecot.org/SharedMailboxes/Public
|
||||
#namespace {
|
||||
# type = public
|
||||
# separator = /
|
||||
# prefix = Public/
|
||||
# location = maildir:PH_PUBLIC_MAILBOX_DIR:CONTROL=%Lh/Maildir/public:INDEXPVT=%Lh/Maildir/public
|
||||
#
|
||||
# # Allow users to subscribe to the public folders.
|
||||
# subscriptions = yes
|
||||
#}
|
||||
|
||||
!include_try PH_DOVECOT_CONF_INCLUDE_DIR/*.conf
|
||||
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# IMAP shared folders. User 'from_user' shares folders to user 'to_user'.
|
||||
# WARNING: Works only with Dovecot 1.2+.
|
||||
#
|
||||
CREATE TABLE IF NOT EXISTS share_folder (
|
||||
from_user VARCHAR(150) NOT NULL,
|
||||
to_user VARCHAR(150) NOT NULL,
|
||||
dummy CHAR(1),
|
||||
PRIMARY KEY (from_user, to_user)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS anyone_shares (
|
||||
from_user VARCHAR(255) NOT NULL,
|
||||
dummy CHAR(1) DEFAULT '1',
|
||||
PRIMARY KEY (from_user)
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS `last_login` (
|
||||
`username` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`domain` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`imap` INT(11) DEFAULT NULL,
|
||||
`pop3` INT(11) DEFAULT NULL,
|
||||
`lda` INT(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`username`),
|
||||
INDEX (`domain`),
|
||||
INDEX (`imap`),
|
||||
INDEX (`pop3`),
|
||||
INDEX (`lda`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,26 @@
|
||||
-- used_quota
|
||||
-- Used to store realtime mailbox quota in Dovecot.
|
||||
-- WARNING: Works only with Dovecot 1.2+.
|
||||
--
|
||||
-- Note: Don't touch this table, it will be updated by Dovecot automatically.
|
||||
CREATE TABLE IF NOT EXISTS `used_quota` (
|
||||
`username` VARCHAR(255) NOT NULL,
|
||||
`bytes` BIGINT NOT NULL DEFAULT 0,
|
||||
`messages` BIGINT NOT NULL DEFAULT 0,
|
||||
`domain` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`username`),
|
||||
INDEX (domain)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Trigger `used_quota_before_insert` is used to set `used_quota.domain`.
|
||||
-- NOTE: `used_quota.domain` is not used by Dovecot, but used in iRedAdmin to
|
||||
-- get better SQL query performance while calculating per-domain used
|
||||
-- quota.
|
||||
DELIMITER //
|
||||
CREATE TRIGGER `used_quota_before_insert`
|
||||
BEFORE INSERT ON `used_quota` FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.domain = SUBSTRING_INDEX(NEW.username, '@', -1);
|
||||
END;
|
||||
//
|
||||
DELIMITER ;
|
||||
@@ -0,0 +1,3 @@
|
||||
[Service]
|
||||
ProtectSystem=false
|
||||
#ProtectHome=false
|
||||
@@ -0,0 +1,10 @@
|
||||
# - Store banned IP in SQL db while it's banned.
|
||||
# - Remove banned IP from SQL db while it's unbanned.
|
||||
|
||||
[Definition]
|
||||
actionstart =
|
||||
actioncheck =
|
||||
|
||||
actionban = /usr/local/bin/fail2ban_banned_db ban <ip> <port> <protocol> <name> <ipjailfailures> <ipjailmatches>
|
||||
actionunban = /usr/local/bin/fail2ban_banned_db unban <ip>
|
||||
actionstop = /usr/local/bin/fail2ban_banned_db cleanup <name>
|
||||
@@ -0,0 +1,236 @@
|
||||
#!/usr/bin/env bash
|
||||
# Author: Zhang Huangbin <zhb@iredmail.org>
|
||||
# Puprpose:
|
||||
# - Store banned IP address in SQL db while it's banned by Fail2ban.
|
||||
# - Remove unbanned IP address from SQL db while it's unbanned by Fail2ban.
|
||||
# - Unban IP addresses which have column `remove=1`.
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# *) Store a banned IP address:
|
||||
#
|
||||
# banned_db ban <ip> <ports> <protocol> <jail> <failures> [loglines]
|
||||
#
|
||||
# - <ip>: One IP address each time.
|
||||
# - <ports>: Network ports. Multiple ports must be separated by comma.
|
||||
# - <protocol>: `tcp` or `udp`.
|
||||
# - <jail>: Fail2ban jail name.
|
||||
# - <failures>: number of times the failure occurred in the log file.
|
||||
# - [loglines]: matched log lines. OPTIONAL.
|
||||
#
|
||||
# *) Remove an one or multiple unbanned IP addresses. Notes:
|
||||
#
|
||||
# - it removes IP from all jails.
|
||||
# - multiple IP addresses must be separated by space.
|
||||
#
|
||||
# banned_db unban <ip> [ip] [ip]
|
||||
#
|
||||
# *) Cleanup a jail. When Fail2ban is stopping or restarting, `cleanup` will
|
||||
# be executed. Cleanup manually is supported too:
|
||||
#
|
||||
# banned_db cleanup <jail>
|
||||
#
|
||||
# *) Query SQL db and remove IP addresses which have `remove=1`.
|
||||
#
|
||||
# banned_db unban_db
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# banned_db ban 192.168.0.1 110,143,993,995 tcp dovecot-iredmail 3
|
||||
# banned_db unban 192.168.0.1
|
||||
# banned_db cleanup dovecot-iredmail
|
||||
# banned_db unban_db
|
||||
|
||||
#
|
||||
# Sample Fail2ban jail config file (/etc/fail2ban/jail.d/xx.local):
|
||||
#
|
||||
# [jail-name]
|
||||
# ...
|
||||
# action = ...[your other actions here]...
|
||||
# banned_db[name=jail-name, port="80", protocol=tcp]
|
||||
#
|
||||
# WARNING: the name set in `banned_db[name=]` must be same as the jail name.
|
||||
|
||||
export PATH="/usr/bin:/usr/local/bin:$PATH"
|
||||
|
||||
export DB_NAME="fail2ban"
|
||||
export DB_TABLE="banned"
|
||||
export DB_USER="fail2ban"
|
||||
|
||||
# GeoIP
|
||||
export CMD_GEOIPLOOKUP="$(which geoiplookup 2>/dev/null)"
|
||||
export CMD_GEOIPLOOKUP6="$(which geoiplookup6 2>/dev/null)"
|
||||
|
||||
# `dig`. Used to query reverse hostname.
|
||||
export CMD_DIG="/usr/bin/dig"
|
||||
|
||||
if [ -f /root/.my.cnf-fail2ban ]; then
|
||||
export CMD_SQL="mysql --defaults-file=/root/.my.cnf-fail2ban ${DB_NAME}"
|
||||
export DB_TYPE="mysql"
|
||||
elif [ -f /root/.my.cnf ]; then
|
||||
export CMD_SQL="mysql --defaults-file=/root/.my.cnf ${DB_NAME}"
|
||||
export DB_TYPE="mysql"
|
||||
else
|
||||
# Absolute path to ~/.pgpass
|
||||
# - RHEL: /var/lib/pgsql/.pgpass
|
||||
# - Debian/Ubuntu: /var/lib/postgresql/.pgpass
|
||||
# - FreeBSD: /var/db/postgres/.pgpass
|
||||
# - OpenBSD: /var/postgresql/.pgpass
|
||||
for dir in \
|
||||
/var/lib/pgsql \
|
||||
/var/lib/postgresql \
|
||||
/var/db/postgres \
|
||||
/var/postgresql; do
|
||||
if [ -f ${dir}/.pgpass ]; then
|
||||
export PGPASSFILE="${dir}/.pgpass"
|
||||
export CMD_SQL="psql -U ${DB_USER} -d ${DB_NAME}"
|
||||
export DB_TYPE="pgsql"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ X"${CMD_SQL}" == X'' ]; then
|
||||
echo "No MySQL or PostgreSQL related config file found. Abort."
|
||||
echo " - MySQL: /root/.my.cnf-fail2ban (or /root/.my.cnf)"
|
||||
echo " - PostgreSQL: ~/.pgpass (under PostgreSQL daemon user's home directory)"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
export _action="$1"
|
||||
|
||||
if [[ X"${_action}" == X"ban" ]]; then
|
||||
_ip="${2}"
|
||||
_ports="${3}"
|
||||
_protocol="${4}"
|
||||
_jail="${5}"
|
||||
_failures="${6}"
|
||||
|
||||
shift 6
|
||||
_rest="$@"
|
||||
# Avoid SQL injection.
|
||||
printf -v _loglines "${_rest}"
|
||||
|
||||
if [[ X"${_ip}" == X'' ]] || \
|
||||
[[ X"${_ports}" == X'' ]] || \
|
||||
[[ X"${_protocol}" == X'' ]] || \
|
||||
[[ X"${_jail}" == X'' ]]; then
|
||||
echo "IP, ports, protocol, or jail name is empty. Abort."
|
||||
exit 255
|
||||
fi
|
||||
|
||||
_hostname="$(hostname)"
|
||||
|
||||
# Lookup for country name.
|
||||
_country=''
|
||||
if echo ${_ip} | grep ':' &>/dev/null; then
|
||||
if [[ -x ${CMD_GEOIPLOOKUP6} ]]; then
|
||||
_country="$(${CMD_GEOIPLOOKUP6} ${_ip} | grep '^GeoIP Country Edition:' | awk -F': ' '{print $2}' | grep -iv 'not found')"
|
||||
fi
|
||||
else
|
||||
if [[ -x ${CMD_GEOIPLOOKUP} ]]; then
|
||||
_country="$(${CMD_GEOIPLOOKUP} ${_ip} | grep '^GeoIP Country Edition:' | awk -F': ' '{print $2}' | grep -iv 'not found')"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Lookup reverse DNS name.
|
||||
_rdns=''
|
||||
if [[ -x "${CMD_DIG}" ]]; then
|
||||
_rdns_orig="$(${CMD_DIG} +short +timeout=3 -x ${_ip} 2>/dev/null)"
|
||||
_rdns_strip="${_rdns_orig%\.}"
|
||||
printf -v _rdns "${_rdns_strip}"
|
||||
fi
|
||||
|
||||
if [ X"${DB_TYPE}" == X'mysql' ]; then
|
||||
# MySQL stores local time with time zone info, we expect UTC time.
|
||||
${CMD_SQL} <<EOF
|
||||
INSERT IGNORE INTO ${DB_TABLE} (
|
||||
ip, ports, protocol, jail,
|
||||
hostname, country, rdns, timestamp,
|
||||
failures, loglines)
|
||||
VALUES (
|
||||
'${_ip}', '${_ports}', '${_protocol}', '${_jail}',
|
||||
'${_hostname}', '${_country}', '${_rdns}', UTC_TIMESTAMP(),
|
||||
'${_failures}', '${_loglines}');
|
||||
EOF
|
||||
else
|
||||
# CentOS 7 ships PostgreSQL-9.2 which doesn't support `ON CONFLICT DO NOTHING`,
|
||||
# so we query it first, insert it if not existing.
|
||||
(${CMD_SQL} <<EOF
|
||||
SELECT id FROM ${DB_TABLE} WHERE ip='${_ip}' AND ports='${_ports}' AND protocol='${_protocol}' AND jail='${_jail}' LIMIT 1;
|
||||
EOF
|
||||
) | grep '1 row' &>/dev/null
|
||||
|
||||
if [[ X"$?" == X'0' ]]; then
|
||||
echo "Already banned."
|
||||
else
|
||||
${CMD_SQL} >/dev/null <<EOF
|
||||
INSERT INTO ${DB_TABLE} (
|
||||
ip, ports, protocol, jail,
|
||||
hostname, country, rdns,
|
||||
failures, loglines)
|
||||
VALUES (
|
||||
'${_ip}', '${_ports}', '${_protocol}', '${_jail}',
|
||||
'${_hostname}', '${_country}', '${_rdns}',
|
||||
'${_failures}', '${_loglines}');
|
||||
EOF
|
||||
echo "Stored."
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [[ X"${_action}" == X"unban" ]]; then
|
||||
shift 1
|
||||
_ips="$@"
|
||||
|
||||
if [[ X"${_ips}" == X'' ]]; then
|
||||
echo "No IP address(es) specified."
|
||||
else
|
||||
for _ip in ${_ips}; do
|
||||
${CMD_SQL} <<EOF
|
||||
DELETE FROM ${DB_TABLE} WHERE ip='${_ip}';
|
||||
EOF
|
||||
done
|
||||
|
||||
[[ X"$?" == X'0' ]] && echo "Removed."
|
||||
fi
|
||||
|
||||
elif [[ X"${_action}" == X"cleanup" ]]; then
|
||||
_jail="$2"
|
||||
|
||||
if [[ X"${_jail}" != X'' ]]; then
|
||||
${CMD_SQL} <<EOF
|
||||
DELETE FROM ${DB_TABLE} WHERE jail='${_jail}';
|
||||
EOF
|
||||
fi
|
||||
|
||||
[[ X"$?" == X'0' ]] && echo "All IP addresses have been removed."
|
||||
elif [[ X"${_action}" == X"unban_db" ]]; then
|
||||
# Call fail2ban-client to unban given IP address(es).
|
||||
tmp_file="$(mktemp)"
|
||||
|
||||
# Exclude extra info on output, just leave jail/ip.
|
||||
(${CMD_SQL} <<EOF
|
||||
SELECT jail, ip FROM ${DB_TABLE} WHERE remove=1;
|
||||
EOF
|
||||
) | grep -Ev '(jail.*ip|\--|\(|^$)' | tr -d '|' >> ${tmp_file}
|
||||
|
||||
while read jail ip; do
|
||||
# Avoid SQL injection: don't allow whitespace, ';', quotes in
|
||||
# jail name and IP address.
|
||||
if echo ${jail} | grep "[ ;\"\']" &>/dev/null; then
|
||||
echo "[WARNING] Invalid jail name: '${jail}'."
|
||||
continue
|
||||
fi
|
||||
|
||||
if echo ${ip} | grep "[ ;\"\']" &>/dev/null; then
|
||||
echo "[WARNING] Invalid IP address: '${ip}'."
|
||||
continue
|
||||
fi
|
||||
|
||||
# fail2ban-client returns number of processed rows on command line,
|
||||
# let's discard it to avoid noise/confusion.
|
||||
fail2ban-client set ${jail} unbanip ${ip} >/dev/null
|
||||
[[ X"$?" == X'0' ]] && echo "Unbanned ${ip} from jail [${jail}]."
|
||||
done < ${tmp_file}
|
||||
rm -f ${tmp_file} &>/dev/null
|
||||
fi
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
[Definition]
|
||||
|
||||
# Option: loglevel. Default is ERROR
|
||||
# Available options: CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG
|
||||
loglevel = INFO
|
||||
|
||||
# Set the log target
|
||||
logtarget = SYSLOG
|
||||
|
||||
# Syslog socket. Required on FreeBSD and OpenBSD.
|
||||
#syslogsocket = PH_SYSLOG_SOCKET
|
||||
|
||||
# Fail2ban socket. Required on FreeBSD.
|
||||
#socket = /var/run/fail2ban/fail2ban.sock
|
||||
@@ -0,0 +1,5 @@
|
||||
[Definition]
|
||||
failregex = Authentication failure.* rip=<HOST>
|
||||
\(auth failed.* rip=<HOST>
|
||||
|
||||
ignoreregex =
|
||||
@@ -0,0 +1,16 @@
|
||||
[Definition]
|
||||
|
||||
# Block clients which cannot pass Postfix postscreen pregreet test.
|
||||
# FYI: http://www.postfix.org/POSTSCREEN_README.html#pregreet
|
||||
#
|
||||
# The SMTP protocol is a classic example of a protocol where the server speaks
|
||||
# before the client. postscreen(8) detects zombies that are in a hurry and that
|
||||
# speak before their turn.
|
||||
failregex = postscreen\[\d+\]: PREGREET .* from \[<HOST>\]:\d+:
|
||||
|
||||
# while setting up new account, Thunderbird doesn't wait for server connection
|
||||
# greeting/banner, this causes Thunderbird cannot pass the Postfix pregreet
|
||||
# test and caught by `failregex` rules listed above (the rule contains
|
||||
# 'PREGREET' line).
|
||||
# FYI: https://bugzilla.mozilla.org/show_bug.cgi?id=538809#c41
|
||||
ignoreregex = postscreen\[\d+\]: PREGREET .* from \[<HOST>\]:\d+: (EHLO|HELO) we-guess.mozilla.org
|
||||
@@ -0,0 +1,17 @@
|
||||
[Definition]
|
||||
# *) '554 5.7.1' is 'Helo command rejected: ACCESS DENIED'
|
||||
#
|
||||
# 'ACCESS DENIED' is string defined in postfix restriction rule `check_helo_access`.
|
||||
# no all rules contains 'ACCESS DENIED', so we use status code insead.
|
||||
|
||||
failregex = \[<HOST>\]: SASL (PLAIN|LOGIN) authentication failed
|
||||
lost connection after (AUTH|UNKNOWN) from (.*)\[<HOST>\]
|
||||
reject: RCPT from .*\[<HOST>\]: .*: Relay access denied
|
||||
reject: RCPT from .*\[<HOST>\]: .*: Sender address rejected: Domain not found
|
||||
reject: RCPT from .*\[<HOST>\]: .*: Helo command rejected: Host not found
|
||||
reject: RCPT from .*\[<HOST>\]: .*: Helo command rejected: need fully-qualified hostname
|
||||
reject: RCPT from .*\[<HOST>\]: 554 5.7.1
|
||||
reject: RCPT from .*\[<HOST>\]:\d+: 550 5.5.1 Protocol error
|
||||
warning: Illegal address syntax from (.*)\[<HOST>\] in RCPT command
|
||||
|
||||
ignoreregex =
|
||||
@@ -0,0 +1,9 @@
|
||||
# 'X-Forwarded-For:` appears when Roundcube is running behind HAProxy.
|
||||
|
||||
[Definition]
|
||||
failregex = roundcube.* Failed login for (.*) from <HOST>\. AUTHENTICATE LOGIN
|
||||
roundcube.* Failed login for (.*) from <HOST> in session
|
||||
roundcube.* Failed login .*\(X-Forwarded-For: <HOST>\) in session
|
||||
roundcube.* Error: Login failed for (.*) from <HOST>\. LOGIN: Authentication failed.
|
||||
|
||||
ignoreregex =
|
||||
@@ -0,0 +1,8 @@
|
||||
[dovecot]
|
||||
backend = polling
|
||||
journalmatch=
|
||||
enabled = true
|
||||
filter = dovecot.iredmail
|
||||
logpath = PH_DOVECOT_LOG_FILE
|
||||
action = PH_FAIL2BAN_ACTION[name=dovecot, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
banned_db[name=dovecot, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
@@ -0,0 +1,8 @@
|
||||
[nginx-http-auth]
|
||||
backend = polling
|
||||
journalmatch=
|
||||
enabled = false
|
||||
filter = nginx-http-auth
|
||||
logpath = PH_NGINX_LOG_ERRORLOG
|
||||
action = PH_FAIL2BAN_ACTION[name=nginx, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
banned_db[name=nginx, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
@@ -0,0 +1,9 @@
|
||||
[postfix-pregreet]
|
||||
backend = polling
|
||||
journalmatch=
|
||||
enabled = true
|
||||
maxretry = 1
|
||||
filter = postfix-pregreet.iredmail
|
||||
logpath = PH_MAILLOG
|
||||
action = PH_FAIL2BAN_ACTION[name=postfix-pregreet, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
banned_db[name=postfix-pregreet, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
@@ -0,0 +1,8 @@
|
||||
[postfix]
|
||||
backend = polling
|
||||
journalmatch=
|
||||
enabled = true
|
||||
filter = postfix.iredmail
|
||||
logpath = PH_MAILLOG
|
||||
action = PH_FAIL2BAN_ACTION[name=postfix, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
banned_db[name=postfix, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
@@ -0,0 +1,9 @@
|
||||
[roundcube]
|
||||
backend = polling
|
||||
journalmatch=
|
||||
enabled = false
|
||||
findtime = 3600
|
||||
filter = roundcube.iredmail
|
||||
logpath = PH_RCM_LOGFILE
|
||||
action = PH_FAIL2BAN_ACTION[name=roundcube, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
banned_db[name=roundcube, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
@@ -0,0 +1,8 @@
|
||||
[sogo]
|
||||
backend = polling
|
||||
journalmatch=
|
||||
enabled = false
|
||||
filter = sogo-auth
|
||||
logpath = PH_SOGO_LOG_FILE
|
||||
action = PH_FAIL2BAN_ACTION[name=sogo, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
banned_db[name=sogo, port="PH_FAIL2BAN_DISABLED_SERVICES", protocol=tcp]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user