From 5d419635ede59fade12a07a734b9492d22733974 Mon Sep 17 00:00:00 2001 From: temasky Date: Fri, 31 Jul 2020 12:45:56 +0000 Subject: [PATCH] recreate --- .gitignore | 1 + Dockerfile | 38 + Release.gpg | 9 + dockerinit.sh | 299 +++ iredmail/ChangeLog | 1841 +++++++++++++++++ iredmail/Documentations | 5 + iredmail/README.md | 29 + iredmail/conf/amavisd | 144 ++ iredmail/conf/clamav | 71 + iredmail/conf/core | 624 ++++++ iredmail/conf/dovecot | 152 ++ iredmail/conf/fail2ban | 69 + iredmail/conf/global | 724 +++++++ iredmail/conf/iredadmin | 37 + iredmail/conf/iredapd | 47 + iredmail/conf/memcached | 32 + iredmail/conf/mlmmj | 67 + iredmail/conf/mysql | 76 + iredmail/conf/netdata | 72 + iredmail/conf/nginx | 69 + iredmail/conf/openldap | 168 ++ iredmail/conf/php | 103 + iredmail/conf/postfix | 91 + iredmail/conf/postgresql | 98 + iredmail/conf/roundcube | 62 + iredmail/conf/sogo | 109 + iredmail/conf/spamassassin | 39 + iredmail/conf/web_server | 63 + iredmail/dialog/config_via_dialog.sh | 254 +++ iredmail/dialog/ldap_config.sh | 58 + iredmail/dialog/mysql_config.sh | 54 + iredmail/dialog/optional_components.sh | 122 ++ iredmail/dialog/pgsql_config.sh | 52 + iredmail/dialog/virtual_domain_config.sh | 94 + iredmail/dialog/web_applications.sh | 65 + iredmail/functions/amavisd.sh | 257 +++ iredmail/functions/backend.sh | 78 + iredmail/functions/clamav.sh | 118 ++ iredmail/functions/cleanup.sh | 399 ++++ iredmail/functions/dovecot.sh | 561 +++++ iredmail/functions/fail2ban.sh | 196 ++ iredmail/functions/iredadmin.sh | 297 +++ iredmail/functions/iredapd.sh | 352 ++++ iredmail/functions/ldap_server.sh | 169 ++ iredmail/functions/mlmmj.sh | 227 ++ iredmail/functions/mysql.sh | 361 ++++ iredmail/functions/netdata.sh | 206 ++ iredmail/functions/nginx.sh | 281 +++ iredmail/functions/openldap.sh | 261 +++ iredmail/functions/optional_components.sh | 32 + iredmail/functions/packages.sh | 785 +++++++ iredmail/functions/packages_freebsd.sh | 1169 +++++++++++ iredmail/functions/php.sh | 96 + iredmail/functions/postfix.sh | 395 ++++ iredmail/functions/postgresql.sh | 239 +++ iredmail/functions/roundcubemail.sh | 306 +++ iredmail/functions/sogo.sh | 332 +++ iredmail/functions/spamassassin.sh | 49 + iredmail/functions/system_accounts.sh | 128 ++ iredmail/functions/web_server.sh | 66 + iredmail/iRedMail.sh | 163 ++ iredmail/pkgs/get_all.sh | 311 +++ iredmail/pkgs/pkgs.freebsd.sha256 | 3 + iredmail/pkgs/pkgs.openbsd.sha256 | 6 + iredmail/pkgs/pkgs.sha256 | 6 + iredmail/samples/amavisd/amavisd.conf | 663 ++++++ iredmail/samples/amavisd/amavisd.mysql | 278 +++ iredmail/samples/amavisd/amavisd.pgsql | 253 +++ iredmail/samples/amavisd/amavisd.schema | 942 +++++++++ .../samples/amavisd/default_spam_policy.sql | 46 + .../samples/dovecot/dovecot-last-login.conf | 50 + iredmail/samples/dovecot/dovecot-ldap.conf | 20 + .../samples/dovecot/dovecot-share-folder.conf | 22 + iredmail/samples/dovecot/dovecot-sql.conf | 28 + .../samples/dovecot/dovecot-used-quota.conf | 13 + iredmail/samples/dovecot/dovecot.sieve | 7 + .../samples/dovecot/dovecot2-quota-warning.sh | 26 + iredmail/samples/dovecot/dovecot22.conf | 506 +++++ iredmail/samples/dovecot/dovecot23.conf | 496 +++++ .../dovecot/sql/imap_share_folder.mysql | 16 + iredmail/samples/dovecot/sql/last_login.mysql | 12 + iredmail/samples/dovecot/sql/used_quota.mysql | 26 + .../samples/dovecot/systemd/override.conf | 3 + .../samples/fail2ban/action.d/banned_db.conf | 10 + .../samples/fail2ban/bin/fail2ban_banned_db | 236 +++ iredmail/samples/fail2ban/fail2ban.local | 14 + .../fail2ban/filter.d/dovecot.iredmail.conf | 5 + .../filter.d/postfix-pregreet.iredmail.conf | 16 + .../fail2ban/filter.d/postfix.iredmail.conf | 17 + .../fail2ban/filter.d/roundcube.iredmail.conf | 9 + .../samples/fail2ban/jail.d/dovecot.local | 8 + .../fail2ban/jail.d/nginx-http-auth.local | 8 + .../fail2ban/jail.d/postfix-pregreet.local | 9 + .../samples/fail2ban/jail.d/postfix.local | 8 + .../samples/fail2ban/jail.d/roundcube.local | 9 + iredmail/samples/fail2ban/jail.d/sogo.local | 8 + iredmail/samples/fail2ban/jail.d/sshd.local | 8 + iredmail/samples/fail2ban/jail.local | 6 + iredmail/samples/fail2ban/openbsd/rc | 26 + iredmail/samples/fail2ban/sql/fail2ban.mysql | 37 + iredmail/samples/fail2ban/sql/fail2ban.pgsql | 37 + .../firewall/firewalld/services/ssh.xml | 6 + .../firewall/firewalld/zones/iredmail.xml | 14 + .../firewall/iptables/ip6tables.init.debian | 362 ++++ .../samples/firewall/iptables/ip6tables.rules | 52 + .../firewall/iptables/iptables.init.debian | 363 ++++ .../samples/firewall/iptables/iptables.rules | 53 + iredmail/samples/firewall/nftables.conf | 57 + .../samples/freebsd/newsyslog.conf.d/dovecot | 3 + .../samples/freebsd/newsyslog.conf.d/iredapd | 1 + .../freebsd/newsyslog.conf.d/mlmmjadmin | 1 + .../samples/freebsd/newsyslog.conf.d/php-fpm | 2 + .../samples/freebsd/newsyslog.conf.d/slapd | 1 + .../samples/freebsd/syslog.d/dovecot.conf | 2 + .../samples/freebsd/syslog.d/fail2ban.conf | 2 + .../samples/freebsd/syslog.d/iredapd.conf | 2 + .../samples/freebsd/syslog.d/mlmmjadmin.conf | 2 + .../samples/freebsd/syslog.d/php-fpm.conf | 2 + iredmail/samples/freebsd/syslog.d/slapd.conf | 2 + iredmail/samples/iredmail/iredmail.mysql | 465 +++++ iredmail/samples/iredmail/iredmail.pgsql | 467 +++++ iredmail/samples/iredmail/iredmail.schema | 452 ++++ iredmail/samples/logrotate/dovecot | 13 + iredmail/samples/logrotate/iredapd | 13 + iredmail/samples/logrotate/mlmmjadmin | 13 + iredmail/samples/logrotate/openldap | 19 + iredmail/samples/logrotate/php-fpm | 13 + iredmail/samples/mlmmj/mlmmj-amime-receive | 92 + iredmail/samples/mlmmj/mlmmjadmin.settings.py | 49 + iredmail/samples/mysql/my.cnf | 95 + .../mysql/sql/add_first_domain_and_user.sql | 32 + .../mysql/sql/delete_anonymous_user.sql | 7 + iredmail/samples/mysql/sql/init_vmail_db.sql | 10 + .../mysql/sql/remote_grant_permission.sql | 9 + iredmail/samples/netdata/go.d.conf | 24 + iredmail/samples/netdata/go.d/mysql.conf | 3 + iredmail/samples/netdata/go.d/nginx.conf | 4 + iredmail/samples/netdata/go.d/phpfpm.conf | 4 + .../samples/netdata/health_alarm_notify.conf | 1 + iredmail/samples/netdata/netdata.conf | 63 + iredmail/samples/netdata/python.d.conf | 49 + .../samples/netdata/python.d/openldap.conf | 8 + .../samples/netdata/python.d/postgres.conf | 5 + iredmail/samples/netdata/systemd-limits.conf | 2 + .../nginx/conf-available/0-general.conf | 1 + .../samples/nginx/conf-available/cache.conf | 8 + .../conf-available/client_max_body_size.conf | 1 + .../nginx/conf-available/default_type.conf | 1 + .../samples/nginx/conf-available/gzip.conf | 10 + .../samples/nginx/conf-available/headers.conf | 7 + .../samples/nginx/conf-available/log.conf | 2 + .../nginx/conf-available/mime_types.conf | 1 + .../samples/nginx/conf-available/php_fpm.conf | 3 + .../nginx/conf-available/sendfile.conf | 1 + .../nginx/conf-available/server_tokens.conf | 2 + .../conf-available/types_hash_max_size.conf | 1 + iredmail/samples/nginx/nginx.conf | 12 + .../nginx/sites-available/00-default-ssl.conf | 21 + .../nginx/sites-available/00-default.conf | 14 + iredmail/samples/nginx/templates/adminer.tmpl | 46 + .../samples/nginx/templates/fastcgi_php.tmpl | 17 + iredmail/samples/nginx/templates/hsts.tmpl | 17 + .../nginx/templates/iredadmin-subdomain.tmpl | 16 + .../samples/nginx/templates/iredadmin.tmpl | 35 + iredmail/samples/nginx/templates/misc.tmpl | 15 + .../nginx/templates/netdata-subdomain.tmpl | 22 + iredmail/samples/nginx/templates/netdata.tmpl | 27 + .../samples/nginx/templates/php-catchall.tmpl | 6 + .../nginx/templates/redirect_to_https.tmpl | 5 + .../nginx/templates/roundcube-subdomain.tmpl | 26 + .../samples/nginx/templates/roundcube.tmpl | 30 + .../nginx/templates/sogo-subdomain.tmpl | 65 + iredmail/samples/nginx/templates/sogo.tmpl | 60 + iredmail/samples/nginx/templates/ssl.tmpl | 21 + .../samples/nginx/templates/stub_status.tmpl | 15 + iredmail/samples/openbsd/ldapd.conf | 58 + iredmail/samples/openbsd/pf.conf | 28 + iredmail/samples/openldap/calentry.schema | 105 + iredmail/samples/openldap/calresource.schema | 184 ++ iredmail/samples/openldap/ldap.conf | 3 + iredmail/samples/openldap/slapd.conf | 240 +++ iredmail/samples/php/fpm/pool.d/www.conf | 30 + iredmail/samples/postfix/command_filter.pcre | 3 + iredmail/samples/postfix/freebsd/mailer.conf | 9 + iredmail/samples/postfix/helo_access.pcre | 182 ++ .../samples/postfix/ldap/catchall_maps.cf | 11 + .../postfix/ldap/recipient_bcc_maps_domain.cf | 11 + .../postfix/ldap/recipient_bcc_maps_user.cf | 11 + .../samples/postfix/ldap/relay_domains.cf | 11 + .../postfix/ldap/sender_bcc_maps_domain.cf | 11 + .../postfix/ldap/sender_bcc_maps_user.cf | 11 + .../sender_dependent_relayhost_maps_domain.cf | 11 + .../sender_dependent_relayhost_maps_user.cf | 11 + .../samples/postfix/ldap/sender_login_maps.cf | 11 + .../postfix/ldap/transport_maps_domain.cf | 11 + .../postfix/ldap/transport_maps_user.cf | 11 + .../postfix/ldap/virtual_alias_maps.cf | 11 + .../postfix/ldap/virtual_group_maps.cf | 11 + .../ldap/virtual_group_members_maps.cf | 11 + .../postfix/ldap/virtual_mailbox_domains.cf | 11 + .../postfix/ldap/virtual_mailbox_maps.cf | 12 + iredmail/samples/postfix/main.cf | 274 +++ iredmail/samples/postfix/main.cf.amavisd | 7 + iredmail/samples/postfix/main.cf.dovecot | 8 + iredmail/samples/postfix/main.cf.ldap | 39 + iredmail/samples/postfix/main.cf.mlmmj | 5 + iredmail/samples/postfix/main.cf.mysql | 39 + iredmail/samples/postfix/main.cf.pgsql | 39 + iredmail/samples/postfix/main.cf.postscreen | 30 + iredmail/samples/postfix/master.cf | 76 + .../samples/postfix/mysql/catchall_maps.cf | 5 + .../mysql/domain_alias_catchall_maps.cf | 5 + .../postfix/mysql/domain_alias_maps.cf | 5 + .../mysql/recipient_bcc_maps_domain.cf | 5 + .../postfix/mysql/recipient_bcc_maps_user.cf | 5 + .../samples/postfix/mysql/relay_domains.cf | 5 + .../postfix/mysql/sender_bcc_maps_domain.cf | 5 + .../postfix/mysql/sender_bcc_maps_user.cf | 5 + .../mysql/sender_dependent_relayhost_maps.cf | 6 + .../postfix/mysql/sender_login_maps.cf | 5 + .../postfix/mysql/transport_maps_domain.cf | 5 + .../postfix/mysql/transport_maps_maillist.cf | 5 + .../postfix/mysql/transport_maps_user.cf | 5 + .../postfix/mysql/virtual_alias_maps.cf | 5 + .../postfix/mysql/virtual_mailbox_domains.cf | 5 + .../postfix/mysql/virtual_mailbox_maps.cf | 5 + .../samples/postfix/pgsql/catchall_maps.cf | 5 + .../pgsql/domain_alias_catchall_maps.cf | 5 + .../postfix/pgsql/domain_alias_maps.cf | 5 + .../pgsql/recipient_bcc_maps_domain.cf | 5 + .../postfix/pgsql/recipient_bcc_maps_user.cf | 5 + .../samples/postfix/pgsql/relay_domains.cf | 5 + .../postfix/pgsql/sender_bcc_maps_domain.cf | 5 + .../postfix/pgsql/sender_bcc_maps_user.cf | 5 + .../pgsql/sender_dependent_relayhost_maps.cf | 6 + .../postfix/pgsql/sender_login_maps.cf | 5 + .../postfix/pgsql/transport_maps_domain.cf | 5 + .../postfix/pgsql/transport_maps_maillist.cf | 5 + .../postfix/pgsql/transport_maps_user.cf | 5 + .../postfix/pgsql/virtual_alias_maps.cf | 5 + .../postfix/pgsql/virtual_mailbox_domains.cf | 5 + .../postfix/pgsql/virtual_mailbox_maps.cf | 5 + .../samples/postfix/postscreen_access.cidr | 6 + .../sql/add_first_domain_and_user.sql | 34 + .../postgresql/sql/grant_permissions.sql | 7 + .../samples/postgresql/sql/init_vmail_db.sql | 11 + iredmail/samples/roundcubemail/config.inc.php | 71 + .../global_ldap_address_book.inc.php | 58 + .../samples/rsyslog.d/1-iredmail-dovecot.conf | 23 + .../rsyslog.d/1-iredmail-fail2ban.conf | 2 + .../samples/rsyslog.d/1-iredmail-iredapd.conf | 12 + .../rsyslog.d/1-iredmail-mlmmjadmin.conf | 12 + .../rsyslog.d/1-iredmail-openldap.conf | 2 + .../samples/rsyslog.d/1-iredmail-phpfpm.conf | 3 + iredmail/samples/sogo/sogo.conf | 389 ++++ iredmail/samples/sogo/sogo.cron | 6 + iredmail/samples/spamassassin/local.cf | 186 ++ iredmail/samples/spamassassin/razor.conf | 1 + .../systemd/clamd.service.d/override.conf | 2 + .../systemd/mariadb.service.d/override.conf | 3 + .../systemd/slapd.service.d/override.conf | 6 + iredmail/samples/yum/CentOS-AppStream.repo | 6 + iredmail/samples/yum/CentOS-PowerTools.repo | 6 + iredmail/samples/yum/symas-openldap.repo | 6 + iredmail/tools/backup_mysql.sh | 227 ++ iredmail/tools/backup_openldap.sh | 230 ++ iredmail/tools/backup_pgsql.sh | 205 ++ iredmail/tools/backup_sogo.sh | 156 ++ iredmail/tools/create_mail_user_OpenLDAP.py | 283 +++ iredmail/tools/create_mail_user_OpenLDAP.sh | 312 +++ iredmail/tools/create_mail_user_SQL.sh | 126 ++ iredmail/tools/enable_postscreen.sh | 144 ++ iredmail/tools/fail2ban_unban_ip.sh | 39 + iredmail/tools/find_sasl_login_ip.sh | 20 + iredmail/tools/find_top_sasl_usernames.sh | 28 + iredmail/tools/generate_ssl_keys.sh | 85 + iredmail/tools/ldap_assign_user_to_groups.py | 151 ++ .../ldap_move_members_to_another_group.py | 129 ++ iredmail/tools/migrate_sql_alias_table.py | 145 ++ iredmail/update/0.9.8/amavisd.mysql | 29 + iredmail/update/0.9.8/amavisd.pgsql | 39 + iredmail/update/0.9.8/iredmail.mysql | 53 + iredmail/update/0.9.8/iredmail.pgsql | 61 + iredmail/update/0.9.9/iredmail.mysql | 2 + iredmail/update/0.9.9/iredmail.pgsql | 2 + iredmail/update/1.0/iredmail.mysql | 2 + iredmail/update/1.0/iredmail.pgsql | 2 + iredmail/update/1.2/last_login.mysql | 16 + iredmail/update/README.md | 1 + iredmail/update/ldap/README.md | 40 + .../update/ldap/update-ldap-dovecot-2.3.py | 69 + .../ldap/updateLDAPValues_050_to_051.py | 62 + .../ldap/updateLDAPValues_051_to_060.py | 74 + .../ldap/updateLDAPValues_061_to_070.py | 77 + .../ldap/updateLDAPValues_072_to_073.py | 73 + .../ldap/updateLDAPValues_074_to_080.py | 71 + .../ldap/updateLDAPValues_080_to_081.py | 71 + .../ldap/updateLDAPValues_083_to_084.py | 68 + .../ldap/updateLDAPValues_086_to_087.py | 69 + .../ldap/updateLDAPValues_087_to_090.py | 69 + .../ldap/updateLDAPValues_094_to_095.py | 69 + .../ldap/updateLDAPValues_095_1_to_096.py | 82 + .../update/ldap/updateLDAPValues_099_to_1.py | 62 + mariadb/master.cnf | 0 test.sh | 19 + testfile | 25 + 306 files changed, 26949 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Release.gpg create mode 100644 dockerinit.sh create mode 100644 iredmail/ChangeLog create mode 100644 iredmail/Documentations create mode 100644 iredmail/README.md create mode 100644 iredmail/conf/amavisd create mode 100644 iredmail/conf/clamav create mode 100644 iredmail/conf/core create mode 100644 iredmail/conf/dovecot create mode 100644 iredmail/conf/fail2ban create mode 100644 iredmail/conf/global create mode 100644 iredmail/conf/iredadmin create mode 100644 iredmail/conf/iredapd create mode 100644 iredmail/conf/memcached create mode 100644 iredmail/conf/mlmmj create mode 100644 iredmail/conf/mysql create mode 100644 iredmail/conf/netdata create mode 100644 iredmail/conf/nginx create mode 100644 iredmail/conf/openldap create mode 100644 iredmail/conf/php create mode 100644 iredmail/conf/postfix create mode 100644 iredmail/conf/postgresql create mode 100644 iredmail/conf/roundcube create mode 100644 iredmail/conf/sogo create mode 100644 iredmail/conf/spamassassin create mode 100644 iredmail/conf/web_server create mode 100644 iredmail/dialog/config_via_dialog.sh create mode 100644 iredmail/dialog/ldap_config.sh create mode 100644 iredmail/dialog/mysql_config.sh create mode 100644 iredmail/dialog/optional_components.sh create mode 100644 iredmail/dialog/pgsql_config.sh create mode 100644 iredmail/dialog/virtual_domain_config.sh create mode 100644 iredmail/dialog/web_applications.sh create mode 100644 iredmail/functions/amavisd.sh create mode 100644 iredmail/functions/backend.sh create mode 100644 iredmail/functions/clamav.sh create mode 100644 iredmail/functions/cleanup.sh create mode 100644 iredmail/functions/dovecot.sh create mode 100644 iredmail/functions/fail2ban.sh create mode 100644 iredmail/functions/iredadmin.sh create mode 100644 iredmail/functions/iredapd.sh create mode 100644 iredmail/functions/ldap_server.sh create mode 100644 iredmail/functions/mlmmj.sh create mode 100644 iredmail/functions/mysql.sh create mode 100644 iredmail/functions/netdata.sh create mode 100644 iredmail/functions/nginx.sh create mode 100644 iredmail/functions/openldap.sh create mode 100644 iredmail/functions/optional_components.sh create mode 100644 iredmail/functions/packages.sh create mode 100644 iredmail/functions/packages_freebsd.sh create mode 100644 iredmail/functions/php.sh create mode 100644 iredmail/functions/postfix.sh create mode 100644 iredmail/functions/postgresql.sh create mode 100644 iredmail/functions/roundcubemail.sh create mode 100644 iredmail/functions/sogo.sh create mode 100644 iredmail/functions/spamassassin.sh create mode 100644 iredmail/functions/system_accounts.sh create mode 100644 iredmail/functions/web_server.sh create mode 100644 iredmail/iRedMail.sh create mode 100644 iredmail/pkgs/get_all.sh create mode 100644 iredmail/pkgs/pkgs.freebsd.sha256 create mode 100644 iredmail/pkgs/pkgs.openbsd.sha256 create mode 100644 iredmail/pkgs/pkgs.sha256 create mode 100644 iredmail/samples/amavisd/amavisd.conf create mode 100644 iredmail/samples/amavisd/amavisd.mysql create mode 100644 iredmail/samples/amavisd/amavisd.pgsql create mode 100644 iredmail/samples/amavisd/amavisd.schema create mode 100644 iredmail/samples/amavisd/default_spam_policy.sql create mode 100644 iredmail/samples/dovecot/dovecot-last-login.conf create mode 100644 iredmail/samples/dovecot/dovecot-ldap.conf create mode 100644 iredmail/samples/dovecot/dovecot-share-folder.conf create mode 100644 iredmail/samples/dovecot/dovecot-sql.conf create mode 100644 iredmail/samples/dovecot/dovecot-used-quota.conf create mode 100644 iredmail/samples/dovecot/dovecot.sieve create mode 100644 iredmail/samples/dovecot/dovecot2-quota-warning.sh create mode 100644 iredmail/samples/dovecot/dovecot22.conf create mode 100644 iredmail/samples/dovecot/dovecot23.conf create mode 100644 iredmail/samples/dovecot/sql/imap_share_folder.mysql create mode 100644 iredmail/samples/dovecot/sql/last_login.mysql create mode 100644 iredmail/samples/dovecot/sql/used_quota.mysql create mode 100644 iredmail/samples/dovecot/systemd/override.conf create mode 100644 iredmail/samples/fail2ban/action.d/banned_db.conf create mode 100644 iredmail/samples/fail2ban/bin/fail2ban_banned_db create mode 100755 iredmail/samples/fail2ban/fail2ban.local create mode 100644 iredmail/samples/fail2ban/filter.d/dovecot.iredmail.conf create mode 100644 iredmail/samples/fail2ban/filter.d/postfix-pregreet.iredmail.conf create mode 100644 iredmail/samples/fail2ban/filter.d/postfix.iredmail.conf create mode 100644 iredmail/samples/fail2ban/filter.d/roundcube.iredmail.conf create mode 100644 iredmail/samples/fail2ban/jail.d/dovecot.local create mode 100644 iredmail/samples/fail2ban/jail.d/nginx-http-auth.local create mode 100644 iredmail/samples/fail2ban/jail.d/postfix-pregreet.local create mode 100644 iredmail/samples/fail2ban/jail.d/postfix.local create mode 100644 iredmail/samples/fail2ban/jail.d/roundcube.local create mode 100644 iredmail/samples/fail2ban/jail.d/sogo.local create mode 100644 iredmail/samples/fail2ban/jail.d/sshd.local create mode 100644 iredmail/samples/fail2ban/jail.local create mode 100755 iredmail/samples/fail2ban/openbsd/rc create mode 100644 iredmail/samples/fail2ban/sql/fail2ban.mysql create mode 100644 iredmail/samples/fail2ban/sql/fail2ban.pgsql create mode 100644 iredmail/samples/firewall/firewalld/services/ssh.xml create mode 100644 iredmail/samples/firewall/firewalld/zones/iredmail.xml create mode 100755 iredmail/samples/firewall/iptables/ip6tables.init.debian create mode 100644 iredmail/samples/firewall/iptables/ip6tables.rules create mode 100755 iredmail/samples/firewall/iptables/iptables.init.debian create mode 100644 iredmail/samples/firewall/iptables/iptables.rules create mode 100644 iredmail/samples/firewall/nftables.conf create mode 100644 iredmail/samples/freebsd/newsyslog.conf.d/dovecot create mode 100644 iredmail/samples/freebsd/newsyslog.conf.d/iredapd create mode 100644 iredmail/samples/freebsd/newsyslog.conf.d/mlmmjadmin create mode 100644 iredmail/samples/freebsd/newsyslog.conf.d/php-fpm create mode 100644 iredmail/samples/freebsd/newsyslog.conf.d/slapd create mode 100644 iredmail/samples/freebsd/syslog.d/dovecot.conf create mode 100644 iredmail/samples/freebsd/syslog.d/fail2ban.conf create mode 100644 iredmail/samples/freebsd/syslog.d/iredapd.conf create mode 100644 iredmail/samples/freebsd/syslog.d/mlmmjadmin.conf create mode 100644 iredmail/samples/freebsd/syslog.d/php-fpm.conf create mode 100644 iredmail/samples/freebsd/syslog.d/slapd.conf create mode 100644 iredmail/samples/iredmail/iredmail.mysql create mode 100644 iredmail/samples/iredmail/iredmail.pgsql create mode 100644 iredmail/samples/iredmail/iredmail.schema create mode 100644 iredmail/samples/logrotate/dovecot create mode 100644 iredmail/samples/logrotate/iredapd create mode 100644 iredmail/samples/logrotate/mlmmjadmin create mode 100644 iredmail/samples/logrotate/openldap create mode 100644 iredmail/samples/logrotate/php-fpm create mode 100755 iredmail/samples/mlmmj/mlmmj-amime-receive create mode 100644 iredmail/samples/mlmmj/mlmmjadmin.settings.py create mode 100644 iredmail/samples/mysql/my.cnf create mode 100644 iredmail/samples/mysql/sql/add_first_domain_and_user.sql create mode 100644 iredmail/samples/mysql/sql/delete_anonymous_user.sql create mode 100644 iredmail/samples/mysql/sql/init_vmail_db.sql create mode 100644 iredmail/samples/mysql/sql/remote_grant_permission.sql create mode 100644 iredmail/samples/netdata/go.d.conf create mode 100644 iredmail/samples/netdata/go.d/mysql.conf create mode 100644 iredmail/samples/netdata/go.d/nginx.conf create mode 100644 iredmail/samples/netdata/go.d/phpfpm.conf create mode 100644 iredmail/samples/netdata/health_alarm_notify.conf create mode 100644 iredmail/samples/netdata/netdata.conf create mode 100644 iredmail/samples/netdata/python.d.conf create mode 100644 iredmail/samples/netdata/python.d/openldap.conf create mode 100644 iredmail/samples/netdata/python.d/postgres.conf create mode 100644 iredmail/samples/netdata/systemd-limits.conf create mode 100644 iredmail/samples/nginx/conf-available/0-general.conf create mode 100644 iredmail/samples/nginx/conf-available/cache.conf create mode 100644 iredmail/samples/nginx/conf-available/client_max_body_size.conf create mode 100644 iredmail/samples/nginx/conf-available/default_type.conf create mode 100644 iredmail/samples/nginx/conf-available/gzip.conf create mode 100644 iredmail/samples/nginx/conf-available/headers.conf create mode 100644 iredmail/samples/nginx/conf-available/log.conf create mode 100644 iredmail/samples/nginx/conf-available/mime_types.conf create mode 100644 iredmail/samples/nginx/conf-available/php_fpm.conf create mode 100644 iredmail/samples/nginx/conf-available/sendfile.conf create mode 100644 iredmail/samples/nginx/conf-available/server_tokens.conf create mode 100644 iredmail/samples/nginx/conf-available/types_hash_max_size.conf create mode 100644 iredmail/samples/nginx/nginx.conf create mode 100644 iredmail/samples/nginx/sites-available/00-default-ssl.conf create mode 100644 iredmail/samples/nginx/sites-available/00-default.conf create mode 100644 iredmail/samples/nginx/templates/adminer.tmpl create mode 100644 iredmail/samples/nginx/templates/fastcgi_php.tmpl create mode 100644 iredmail/samples/nginx/templates/hsts.tmpl create mode 100644 iredmail/samples/nginx/templates/iredadmin-subdomain.tmpl create mode 100644 iredmail/samples/nginx/templates/iredadmin.tmpl create mode 100644 iredmail/samples/nginx/templates/misc.tmpl create mode 100644 iredmail/samples/nginx/templates/netdata-subdomain.tmpl create mode 100644 iredmail/samples/nginx/templates/netdata.tmpl create mode 100644 iredmail/samples/nginx/templates/php-catchall.tmpl create mode 100644 iredmail/samples/nginx/templates/redirect_to_https.tmpl create mode 100644 iredmail/samples/nginx/templates/roundcube-subdomain.tmpl create mode 100644 iredmail/samples/nginx/templates/roundcube.tmpl create mode 100644 iredmail/samples/nginx/templates/sogo-subdomain.tmpl create mode 100644 iredmail/samples/nginx/templates/sogo.tmpl create mode 100644 iredmail/samples/nginx/templates/ssl.tmpl create mode 100644 iredmail/samples/nginx/templates/stub_status.tmpl create mode 100644 iredmail/samples/openbsd/ldapd.conf create mode 100644 iredmail/samples/openbsd/pf.conf create mode 100644 iredmail/samples/openldap/calentry.schema create mode 100644 iredmail/samples/openldap/calresource.schema create mode 100644 iredmail/samples/openldap/ldap.conf create mode 100644 iredmail/samples/openldap/slapd.conf create mode 100755 iredmail/samples/php/fpm/pool.d/www.conf create mode 100644 iredmail/samples/postfix/command_filter.pcre create mode 100644 iredmail/samples/postfix/freebsd/mailer.conf create mode 100644 iredmail/samples/postfix/helo_access.pcre create mode 100644 iredmail/samples/postfix/ldap/catchall_maps.cf create mode 100644 iredmail/samples/postfix/ldap/recipient_bcc_maps_domain.cf create mode 100644 iredmail/samples/postfix/ldap/recipient_bcc_maps_user.cf create mode 100644 iredmail/samples/postfix/ldap/relay_domains.cf create mode 100644 iredmail/samples/postfix/ldap/sender_bcc_maps_domain.cf create mode 100644 iredmail/samples/postfix/ldap/sender_bcc_maps_user.cf create mode 100644 iredmail/samples/postfix/ldap/sender_dependent_relayhost_maps_domain.cf create mode 100644 iredmail/samples/postfix/ldap/sender_dependent_relayhost_maps_user.cf create mode 100644 iredmail/samples/postfix/ldap/sender_login_maps.cf create mode 100644 iredmail/samples/postfix/ldap/transport_maps_domain.cf create mode 100644 iredmail/samples/postfix/ldap/transport_maps_user.cf create mode 100644 iredmail/samples/postfix/ldap/virtual_alias_maps.cf create mode 100644 iredmail/samples/postfix/ldap/virtual_group_maps.cf create mode 100644 iredmail/samples/postfix/ldap/virtual_group_members_maps.cf create mode 100644 iredmail/samples/postfix/ldap/virtual_mailbox_domains.cf create mode 100644 iredmail/samples/postfix/ldap/virtual_mailbox_maps.cf create mode 100644 iredmail/samples/postfix/main.cf create mode 100644 iredmail/samples/postfix/main.cf.amavisd create mode 100644 iredmail/samples/postfix/main.cf.dovecot create mode 100644 iredmail/samples/postfix/main.cf.ldap create mode 100644 iredmail/samples/postfix/main.cf.mlmmj create mode 100644 iredmail/samples/postfix/main.cf.mysql create mode 100644 iredmail/samples/postfix/main.cf.pgsql create mode 100644 iredmail/samples/postfix/main.cf.postscreen create mode 100644 iredmail/samples/postfix/master.cf create mode 100644 iredmail/samples/postfix/mysql/catchall_maps.cf create mode 100644 iredmail/samples/postfix/mysql/domain_alias_catchall_maps.cf create mode 100644 iredmail/samples/postfix/mysql/domain_alias_maps.cf create mode 100644 iredmail/samples/postfix/mysql/recipient_bcc_maps_domain.cf create mode 100644 iredmail/samples/postfix/mysql/recipient_bcc_maps_user.cf create mode 100644 iredmail/samples/postfix/mysql/relay_domains.cf create mode 100644 iredmail/samples/postfix/mysql/sender_bcc_maps_domain.cf create mode 100644 iredmail/samples/postfix/mysql/sender_bcc_maps_user.cf create mode 100644 iredmail/samples/postfix/mysql/sender_dependent_relayhost_maps.cf create mode 100644 iredmail/samples/postfix/mysql/sender_login_maps.cf create mode 100644 iredmail/samples/postfix/mysql/transport_maps_domain.cf create mode 100644 iredmail/samples/postfix/mysql/transport_maps_maillist.cf create mode 100644 iredmail/samples/postfix/mysql/transport_maps_user.cf create mode 100644 iredmail/samples/postfix/mysql/virtual_alias_maps.cf create mode 100644 iredmail/samples/postfix/mysql/virtual_mailbox_domains.cf create mode 100644 iredmail/samples/postfix/mysql/virtual_mailbox_maps.cf create mode 100644 iredmail/samples/postfix/pgsql/catchall_maps.cf create mode 100644 iredmail/samples/postfix/pgsql/domain_alias_catchall_maps.cf create mode 100644 iredmail/samples/postfix/pgsql/domain_alias_maps.cf create mode 100644 iredmail/samples/postfix/pgsql/recipient_bcc_maps_domain.cf create mode 100644 iredmail/samples/postfix/pgsql/recipient_bcc_maps_user.cf create mode 100644 iredmail/samples/postfix/pgsql/relay_domains.cf create mode 100644 iredmail/samples/postfix/pgsql/sender_bcc_maps_domain.cf create mode 100644 iredmail/samples/postfix/pgsql/sender_bcc_maps_user.cf create mode 100644 iredmail/samples/postfix/pgsql/sender_dependent_relayhost_maps.cf create mode 100644 iredmail/samples/postfix/pgsql/sender_login_maps.cf create mode 100644 iredmail/samples/postfix/pgsql/transport_maps_domain.cf create mode 100644 iredmail/samples/postfix/pgsql/transport_maps_maillist.cf create mode 100644 iredmail/samples/postfix/pgsql/transport_maps_user.cf create mode 100644 iredmail/samples/postfix/pgsql/virtual_alias_maps.cf create mode 100644 iredmail/samples/postfix/pgsql/virtual_mailbox_domains.cf create mode 100644 iredmail/samples/postfix/pgsql/virtual_mailbox_maps.cf create mode 100644 iredmail/samples/postfix/postscreen_access.cidr create mode 100644 iredmail/samples/postgresql/sql/add_first_domain_and_user.sql create mode 100644 iredmail/samples/postgresql/sql/grant_permissions.sql create mode 100644 iredmail/samples/postgresql/sql/init_vmail_db.sql create mode 100644 iredmail/samples/roundcubemail/config.inc.php create mode 100644 iredmail/samples/roundcubemail/global_ldap_address_book.inc.php create mode 100644 iredmail/samples/rsyslog.d/1-iredmail-dovecot.conf create mode 100755 iredmail/samples/rsyslog.d/1-iredmail-fail2ban.conf create mode 100644 iredmail/samples/rsyslog.d/1-iredmail-iredapd.conf create mode 100644 iredmail/samples/rsyslog.d/1-iredmail-mlmmjadmin.conf create mode 100644 iredmail/samples/rsyslog.d/1-iredmail-openldap.conf create mode 100644 iredmail/samples/rsyslog.d/1-iredmail-phpfpm.conf create mode 100644 iredmail/samples/sogo/sogo.conf create mode 100644 iredmail/samples/sogo/sogo.cron create mode 100644 iredmail/samples/spamassassin/local.cf create mode 100644 iredmail/samples/spamassassin/razor.conf create mode 100644 iredmail/samples/systemd/clamd.service.d/override.conf create mode 100644 iredmail/samples/systemd/mariadb.service.d/override.conf create mode 100644 iredmail/samples/systemd/slapd.service.d/override.conf create mode 100644 iredmail/samples/yum/CentOS-AppStream.repo create mode 100644 iredmail/samples/yum/CentOS-PowerTools.repo create mode 100644 iredmail/samples/yum/symas-openldap.repo create mode 100644 iredmail/tools/backup_mysql.sh create mode 100755 iredmail/tools/backup_openldap.sh create mode 100644 iredmail/tools/backup_pgsql.sh create mode 100644 iredmail/tools/backup_sogo.sh create mode 100644 iredmail/tools/create_mail_user_OpenLDAP.py create mode 100644 iredmail/tools/create_mail_user_OpenLDAP.sh create mode 100644 iredmail/tools/create_mail_user_SQL.sh create mode 100644 iredmail/tools/enable_postscreen.sh create mode 100644 iredmail/tools/fail2ban_unban_ip.sh create mode 100644 iredmail/tools/find_sasl_login_ip.sh create mode 100644 iredmail/tools/find_top_sasl_usernames.sh create mode 100644 iredmail/tools/generate_ssl_keys.sh create mode 100644 iredmail/tools/ldap_assign_user_to_groups.py create mode 100644 iredmail/tools/ldap_move_members_to_another_group.py create mode 100644 iredmail/tools/migrate_sql_alias_table.py create mode 100644 iredmail/update/0.9.8/amavisd.mysql create mode 100644 iredmail/update/0.9.8/amavisd.pgsql create mode 100644 iredmail/update/0.9.8/iredmail.mysql create mode 100644 iredmail/update/0.9.8/iredmail.pgsql create mode 100644 iredmail/update/0.9.9/iredmail.mysql create mode 100644 iredmail/update/0.9.9/iredmail.pgsql create mode 100644 iredmail/update/1.0/iredmail.mysql create mode 100644 iredmail/update/1.0/iredmail.pgsql create mode 100644 iredmail/update/1.2/last_login.mysql create mode 100644 iredmail/update/README.md create mode 100644 iredmail/update/ldap/README.md create mode 100644 iredmail/update/ldap/update-ldap-dovecot-2.3.py create mode 100644 iredmail/update/ldap/updateLDAPValues_050_to_051.py create mode 100644 iredmail/update/ldap/updateLDAPValues_051_to_060.py create mode 100644 iredmail/update/ldap/updateLDAPValues_061_to_070.py create mode 100644 iredmail/update/ldap/updateLDAPValues_072_to_073.py create mode 100644 iredmail/update/ldap/updateLDAPValues_074_to_080.py create mode 100644 iredmail/update/ldap/updateLDAPValues_080_to_081.py create mode 100644 iredmail/update/ldap/updateLDAPValues_083_to_084.py create mode 100644 iredmail/update/ldap/updateLDAPValues_086_to_087.py create mode 100644 iredmail/update/ldap/updateLDAPValues_087_to_090.py create mode 100644 iredmail/update/ldap/updateLDAPValues_094_to_095.py create mode 100644 iredmail/update/ldap/updateLDAPValues_095_1_to_096.py create mode 100644 iredmail/update/ldap/updateLDAPValues_099_to_1.py create mode 100644 mariadb/master.cnf create mode 100755 test.sh create mode 100644 testfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9baaaf1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +main.cvd diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f9761e4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM ubuntu:bionic +MAINTAINER Artem Shvidkiy +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 \ +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 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 diff --git a/Release.gpg b/Release.gpg new file mode 100644 index 0000000..f68ee0c --- /dev/null +++ b/Release.gpg @@ -0,0 +1,9 @@ +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1 + +iJwEAAEKAAYFAl8WmosACgkQT06gquUmemySfQP/dV/jDbPss4PgodNkA5FDWM9Z +yXslmrCLaXCHO1xvxnbMHq0YlHmCET0G62i4wTMwrA4tywcUixBnwPf9hePHAEq5 +/hLhRAlNcxJEE1/GZfIsa5jdSfX8rqpUNTc5uRzbZSELMdmMfQHO/k2Qx7qK/sR4 +S3ipnNuH9g2mCbTNYAs= +=5rrH +-----END PGP SIGNATURE----- diff --git a/dockerinit.sh b/dockerinit.sh new file mode 100644 index 0000000..df8fa3c --- /dev/null +++ b/dockerinit.sh @@ -0,0 +1,299 @@ +#!/bin/bash + +if [[ ! -f ".configured" ]]; then + + exec > >(tee -i /iredmail.log) + + exec 2>&1 + + set -x + +: ${IPADDR:=127.0.0.1} +: ${MYSQLIP:=127.0.0.1} +: ${MYSQLPORT:=3306} +: ${MYSQLUSER:=admin_iredmail} +: ${MYSQLPASS:=admin_password} +: ${MYSQLEXIST:=NO} +: ${SETFQDN:=test.testdomain.ru} +: ${STORAGE_BASE_DIR:=/var/vmail} +: ${WEB_SERVER:=NGINX} +: ${BACKEND_ORIG:=OPENLDAP} +: ${BACKEND:=OPENLDAP} +: ${VMAIL_DB_BIND_PASSWD:=`eval /dev/null || head -c 20)`} +: ${VMAIL_DB_ADMIN_PASSWD:=`eval /dev/null || head -c 20)`} +: ${MLMMJADMIN_API_AUTH_TOKEN:=`eval /dev/null || head -c 20)`} +: ${NETDATA_DB_PASSWD:=`eval /dev/null || head -c 20)`} +: ${LDAP_SUFFIX:=dc=testdomain,dc=ru} +: ${LDAP_BINDPW:=`eval /dev/null || head -c 20)`} +: ${LDAP_ADMIN_PW:=`eval /dev/null || head -c 20)`} +: ${LDAP_ROOTPW:=`eval /dev/null || head -c 20)`} +: ${LDAP_SEARCH_BASE:=cn=users,dc=testdomain,dc=ru} +: ${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/null || head -c 20)`} +: ${FIRST_DOMAIN:=testdomain.ru} +: ${DOMAIN_ADMIN_PASSWD_PLAIN:=`eval /dev/null || head -c 20)`} +: ${USE_IREDADMIN:=YES} +: ${USE_ROUNDCUBE:=YES} +: ${AMAVISD_DB_PASSWD:=`eval /dev/null || head -c 20)`} +: ${IREDADMIN_DB_PASSWD:=`eval /dev/null || head -c 20)`} +: ${RCM_DB_PASSWD:=`eval /dev/null || head -c 20)`} +: ${SOGO_DB_PASSWD:=`eval /dev/null || head -c 20)`} +: ${SOGO_SIEVE_MASTER_PASSWD:=`eval /dev/null || head -c 20)`} +: ${IREDAPD_DB_PASSWD:=`eval /dev/null || head -c 20)`} +: ${FAIL2BAN_DB_PASSWD:=`eval /dev/null || head -c 20)`} + +useradd -U --home-dir /home/syslog --groups adm -s /usr/sbin/nologin syslog + + if [[ X"${MYSQLEXIST}" == X'YES' || X"${MYSQLEXIST}" == X'yes' ]]; then + while ! mysqladmin ping -h"$MYSQLIP" --silent; do + sleep 1 + done + fi + +cat < /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=$MYSQLIP \ + MYSQL_SERVER_PORT=$MYSQLPORT MYSQL_ROOT_USER=$MYSQLUSER \ + MYSQL_ROOT_PASSWD=$MYSQLPASS MYSQL_GRANT_HOST=$IPADDR \ + 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 + 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 + +# 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 < /etc/postfix/transport +$FIRST_DOMAIN dovecot +EOF + +postmap hash:/etc/postfix/transport + +cat < /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 = (&(objectclass=person)(userPrincipalName=%s)) +result_attribute= mail +result_format = %d/%u/Maildir/ +debuglevel = 0 +EOF + +cat < /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)(mail=%s)) +result_attribute= userPrincipalName +result_format = %d/%u/Maildir/ +debuglevel = 0 +EOF + +cat < /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= mail +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 < /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 <> /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 + + touch /.configured + +else + + if [[ X"${MYSQLEXIST}" == X'YES' || X"${MYSQLEXIST}" == X'yes' ]]; then + service mysql start + fi + service iredapd start + service dovecot start + service clamav_clamd start + service clamav_freshclam start + service nginx start + service php7.2-fpm start + service amavisd start + service postfix start + service mlmmjadmin_enable start + service uwsgi start + service slapd start + + + while true; do sleep 1; done +fi diff --git a/iredmail/ChangeLog b/iredmail/ChangeLog new file mode 100644 index 0000000..2cf3f22 --- /dev/null +++ b/iredmail/ChangeLog @@ -0,0 +1,1841 @@ +iRedMail-1.3.1: + * Fixed issues: + - Fail2ban match rules were not up to date to match log lines produced + by the latest Roundcube. + Thanks Igor Cej for the feedback. + + * Updated packages: + + Roundcube webmail 1.4.7, with one security fix. + + netdata -> 1.23.1 + + iRedAPD-4.2, with a critical issue fixed. + +iRedMail-1.3: + * Supports new distribution releases: + + Ubuntu 20.04. All backends are supported: MariaDB, PostgreSQL, OpenLDAP. + + OpenBSD 6.7. All backends are supported: MariaDB, PostgreSQL, OpenLDAP. + + * DROPPED distribution release: + - OpenBSD 6.6. Please use the latest stable release 6.7 instead. + + * Improvements: + + Enable SOGo for CentOS 8 and Ubuntu 20.04. Thanks to SOGo team. + + Port scripts `tools/*.py` to Python 3. + + * Fixed issues: + - Enable TLSv1 on CentOS 7 due to the php package doesn't support TLSv1.2. + - Fix incorrect permission of Fail2ban log file, should be 0755 so + that netdata can read banned/unbanned info. + - Add missing INDEX for SQL column `msgs.time_iso` in `amavisd` + database. + + * Updated packages: + + Roundcube webmail -> 1.4.6, it includes few security fixes. + + iRedAPD -> 4.1. WARNING: Python 3.5+ is required, Python 2 support + has been completely dropped. + + mlmmjadmin -> 3.0. WARNING: Python 3.5+ is required, Python 2 + support has been completely dropped. + + netdata -> 1.23.0 + +iRedMail-1.2.1: + * Switch self-signed ssl cert key length to 4096. + * Swith DKIM key length to 2048. + * Updated packages: + + Roundcube webmail -> 1.4.4. it includes few security fixes. + +iRedMail-1.2: + * Supports new distribution release: + + CentOS 8 + + * Dropped distribution release: + - OpenBSD 6.5. Please use the latest stable release 6.6 instead. + + * Improvements: + + Able to store banned IP addresses in SQL db. + iRedAdmin-Pro customers can view banned addresses and unban them on + web UI directly. + + Fail2ban now works on OpenBSD. + + Track last login of both POP3/IMAP logins. + + * Fixed issues: + - Use 'pspell' spell check engine instead of default 'googie' which + sends data to Roundcube website. + - Not install package `libclamunrar9` for unpacking rar file on Ubuntu. + - installer: not correctly update allowed_clients in php-fpm pool + config file for FreeBSD Jail. + - Amavisd can not store mail subject with emoji characters. + + * Updated packages: + + Roundcube webmail -> 1.4.3 + + iRedAPD -> 3.6 + + netdata -> 1.21.1 + +iRedMail-1.1: + * Improvements: + - tools/backup_*.sh: do not rely on Python to calculate dates. + + * Fixed issues: + - PostgreSQL backend: improper index for table `vmail.sender_relayhost`. + - LDAP backend: improper filter which causes missing external members + while querying (not-subscribeable) mailing list with alias domain. + Thanks to Alyssa Hullinger for the report. + - Backup MX doesn't work. + - rsyslog config file `/etc/rsyslog.d/1-iredmail-iredapd.conf` doesn't + work on CentOS. + - Installer: + - Not enable IPv6 in Nginx. + - Not disable checks for energid in netdata. + Port 9998 is used by Amavisd and energid (not installed by + iRedMail) by default, netdata will try to send http request to + this port, hence it causes error message in Amavisd log file each + time netdata starts. + - Not correctly set Nginx log file path in Fail2ban. + - Not set message size limit in Roundcube ($config['max_message_size']). + - Not remove `!SSLv2` in Dovecot on Ubuntu 18.04. + Note: SSLv2 is actually disabled by OpenSSL. + + * Updated packages: + + Roundcube -> 1.4.2. + + iRedAdmin -> 1.0 + + iRedAPD -> 3.4. + + FreeBSD: postgresql-12, python-3.8, php-7.4 + +iRedMail-1.0: + * Supports new distribution release: + + OpenBSD 6.6 + + * Improvements: + - Netdata: Replace few Python modules by Go modules to collect data + for better performance. + - Disable email notification since netdata is too sensitive and the + notification message is "useless". + + * Fixed issues: + - Timeout for clamd service to load virus database is too short on + CentOS 7. + - Rejects the new Facebook servers which contain IP address in their + HELO identities. + + * Updated packages: + + Roundcube webmail -> 1.4.1 + + iRedAPD -> 3.3 + + iRedAdmin -> 0.9.9 + + netdata -> 1.19.0 + +iRedMail-1.0-beta2: + * Removed OpenDMARC integration due to internal bug which caused incorrect + email rejection. Bug reported to upstream: + https://github.com/trusteddomainproject/OpenDMARC/issues/50 + + * Improvements: + + tools/backup_*.sh: Remove old empty backup directory. + + * Fixed issues: + - Incorect SSL CA file path on FreeBSD. + - Improper postrotate command for log files on Linux. + + * Updated packages: + + iRedAPD -> 3.2 + + netdata -> 1.18.0 + +iRedMail-1.0-beta1: + * Supports new distribution release: + + OpenBSD 6.5 + + Debian 10 + + * Drop support for old distribution releases: + - OpenBSD 6.4 + - Ubuntu 16.04, 18.10. + + NOTE: We have no plan to support non-LTS edition anymore, only the + latest LTS edition will be supported. + + * Drop support for OpenBSD ldapd backend. + * Improvements: + + Dovecot: + - Enable quota-status service. Postfix can query this service and + reject email immediately if user's mailbox is over quota. + - Enable tracking user loast login time by default for + MySQL/MariaDB and OpenLDAP backends. + Note: Dovecot doesn't support this with PostgreSQL yet. + + + netdata: Disable sending anonymous statistics to netdata cloud. + + * Fixed issues: + - Improper order of restriction rules in Postfix + `smtpd_sender_restrictions` setting. + - Fail2ban jail config file doesn't correctly set sshd port number(s). + - Loose Fail2ban filter rules (postfix/dovecot) to reduce negative bans. + - [Linux] Not send kill signal to php-fpm daemon process to reopen log + file after logrotation. + - tools/create_mail_user_OpenLDAP.py: + - Fix missing comma which causes incorrect value of + ldap attribute 'enabledService'. + Thanks Michael Chong. + + * Updated packages: + + Roundcube webmail -> 1.3.10 + + iRedAdmin -> 0.9.8 + + iRedAPD -> 3.1 + + mlmmjadmin -> 2.1 + + netdata -> 1.17.0 + + php -> 7.3 (FreeBSD only) + +iRedMail-0.9.9 (Dec 17, 2018): + * Supports new distribution release: + + OpenBSD 6.4 + + Ubuntu 18.10. WARNING: It receives only 9 months of security and + maintenance updates, until July 2019. + NOT RECOMMENDED FOR PRODUCTION SERVER. + + * Improvements: + + netdata is able to monitor OpenLDAP. + + SOGo now supports resource management with OpenLDAP backend. + + Add rc script and rules for ip6tables on Debian/Ubuntu. + + iRedAdmin is now running as a standalone uwsgi instance (service + name 'iredadmin'), not controlled by 'uwsgi' service anymore. + + Use /opt/www to store web applications on all Linux distros and + OpenBSD. + + Able to set per-user mailbox format (e.g. mdbox) and mailbox folder + appended to maildir path in SQL/LDAP. + + Switch to utf8mb4 as default character set in MySQL. + + Set file/directory permission to 0400 for dumpped SQL backup files. + + OpenLDAP log file has been moved to /var/log/openldap/openldap.log + (was /var/log/openldap.log). + + * Fixed issues: + - Not correctly generate/update firewall rules if ssh is listening on + 2 network ports. + - Not index ldap attribute `mobile`. + - Not always specify a plain text footer file for altermime to update + email sent to mlmmj mailing list. + + Use accurate Nginx url match for Roundcube. + - mlmmjadmin: + - Not set correct owner/group for config file. + - Not use correct syslog socket path on FreeBSD. + - SQL backends: + - Not handle alias domains for relay in Postfix. + + * Updated packages: + + Roundcube -> 1.3.8 + + iRedAdmin -> 0.9.2 + + iRedAPD -> 2.3 + + mlmmjadmin -> 1.9 + + netdata -> 1.11.1 + + uwsgi -> 2.0.17.1 (OpenBSD only) + +iRedMail-0.9.8: + * Supports new distribution release: + + OpenBSD 6.2, 6.3 + + Ubuntu 18.04 + + * Dropped distribution releases: + + RHEL/CentOS 6 + + Ubuntu 14.04 LTS, 17.04 + + Debian 8 + + OpenBSD 6.1 + + * Remove components: + - Apache has been removed, Nginx is the only one web server available. + + * New components: + + netdata (1.10.0) monitor integration: http://my-netdata.io + Note: netdata currently works on Linux and FreeBSD, not OpenBSD. + + - Integrate netdata on Linux server: + https://docs.iredmail.org/integration.netdata.linux.html + + - Integrate netdata on FreeBSD server: + https://docs.iredmail.org/integration.netdata.freebsd.html + + + Integrate 'mlmmj' mailing list manager, and 'mlmmjadmin' RESTful API + server for easy mlmmj management. + + - mlmmj: http://mlmmj.org/ + - mlmmjadmin (developed and maintained by iRedMail team): + https://github.com/iredmail/mlmmjadmin + - Integrate mlmmj & mlmmjadmin: + - LDAP backends: https://docs.iredmail.org/integration.mlmmj.ldap.html + - MySQL/MariaDB backends: https://docs.iredmail.org/integration.mlmmj.mysql.html + - PostgreSQL backend: https://docs.iredmail.org/integration.mlmmj.pgsql.html + + Note: mlmmj & mlmmjadmin are now core components in iRedMail. + + * Improvements: + - SQL backends: + - New table: maillists. + - New columns: domain.maillists, forwardings.is_maillist. + - Removed column: mailbox.local_part. + It's inherited from PostfixAdmin at the beginning, but not used + by any applications, time to drop it. + - Table renamed: alias_moderators -> moderators. + - LDAP backend: + - Allow mail list account to use 2 attributes: member, uniqueMember. + - Nginx: redirect all traffic from http to https by default. + - Fail2ban: new jail `postfix-pregreet`. + - Dovecot: Log subject, sender, size in mail deliver log. + - Amavisd: Add new sql column `maddr.email_raw` and trigger to store + email address without address extension. + + * Fixed issues: + - iRedMail Installer: + - not correctly configure SOGo with IPv6 SQL server address. + Thanks to Wraptor for the report in + forum. + - not check whether mailbox storage is set to /root. + - Postfix: don't block the HELOs used by SendGrid. + - Nginx: + - Use single config file for default web hosts. + - [SECURITY FIX] Not block access to Roundcube sensitive files. + - SOGo: Cannot sync contacts on Android devices via EAS. + - Amavisd: cannot store mail subject if contains emoji. + - SQL backends: + - User under disabled domain is able to send email with smtp protocol. + - Add new SQL column `mailbox.enableimaptls`, required by + Dovecot-2.3. + - tools/backup_sogo.sh + - Not set correct owner and permission on backup files. + - Cannot remove old backup files. + - tools/backup_openldap.sh: + - Cannot log backup result to SQL db. + Note: backup is fine, just no log in SQL db. + Thanks swejun for the feedback and fix + in forum. + - tools/create_mail_user_*: + - Not use current date as password last change date for newly + created user. + - tools/migrate_sql_alias_table.py: + - Doesn't support 'utf8' charset. + Thanks Kacper Guzik for the + report and code contribution. + + * Updated packages: + + Roundcube -> 1.3.5 + + iRedAdmin -> 0.9 + + iRedAPD -> 2.2 + + uwsgi -> 2.0.17 (OpenBSD only) + + SOGo -> 4.0 (switched yum/apt repo to SOGo v4 nightly builds) + +iRedMail-0.9.7: + * Supports new distribution release: + + OpenBSD 6.1. OpenBSD 6.0 is not supported anymore. + + Ubuntu 17.04. Ubuntu 16.10 is not supported anymore. + + Debian 9 (code name: stretch). Tested with Debian 9 RC3. + + * Improvements: + - SQL structure change (for SQL backends): drop few columns in sql + table `vmail.alias`, and creates 2 new tables: forwardings, + alias_moderators. For more technical details, please check this issue: + https://bitbucket.org/zhb/iredmail/issues/101 + + - SOGo: + + New script 'tools/backup_sogo.sh'. used to backs up SOGo data + with 'sogo-tool backup' command. + + - Fail2ban: + + Add one new regular expession to filter Roundcube log. + + Enable 2 new jails: apache-auth, nginx-http-auth. + + Split jail.local to multiple modular jail config files under + /etc/fail2ban/jail.d. + + - Nginx: Use different directories to store different type of config + files for easier customization. + - /etc/nginx/conf.d/ - store configurations used inside 'http {}' + - /etc/nginx/sites-available/ - store config files for web sites. + All files under this directory are NOT loaded by default. + - /etc/nginx/sites-enabled/ - store config files for web sites. + All files under this directory will be loaded by default. + Usually file under this directory is a symbol link to file under + /etc/nginx/sites-available/. This way we can easily enable or + disable a site without renaming or moving its config file. + - /etc/nginx/sites-conf.d/ - store per-site modular config files. + for example, for web domain 'iredmail.org', we use directory + '/etc/nginx/sites-conf.d/iredmail.org/' to store modular config + files for all its http settings, and + '/etc/nginx/sites-conf.d/iredmail.org-ssl/' for all https + settings. You can use a prefixed digital number or letter to + define the order of config files loaded by Nginx. For example, + '00-listen.conf' will be loaded before other files. + + NOTE: of course you're not forced to use this directory, and + you're free to write all settings in one file like + '/etc/nginx/sites-available/.conf'. it's just a different + way (which we think it's better) to manage per-site settings. + + Examples: + + - sites-conf.d/iredmail.org/server_name.conf: define the server + name ('server_name iredmail.org;') + - sites-conf.d/iredmail.org/listen.conf: define the listen port + ('port 80;'). + - sites-conf.d/iredmail.org/root.conf: define the document root + directory ('root /var/www/vhosts/iredmail.org;') + + - Generate /root/.my.cnf-: + - /root/my.cnf-vmail + - /root/my.cnf-vmailadmin + - /root/my.cnf-amavisd + - /root/my.cnf-iredapd + - /root/my.cnf-iredadmin + - /root/my.cnf-sogo + - /root/my.cnf-roundcube + * Fixed issues: + - Enable 'iterate_query =' in 'dovecot-mysql.conf', so that doveadm + works fine if it needs to get all mail users. + - Not enable cron job for iRedAdmin script: tools/delete_mailboxes.py. + Thanks sergiocesar for the report. + - tools/backup_mysql.sh: Backup sql databases with mysqldump option + '--skip-comments' to avoid possible backdooring hack. + FYI: https://blog.tarq.io/cve-2016-5483-backdooring-mysqldump-backups/ + - FreeBSD: + - installing port 'archives/arj' interrupts iRedMail installation. + This is caused by global variable 'LANGUAGE=C'. + - Cannot reset MySQL (5.7) password. + + * Updated packages: + + iRedAPD -> 2.1 + + iRedAdmin -> 0.8 + + Roundcube -> 1.3.0 + + uwsgi -> 2.0.15 (OpenBSD only) + +iRedMail-0.9.6: + * Supports new distribution release: + + OpenBSD 6.0. OpenBSD 5.9 is not supported anymore. + + FreeBSD 11.0. + + Ubuntu 16.10. WARNING: Ubuntu 16.10 will end of life in July 2017, + Ubuntu 16.04 LTS edition is recommended for a production server. + + * Improvements: + - Use rsyslog (requires version 8.x) instead of internal logging system + for Dovecot on CentOS 7 and Ubuntu 16.04, 16.10. + + rsyslog is default syslog program on CentOS, Debian and Ubuntu. + With rsyslog, we're able to discard log messages which matches + given regular expressions if it produces too fast. for example, + HAProxy performs health check every few seconds for POP3/IMAP (and + other) services, we can easily discard those health check related + logs to save disk space. + + - Switch Awstats user authentication from SQL/LDAP to basic auth based + on file, Awstats is now available for both Apache and Nginx. + - Installer: + + Able to choose not to install web server and web applications. + + - Nginx: + - Add HSTS header for Roundcube, iRedAdmin, SOGo. + - Add sample config files to run Roundcube, iRedAdmin, SOGo as a + subdomain. + + - Roundcube webmail: + - Enable plugin `enigma` by default for PGP encryption. + WARNING: The plugin uses gpg binary on the server and stores all + keys (including private keys of the users) on the server. + Encryption/decryption is done server-side. So, this plugin + is for users that trust the server. + + If you get error `Identity must have a user name defined` while + first trying to generate gpg key, please add a name for your + email account in Roundcube: `Settings -> Identities`. + + - SOGo: + - List all contacts by default in SOGo global address book. + + - FreeBSD: + - Switch from OpenSSL to LibreSSL by default. + + * Fixed issues: + - LDAP backends: mail accounts (user, alias, list) are still active + when domain is disabled. + - Fix the HTTPROXY vulnerability in Apache and Nginx. + Reference: https://httpoxy.org/ + - Not convert domain name and email address to lower cases while + creating mail accounts with scripts tools/create_mail_user_*. + Thanks Santosh Gupta for the + report. + + - SOGo: + - Not correctly redirect access to https in Apache. + + - Postfix: + - Not enable opportunistic TLS support for remote smtp clients. + - Incorrect HELO restriction rule which causes Postfix rejects smtp + session with HELO "[IP_ADDRESS]" (with squared brackets). + + - Nginx: + - Not allow access to '/.well-known/'. + - Not forward real client IP address to SOGo. + - Config file for catch-all virtual host `default.conf` has been + renamed to `00-default.conf`, to make sure it will be loaded + before other virtual host config files. + + - Roundcube webmail: + - Missing cron job used to clean up old Roundcube temporary files + (bin/gc.sh). + - Not set proper file owner (apache/nginx) and permission (0600) + for config file of password plugin. + + - iRedAPD: + - Not add FreeBSD Jail IP address as trusted client. This causes + mail delivery failure while sending to user under same domain. + Thanks Erez Zabusky for the report. + + - OpenBSD: + - not enable uwsgi service. + - not create symbol links for PHP programs. + + * Updated packages: + + Roundcube -> 1.2.3 + + iRedAPD -> 2.0 + + iRedAdmin -> 0.7 + + uwsgi -> 2.0.14 (OpenBSD only) + + FreeBSD: + - php-7.0 + - mysql-5.7 + +iRedMail-0.9.5-1: + * Fixed issues: + - Postfix: + - Cannot deliver email to system account. + - OpenLDAP: + - Incorrect default password scheme if module 'pw-sha2' is not + available. + - PHP + - Allow functions: 'popen', 'openlog'. Required by Roundcube. + - Incorrect compress command used in logrotate config files. + - Add missing package 'mcrypt' on RHEL/CentOS 6. + + * Updated packages: + + iRedAPD -> 1.9.1 + +iRedMail-0.9.5: + * Supports new distribution release: + + Ubuntu 16.04 LTS (code name: xenial). + + OpenBSD 5.9. + + * Drop support for old distribution releases: + - Ubuntu 15.10 (code name: wily). + - OpenBSD 5.8. + - Debian 7 (code name: Wheezy). Please use Debian 8 instead. + + Debian team stops offering security updates for Debian 7 after + April 25, 2016. Reference: https://wiki.debian.org/DebianOldStable + + * Improvements: + - Postfix: + + Supports Postfix parameter `sender_dependent_relayhost_maps`. + + SMTP SASL AUTH is disabled on port 25. Please use port 587 instead. + - Amavisd: + + Add custom Amavisd log template (at log level 0) to always log + SpamAssassin testing result. + - OpenLDAP: + + Switch OpenLDAP backend to mdb (Memory-Mapped DB backend to slapd) + on Linux and FreeBSD (not available on OpenBSD yet). + + Enable OpenLDAP overlay 'pw-sha2' to support password verification + with sha2 algorithms. + - SOGo: + + SOGo is configured to store password in SSHA512 (instead of ssha) + hash by default. + + Switch SOGo to 3.x from 2.x on Linux/FreeBSD (OpenBSD offers v2). + + Able to enable/disable sogo service for a single user with new SQL + column `mailbox.enablesogo` and LDAP attribute/value + `enabledService=sogo`. + - OpenBSD ldapd(8): + + Add script and daily cron job to backup ldapd. + + * Fixed issues: + - Not correctly setup Fail2ban jail `action=` setting to block bad ssh + client IP address. + - Improper proxy timeout setting in SOGo and Nginx which cause SOGo + error 'client disconnected during delivery of response'. + - Not correctly add Postfix alias 'virusalert: root' for + non-(Debian/Ubuntu) OSes. + - Not create directory used to store php session files. + - Not enable cron job to auto update SpamAssassin rules on RHEL/CentOS. + + * Updated packages: + + Roundcube webmail -> 1.1.5 + + iRedAdmin -> 0.6 + + iRedAPD -> 1.9.0 + +iRedMail-0.9.4: + * New scripts: + - tools/fail2ban_unban_ip.sh. Used to unban specified IP addresses + from ALL fail2ban jails. + + * Fixed issues: + - Not enable port 25 in OpenBSD PF rule. + - Not detect IPv6 support on server. + - Not correct set file permission of /etc/mail/mailer.conf on FreeBSD. + - Not install port 'www/sogo-activesync' on FreeBSD. + - Installation inside FreeBSD Jail: + - Not correctly set MySQL/PostgreSQL/SOGo/Amavisd bind addresses. + - Not updating Postfix `mynetworks=` to use specified local + address. + Thanks Peter2121 for the report in forum. + - Use only 2 DNSBL services in postscreen service: + zen.spamhaus.org, b.barracudacentral.org. + - Cannot use specified MySQL root password on command line while + installing with remote MySQL server. + + * Updated packages: + + Roundcube webmail -> 1.1.4 + + iRedAPD -> 1.8.0 + + iRedAdmin -> 0.5 + + uwsgi -> 2.0.12 (OpenBSD only) + +iRedMail-0.9.3: + * Works on new distribution releases: + - Ubuntu 15.10. [Note: old 15.04 is not supported.] + - OpenBSD 5.8. Notes: + + 5.7 and earlier releases are not supported. + + spamd(8) is not enabled and replaced by postscreen, because + postscreen is better to reduce spam (e.g. with help of DNSBL + services). + + * Remove components: + - Cluebringer has been removed. It's not under active development and + no new release since 2013 (the latest stable release doesn't support + IPv6), we have greylisting and throttling support in iRedAPD as + replacement. + + * Improvements: + - SOGo Groupware is now available on FreeBSD. + - Enable HSTS (HTTP Strict Transport Security) in both Apache and Nginx. + - Update Fail2ban filter to catch postscreen log. + - Enable global address book for SQL backends in SOGo by default, + domains are isolated. Thanks dnwahs for the + sharing in iRedMail forum. + - Supports per-user alias address in SQL backends. 2 new sql columns + are required: `alias.is_alias`, `alias.alias_to`. + - Enable postscreen service in Postfix by default. + Important Note: all users must use port 587 for sending email, port + 25 doesn't accept submitted mail by authenticated users anymore. + - New SQL table `amavisd.outbound_wblist`, used to store whitelists + and blacklists for outbound messages. It's required by iRedAPD + plugin 'amavisd_wblist'. + + * New scripts: + - tools/ldap_assign_user_to_groups.py. Used to assign user to specified + mailing lists, or remove membership. + - tools/ldap_move_members_to_another_group.py. Used to move or copy ALL + members of specified mailing list to another. + + * Fixed issues: + - Key length 2048 of DKIM key is too long, too many complains because + many DNS vendors don't support it. So we generate with 1024 instead. + - Not add 'virusalert' in Postfix alias file. + - Not use correct postrotate command to rotate log file on Debian. + - Incorrectly set default fireewall zone on RHEL/CentOS 7 if you + didn't choose to restart firewall immediately. + - 'daemonze =' is required by RHEL/CentOS v6, but not v7. + - Incorrect Dovecot Master User account used by SOGo. + - Dovecot Master User doesn't work with LDAP backend. + - Incorrect quota warning priorities in Dovecot. + Thanks Peter for the feedback. + - Incorrect Amavisd setting to sign DKIM on inbound messages. + - [RHEL/CentOS] Cannot start uwsgi service with 'daemonize' setting in + /etc/uwsgi.ini. + - Not preserve the case of ${extension} while delivering message to + mailbox. + + * Updated packages: + + Roundcube webmail -> 1.1.3. + + uwsgi -> 2.0.11.2 (OpenBSD only) + + iRedAPD -> 1.7.0 + + iRedAdmin -> 0.4.3 + + FreeBSD: + - php-5.6 + +iRedMail-0.9.2: + * SOGo now works on Debian 8. + * Improvements: + - LMTP (port 24) and managesieve (port 4190) services are now listening + on only localhost (127.0.0,1 and ::1) by default. + - Improve Fail2ban filter `postfix.iredmail.conf` to prevent DoS + attack to SMTP service. + + * Fixed issues: + - Cannot create required SQL tables in `vmail` database with PostgreSQL + backend. + - catch-all support doesn't work with user+extension@domain.com. + Thanks to stevekez for the contribution + in iRedMail support forum. + - uwsgi service doesn't work on RHEL/CentOS. A new version of uwsgi + package was submitted to EPEL repo with higher priority (not + submitted by iRedMail team), it's not compatible with settings + configured by iRedMail, this causes uwsgi service cannot be started. + - Cannot import MySQL database on Jailed FreeBSD. + - Not install required port 'databases/py-sqlalchemy' on FreeBSD. + - Fix 'The Logjam Attack' ssl related issue. Reference: + https://weakdh.org/ + + * Updated packages: + + iRedAPD -> 1.6.0, bug fixes. + +iRedMail-0.9.1: + * Works on new distribution releases: + - Debian 8, Ubuntu 15.04. Notes: + o Roundcube and iRedAdmin are now stored under /opt/www. + o Cluebringer is not installed due to package missing in official + repo, that means your server doesn't support greylisting and + throttling. + o SOGo is not installed due to package missing in upstream (SOGo) + repo. + + - OpenBSd 5.7. Notes: + o No official MySQL binary packages, so please use MariaDB instead. + + * Drop support for old distribution releases: + - Ubuntu 12.04, 14.10. Please use Ubuntu 14.04 LTS or 15.04 instead. + + * Improvements: + - Log most terminal output of iRedMail installation to file + 'runtime/install.log', used for troubleshooting after installation. + - Backup scripts are able to delete old backup copies. Default setting + is keeping backup copies for 90 days. + - [LDAP] Allow mailing list account to use attributes: gidNumber, + memberUid. + - Don't install both Apache and Nginx, just one of them. + + Debian/Ubuntu package maintainer over-designed the post-install + script, it will restart service after package installed, if we have + both installed, installing another one will fail, because network + ports are used by the first one. + + Same reason as above, if we have both installed, upgrading both of + them will trigger service restarting too. This may cause the + currently running web service cannot start. + + - Make Dovecot subscribe newly created folder automatically. + Thanks Michael Telatynski for the + patch. + - Able to restrict user to login for specified IP addresses or + networks, multiple IP addresses or networks must be separated by + comma. + + o LDAP: IP addresses or networks must be listed in attribute + `allowNets` in user object. + o SQL: IP addresses or networks must be listed in SQL column + `mailbox.allow_nets`. + + - Bypass greylisting for some big ISPs + (samples/cluebringer/greylisting-whitelist.sql). + - Setup Fail2ban to monitor SOGo log file. + - Add two new Fail2ban filters to help catch spam. + + * Fixed issues: + - Amavisd cannot ban zipped '.exe' file on RHEL/CentOS. + - Install package `unrar` as rar unarchiver on RHEL/CentOS/Debian/Ubuntu. + - Incorrect log file and owner/group in /etc/logrotate.d/policyd. + - Cannot send email to user+ext@domain.com when per-domain catch-all + is enabled. Note: not fixed with LDAP backend yet. + - Cannot send mail with Roundcube and PHP 5.6. + - Cannot run PHP scripts under web document root with Nginx. + - Not use user's identity as envelope sender for 'return receipt' + responses. + - Not backup SOGo SQL database. + - Incorrect path of command 'sogo-tool' on OpenBSD. + - Not apply service restriction in Dovecot SQL query file while acting + as SASL server. + + * Updated packages: + + Roundcube webmail -> 1.1.1 + + uwsgi -> 2.0.10. OpenBSD only. + + iRedAdmin -> 0.4.2 (open source edition). + + iRedAPD -> 1.5.0. + + * Known issues: + + OpenLDAP backend: + - if you have catch-all account enabled for mail domain, email + sent to user+extension@domain.com will be delivered to catch-all + account. + +iRedMail-0.9.0: + * Works on new distribution releases: + - RHEL/CentOS 7 + - Ubuntu 14.10 (codename: utopic) + - OpenBSD 5.6. Note: Nginx is used as web server, the new built-in + httpd daemon (not Apache-1.3) is not used. + + * SOGo groupware integration: + + SOGo groupware provides a rich AJAX-based Web interface and supports + multiple native clients through the use of standard protocols such as + CalDAV, CardDAV and GroupDAV, as well as Microsoft ActiveSync. + Check its website for more details: http://sogo.nu/ + + Important notes of SOGo integration in iRedMail: + + o SOGo integration is available on below Linux distributions and releases: + + - RHEL/CentOS 6. SOGo project doesn't provide RPMs for CentOS 7 yet. + - Debian 7. + - Ubuntu 12.04 and 14.04. No official packages for 14.10 yet. + - OpenBSD 5.6. + + o Full/native Exchange protocol support requires OpenChange and Samba4, + but they're not integrated in iRedMail, so iRedMail-0.9.0 doesn't + provide full/native support for Microsoft Outlook clients, Apple + Mail.app and iOS devices. BlackBerry 10 works fine. + + Check our tutorial to setup your mail clients: + http://www.iredmail.org/docs/index.html#configure-mail-client-applications + + o If you choose to install both Roundcube webmail and SOGo, Managesieve + service is disabled in SOGo by default, because sieve rules generated + by SOGo is not compatible with Roundcube webmail. but if you don't + install Roundcube, managesieve will be enabled in SOGo by default, plus + vacation and forwarding support. + + o User cannot change password with PostgreSQL backend. + + * Improvements: + - Nginx support is now available on all Linux/BSD distributions. + + If you choose to use Nginx as default web server, both Awstats and + Cluebringer are not accessible, because Nginx doesn't have official + SQL/LDAP auth modules. You have to switch to Apache instead, and + reset mail user password to MD5. + + - MariaDB support is now available on FreeBSD. + - Add new index for SQL column 'msgs.spam_level' in 'amavisd' database. + - With MySQL/PostgreSQL backends, password hash is now SSHA512 by + default password on Linux, and BCRYPT on FreeBSD and OpenBSD. + Both Roundcube password plugin and iRedAdmin support them. + + if you want to login to Awstats/Cluebringer, you have to reset mail + user password to MD5 since Apache sql/ldap auth doesn't support + SSHA512/BCRYPT. + + - Enable global sieve script in Dovecot to move spam to Junk folder by + default. + - Disable SSLv3 in Postfix, Dovecot, Apache, Nginx. + - Backup scripts will log backup status in SQL table `iredadmin`, so + that admin can easily check backup status with iRedAdmin. + - Enable '@lookup_sql_dsn' in Amavisd by default, used for + per-recipient lookup policy, including white/blacklist, spam policy, + incoming message size limit. + - New index in `amavisd` database for SQL column `policy.policy_name`. + Required by iRedAdmin-Pro self-service. + + * Fixed issues: + - Replace mod_auth_mysql/pgsql by apr-util-mysql/pgsql for Awstats + and Cluebringer webui user authentication on Debian/Ubuntu. + - Not enable cron job to update SpamAssassin rules in file + /etc/default/spamassassin (CRON=1) on Debian/Ubuntu. + - Incorrect quota dict name in Dovecot quota warning script. + - Decrease number of pre-forked Amavisd processes ($max_servers) to 4 + by default to reduce memory usage. + - Add missing SQL column (mailbox.enableindexer-worker) and LDAP + attribute/value pair: enabledService=indexer-worker. Required by + Dovecot. + Thanks dwbotsch for the report. + + * Updated packages: + + Roundcube webmail -> 1.0.4 + + iRedAPD -> 1.4.4. 3 new plugins, bug fixes, performance improvements. + + iRedAdmin -> 0.4.1. New tool scripts, fixes several issues. + + * FreeBSD ports of major component: + o Apache: www/apache24 + o PHP: lang/php55 + o MySQL: databases/mysql56-server + o MariaDB: databases/mariadb55-server + o PostgreSQL: databases/postgresql93-server + + * Below packages are removed from iRedMail due to security concern: + - phpMyAdmin + - phpPgAdmin + - phpLDAPadmin + + If you need a sql management tool, please try http://adminer.org/ + (web-based, a single PHP file) or other desktop applications instead. + For local LDAP management, you can try ldapvi + (http://www.lichteblau.com/ldapvi/) in terminal. + For remote LDAP management, you can try http://www.ldapadmin.org/ on + Windows PC, or Apache Directory Studio on Windows/Linux/BSD/Mac: + http://directory.apache.org/studio/ (Java application). + +iRedMail-0.8.7: + * Works on new Linux/BSD distribution releases: + + Ubuntu 14.04 LTS. With MariaDB support. + + OpenBSD 5.5 + + * Drop support for below releases: + - Ubuntu 13.04, 13.10 + - OpenBSD 5.4 + + * Increase default Amavisd prefork children to 10 (default is 2). + * Allows sasl authentication ONLY over a TLS-encrypted smtp connection. + * Enable LMTP service in Dovecot by default. + To use LMTP instead of Dovecot LDA as per-domain or per-user local + deliver agent in Postfix, you need to use one of below: + - LMTP socket: lmtp:unix:private/dovecot-lmtp + - LMTP inet listener: lmtp:inet:127.0.0.1:24 + + * Removed columns for MySQL and PostgreSQL backends: + - domain.defaultlanguage + - domain.defaultuserquota + - domain.defaultuseraliases + - domain.disableddomainprofiles + - domain.disableduserprofiles + - domain.defaultpasswordscheme + - domain.minpasswordlength + - domain.maxpasswordlength + + They all are merged into column 'domain.settings'. For example: + domain.settings='default_language:en_US;default_user_quota:1024;' + + Please check iRedMail upgrade tutorial to migrate these columns: + http://www.iredmail.org/wiki/index.php?title=Upgrade/iRedMail/0.8.6-0.8.7 + + * New columns for MySQL and PostgreSQL backends: + + mailbox.enablelmtp: used by Dovecot LMTP server. + + domain.settings: used to store per-domain settings, userd in + iRedAdmin-Pro. + + mailbox.settings: used to store per-user settings, used in + iRedAdmin-Pro. + + admin.settings: used to store per-user settings, used in + iRedAdmin-Pro. + + alias.islist: used to mark a sql record is a mail list account. + + * New LDAP attribute/value pairs for mail users: + + enabledService=lmtp: used by Dovecot LMTP server. + + * Fixed issues: + + Postfix cannot resolve IP address under chroot on RHEL/CentOS. + + * Updated packages: + + Roundcube webmail -> 1.0.1 + + phpMyAdmin -> 4.2.0 + + iRedAdmin -> 0.3.3 + + iRedAPD -> 1.4.3 + +iRedMail-0.8.6: + * Works on new Linux/BSD distribution releases: + - Works on Ubuntu 13.10 (saucy). NOTE: phpLDAPadmin is not available + for OpenLDAP backend because it cannot be installed at all. + - OpenBSD 5.4, plus Awstats support. + + * Drop support for below releases: + + Debian 6 (squeeze). Please use Debian 7 (wheezy) instead. + + OpenBSD 5.3. Please use OpenBSD 5.4 (released on 2013-11-01) instead. + + * Drop support for Gentoo Linux and openSUSE linux. + Just few users chose them, so we decided to drop it to reduce our + workload and bring you better support for supported Linux/BSD distributions. + + * Better support for installing iRedMail with remote MySQL server. + Reference: + http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/MySQL/install.iredmail.with.remote.mysql.server + * Enable 'innodb_file_per_table' (per-table tablespaces) in MySQL by + default, this parameter avoids large ibdata files (.idb). + Reference: + http://dev.mysql.com/doc/refman/5.5/en/innodb-multiple-tablespaces.html + * Enable Opportunistic TLS support in Postfix when sending mail to remote + SMTP server (smtp_tls_security_level=may). + Thanks kotso and vlastikcz for the report. + * Switch from Policyd-1.8 to Cluebringer on all Linux/BSD distributions. + NOTE: The latest iRedAdmin-Pro supports Cluebringer management, includes + white/black/greylisting, throttling. + * Add parameter 'inet6 => 0' in Amavisd ldap settings to avoid ldap + connection error. + + * Fixed issues: + + Not rotate Cluebringer log file. + + Not setup cron job to cleanup expired entries in Cluebringer database. + + * Updated packages: + + iRedAPD -> 1.4.2. Fixed a bug in plugin sql_user_restrictions.py. + + iRedAdmin -> 0.3. Use python source file as config file. + + Roundcube webmail -> 0.9.5 + + phpMyAdmin -> 4.0.10 + +iRedMail-0.8.5: + * Use EPEL yum repo on RHEL/CentOS 6 by default. + * Update SQL triggers to insert value for column 'used_quota.domain' + automatically. + * SQL backends: Allow to assign mail list/alias as member of mailing list. + * New SQL column and LDAP attribute for mail domain, used to store + preferred language for newly created mail users. + - SQL: column domain.defaultlang + - OpenLDAP: attribute 'preferredLanguage' for mailDomain object + + * Drop support for below releases: + + Ubuntu 12.10 + + RHEL/CentOS 5.x + + OpenBSD 5.1, 5.2. + + openSUSE 12.1, 12.2. + + * Fixed: + + Incorrect Amavisd column name: + policy.unchecked_lovers_maps (incorrect) -> policy.unchecked_lover. + + Incorrect LDAP ACL for attribute "memberOfGroup". + Thanks Hoang Tuan Viet for the report. + + * Package update: + + Roundcube webmail -> 0.9.2 + + phpMyAdmin -> 4.0.4.1 + + iRedAdmin -> 0.2.2 + + iRedAPD -> 1.4.1 + + phpPgAdmin -> 5.1 + +iRedMail-0.8.4: + * Enable Dovecot Master User by default, but no pre-defined account. + * [SQL] New SQL columns in `vmail.mailbox` for per-user restriction, used + by iRedAPD: + allowedsenders, rejectedsenders, allowedrecipients, rejectedrecipients + * Now supports OpenBSD built-in LDAP daemon: ldapd(8). + * Fixed: + + [FreeBSD] Force all ports to use database/db48 by setting + 'WANT_BDB_VER=48' in /etc/make.conf. + Thanks hunci for the report. + - [ldap] Cannot mail to external members of mailing list if we use + alias domain as recipient (user@[alias_domain). + Thanks Soundar Rajan for the report. + - Add new alias 'virusalert' in Postfix for Amavisd. + Thanks Frankstar for the report. + - [ldap] Not enable OpenLDAP TLS/SSL support on OpenBSD by default. + - [ldap] Cannot handle alias domain in Postfix per-user bcc. + Thanks Ward De Backer for the report. + + * Package update: + + iRedAPD -> 1.4.0 + + iRedAdmin (open source edition) -> 0.2.1 + + Roundcube webmail -> 0.8.6 + + phpMyAdmin -> 3.5.5 + + phpLDAPadmin -> 1.2.3 + +iRedMail-0.8.3: + * Works on OpenBSD 5.2. + * Works on Ubuntu 12.10 (quantal). + * Dovecot will send an email to postmaster@ if user's mailbox is larger + than or equal to 95% full. + * Drop support for below distributions and releases: + + FreeBSD 8.x. + + Ubuntu 10.04 (lucid). Please use 12.04 (precise) instead. + + openSUSE 12.1 (asparagus). Please use 12.2 (mantis) instead. + + * Fixed: + + Incorrect LDAP uri in cluebringer Apache config file. + Thanks labasus for the report. + + amavisLocal=true should be amavisLocal=TRUE (upper cases) in + tools/create_mail_user_OpenLDAP.sh. + Thanks soxgoon @https://bitbucket.org/ (issue #6) + + Incorrect SQL table name in Cluebringer httpd config file. + + Empty value of AMAVISD_VIRUSMAILS_DIR on RHEL/CENTOS/Scientific 6. + This issue causes cron job deletes DKIM pem files. + Thanks kislik for the report. + + * Package update: + + phpMyAdmin -> 3.5.3 + + iRedAdmin -> 0.2 + + Roundcube webmail -> 0.8.2 + +iRedMail-0.8.2: + * Add shell script to backup PostgreSQL databases in cron by default. + Script is /var/vmail/backup/backup_pgsql.sh, backup directory is + /var/vmail/backup/pgsql/. + * It now works on openSUSE-12.2 with all 3 backends available. + * Drop support for Ubuntu-11.10 (oneiric). + * New columns for MySQL/PGSQL backend in table vmail.mailbox: + isadmin, isglobaladmin, language. + * Allow to use LDAP attribute shadowAddress for mail list account. + Thanks chrisjrob for the report. + * Add checkpoint setting in OpenLDAP for data recovery, used to define + the time between BDB checkpoint operations. Default is whenever 128kb + data bytes written or 5 minutes has elapsed whichever occurs first. + * Rotate Dovecot log files on OpenBSD and FreeBSD. + * Allow to use LDAP attribute domainGlobalAdmin for mail user. + * Fixed: + + Don't orerride default SpamAssassin score of SPF_PASS, SPF_FAIL. + Thanks brandon and imknight + for the feedback. + + [LDAP] Incorrect maildir path while using Postfix built-in + 'virtual' transport. + + Incorrect log rotate setting of iRedAPD log file on FreeBSD. + Thanks openbsdnoob for the report. + * Package update: + + phpMyAdmin -> 3.5.2.2 + + iRedAPD -> 1.3.8 + + iRedAdmin -> 0.1.9 + + Roundcube webmail -> 0.8.1 + +iRedMail-0.8.1: + * It now works on Debian wheezy. Tested with Debian wheezy alpha 1. + * Drop support for Linux Mint. Sorry, not a server OS. + * Add new column 'mailbox.language' in MySQL & PGSQL backends, used by + iRedAdmin. + * Make sure per-user BCC settings have higher priority than per-domain + settings. + * Enforce connections over https in Roundcube. + * Fixed: + + Incorrect MySQL user password and databases in MySQL backup script. + + Add missing rotate config for iRedAPD log file on FreeBSD, OpenBSD. + + Add missing config and SQL table required for sharing IMAP folder to + anyone. Thanks BigMichi1 . + + Add missing auth service in Dovecot-2: auth-userdb. + + Add new LDAP attribute and SQL column required by Dovecot-2 share folder: + enabledService=lib-storage (ldap), enablelib-storage=1 (SQL). + Thanks moreni for the report. + + [mysql & pgsql] Incorrect maildir path while using Postfix built-in + 'virtual' as transport. + + [ldap] Require enabledService=deliver instead of enabledService=smtp + for maillist members. + Thanks rain6966 for the report. + + * Package update: + + iRedAdmin -> 0.1.8 + + phpMyAdmin -> 3.5.1 + +iRedMail-0.8.0: + * It now works on OpenBSD. Tested with OpenBSD 5.1. + +iRedMail-0.8.0-beta4: + * Add new value of enabledService: doveadm. Required by Dovecot-2.0 + service doveadm. + * All clients are forced to use IMAPS and POPS (via STARTTLS). + To enable POP3/IMAP without STARTTLS again, set 'ssl=yes' and + 'disable_plaintext_auth=no' in dovecot.conf. + * Drop support for Dovecot-1.1. At least Dovecot-1.2 is required. + * Fixed: + + DEBUG=NO in conf/global breaks postfix installation on FreeBSD. + * Package update: + + iRedAdmin -> 0.1.7. It now works with PostgreSQL. + + iRedAPD -> 1.3.7. It now works with PostgreSQL. + +iRedMail-0.8.0-beta3: + * Enable PostgreSQL support on FreeBSD, RHEL/CentOS 6. + * Add shell scripts to backup OpenLDAP and/or MySQL in cron by default. + * Use Dovecot-2.0 instead of 1.2.x on openSUSE-12.1. + * Drop support for below distributions and releases: + + Debian 5 (Lenny) + + Ubuntu 8.x, 9.x, 10.10, 11.04 + + openSUSE: 11.x + + FreeBSD: 7.x + * Enable greylist opt-in in Policyd-1.x by default. + * It now works on Ubuntu Linux 12.04 (precise). Tested on Alpha 2. + * It now works on Linux Mint 12 (based on Ubuntu, code name: lisa). + * Add share folder support within Dovecot 2. + * Fixed: + + Incorrect postrotate command for dovecot log files. + Thanks raffayellow@gmail for the report. + + Two Dovecot config files are world readable: used_quota.conf, + share-folder.conf. + Thanks Martin Kuchar for the report. + * Package update: + + Roundcube -> 0.7.2 + + MySQL -> 5.5 (FreeBSD) + + Dovecot -> 2.0 (FreeBSD) + + iRedAPD -> 1.3.7 + +iRedMail-0.8.0-beta2: + * It now works perfectly on Gentoo. + * Fixed: + + Dovecot cannot store realtime quota usage in PostgreSQL. + + User authentication in Roundcube is case sensitive (login_lc). + +iRedMail-0.8.0-beta1: + * It now supports PostgreSQL as backend on Ubuntu 11.10/12.04. + * Package update: + + Roundcube webmail -> 0.7.1 + +iRedMail-0.7.4: + * Enable two sample dovecot sieve filters in Roundcube webmail: + Move spam to Junk, Vacation. Both are disabled by default. + * Store realtime mailbox quota in separate SQL table in MySQL backend. + * It now works on Ubuntu 11.10, openSUSE 12.1. + * SPF verification is now enabled by default. + * Add Policyd-2.0.x (code name "cluebringer") support on Ubuntu 11.10. + * Fixed: + + Apache daemon user doesn't have permission to read Apache log files in + Awstats's cron job. + + Incorrect per-user realtime mailbox quota if loggin in with shadowAddress. + OpenLDAP backend only. Thanks tmihalicek . + + Incorrect per-user sieve_dir setting in Dovecot. + Thanks cetex . + + Add missing INDEXes for Amavisd database: msgs.mail_id, (msgs.content, + msgs.time_num), quarantine.mail_id. + Thanks rjnena , David . + * Package update: + + phpLDAPadmin -> 1.2.2 + + Roundcube webmail -> 0.7.0 + + phpMyAdmin -> 3.4.8 + +iRedMail-0.7.3: + * Add enabledService=lda for newly created LDAP mail user. Required by + Dovecot 2.x. + * Works on CentOS 6.0, RHEL 6.x, Scientific Linux 6.x. + * Mbox format mailbox is not supported anymore. + * Add smtp-amavis_destination_recipient_limit=1 in Postfix for concurrency + per-recipient limit. Thanks beez . + * Package update: + + Roundcube webmail -> 0.5.4 + + iRedAdmin -> 0.1.6 + + phpMyAdmin -> 3.4.3.2 + +iRedMail-0.7.2: + * Works on Ubuntu 11.04. + * Enable LDAPS on FreeBSD by default. Thanks Markus Wyrsch . + * Improvements: + + Add alias domain support in postfix virtual_mailbox_domains (MySQL + backend special). + * Fixed: + + Set 'ServerTokens' to 'ProductOnly' in Apache on Debian/Ubuntu. + Thanks c33s@forum. + * Package update: + + Roundcube webmail -> 0.5.3 + + phpLDAPadmin -> 1.2.1.1 + + phpMyAdmin -> 3.4.1 + + iRedAPD -> 1.3.6. Fix two issues for MySQL backend. + + iRedAdmin -> 0.1.5. Security fix edition. + +iRedMail-0.7.1: + * Fix incorrect icon path in awstats. Thanks for the feedback. + * Use 2048 as default SSL key length. Thanks mike.f@forum . + * Increase Postfix timeout seconds: smtp_data_init_timeout (120s -> 240s), + and smtp_data_xfer_timeout (180s -> 600s). Hope to avoid some timeout + issues. Thanks write4saini@forum, mbsouth@forum. + * Integrate Fail2ban. Note: It doesn't work on FreeBSD yet. + * Support domain alias in postfix relay_domains (MySQL backend special). + Thanks atros@forum. + * Support domain alias in mail alias, catch-all account. + * Package update/changes: + + Roundcube -> 0.5.2 + + iRedAPD -> 1.3.5 + +iRedMail-0.7.0: + * Append '-f /path/to/slapd.conf' to slapcat in tools/backup_openldap.sh. + Thanks Enrico Cotti . + * Save date of password last change while updating password in roundcube. + +iRedMail-0.7.0-rc3: + * Make IMAP share folder work with LDAP backend. Thanks alexp@forum. + * Update phpMyAdmin to 3.3.10. + +iRedMail-0.7.0-rc2: + * Check domain status in dovecot MySQL lookup and postfix + virtual_mailbox_maps, virtual_alias_maps, sender_login_maps, per-user + transport_maps, per-user sender_bcc_maps and recipient_bcc_maps (MySQL + backend). + +iRedMail-0.7.0-rc1: + * Make catch-all account work as expected with MySQL backend. + * Create indexes for some columns in MySQL backend. + +iRedMail-0.7.0-beta6: + * Enable iRedAPD for MySQL backend. Used for mail alias deliver + restrictions. Reference: + http://www.iredmail.org/wiki/index.php?title=Install/iRedAPD/MySQL + +iRedMail-0.7.0-beta5: + * Reverse Amavisd LDAP query base dn. + * Install python-xml on OpenSuSE 11.4. + +iRedMail-0.7.0-beta4: + * Works on OpenSuSE 11.4. + * Improvements: + + Alias domain support for catchall account in LDAP backend. + + * Package update/changes: + + phpMyAdmin -> 3.3.9.2. + +iRedMail-0.7.0-beta3: + * New features: + + Enable personal LDAP address book for OpenLDAP backend. + + New column for MySQL backend: domain.defaultpasswordscheme. Used + to store per-domain password scheme. + + * Improvements: + + Check domain status in virtual_mailbox_maps, virtual_alias_maps + for MySQL backend. + + Don't allow user to view ldap attributes: domainAdmin, + domainGlobalAdmin. + + * Fixed: + + Remove unique index (primary key) on table amavisd.msgrcpt to avoid + duplicate entries. + + Incorrect path of phpLDAPadmin on Ubuntu 10.04.x/10.10.x. + Thanks xulingyun@bbs for the feedback. + + * Package update/changes: + + PostfixAdmin -> Removed. + + iRedAdmin -> 0.1.4. + + Roundcube webmail -> 0.5.1. Remove 3rd-party plugin: imap_acl. + +iRedMail-0.7.0-beta2: + * Improvements: + + Auto create default IMAP folders with dovecot plugin: autocreate. + + Add plugin 'imap_acl' for roundcube to let users manage their + mailbox sharing, but disabled by default. + + Mailbox sharing support with dovecot 1.2. Disabled by default. + + Show realtime quota usage with dovecot-1.2 dict quota in + PostfixAdmin. + + Don't quarantine mails with bad header in Amavisd. + '$bad_header_quarantine_method=undef;' + + Increase dovecot "mail_process_size" to 1024MB by default. Hope to + avoid a dovecot "out of memory" issue when processing large mailbox. + Thanks James Kong. + + Enable whitelising sender (WHITELISTSENDER=1) in policyd by default. + * Fixed: + + Make sure apache wsgi module is loaded on RHEL/CentOS. + Thanks Murat Uğur Eminoğlu for the feedback. + + Fix incorrect file localtion of php.ini on OpenSuSE. + * Package Update: + + Roundcube webmail -> 0.5 + + phpMyAdmin -> 3.3.9.1 + +iRedMail-0.7.0-beta1: + * Works on OpenSuSE 11.3. Tested on 11.3, but it should work well on + 11.2, 11.1 too. + * Improvements: + + Store realtime quota usage in MySQL with Dovecot-1.2. Reference: + http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/Store.Realtime.Quota.In.MySQL + + Use repository 'backports.debian.org' on Debian 5. + + Bypass shadow address in postfix sender login checking. + + Improve postfix ldap lookup to make mail list of alias domain work. + Thanks for Andrea Di Dato's feedback and testing. + + Integrate MySQL in Amavisd: @storage_sql_dsn. + + Improve backup mx support with MySQL backend. Thanks tiangangnet@bbs + + Replaced ldap attribute: + - gn (old) -> givenName + - fax (old) -> facsimileTelephoneNumber + * New backup scripts: tools/backup_openldap.sh, tools/backup_mysql.sh. + Reference: http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/Backup + * Upgrade packages: + + Dovecot -> 1.2.x. On RHEL/CentOS & Debian 5 (with backports). + + PostfixAdmin -> 2.3.2 + + phpMyAdmin -> 3.3.7 + + Roundcube webmail -> 0.4.2 + * Fixed: + + Fix incorrect file location of awstats.pl on Debian/Ubuntu. + +iRedMail-0.6.1: + * Add missing mail log files (mail.info, mail.err, mail.warn) in logrotate. + Thanks to BigMichi1@forum. + * Catch-all account support in MySQL backend. + * Run iRedAdmin as a low privilege user (iredadmin). + * Improve Ubuntu 10.04 support. + * Update iRedAPD to 1.3.3. Run iRedAPD as a low privilege user (iredapd). + +iRedMail-0.6.0: + * Disallow to use multiple identities in postfix and roundcube. + * Update iRedAPD to 1.3.0. + * Add missing table on Debian 5 and Ubuntu 9.04: + postfixpolicyd.blacklist_dnsname. + * Upgrade phpMyAdmin to 2.11.10. + * Add 'enableinternal=1' in vmail.mailbox and 'enabledService: internal' + in OpenLDAP. + * Not allow to login with shadow address. It may cause login failed due + to duplicate ldap query result (normal user, another normal user with + shadow address). + * Fix shabang line of dovecot quota warning script. Thanks Alex Stanciu. + * Fix loading awstats issue on FreeBSD. Thanks dbetts22@forum. + * New LDAP attributes: mailWhitelistRecipient, mailBlacklistRecipient. + Used for per-user recipient restrictions. + * Fix: freshclam can't start after update to 0.96. Fixed by removing inline + comment in freshclam setting. Thanks wildweasel@forum. + * Fix incorrect path of policyd-cleanup on Debian & Ubuntu. Thanks + tkuntario@forum. + * Improve ldap scheme file to use 'sub' index. + +iRedMail-0.6.0-RC1: + * Add catch-all account support in LDAP backend. + * Fix amavisd startup issue on FreeBSD: run sa-update first. + * Patch to fix roundcube security issue: CVE-2010-0464, Disable DNS + prefetching. + * New LDAP attribute: userManager. Used to replace 'manager' attribute. + * Hide template warning in phpLDAPadmin. + * Update iRedAPD to 1.2.3. + +iRedMail-0.6.0-beta3: + * Fix incorrect symbol link of /usr/lib/sendmail on FreeBSD. + * Fix iRedAPD rc script on FreeBSD. + * Fix rc.conf setting for policyd on FreeBSD. + +iRedMail-0.6.0-beta2: + * Integrate iRedAPD-1.2 to provide mail list access management for LDAP + backend. + * Upgrade phpLDAPadmin to 1.2.0.5. + * Use yum repository to install all rpm packages on RHEL/CentOS. + * Move dovecot-quota-warning.sh to /usr/local/bin/. Thanks chunlinyao@bbs. + * Don't use 'mktemp' to generate random temp file. Thanks chunlinyao@bbs. + +iRedMail-0.6.0-beta1: + * Update dovecot to 1.1.20 on RHEL/CentOS. + * Update postfixadmin to 2.3. + * Add domain alias support in MySQL backend. + * Update phpMyAdmin to 2.11.9.6. + * New LDAP attribute: accountSetting. + * Update roundcube to 0.3.1. + * Add script used to generate new SSL keys: tools/generate_ssl_keys.sh. + * Add 'disclaimer' in mail user object, used to store per-user + disclaimer text. + * Allow ping from remote hosts in iptables rule. + * Update clamav to 0.95.3. Thanks http://dag.wieers.com. + +iRedMail-0.5.1: + * Remove three more unnecessary dialog pages. + * Use random password for ldap admin dn: cn=vmailadmin. + * Add domain alias support with new ldap attribute: domainAliasName. + * Ability to restrict POP3S & IMAPS in dovecot now. + * LDAP attribute 'domainName' now allow multi-value. + * Enable mod_deflate in apache by default. + * Update dovecot to 1.1.16 on Debian 5, patched to fix security holes in + CMU Sieve plugin. Reference: + http://marc.info/?l=dovecot&m=125288621404279&w=2 + * Add script (tools/clear_iredmail.sh) to remove main components + installed by iRedMail. + * Use postfix proxymap(8) to reduce server load under high load. + * Update dovecot to 1.1.19 on RHEL/CentOS. + * Add 'preferredLanguage' in objectClass mailUser. + * Increase ldap server-side sizelimit to 1000. + * Add external user support in mail list. + * Allow to use multiple identities. + * Fix incorrect postfix setting which will cause mail forwarding and bcc + invalid after upgrade to 2.5. + * Make user can't change employeeNumber. + * Add more LDAP attributes: domainDefaultUserQuota, + domainMinPasswordLength, domainMaxPasswordLength. + * Add more sql columns: defaultuserquota, minpasswordlength, maxpasswordlength. + * Update postfix to 2.5.9. + * Replace sshd port number in default iptable rule by the current setting. + * Add @mynetworks in amavisd config for Debian/Ubuntu. + * Make file world-readable if ACL is not available. + * Add per-user shadow address support in LDAP backend, and it's allowed to + login with shadow address. + * Add missing pkg: altermime for RHEL/CentOS (i386). Thanks to + sdaniel@bbs. + * Remove php-eaccelerator, will abort installation process when php-5.2+ + already installed. + * Add missing service control in postfix ldap lookup table. + * Fix per-user sieve setting in dovecot. Thanks Emidio Reggiani + and Caliban @forum. + +iRedMail-0.5.0: + * Fix mod_auth_mysql config issue on Ubuntu. + * Update: dovecot -> 1.1.18. + * Fix DKIM singing issue on Debian/Ubuntu. Thanks shake.chen@gmail. + * Add columns/attributes to store user last-login data. + * Support per-user transport maps, enabled by default. + * Remove unnecessary ldap lookup in postfix. + * Set storagebasedirectory in MySQL template. + * Add ldap attribute and mysql column 'disclaimer' to store disclaimer + text. + * Enable dovecot quota warning by default. + * Move default mail storage directory: /home/vmail -> /var/vmail/. Use + /var/vmail/vmail01 as default storage base directory. Thanks mbsouth + @forum. + * Only modify /etc/amavis/conf.d/50-user in debian & ubuntu. + * Fix DKIM singing issue: disable 'forward_method' in policy_bank + 'ORIGINATING'. Thanks webstudio@forum. + +iRedMail-0.5.0-rc2: + * Add relay_domains & relay_recipient_maps in postfix, used for backup mx. + * Improve global ldap address book in roundcube, make it search accounts + which in the same domain. + * Fix dovecot setting for mysql backend. + * Update: clamav -> 0.95.2, awstats -> 6.9-2, dovecot -> 1.1.16. + * Add two more LDAP attributes in iredmail.schema: + domainMaxListNumber, domainCurrentListNumber. + * Add missing package vixie-cron & tmpwatch in RHEL/CentOS. + * Enable anti-spam & anti-virus on Debian & Ubuntu by default. Thanks + Falador@forum. + * Add quota warning report tool: tools/dovecot-quota-warning.sh. + * Automatically add a disclaimer to outgoing emails with Amavisd-new + + alterMIME (v0.3.10). + * Update Mail-DKIM to 0.36. Thanks to lidaobing@gmail for ubuntu 8.04 and + debian lenny packages. + * Add /extra/ directory for 3rd-party service integration. + * Improve tools/create_mail_user_OpenLDAP.sh to integrate pureftpd + schema. + * Hashed maildir string: hash_domain(), hash_maildir in conf/functions. + * Flexible storage base directory used to store users' mail data, easy + to change, useful for large-scale deployment. e.g.: + Your mail data are all stored in /home/vmail01, but disk storage is + nearly full, it's easy to make new users use new storage like + /home/vmail02, /home/vmail03 or whatever: + - Prevous maildir: /home/vmail01/z/zh/zha/zhang/ + - Current maildir: /home/vmail02/h/hu/hua/huang/ + You can set the storage base directory in either MySQL (column: + vmail.storagebasedirectory) or OpenLDAP backend (attribute: + storageBaseDirectory). + + In addition, maildir and user's HOME directory are seperated (maildir + is $HOME/Maildir/ by default), so that you can integrate more + applications against LDAP user auth like OpenSSH, FTP service, SugarCRM + or whatever you want, data stored in disk storage of each service will + not be mixed. + * Add group 'all@domain.ltd' by default for ldap solution. + * Add 'enabledService=displayedInGlobalAddressBook' for ldap solution, + used to control mail address displayed in global ldap address book or + not. + +iRedMail-0.5.0-rc1: + * Update perl-Mail-DKIM to 0.35. hope to fix dkim issue in amavisd: + Reference: http://marc.info/?t=124300167400002&r=1&w=2 + * Add new ldap attribute: memberOfGroup. + * Update SquirrelMail to 1.4.19. + * Works on Ubuntu 9.04 (Juanty) now. + * Add rc script for iptables used on Debian. + * Works on Debian (Lenny, 5.0.1) now. + * Add priority (=1) in iRedMail repo file. Thanks scrummie02@forum. + * Update phpLDAPadmin to 1.1.0.7. + * Add bcc control in postfix bcc lookup map. + * LDAP attribute 'domainStatus' is deprecated, use accountStatus instead. + * Add more ldap attributes: domainCurrentQuotaSize, + domainCurrentUserNumber, domainCurrentAliasNumber. + * Add objectclass mailAlias in ldap schema, sync postfix alias lookup + and roundcube global address book lookup, both will search mailList, + mailAlias, mailUser forwarding in one search filter. + * Add forwarding control in postfix alias lookup map. + * Update dovecot to 1.1.14. + * Add 'employeeID' in SQL template. + * Add robots.txt in web server document root to disallow search engines. + * POP3/IMAP are enabled by default, dialog page removed. + * Known issue: pysieved will cause a zombie process. + * Update clamav to 0.95.1. + * Update roundcube and related patches to 0.2.1-stable. + * managesieve service (pysieved) is now not a optional function. + * Add one more object to ldap user/admin: shadowAccount. + * Add ldap attribute to store user's backup mail address, used for + password reset or whatever. + * Add backup mx detect in virtual domain lookup. + * Update phpMyAdmin to 2.11.9.5. + * Address of mail group/list will be autocomplete while you type + recipients in roundcube now. + * Say goodbye to Horde. + * Add group mail/alias support for openldap backend. + * Add attribute for mail list access policy control. + * Add missing index attributes in OpenLDAP: listMember, listAllowedUser, + accessPolicy. + * userPassword & accountStatus are optional for objectclass mailAdmin. + * Fixed OpenLDAP ACL. + * Fixed: Make awstats access via https only. + * Create symbol link for all web-based programs, so that we don't have + to restart apache while upgrade them. + * Fix file permission: /etc/pysieved.ini, should be owned by vmail:vmail. + * Add max length limit for several ldap attributes, remove unnecessary + attribute. + * Adjust mail_location setting in dovecot, use home directory now. + * Replace 'gn' by 'givenName' in roundcube global ldap address book. + Thanks shake.chen@gmail. + * Add script for mysql database backup: tools/backup_MySQL.sh. + +iRedMail-0.4.0: + * Say goodbye to mailgraph. + * Say goodbye to ExtMail. + * Add two tool scripts for winwebmail and extmail mailbox migration. + * Change ${SIEVE_DIR} to ${VMAIL_USER_HOME_DIR}/sieve/. + * Add patch for roundcube-0.2 to change ldap password. + * Use mod_auth_mysql for user auth in awstats. + * Improve LDAP schema. + * Avoid quote in HOSTNAME variable. Thanks shake.chen@gmail. + * Update rrdtool to 1.2.30. + * Enable preview pane in roundcube by default. + * Remove phpLDAPadmin templates. + * Add shell script for creating ldap virtual user. + * Update amavisd-new to 2.6.2, dovecot to 1.1.11, lzo to 1.08-5, nomarch + to 1.4-2. + * Remove package: cyrus-sasl, mailman. + * Prompt to choose the default language for webmails. + * Update awstats to 6.9. + * Make webmail can be accessed via HTTPS (except horde). + * Use syslog as default log driver in roundcube. + * Directory renamed: tools/ => dialog/. + * Make phpLDAPadmin, phMyAdmin, PostfixAdmin can be accessed via HTTPS + only. + * Improve LDAP schema, use 'enabledService=XXX' instead of + enableXXXService. + * Make awstats use LDAP user auth if use OpenLDAP as backend. + * Update dovecot-sieve to 1.1.6. + * Use variable to control whether download packages from official yum + repository or not. + * Mark iptables as a must service. + * Update packages: Dovecot => 1.1.8, rrdtool => 1.2.29, postfix => 2.5.6. + * Fix incorrect parameter in postfix ldap lookup table: debug_level => + debuglevel. + * Add container to disable autoindex in apache. Thanks + muniao@gmail. + * Update Postfix to 2.5.5. + * Add one more helo pcre rule, prepend helo identifier in mail header. + * Add missing package 'perl-Encode-Detect', required by sa-update. + * Update phpLDAPadmin to 1.1.0.6. + * Fix crontab job for expire mail in dovecot. Thanks xcrossbow@gmail. + * Reduce postfix queue run retry time to '300s'. + * Add one more pcre expression for smtpd helo restriction to block client + which use dynamic ip address. Thanks muniao@gmail. + * Fix incorrect crontab job for vmail user. Thanks xcrossbow@gmail. + * Set maximal_queue_lifetime and bounce_queue_lifetime to '1d'. Thanks + muniao@gmail. + * Fix incorrect filename while attachment file with Chinese (non-ascii) + characters in Roundcube-0.1.1-stable. Thanks bruce.16899@gmail and + tao.xu.man@gmail. + * Fix postfix aliases file. + +iRedMail-0.3.2: + * Export PATH variable while switch to root user. Thanks xcrossbow@gmail. + * Update phpMyAdmin to 2.11.9.4. + * Fix MySQL password issue while contains special characters. Thanks + xcrossbow@gmail. + * Make some command operating system independent. + * Update Dovecot to 1.1.7. + * Update SquirrelMail to 1.4.17. + * Don't specify vmail uid/gid. + * Generate sieve global filter rule sample file. + * Use mail log config in awstats as default config file. + * Fix file permission for awstats if we use ExtMail at the same time. + * Remove two extra packages: roundcubemail-0.1.1-buttons-zh_CN.tar.bz2, + roundcubemail-0.1.1-skin-default-labels.tar.bz2. + * Update clamav to 0.94.2. + * Add patch for ExtMail to make it create user maildir automatic. + * Clear default account in ExtMail global address book. + * Fix change password issue in ExtMail-1.0.5. Thanks ilovell.pan@gmail. + +iRedMail-0.3.2-beta1: + * Fix missing php-mysql installation. Thanks webyuhang@hotmail. + * Add LDAP attrubites for service control: enableMailService, + enableFTPService, enableIMService. + * Split dialog config, make webmail program in a standlone page. + * Use unix socket to connect mysql server by default. + * Make Horde Ingo mail filter rules manager works with pysieved. + * Make horde sql database use utf8 as default charset. Thanks + bruce.16899@gmail for his remind. + * Add global ldap address book for horde when use OpenLDAP as backend. + Thanks bruce.16899@gmail for his remind. + * Initialize import php-eaccelerator. + * Update clamav to 0.94.1. Thanks to chenwei for his remind. + * Update php-rrdtool, rrdtool to 1.2.28. + * Initialize import awstats as web and mail log analyzer. + * Improve mailgraph, it can display greylist counter now. Merge css code + to mailgraph.cgi. + * Update phpMyAdmin to 2.11.9.3. + * Set default language to zh_CN in horde, roundcube, squirrelmail. + * Make Roundcube WebMail work while use OpenLDAP as backend, use OpenLDAP + as global ldap address book. + Note: Change password and forwarding setting are disabled yet. + * Remove postgrey, it's replaced by policyd. + Note: Due to this change, MySQL will be installed if you choose OpenLDAP + as backend. + * Fix mail attachment size in ExtMail. Thanks tongds@gmail. + * Add patch to fix login security issue. Reference: + https://sourceforge.net/mailarchive/forum.php?thread_name=49057E07.3060806%40gmail.com&forum_name=postfixadmin-devel + * Improve dovecot quota warning support. + * Add bzip2 as compress command in logrotate. Enabled by default. + * Integrate expire plugin support for Dovecot. + * Enable SSL support for MySQL. + * Fix issue of TERM variable. Thanks yao.xu at + http://bbs.iredmail.org. + * Improve support for exist amp. + * Add missing backup of postfix main.cf file. + * Remove some scripts: + - tools/backup_mysql_db.sh + - tools/convert_winmail_mailbox.sh + - tools/create_mail_user_ldap.sh + - tools/create_mail_user_mysql.sh + - tools/get_helo_count.sh + - tools/migrate_extmail_mailbox.sh + - tools/sysreport.sh + +iRedMail-0.3.1: + * Do not allow empty username while create first user. Thanks + edisonwang2007 gmail. + * Make sieve.log logrotate setting file standalone. Thanks + chenwei1973 gmail. + * Set file permission for phpldapadmin. Thanks ipostfix + gmail.com + * Set TERM to 'pcconsole'. + * Remove folder prefix in SquirrelMail. + * Remove non-exist function call: openldap_tls_config. Thanks + ipostfix gmail.com + * Add crontab job for vmail user to delete amavisd virus mail per + month. Thanks xcrossbow gmail. + * Update packages: + - perl-Error => 0.17015-1. + - perl-Compress-Raw-Zlib => 2.015-1. + - perl-BerkeleyDB => 0.36-1. + - perl-IO-Multiplex => 1.10-1. + - perl-MailTools => 2.04-1. + - perl-Mail-SPF => 2.006-1. + - perl-Archive-Zip => 1.26-1. + - Horde WebMail => 1.2. + - Dovecot => 1.1.4. + - SquirrelMail => 1.4.16. + - phpMyAdmin => 2.11.9.2. + * Use unique SSL cert file in Postfix, Dovecot, Apache, OpenLDAP: + /etc/pki/iRedMail{Key,Cert}.pem. + * Disable pysieved service in xinetd. + * Fix 'killall' command path in dovecot logrotate file. Thanks + chenwei gmail.com. + +iRedMail-0.3: + * Update ExtMail to 1.0.5. + * Enable submission in postfix. + * Bypass checks for internally generated mail: master.cf. + * Hide Apache + PHP version. + * Fix smtpd.conf file location on x86_64. + * Add SquirrelMail plugin: add_address. + * Update phpMyAdmin to '2.11.9.1'. + * Re-enable select_language plugin in SquirrelMail. + * Make managesieve as an optional component. + +iRedMail-0.3-beta1: + * Add plugin section for sieve in dovecot.conf, remove sample + sieve filter rule file. + * Hide SquirrelMail version number and other attributions in login + page. + * Set default language to English in all webmail program. + * Update Horde WebMail to 1.1.2. + * Add avelsieve plugin for SquirrelMail. + * Initialize import pysieved-1.0 for managesieve service. + * Use 'iredmail.org' as example, replace 'osspinc.com'. + * Update unrar to 3.8.2-1. + * Update perl-MailTools to 2.03-1. + * Update perl-Mail-DKIM to 0.32-1. + * Update perl-Error to 0.17014-1. + * Update perl-BerkeleyDB to 0.34-1. + * Update ClamAV to 0.94-1. + * Update Dovecot to 1.1.3-0_80. + * Change official package mirror to 'www.iredmail.org'. + * Add one more SquirrelMail plugin: login_auto, disable + 'select_language' plugin. + * Bulk change ldap lookup filenames for postfix. + * Remove external iRedMail logo link. + * Update phpMyAdmin to '2.11.9'. + * Compaction 'smtpd_sender_login_maps' in postfix. Thanks shing. + * Correct 'local' and 'virtual' domains in Postfix. Thanks shing. + * Enable SMTP AUTH while sending email in SquirrelMail. + * Make SquirrelMail work with MySQL backend. + * Update SquirrelMail plugin 'compatibility' to '2.0.13-1.0'. + * Fix perl regular expression while modify ldap init script. + Thanks to ejzhang@www.iredmail.org/bbs/. + * Add script to backup mysql databases: 'tools/backup_mysql_db.sh'. + * Fix policyd crontab job, configuration file permission. + * Add 'default-character-set=utf8' in my.cnf. + +iRedMail-0.2: + * Add iRedMail logo in several web-base programs, used to track + how many users use them. + * Remove per-user restriction feature. + * Update postgrey to 1.32. + * Update postfix to 2.3.15. Reference: + http://groups.google.com/group/iredmail/t/d38f9d6a8c1e9cf0 + * Add 'expired' field in SQL template for expired date, used for + per-domain, per-user, alias, domain bcc, user bcc. + * Add expire plugin in dovecot. Disabled by default. + * Enable zlib plugin in dovecot by default. + * Improve postfixadmin config dialog, fill with default domain + admin address. + * Sync LDAP schema. + * Fix postfix sender_access ldap lookup. + * Add pcre rule in header_checks(5) for postfix to replace + internal IP address by external IP address or whatever you + want. Disabled default. Thanks muniao. :) + * Change 'virus_admin_maps' and 'spam_admin_maps' to + 'root@mydomain' in amavisd.conf. Thanks hihihihi + 'www.osspinc.com/bbs/'. + * Make saslauthd disabled while we use dovecot sasl mechanism. + +iRedMail-0.2-rc3: + * Update postfixadmin to 2.2.1.1. + * New roundcubemail plugin: vacation. Created by KaraDog + gmail.com. Thanks kara :) + * New feature: Protecting internal email addresses, such as mail + list addresses. + * Remove postfixadmin vacation table in mysql template, disable + vacation functions in postfixadmin. + * Disable mailman, it should be integrated more smoothly. + * New feature: Restricting what users can send mail to off-site + destinations. + * Add 'mail_name', 'mail_version' in postfix. Thanks muniao. :) + * Update dovecot to 1.1.2. Thanks atrpms.net. + * Update phpMyAdmin to 2.11.8.1. + * Add maillog analyze tool: tools/get_helo_count.sh. + * Fix sieve log file permission. + * Make maillog as standalone logrotated job. + * Disable blacklist_helo in policyd, replaced by pcre table in + postfix. + * Remove policyd_blacklist_helo.sql, it was merged into file: + samples/check_helo_access.pcre. We won't import blacklist_helo + records shipped within policyd by default. + * Enable smtpd_helo_restrictions in Postfix and sample pcre table. + * Replace reject_invalid_hostname by reject_invalid_helo_hostname. + Thanks muniao. :) + * Make saslauthd service disabled while we use dovecot as SASL + auth mechanism in Postfix. + * Add more blacklist helo records for policyd. Disabled by + default. Thanks for muniao & ipostfix's help. + * Fix mailgraph directory and cgi file permission for extmail. + Bug reported by ranjun. Thanks :) + * Make 'crond' as enabled services. + * Add default whitelist and blacklist records shipped within + policyd. + * Add another policyd instance for sender throttle feature, + sync init script, crontab job, pidfile. Disabled by default. + * Update ClamAV to 0.93.3. + * Update perl-Convert-UUlib to 1.11. Bug fix version. + +iRedMail-0.2-rc2: + * Add file: AUTHORS. include all members. + * Initialize import karadog@gmail's roundcubemail patch for + attachment name with Chinese characters. Thanks Kara. :) + * Initialize import karadog@gmail's roundcubemail patch for + national imap folder name. Good Job, Kara. :) + * Add optional package for Roundcubemail: php-pecl-fileinfo. + * Changed 'SENDER_QUOTA_REJECTION' msg, reduce SENDERMSGLIMIT to + 60 msgs per hour. Thanks chenwei. :) + * Implement vacation via dovecot-sieve vacation feature, vacation + rule sample was added. We need a roundcubemail plugin now. + * Allow specify non-standard httpd port in 'conf/httpd' now. + * Mailgraph localtion changed to '/var/www/cgi-bin/mailgraph.cgi'. + * Add 'redirect' command in sieve rule file. + * Drop SPAM mail to INBOX, not Junk. + * Set policyd chroot directory to its home directory. + * Create HOME directory for policyd user. otherwise, crontabs will + failed. Thanks chenwei. :) + * Add 'SMTP_SERVER' for distribute deployment. + * Add iRedMail VERSION info in 'conf/global'. + * Set 'BLACKLIST_TEMP_REJECT=0'. Disabled by default. Thanks muniao. + * Add policyd blacklist_helo list. Thanks muniao. :) + * Improve tool/create_mail_user_mysql.sh, use username as password + by default. + * Make policyd reject 5xx code while user quota exceeded. Thanks + chenwei1973@gmail. + * Remove 'reject_unverified_recipient, reject_unlisted_recipient,' + in smtpd_recipient_restrictions. + * Remove INDEX on vmail.mailbox. + * Add 'smtpd_helo_required=yes' in Postfix. + * Add 'BLACKLIST_REJECTION', 'GREYLIST_REJECTION', 'SPAMTRAP_REJECTION' + in policyd, disabled by default. + * Add 'reject_unknown_sender_domain' in smtpd_recipient_restrictions. + +iRedMail-0.2-rc1: + * Add more amavisd options. + * Adjust mailgraph filter rule, add greylist graph. + * Fix quota config in dovecot for 1.1.x. Thanks chenwei. :) + Warning: we use '10' as '10M' now. please refer dovecot userbd + setting file: /etc/dovecot-{mysql,ldap}.conf. + * Make amavisd log to /var/log/maillog by default, so that + mailgraph will detect spam mails. + * Fix SQL while SITE_ADMIN_NAME equal to FIRST_DOMAIN_ADMIN_NAME. + Reported by muniao. Thanks :) + * Add script to convert WinMail user mailboxes to standard IMAP + directory structure. + * Fix ExtMail configuration about 'SYS_MAILDIR_BASE' in webmail.cf, + Thanks xcrossbow@gmail. + * Typo in Roundcubemail display_username.patch. remove 'dot' after + username, so that it won't make user confused. Thanks + xcrossbow@gmail. + * Fix typo error in 'create_mail_mysql_user.sh'. Thanks muniao. + * Remove roundcubemail version info in 'useragent' option in + 'config/main.inc.php', less is more. + * Add 'signed_header_fields' in amavisd.conf. + * Update dovecot to 1.1.1. + * Update amavisd-new to 2.6.1. + +iRedMail-0.1: + * Add 'policy_time_limit=3600'. Reminded by Edison. Thanks :) + * Add 'delay_warning_time=30m'. Reminded by muniao. Thanks :) + * Add perl-Mail-SPF-Query.noarch as mandatory for SPF feature. + * Initialize version of iRedMail. based on rhms-0.5.0-rc2. + rhms ChangeLog please check: + http://rhms.googlecode.com/svn/trunk/rhms/ChangeLog diff --git a/iredmail/Documentations b/iredmail/Documentations new file mode 100644 index 0000000..afe8c90 --- /dev/null +++ b/iredmail/Documentations @@ -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 diff --git a/iredmail/README.md b/iredmail/README.md new file mode 100644 index 0000000..841c5b8 --- /dev/null +++ b/iredmail/README.md @@ -0,0 +1,29 @@ +iRedMail is a full-featured mail server solution. It supports few mainstream +Linux/BSD distributions: + +- CentOS 7, 8 +- Debian 10 (recommended), 9 +- Ubuntu 18.04, 20.04 +- FreeBSD 12.x +- OpenBSD 6.7 + +More info: + +- License: GPL v3 +- Authors: Zhang Huangbin (zhb _at_ iredmail.org) +- Check and download the latest stable release from [website](https://www.iredmail.org/download.html) +- Install iRedMail by following our installation guides strictly: + [Installation Guides](https://docs.iredmail.org/#install) +- Community, bug report, feature requests: + [online support forum](https://forum.iredmail.org/) +- We offer [paid support services](https://www.iredmail.org/support.html) +- Source packages patched or modified for RHEL/CentOS can be found + [here](https://dl.iredmail.org/yum/srpms/), other RPM packages are all + installed from official yum repository and + [EPEL](http://fedoraproject.org/wiki/EPEL). + +We recommend to deploy iRedMail server with the [iRedMail Easy platform](https://www.iredmail.org/easy.html), +it offers easy deployment, one-click upgrade, and tech support via the ticket +system. Check our [website](https://www.iredmail.org/easy.html) for more details. + +There's also an all-in-one Docker edition here: [iredmail/dockerized](https://github.com/iredmail/dockerized). diff --git a/iredmail/conf/amavisd b/iredmail/conf/amavisd new file mode 100644 index 0000000..cd08d95 --- /dev/null +++ b/iredmail/conf/amavisd @@ -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 . +#--------------------------------------------------------------------- + +# 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 diff --git a/iredmail/conf/clamav b/iredmail/conf/clamav new file mode 100644 index 0000000..3954d5a --- /dev/null +++ b/iredmail/conf/clamav @@ -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 . +#--------------------------------------------------------------------- + +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 diff --git a/iredmail/conf/core b/iredmail/conf/core new file mode 100644 index 0000000..a978a61 --- /dev/null +++ b/iredmail/conf/core @@ -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 . +#--------------------------------------------------------------------- + +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 + # It means: owns + 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} </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] +# Linux: for multiple services: +# service_control [enable|disable|start|stop|restart] ... +# FreeBSD: for one service: +# service_control enable '_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} <> ${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 + # Storage value to file /root/.iredmail/kv/. + 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} +} diff --git a/iredmail/conf/dovecot b/iredmail/conf/dovecot new file mode 100644 index 0000000..493c3d3 --- /dev/null +++ b/iredmail/conf/dovecot @@ -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 . +#--------------------------------------------------------------------- + +# ---------------------------------------- +# 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:: +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:=}" diff --git a/iredmail/conf/fail2ban b/iredmail/conf/fail2ban new file mode 100644 index 0000000..ae1841e --- /dev/null +++ b/iredmail/conf/fail2ban @@ -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 . +#--------------------------------------------------------------------- + +# 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' diff --git a/iredmail/conf/global b/iredmail/conf/global new file mode 100644 index 0000000..9df17e1 --- /dev/null +++ b/iredmail/conf/global @@ -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 . +#--------------------------------------------------------------------- + +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/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 </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}" diff --git a/iredmail/conf/iredadmin b/iredmail/conf/iredadmin new file mode 100644 index 0000000..31ac22d --- /dev/null +++ b/iredmail/conf/iredadmin @@ -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 . +#--------------------------------------------------------------------- + +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' diff --git a/iredmail/conf/iredapd b/iredmail/conf/iredapd new file mode 100644 index 0000000..d2d50aa --- /dev/null +++ b/iredmail/conf/iredapd @@ -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 . +#--------------------------------------------------------------------- + +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' diff --git a/iredmail/conf/memcached b/iredmail/conf/memcached new file mode 100644 index 0000000..0595a68 --- /dev/null +++ b/iredmail/conf/memcached @@ -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 . +#--------------------------------------------------------------------- + +# 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 diff --git a/iredmail/conf/mlmmj b/iredmail/conf/mlmmj new file mode 100644 index 0000000..2770c74 --- /dev/null +++ b/iredmail/conf/mlmmj @@ -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 . +#--------------------------------------------------------------------- + +# 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" diff --git a/iredmail/conf/mysql b/iredmail/conf/mysql new file mode 100644 index 0000000..2379b04 --- /dev/null +++ b/iredmail/conf/mysql @@ -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 . +#--------------------------------------------------------------------- + +# 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}" diff --git a/iredmail/conf/netdata b/iredmail/conf/netdata new file mode 100644 index 0000000..c6dcc27 --- /dev/null +++ b/iredmail/conf/netdata @@ -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 . +#--------------------------------------------------------------------- + +# +# 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' diff --git a/iredmail/conf/nginx b/iredmail/conf/nginx new file mode 100644 index 0000000..8250469 --- /dev/null +++ b/iredmail/conf/nginx @@ -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 . +#--------------------------------------------------------------------- + +# 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" diff --git a/iredmail/conf/openldap b/iredmail/conf/openldap new file mode 100644 index 0000000..a1dac1f --- /dev/null +++ b/iredmail/conf/openldap @@ -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 . +#--------------------------------------------------------------------- + +# 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}" diff --git a/iredmail/conf/php b/iredmail/conf/php new file mode 100644 index 0000000..190e060 --- /dev/null +++ b/iredmail/conf/php @@ -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 . +#--------------------------------------------------------------------- + +# 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' diff --git a/iredmail/conf/postfix b/iredmail/conf/postfix new file mode 100644 index 0000000..a1ebda0 --- /dev/null +++ b/iredmail/conf/postfix @@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# 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' diff --git a/iredmail/conf/postgresql b/iredmail/conf/postgresql new file mode 100644 index 0000000..95fb663 --- /dev/null +++ b/iredmail/conf/postgresql @@ -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 . +#--------------------------------------------------------------------- + +# 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 diff --git a/iredmail/conf/roundcube b/iredmail/conf/roundcube new file mode 100644 index 0000000..08daf37 --- /dev/null +++ b/iredmail/conf/roundcube @@ -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 . +#--------------------------------------------------------------------- + +# --------------------------------------- +# 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}" diff --git a/iredmail/conf/sogo b/iredmail/conf/sogo new file mode 100644 index 0000000..ca2e36a --- /dev/null +++ b/iredmail/conf/sogo @@ -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 . +#--------------------------------------------------------------------- + +# 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" diff --git a/iredmail/conf/spamassassin b/iredmail/conf/spamassassin new file mode 100644 index 0000000..73389a9 --- /dev/null +++ b/iredmail/conf/spamassassin @@ -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 . +#--------------------------------------------------------------------- + +# 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" diff --git a/iredmail/conf/web_server b/iredmail/conf/web_server new file mode 100644 index 0000000..f79fd84 --- /dev/null +++ b/iredmail/conf/web_server @@ -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 . +#--------------------------------------------------------------------- + +# 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 diff --git a/iredmail/dialog/config_via_dialog.sh b/iredmail/dialog/config_via_dialog.sh new file mode 100644 index 0000000..8a9a8db --- /dev/null +++ b/iredmail/dialog/config_via_dialog.sh @@ -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 . +#--------------------------------------------------------------------- + +# 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 < + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# -------------------------------------------------- +# --------------------- 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} diff --git a/iredmail/dialog/mysql_config.sh b/iredmail/dialog/mysql_config.sh new file mode 100644 index 0000000..95f1fc4 --- /dev/null +++ b/iredmail/dialog/mysql_config.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# -------------------------------------------------- +# --------------------- 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 diff --git a/iredmail/dialog/optional_components.sh b/iredmail/dialog/optional_components.sh new file mode 100644 index 0000000..d331b22 --- /dev/null +++ b/iredmail/dialog/optional_components.sh @@ -0,0 +1,122 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# ---------------------------------------- +# 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} diff --git a/iredmail/dialog/pgsql_config.sh b/iredmail/dialog/pgsql_config.sh new file mode 100644 index 0000000..eae816e --- /dev/null +++ b/iredmail/dialog/pgsql_config.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# -------------------------------------------------- +# --------------------- 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 diff --git a/iredmail/dialog/virtual_domain_config.sh b/iredmail/dialog/virtual_domain_config.sh new file mode 100644 index 0000000..2a5acc3 --- /dev/null +++ b/iredmail/dialog/virtual_domain_config.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# 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} < + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# --------------------------------------------------------------- +# 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 diff --git a/iredmail/functions/amavisd.sh b/iredmail/functions/amavisd.sh new file mode 100644 index 0000000..308d5e5 --- /dev/null +++ b/iredmail/functions/amavisd.sh @@ -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 . +#--------------------------------------------------------------------- + +# -------------------------------------------- +# 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} < /root/.my.cnf-${AMAVISD_DB_USER} <> ${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 <> ${INSTALL_LOG} 2>&1 <> ${INSTALL_LOG} + + su - ${SYS_USER_PGSQL} -c "psql -U ${AMAVISD_DB_USER} -d ${AMAVISD_DB_NAME}" >> ${INSTALL_LOG} 2>&1 <> ${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} <> ${TIP_FILE} <> ${TIP_FILE} <> ${INSTALL_LOG}) +EOF + else + cat >> ${TIP_FILE} <> ${INSTALL_LOG}) +EOF + fi + + write_iredmail_kv "sql_user_${AMAVISD_DB_USER}" "${AMAVISD_DB_PASSWD}" + echo 'export status_amavisd_config="DONE"' >> ${STATUS_FILE} +} diff --git a/iredmail/functions/backend.sh b/iredmail/functions/backend.sh new file mode 100644 index 0000000..51f87c0 --- /dev/null +++ b/iredmail/functions/backend.sh @@ -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 . +#--------------------------------------------------------------------- + +# ------------------------------------------------------- +# ------------- 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}" +} diff --git a/iredmail/functions/clamav.sh b/iredmail/functions/clamav.sh new file mode 100644 index 0000000..6b7dadf --- /dev/null +++ b/iredmail/functions/clamav.sh @@ -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 . +#--------------------------------------------------------------------- + +# -------------------------------------------- +# 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} <> ${STATUS_FILE} +} diff --git a/iredmail/functions/cleanup.sh b/iredmail/functions/cleanup.sh new file mode 100644 index 0000000..93dcddd --- /dev/null +++ b/iredmail/functions/cleanup.sh @@ -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 . +#--------------------------------------------------------------------- + +# 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 #' ${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 < ${FILE_IREDMAIL_INSTALLATION_DETAILS} < ${FILE_IREDMAIL_LINKS} < ${FILE_IREDMAIL_MUA_SETTINGS} </SOGo/dav/ + +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 <> ${STATUS_FILE} +} diff --git a/iredmail/functions/dovecot.sh b/iredmail/functions/dovecot.sh new file mode 100644 index 0000000..c8dd271 --- /dev/null +++ b/iredmail/functions/dovecot.sh @@ -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 . +#--------------------------------------------------------------------- + +# ------------------------------------------------------- +# 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} <= 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 </dev/null; then + # Define command used to reopen log service after rotated + cat >> /etc/newsyslog.conf </dev/null; then + # Define command used to reopen log service after rotated + cat >> /etc/newsyslog.conf <> ${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 <> ${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 <> ${STATUS_FILE} +} + diff --git a/iredmail/functions/fail2ban.sh b/iredmail/functions/fail2ban.sh new file mode 100644 index 0000000..bcc86da --- /dev/null +++ b/iredmail/functions/fail2ban.sh @@ -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 . +#--------------------------------------------------------------------- +_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} < /root/.my.cnf-${FAIL2BAN_DB_USER} <> ${INSTALL_LOG} <> ${INSTALL_LOG} <> ${INSTALL_LOG} 2>&1 <> ${CRON_FILE_ROOT} <> ${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 <> ${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} +} diff --git a/iredmail/functions/iredadmin.sh b/iredmail/functions/iredadmin.sh new file mode 100644 index 0000000..2b7595b --- /dev/null +++ b/iredmail/functions/iredadmin.sh @@ -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 . +#--------------------------------------------------------------------- + +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} < /root/.my.cnf-${IREDADMIN_DB_USER} </dev/null + chmod 0777 ${PGSQL_DATA_DIR}/iredadmin.pgsql >/dev/null + su - ${SYS_USER_PGSQL} -c "psql -d template1" >> ${INSTALL_LOG} 2>&1 <> ${INSTALL_LOG} 2>&1 <> ${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} <> ${STATUS_FILE} +} + +iredadmin_cron_setup() +{ + cat >> ${CRON_FILE_ROOT} </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} <> ${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} +} diff --git a/iredmail/functions/iredapd.sh b/iredmail/functions/iredapd.sh new file mode 100644 index 0000000..ffc19f8 --- /dev/null +++ b/iredmail/functions/iredapd.sh @@ -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 . +#--------------------------------------------------------------------- + + +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} < /root/.my.cnf-${IREDAPD_DB_USER} </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 <> ${INSTALL_LOG} 2>&1 <> ${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 <> ${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} </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} <> ${STATUS_FILE} +} diff --git a/iredmail/functions/ldap_server.sh b/iredmail/functions/ldap_server.sh new file mode 100644 index 0000000..4a14b0a --- /dev/null +++ b/iredmail/functions/ldap_server.sh @@ -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} </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} <> ${TIP_FILE} <> ${STATUS_FILE} +} diff --git a/iredmail/functions/mlmmj.sh b/iredmail/functions/mlmmj.sh new file mode 100644 index 0000000..3078b31 --- /dev/null +++ b/iredmail/functions/mlmmj.sh @@ -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 . +#--------------------------------------------------------------------- + +# ------------------------------------------------------- +# ------------------ 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} <> ${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} <> ${MLMMJADMIN_CONF} <> ${MLMMJADMIN_CONF} + elif [ X"${BACKEND}" == X'PGSQL' ]; then + echo 'iredmail_sql_db_type = "pgsql"' >> ${MLMMJADMIN_CONF} + fi + + cat >> ${MLMMJADMIN_CONF} <> ${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 <> ${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} +} diff --git a/iredmail/functions/mysql.sh b/iredmail/functions/mysql.sh new file mode 100644 index 0000000..07f8181 --- /dev/null +++ b/iredmail/functions/mysql.sh @@ -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 . +#--------------------------------------------------------------------- + +# 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 '\' >> ${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 '\' >> ${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} <> ${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} <> ${MYSQL_DEFAULTS_FILE_ROOT} < /root/.my.cnf-${VMAIL_DB_BIND_USER} < /root/.my.cnf-${VMAIL_DB_ADMIN_USER} <> ${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 '\' &>/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 '\' &>/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} <> ${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} <> ${TIP_FILE} <> ${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} +} diff --git a/iredmail/functions/netdata.sh b/iredmail/functions/netdata.sh new file mode 100644 index 0000000..bf46d15 --- /dev/null +++ b/iredmail/functions/netdata.sh @@ -0,0 +1,206 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- +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@ 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 <> ${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 <> ${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} <> ${STATUS_FILE} +} diff --git a/iredmail/functions/nginx.sh b/iredmail/functions/nginx.sh new file mode 100644 index 0000000..83cb456 --- /dev/null +++ b/iredmail/functions/nginx.sh @@ -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 . +#--------------------------------------------------------------------- + +# ------------------------------------------------------- +# ------------------- 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 </dev/null; then + cat >> /etc/newsyslog.conf <> ${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} <> ${STATUS_FILE} +} diff --git a/iredmail/functions/openldap.sh b/iredmail/functions/openldap.sh new file mode 100644 index 0000000..b1444a5 --- /dev/null +++ b/iredmail/functions/openldap.sh @@ -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 . +#--------------------------------------------------------------------- + +# ------------------------------------------------------- +# ------------------- 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} <> ${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 <> ${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} <> ${STATUS_FILE} +} + diff --git a/iredmail/functions/optional_components.sh b/iredmail/functions/optional_components.sh new file mode 100644 index 0000000..fdb840f --- /dev/null +++ b/iredmail/functions/optional_components.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +# ------------------------------------------- +# 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 +} diff --git a/iredmail/functions/packages.sh b/iredmail/functions/packages.sh new file mode 100644 index 0000000..41d5365 --- /dev/null +++ b/iredmail/functions/packages.sh @@ -0,0 +1,785 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +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 < /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} <&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 +} diff --git a/iredmail/functions/packages_freebsd.sh b/iredmail/functions/packages_freebsd.sh new file mode 100644 index 0000000..36927a1 --- /dev/null +++ b/iredmail/functions/packages_freebsd.sh @@ -0,0 +1,1169 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +install_all() +{ + # Port name under /usr/ports/. e.g. mail/dovecot. + ALL_PORTS='' + # Ports which are going to be bulit with Python 2. + # Installed with command `make USES=python2.7 install clean`. + PY2_PORTS='' + + # Extension used for backup file during in-place editing. + SED_EXTENSION="iredmail" + CMD_SED="sed -i ${SED_EXTENSION}" + + # Make it don't popup dialog while building ports. + export PACKAGE_BUILDING='yes' + export BATCH='yes' + + # Preferred package versions. Don't forget to update DEFAULT_VERSIONS below. + export PREFERRED_OPENLDAP_VER='24' + export PREFERRED_MARIADB_VER='104' + export PREFERRED_BDB_VER='5' + export PREFERRED_PHP_VER='74' + export PREFERRED_PY3_VER='3.8' + + if [ X"${WEB_SERVER}" == X'NGINX' ]; then + export IREDMAIL_USE_PHP='YES' + fi + + freebsd_make_conf_add 'WANT_OPENLDAP_VER' "${PREFERRED_OPENLDAP_VER}" + freebsd_make_conf_add 'WANT_OPENLDAP_SASL' "YES" + freebsd_make_conf_add 'WANT_PGSQL_VER' "${PGSQL_VERSION}" + freebsd_make_conf_add 'WANT_BDB_VER' "${PREFERRED_BDB_VER}" + freebsd_make_conf_add 'DEFAULT_VERSIONS' "ssl=libressl python=${PREFERRED_PY3_VER} python2=2.7 python3=${PREFERRED_PY3_VER} pgsql=${PGSQL_VERSION} php=7.4 mysql=10.4m ruby=2.7" + + freebsd_make_conf_plus_option 'OPTIONS_SET' 'SASL' + freebsd_make_conf_plus_option 'OPTIONS_UNSET' 'X11' + freebsd_make_conf_plus_option 'LICENSES_ACCEPTED' 'DCC' + + for p in \ + archivers_arj \ + archivers_p5-Archive-Tar \ + archivers_p7zip \ + archivers_rar \ + converters_libiconv \ + databases_postgresql${PGSQL_VERSION}-client \ + databases_postgresql${PGSQL_VERSION}-contrib \ + databases_postgresql${PGSQL_VERSION}-server \ + databases_mariadb${PREFERRED_MARIADB_VER}-server \ + databases_mariadb${PREFERRED_MARIADB_VER}-client \ + databases_py-sqlalchemy10 \ + devel_cmake \ + devel_apr1 \ + devel_dbus \ + devel_m4 \ + devel_py-Jinja2 \ + devel_py-babel \ + devel_sope4 \ + dns_p5-Net-DNS \ + dns_py-dnspython \ + ftp_curl \ + mail_spamassassin \ + lang_perl5.20 \ + lang_php${PREFERRED_PHP_VER} \ + lang_php${PREFERRED_PHP_VER}-extensions \ + www_mod_php${PREFERRED_PHP_VER} \ + graphics_php${PREFERRED_PHP_VER}-gd \ + graphics_cairo \ + www_pecl-APC \ + lang_python27 \ + mail_dovecot \ + mail_postfix \ + mail_roundcube \ + net_openldap${PREFERRED_OPENLDAP_VER}-client \ + net_openldap${PREFERRED_OPENLDAP_VER}-sasl-client \ + net_openldap${PREFERRED_OPENLDAP_VER}-server \ + net_openslp \ + net_py-ldap \ + net-mgmt_netdata \ + security_amavisd-new \ + security_ca_root_nss \ + security_clamav \ + security_cyrus-sasl2 \ + security_gnupg \ + security_libssh2 \ + security_p5-Authen-SASL \ + security_p5-IO-Socket-SSL \ + www_nginx \ + www_uwsgi \ + www_sogo4; do + mkdir -p /var/db/ports/${p} >> ${INSTALL_LOG} 2>&1 + done + + # cmake. DEPENDENCE + cat > /var/db/ports/devel_cmake/options < /var/db/ports/devel_dbus/options < /var/db/ports/devel_m4/options < /var/db/ports/converters_libiconv/options < /var/db/ports/archivers_arj/options < /var/db/ports/security_cyrus-sasl2/options < /var/db/ports/lang_perl5.20/options < /var/db/ports/net_openslp/options < /var/db/ports/net_openldap${PREFERRED_OPENLDAP_VER}-server/options < /var/db/ports/net_openldap${PREFERRED_OPENLDAP_VER}-client/options < /var/db/ports/net_openldap${PREFERRED_OPENLDAP_VER}-sasl-client/options < /var/db/ports/databases_postgresql${PGSQL_VERSION}-server/options < /var/db/ports/databases_postgresql${PGSQL_VERSION}-client/options < /var/db/ports/databases_mariadb${PREFERRED_MARIADB_VER}-server/options < /var/db/ports/databases_mariadb${PREFERRED_MARIADB_VER}-client/options < /var/db/ports/mail_dovecot/options </dev/null + + # ca_root_nss. DEPENDENCE. + cat > /var/db/ports/security_ca_root_nss/options < /var/db/ports/security_libssh2/options < /var/db/ports/ftp_curl/options < /var/db/ports/security_gnupg/options < /var/db/ports/security_p5-IO-Socket-SSL/options < /var/db/ports/archivers_p5-Archive-Tar/options < /var/db/ports/archivers_p7zip/options < /var/db/ports/archivers_rar/options < /var/db/ports/dns_p5-Net-DNS/options < /var/db/ports/dns_py-dnspython/options < /var/db/ports/mail_spamassassin/options </dev/null + + ALL_PORTS="${ALL_PORTS} mail/spamassassin" + + cat > /var/db/ports/security_p5-Authen-SASL/options < /var/db/ports/security_amavisd-new/options </dev/null + + ALL_PORTS="${ALL_PORTS} security/amavisd-new" + + # Postfix. REQUIRED. + cat > /var/db/ports/mail_postfix/options </dev/null + + ALL_PORTS="${ALL_PORTS} mail/postfix" + + # Apr. DEPENDENCE. + cat > /var/db/ports/devel_apr1/options </dev/null + + # Python v2.7 + cat > /var/db/ports/lang_python27/options < /var/db/ports/www_nginx/options < /var/db/ports/www_uwsgi/options < /var/db/ports/lang_php${PREFERRED_PHP_VER}/options < /var/db/ports/lang_php${PREFERRED_PHP_VER}-extensions/options </dev/null + + cat > /var/db/ports/graphics_php${PREFERRED_PHP_VER}-gd/options < /var/db/ports/graphics_cairo/options < /var/db/ports/www_mod_php${PREFERRED_PHP_VER}/options < /var/db/ports/www_pecl-APC/options < /var/db/ports/security_clamav/options < /var/db/ports/mail_roundcube/options </dev/null + + cat > /var/db/ports/devel_py-Jinja2/options < /var/db/ports/devel_py-babel/options < /var/db/ports/devel_sope4/options < /var/db/ports/www_sogo4/options </dev/null + fi + + # Python database interfaces + if [ X"${BACKEND}" == X'OPENLDAP' ]; then + ALL_PORTS="${ALL_PORTS} net/py-ldap databases/py-pymysql" + PY2_PORTS="${PY2_PORTS} net/py-ldap databases/py-pymysql" + elif [ X"${BACKEND}" == X'MYSQL' ]; then + ALL_PORTS="${ALL_PORTS} databases/py-pymysql" + PY2_PORTS="${PY2_PORTS} databases/py-pymysql" + elif [ X"${BACKEND}" == X'PGSQL' ]; then + ALL_PORTS="${ALL_PORTS} databases/py-psycopg2" + fi + + # py-sqlalchemy + ALL_PORTS="${ALL_PORTS} databases/py-sqlalchemy10" + cat > /var/db/ports/databases_py-sqlalchemy10/options < /var/db/ports/net_py-ldap/options < /var/db/ports/net-mgmt_netdata/options <> ${STATUS_FILE} + else + ECHO_ERROR "Tarballs were not downloaded correctly, please fix it manually and then re-execute iRedMail.sh." + exit 255 + fi + else + ECHO_SKIP "Fetching all distfiles for port ${i} and dependencies" + fi + fi + done + + echo "export status_fetch_all_src_tarballs='DONE'" >> ${STATUS_FILE} + } + + install_port() { + # Usage: install_port [make_flags] + _port="${1}" + shift 1 + _flags="$@" + + ECHO_INFO "Install port: ${_port}" + + start_time="$(date +%s)" + if [ X"${_port}" != X'' ]; then + # Remove special characters in port name: -, /, '.'. + _portname="$( echo ${_port} | tr '/' '_' | tr -d '[-\.]')" + + _status="\$status_install_port_${IREDMAIL_PORT_PKG_NAME_PREFIX}${_portname}" + _status_name="$(echo ${_status} | tr -d '$')" + if [ X"$(eval echo ${_status})" != X"DONE" ]; then + _port_dir="${PORT_WORKDIRPREFIX}/${_port}" + if [[ ! -d ${_port_dir} ]]; then + echo "Port directory ${_port_dir} doesn't exist." + exit 255 + fi + + cd ${_port_dir} + ECHO_INFO "Installing port: ${_port} ($(date '+%Y-%m-%d %H:%M:%S')) ..." + echo "export ${_status_name}='processing'" >> ${STATUS_FILE} + + if echo "${_port}" | grep '/py' &>/dev/null; then + # Some ports use zip archive instead of default `.tar.gz`. + if grep '^USES' ${_port_dir}/Makefile | grep '\' &>/dev/null; then + _flags="${_flags} USES+=zip" + fi + fi + + # Get time as a UNIX timestamp (seconds elapsed since Jan 1, 1970 0:00 UTC) + port_start_time="$(date +%s)" + + # Clean up and compile + make clean + make \ + DISABLE_MAKE_JOBS=yes \ + ${_flags} \ + install clean + + if [ X"$?" == X"0" ]; then + # Log used time + used_time="$(($(date +%s)-port_start_time))" + + echo "export ${_status_name}='DONE' # ${used_time} seconds, ~= $((used_time/60)) minute(s)." >> ${STATUS_FILE} + else + ECHO_ERROR "Port was not successfully installed, please fix it manually and then re-execute this script." + exit 255 + fi + else + ECHO_SKIP "Installing port: ${_port}." + fi + fi + } + + # Install all packages. + install_all_ports() + { + ECHO_INFO "All ports: ${ALL_PORTS}" + ECHO_INFO "All ports for Python 2: ${PY2_PORTS}" + + start_time="$(date +%s)" + for _port in ${ALL_PORTS}; do + if echo "${_port}" | grep -E '(/py|uwsgi)' &>/dev/null; then + # Install modules for Python 3. + install_port ${_port} USES=python:${PREFERRED_PY3_VER} + else + install_port ${_port} + fi + done + + export IREDMAIL_PORT_PKG_NAME_PREFIX='py27_' + for _port in ${PY2_PORTS}; do + # Install for Python 2. + install_port ${_port} USES=python:2.7 + done + unset IREDMAIL_PORT_PKG_NAME_PREFIX + + # Log and print used time + all_used_time="$(($(date +%s)-start_time))" + ECHO_INFO "Total time of ports compiling: ${all_used_time} seconds, ~= $((all_used_time/60)) minute(s)" + } + + # Install all packages. + post_install_cleanup() + { + ECHO_DEBUG "Post-install cleanup." + + ECHO_DEBUG "Create symbol links for python2/3." + ln -sf /usr/local/bin/python2.7 /usr/local/bin/python2 + ln -sf /usr/local/bin/python${PREFERRED_PY3_VER} /usr/local/bin/python3 + + # Create syslog.d and logrotate.d + mkdir -p ${SYSLOG_CONF_DIR} >> ${INSTALL_LOG} 2>&1 + mkdir -p ${LOGROTATE_DIR} >> ${INSTALL_LOG} 2>&1 + + echo "export status_post_install_cleanup='DONE'" >> ${STATUS_FILE} + } + + check_status_before_run fetch_all_src_tarballs + + # Do not run it 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_ports + + check_status_before_run post_install_cleanup +} diff --git a/iredmail/functions/php.sh b/iredmail/functions/php.sh new file mode 100644 index 0000000..805ef25 --- /dev/null +++ b/iredmail/functions/php.sh @@ -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 . +#--------------------------------------------------------------------- + + +# 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} <> ${STATUS_FILE} +} diff --git a/iredmail/functions/postfix.sh b/iredmail/functions/postfix.sh new file mode 100644 index 0000000..9179681 --- /dev/null +++ b/iredmail/functions/postfix.sh @@ -0,0 +1,395 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# ------------------------------------------------------- +# ---------------------- 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 `. + 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} <> ${STATUS_FILE} +} diff --git a/iredmail/functions/postgresql.sh b/iredmail/functions/postgresql.sh new file mode 100644 index 0000000..94b68de --- /dev/null +++ b/iredmail/functions/postgresql.sh @@ -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 . +#--------------------------------------------------------------------- + +# ------------------------------------------------------- +# -------------------- 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 <> ${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} <> ${INSTALL_LOG} 2>&1 + + cat >> ${TIP_FILE} <> ${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} <> ${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} <> ${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} +} diff --git a/iredmail/functions/roundcubemail.sh b/iredmail/functions/roundcubemail.sh new file mode 100644 index 0000000..2a428c0 --- /dev/null +++ b/iredmail/functions/roundcubemail.sh @@ -0,0 +1,306 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +# ----------------------- +# 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} < /root/.my.cnf-${RCM_DB_USER} <> ${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 <> ${INSTALL_LOG} 2>&1 </dev/null" >> ${INSTALL_LOG} 2>&1 <> ${INSTALL_LOG} 2>&1 + fi + + # Grant privileges + if [ X"${BACKEND}" == X'MYSQL' ]; then + ${MYSQL_CLIENT_ROOT} <> ${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} <> ${STATUS_FILE} +} + +rcm_cron_setup() +{ + ECHO_DEBUG "Setup daily cron job to keep SQL database clean." + cat >> ${CRON_FILE_ROOT} </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} +} diff --git a/iredmail/functions/sogo.sh b/iredmail/functions/sogo.sh new file mode 100644 index 0000000..e5fb79c --- /dev/null +++ b/iredmail/functions/sogo.sh @@ -0,0 +1,332 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +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} <> ${tmp_sql} <> ${tmp_sql} < /root/.my.cnf-${SOGO_DB_USER} < ${tmp_sql} <> ${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} <> ${SOGO_SIEVE_CREDENTIAL_FILE} <> ${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} <> ${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} <> ${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} +} diff --git a/iredmail/functions/spamassassin.sh b/iredmail/functions/spamassassin.sh new file mode 100644 index 0000000..9056922 --- /dev/null +++ b/iredmail/functions/spamassassin.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +# --------------------------------------------------------- +# 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} <> ${STATUS_FILE} +} diff --git a/iredmail/functions/system_accounts.sh b/iredmail/functions/system_accounts.sh new file mode 100644 index 0000000..2b326dd --- /dev/null +++ b/iredmail/functions/system_accounts.sh @@ -0,0 +1,128 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin + +# 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} <> ${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 +} diff --git a/iredmail/functions/web_server.sh b/iredmail/functions/web_server.sh new file mode 100644 index 0000000..28cff45 --- /dev/null +++ b/iredmail/functions/web_server.sh @@ -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 . +#--------------------------------------------------------------------- + +web_server_extra() +{ + # Create robots.txt. + if [ ! -e ${HTTPD_DOCUMENTROOT}/robots.txt ]; then + cat >> ${HTTPD_DOCUMENTROOT}/robots.txt <' > ${HTTPD_DOCUMENTROOT}/index.html + elif [ X"${USE_SOGO}" == X'YES' ]; then + echo '' > ${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} +} diff --git a/iredmail/iRedMail.sh b/iredmail/iRedMail.sh new file mode 100644 index 0000000..d6330ae --- /dev/null +++ b/iredmail/iRedMail.sh @@ -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 . +#--------------------------------------------------------------------- + +# ------------------------------ +# 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 <. +#--------------------------------------------------------------------- + +_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 `. + _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} <> ${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 < ${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} diff --git a/iredmail/pkgs/pkgs.freebsd.sha256 b/iredmail/pkgs/pkgs.freebsd.sha256 new file mode 100644 index 0000000..c511866 --- /dev/null +++ b/iredmail/pkgs/pkgs.freebsd.sha256 @@ -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 diff --git a/iredmail/pkgs/pkgs.openbsd.sha256 b/iredmail/pkgs/pkgs.openbsd.sha256 new file mode 100644 index 0000000..2e00d87 --- /dev/null +++ b/iredmail/pkgs/pkgs.openbsd.sha256 @@ -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 diff --git a/iredmail/pkgs/pkgs.sha256 b/iredmail/pkgs/pkgs.sha256 new file mode 100644 index 0000000..56f02f4 --- /dev/null +++ b/iredmail/pkgs/pkgs.sha256 @@ -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 diff --git a/iredmail/samples/amavisd/amavisd.conf b/iredmail/samples/amavisd/amavisd.conf new file mode 100644 index 0000000..1aebab9 --- /dev/null +++ b/iredmail/samples/amavisd/amavisd.conf @@ -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: + # '' => /path/to/disclaimer.txt, + # '' => /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 diff --git a/iredmail/samples/amavisd/amavisd.mysql b/iredmail/samples/amavisd/amavisd.mysql new file mode 100644 index 0000000..1adbad1 --- /dev/null +++ b/iredmail/samples/amavisd/amavisd.mysql @@ -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 + diff --git a/iredmail/samples/amavisd/amavisd.pgsql b/iredmail/samples/amavisd/amavisd.pgsql new file mode 100644 index 0000000..af889d9 --- /dev/null +++ b/iredmail/samples/amavisd/amavisd.pgsql @@ -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 diff --git a/iredmail/samples/amavisd/amavisd.schema b/iredmail/samples/amavisd/amavisd.schema new file mode 100644 index 0000000..d34b152 --- /dev/null +++ b/iredmail/samples/amavisd/amavisd.schema @@ -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. diff --git a/iredmail/samples/amavisd/default_spam_policy.sql b/iredmail/samples/amavisd/default_spam_policy.sql new file mode 100644 index 0000000..a01a7da --- /dev/null +++ b/iredmail/samples/amavisd/default_spam_policy.sql @@ -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); diff --git a/iredmail/samples/dovecot/dovecot-last-login.conf b/iredmail/samples/dovecot/dovecot-last-login.conf new file mode 100644 index 0000000..cd7e10e --- /dev/null +++ b/iredmail/samples/dovecot/dovecot-last-login.conf @@ -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 + } +} diff --git a/iredmail/samples/dovecot/dovecot-ldap.conf b/iredmail/samples/dovecot/dovecot-ldap.conf new file mode 100644 index 0000000..bca2119 --- /dev/null +++ b/iredmail/samples/dovecot/dovecot-ldap.conf @@ -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 diff --git a/iredmail/samples/dovecot/dovecot-share-folder.conf b/iredmail/samples/dovecot/dovecot-share-folder.conf new file mode 100644 index 0000000..5e0a656 --- /dev/null +++ b/iredmail/samples/dovecot/dovecot-share-folder.conf @@ -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 + } +} diff --git a/iredmail/samples/dovecot/dovecot-sql.conf b/iredmail/samples/dovecot/dovecot-sql.conf new file mode 100644 index 0000000..9ccb45c --- /dev/null +++ b/iredmail/samples/dovecot/dovecot-sql.conf @@ -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 diff --git a/iredmail/samples/dovecot/dovecot-used-quota.conf b/iredmail/samples/dovecot/dovecot-used-quota.conf new file mode 100644 index 0000000..54a87f7 --- /dev/null +++ b/iredmail/samples/dovecot/dovecot-used-quota.conf @@ -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 +} diff --git a/iredmail/samples/dovecot/dovecot.sieve b/iredmail/samples/dovecot/dovecot.sieve new file mode 100644 index 0000000..0cb8e91 --- /dev/null +++ b/iredmail/samples/dovecot/dovecot.sieve @@ -0,0 +1,7 @@ +require ["fileinto"]; + +# rule:[Move Spam to Junk Folder] +if header :is "X-Spam-Flag" "YES" +{ + fileinto "Junk"; +} diff --git a/iredmail/samples/dovecot/dovecot2-quota-warning.sh b/iredmail/samples/dovecot/dovecot2-quota-warning.sh new file mode 100644 index 0000000..a95f758 --- /dev/null +++ b/iredmail/samples/dovecot/dovecot2-quota-warning.sh @@ -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 diff --git a/iredmail/samples/dovecot/dovecot22.conf b/iredmail/samples/dovecot/dovecot22.conf new file mode 100644 index 0000000..28b3a5b --- /dev/null +++ b/iredmail/samples/dovecot/dovecot22.conf @@ -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 = 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 = ). + 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 '. 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 diff --git a/iredmail/samples/dovecot/dovecot23.conf b/iredmail/samples/dovecot/dovecot23.conf new file mode 100644 index 0000000..89ea429 --- /dev/null +++ b/iredmail/samples/dovecot/dovecot23.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 = 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 = ). + 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 '. 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 diff --git a/iredmail/samples/dovecot/sql/imap_share_folder.mysql b/iredmail/samples/dovecot/sql/imap_share_folder.mysql new file mode 100644 index 0000000..549c7da --- /dev/null +++ b/iredmail/samples/dovecot/sql/imap_share_folder.mysql @@ -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) +); diff --git a/iredmail/samples/dovecot/sql/last_login.mysql b/iredmail/samples/dovecot/sql/last_login.mysql new file mode 100644 index 0000000..2cdfc4c --- /dev/null +++ b/iredmail/samples/dovecot/sql/last_login.mysql @@ -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; diff --git a/iredmail/samples/dovecot/sql/used_quota.mysql b/iredmail/samples/dovecot/sql/used_quota.mysql new file mode 100644 index 0000000..a17eb94 --- /dev/null +++ b/iredmail/samples/dovecot/sql/used_quota.mysql @@ -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 ; diff --git a/iredmail/samples/dovecot/systemd/override.conf b/iredmail/samples/dovecot/systemd/override.conf new file mode 100644 index 0000000..78ba2fc --- /dev/null +++ b/iredmail/samples/dovecot/systemd/override.conf @@ -0,0 +1,3 @@ +[Service] +ProtectSystem=false +#ProtectHome=false diff --git a/iredmail/samples/fail2ban/action.d/banned_db.conf b/iredmail/samples/fail2ban/action.d/banned_db.conf new file mode 100644 index 0000000..82e47ad --- /dev/null +++ b/iredmail/samples/fail2ban/action.d/banned_db.conf @@ -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 +actionunban = /usr/local/bin/fail2ban_banned_db unban +actionstop = /usr/local/bin/fail2ban_banned_db cleanup diff --git a/iredmail/samples/fail2ban/bin/fail2ban_banned_db b/iredmail/samples/fail2ban/bin/fail2ban_banned_db new file mode 100644 index 0000000..630ac5a --- /dev/null +++ b/iredmail/samples/fail2ban/bin/fail2ban_banned_db @@ -0,0 +1,236 @@ +#!/usr/bin/env bash +# Author: Zhang Huangbin +# 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 [loglines] +# +# - : One IP address each time. +# - : Network ports. Multiple ports must be separated by comma. +# - : `tcp` or `udp`. +# - : Fail2ban jail name. +# - : 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] +# +# *) Cleanup a jail. When Fail2ban is stopping or restarting, `cleanup` will +# be executed. Cleanup manually is supported too: +# +# banned_db cleanup +# +# *) 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} </dev/null + + if [[ X"$?" == X'0' ]]; then + echo "Already banned." + else + ${CMD_SQL} >/dev/null <> ${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 diff --git a/iredmail/samples/fail2ban/fail2ban.local b/iredmail/samples/fail2ban/fail2ban.local new file mode 100755 index 0000000..02fc4bc --- /dev/null +++ b/iredmail/samples/fail2ban/fail2ban.local @@ -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 diff --git a/iredmail/samples/fail2ban/filter.d/dovecot.iredmail.conf b/iredmail/samples/fail2ban/filter.d/dovecot.iredmail.conf new file mode 100644 index 0000000..765dc01 --- /dev/null +++ b/iredmail/samples/fail2ban/filter.d/dovecot.iredmail.conf @@ -0,0 +1,5 @@ +[Definition] +failregex = Authentication failure.* rip= + \(auth failed.* rip= + +ignoreregex = diff --git a/iredmail/samples/fail2ban/filter.d/postfix-pregreet.iredmail.conf b/iredmail/samples/fail2ban/filter.d/postfix-pregreet.iredmail.conf new file mode 100644 index 0000000..ebeeb2c --- /dev/null +++ b/iredmail/samples/fail2ban/filter.d/postfix-pregreet.iredmail.conf @@ -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 \[\]:\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 \[\]:\d+: (EHLO|HELO) we-guess.mozilla.org diff --git a/iredmail/samples/fail2ban/filter.d/postfix.iredmail.conf b/iredmail/samples/fail2ban/filter.d/postfix.iredmail.conf new file mode 100644 index 0000000..63f2adc --- /dev/null +++ b/iredmail/samples/fail2ban/filter.d/postfix.iredmail.conf @@ -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 = \[\]: SASL (PLAIN|LOGIN) authentication failed + lost connection after (AUTH|UNKNOWN) from (.*)\[\] + reject: RCPT from .*\[\]: .*: Relay access denied + reject: RCPT from .*\[\]: .*: Sender address rejected: Domain not found + reject: RCPT from .*\[\]: .*: Helo command rejected: Host not found + reject: RCPT from .*\[\]: .*: Helo command rejected: need fully-qualified hostname + reject: RCPT from .*\[\]: 554 5.7.1 + reject: RCPT from .*\[\]:\d+: 550 5.5.1 Protocol error + warning: Illegal address syntax from (.*)\[\] in RCPT command + +ignoreregex = diff --git a/iredmail/samples/fail2ban/filter.d/roundcube.iredmail.conf b/iredmail/samples/fail2ban/filter.d/roundcube.iredmail.conf new file mode 100644 index 0000000..eb50692 --- /dev/null +++ b/iredmail/samples/fail2ban/filter.d/roundcube.iredmail.conf @@ -0,0 +1,9 @@ +# 'X-Forwarded-For:` appears when Roundcube is running behind HAProxy. + +[Definition] +failregex = roundcube.* Failed login for (.*) from \. AUTHENTICATE LOGIN + roundcube.* Failed login for (.*) from in session + roundcube.* Failed login .*\(X-Forwarded-For: \) in session + roundcube.* Error: Login failed for (.*) from \. LOGIN: Authentication failed. + +ignoreregex = diff --git a/iredmail/samples/fail2ban/jail.d/dovecot.local b/iredmail/samples/fail2ban/jail.d/dovecot.local new file mode 100644 index 0000000..ec56061 --- /dev/null +++ b/iredmail/samples/fail2ban/jail.d/dovecot.local @@ -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] diff --git a/iredmail/samples/fail2ban/jail.d/nginx-http-auth.local b/iredmail/samples/fail2ban/jail.d/nginx-http-auth.local new file mode 100644 index 0000000..974ae97 --- /dev/null +++ b/iredmail/samples/fail2ban/jail.d/nginx-http-auth.local @@ -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] diff --git a/iredmail/samples/fail2ban/jail.d/postfix-pregreet.local b/iredmail/samples/fail2ban/jail.d/postfix-pregreet.local new file mode 100644 index 0000000..23d96e2 --- /dev/null +++ b/iredmail/samples/fail2ban/jail.d/postfix-pregreet.local @@ -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] diff --git a/iredmail/samples/fail2ban/jail.d/postfix.local b/iredmail/samples/fail2ban/jail.d/postfix.local new file mode 100644 index 0000000..f5a7442 --- /dev/null +++ b/iredmail/samples/fail2ban/jail.d/postfix.local @@ -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] diff --git a/iredmail/samples/fail2ban/jail.d/roundcube.local b/iredmail/samples/fail2ban/jail.d/roundcube.local new file mode 100644 index 0000000..7f0f192 --- /dev/null +++ b/iredmail/samples/fail2ban/jail.d/roundcube.local @@ -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] diff --git a/iredmail/samples/fail2ban/jail.d/sogo.local b/iredmail/samples/fail2ban/jail.d/sogo.local new file mode 100644 index 0000000..bdefcfa --- /dev/null +++ b/iredmail/samples/fail2ban/jail.d/sogo.local @@ -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] diff --git a/iredmail/samples/fail2ban/jail.d/sshd.local b/iredmail/samples/fail2ban/jail.d/sshd.local new file mode 100644 index 0000000..3952459 --- /dev/null +++ b/iredmail/samples/fail2ban/jail.d/sshd.local @@ -0,0 +1,8 @@ +[sshd] +backend = polling +journalmatch= +enabled = true +filter = sshd +logpath = PH_SSHD_LOGFILE +action = PH_FAIL2BAN_ACTION[name=sshd, port="PH_SSHD_PORT", protocol=tcp] + banned_db[name=sshd, port="PH_SSHD_PORT", protocol=tcp] diff --git a/iredmail/samples/fail2ban/jail.local b/iredmail/samples/fail2ban/jail.local new file mode 100644 index 0000000..0fc715d --- /dev/null +++ b/iredmail/samples/fail2ban/jail.local @@ -0,0 +1,6 @@ +[DEFAULT] +# time is in seconds. 3600 = 1 hour, 86400 = 24 hours (1 day) +findtime = 3600 +bantime = 3600 +maxretry = 5 +ignoreip = PH_LOCAL_ADDRESS 127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 diff --git a/iredmail/samples/fail2ban/openbsd/rc b/iredmail/samples/fail2ban/openbsd/rc new file mode 100755 index 0000000..8f2700f --- /dev/null +++ b/iredmail/samples/fail2ban/openbsd/rc @@ -0,0 +1,26 @@ +#!/bin/sh + +daemon="/usr/local/bin/fail2ban-client" + +. /etc/rc.d/rc.subr + +rc_bg=YES +rc_reload=NO + +rc_pre() { + install -d -o root -m 0700 /var/run/fail2ban +} + +rc_start() { + ${rcexec} "${daemon} start ${daemon_flags} ${_bg}" +} + +rc_check() { + pgrep -q -f "fail2ban-server" +} + +rc_stop() { + ${rcexec} "${daemon} stop" +} + +rc_cmd $1 diff --git a/iredmail/samples/fail2ban/sql/fail2ban.mysql b/iredmail/samples/fail2ban/sql/fail2ban.mysql new file mode 100644 index 0000000..eddb377 --- /dev/null +++ b/iredmail/samples/fail2ban/sql/fail2ban.mysql @@ -0,0 +1,37 @@ +-- +-- Used to store banned/unbanned clients +-- +CREATE TABLE IF NOT EXISTS `banned` ( + `id` BIGINT(20) UNSIGNED AUTO_INCREMENT, + -- Banned client IP address + `ip` VARCHAR(46) NOT NULL DEFAULT '', + -- A list of banned network ports, separated by comma + `ports` VARCHAR(255) NOT NULL DEFAULT '', + -- protocol: tcp, udp, ... + `protocol` VARCHAR(10) NOT NULL DEFAULT 'tcp', + -- Fail2ban jail name + `jail` VARCHAR(50) NOT NULL DEFAULT '', + -- The server hostname which the ban/unban happens + `hostname` VARCHAR(255) NOT NULL DEFAULT '', + `country` VARCHAR(255) NOT NULL DEFAULT '', + -- reverse DNS name of banned IP address. + `rdns` VARCHAR(255) NOT NULL DEFAULT '', + -- number of times the failure occurred in the log file. + -- we use Fail2ban action tag `ipjailfailures` here. + `failures` INT(2) NOT NULL DEFAULT 0, + -- matched log lines. + -- we use Fail2ban action tag `ipjailmatches` here. + `loglines` TEXT, + -- When the ban happens + `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + -- if `remove=1`, `ip` will be removed by cron job. + `remove` TINYINT(1) DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE INDEX (`ip`, `ports`, `protocol`), + INDEX (`hostname`), + INDEX (`rdns`), + INDEX (`jail`), + INDEX (`country`), + INDEX (`timestamp`), + INDEX (`remove`) +) ENGINE=InnoDB; diff --git a/iredmail/samples/fail2ban/sql/fail2ban.pgsql b/iredmail/samples/fail2ban/sql/fail2ban.pgsql new file mode 100644 index 0000000..9e9edd3 --- /dev/null +++ b/iredmail/samples/fail2ban/sql/fail2ban.pgsql @@ -0,0 +1,37 @@ +-- +-- Used to store banned/unbanned clients +-- +CREATE TABLE banned ( + id SERIAL PRIMARY KEY, + -- Banned client IP address + ip VARCHAR(46) NOT NULL DEFAULT '', + -- A list of banned network ports, separated by comma + ports VARCHAR(255) NOT NULL DEFAULT '', + -- protocol: tcp, udp, ... + protocol VARCHAR(10) NOT NULL DEFAULT 'tcp', + -- Fail2ban jail name + jail VARCHAR(50) NOT NULL DEFAULT '', + -- The server hostname which the ban/unban happens + hostname VARCHAR(255) NOT NULL DEFAULT '', + country VARCHAR(255) NOT NULL DEFAULT '', + -- reverse DNS name of banned IP address. + rdns VARCHAR(255) NOT NULL DEFAULT '', + -- number of times the failure occurred in the log file. + -- we use Fail2ban action tag `ipjailfailures` here. + failures SMALLINT NOT NULL DEFAULT 0, + -- matched log lines. + -- we use Fail2ban action tag `ipjailmatches` here. + loglines TEXT, + -- When the ban happens + timestamp TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT (CURRENT_TIMESTAMP(0) AT TIME ZONE 'UTC'), + -- if `remove=1`, `ip` will be removed by cron job. + remove INT2 DEFAULT 0 +); + +CREATE UNIQUE INDEX idx_banned_ip_ports_protocol ON banned (ip, ports, protocol); +CREATE INDEX idx_banned_jail ON banned (jail); +CREATE INDEX idx_banned_hostname ON banned (hostname); +CREATE INDEX idx_banned_country ON banned (country); +CREATE INDEX idx_banned_timestamp ON banned (timestamp); +CREATE INDEX idx_banned_remove ON banned (remove); +CREATE INDEX idx_banned_rdns ON banned (rdns); diff --git a/iredmail/samples/firewall/firewalld/services/ssh.xml b/iredmail/samples/firewall/firewalld/services/ssh.xml new file mode 100644 index 0000000..4205127 --- /dev/null +++ b/iredmail/samples/firewall/firewalld/services/ssh.xml @@ -0,0 +1,6 @@ + + + SSH + Secure Shell (SSH) is a protocol for logging into and executing commands on remote machines. It provides secure encrypted communications. If you plan on accessing your machine remotely via SSH over a firewalled interface, enable this option. You need the openssh-server package installed for this option to be useful. + + diff --git a/iredmail/samples/firewall/firewalld/zones/iredmail.xml b/iredmail/samples/firewall/firewalld/zones/iredmail.xml new file mode 100644 index 0000000..b9db1e6 --- /dev/null +++ b/iredmail/samples/firewall/firewalld/zones/iredmail.xml @@ -0,0 +1,14 @@ + + + Mail services + Allow access to mail services from external network. + + + + + + + + + + diff --git a/iredmail/samples/firewall/iptables/ip6tables.init.debian b/iredmail/samples/firewall/iptables/ip6tables.init.debian new file mode 100755 index 0000000..1677420 --- /dev/null +++ b/iredmail/samples/firewall/iptables/ip6tables.init.debian @@ -0,0 +1,362 @@ +#!/usr/bin/env bash + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# +### BEGIN INIT INFO +# Provides: ip6tables +# Required-Start: $network $syslog +# Required-Stop: $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Control ip6tables firewall. +### END INIT INFO +# +# This init.d script is used to control ip6tables, based on +# /etc/init.d/ip6tables on Red Hat Enterprise Linux 5.3, modified +# by Zhang Huangbin (zhb _at_ iredmail.org), iRedMail project +# (http://www.iredmail.org/). +# + +# +# config: /etc/default/ip6tables + +# Source function library. +. /lib/lsb/init-functions + +IPTABLES='ip6tables' +IPTABLES_DATA="/etc/default/$IPTABLES" +IPTABLES_CONFIG="/etc/default/${IPTABLES}-config" +IPV="${IPTABLES%tables}" # ip for ipv4 | ip6 for ipv6 +PROC_IPTABLES_NAMES="/proc/net/${IPV}_tables_names" +VAR_SUBSYS_IPTABLES="/var/lock/subsys/$IPTABLES" +[ -d $(dirname ${VAR_SUBSYS_IPTABLES}) ] || mkdir -p $(dirname ${VAR_SUBSYS_IPTABLES}) + +if [ ! -x /sbin/$IPTABLES ]; then + log_daemon_msg "/sbin/$IPTABLES does not exist." "ip6tables" + exit 0 +fi + +if lsmod 2>/dev/null | grep -q ipchains ; then + log_daemon_msg "ipchains and $IPTABLES can not be used together." "ip6tables" + exit 0 +fi + +# Old or new modutils +/sbin/modprobe --version 2>&1 | grep -q module-init-tools \ + && NEW_MODUTILS=1 \ + || NEW_MODUTILS=0 + +# Default firewall configuration: +IPTABLES_MODULES="" +IPTABLES_MODULES_UNLOAD="no" +IPTABLES_SAVE_ON_STOP="no" +IPTABLES_SAVE_ON_RESTART="no" +IPTABLES_SAVE_COUNTER="no" +IPTABLES_STATUS_NUMERIC="yes" + +# Load firewall configuration. +[ -f "$IPTABLES_CONFIG" ] && . "$IPTABLES_CONFIG" + +rmmod_r() { + # Unload module with all referring modules. + # At first all referring modules will be unloaded, then the module itself. + local mod=$1 + local ret=0 + local ref= + + # Get referring modules. + # New modutils have another output format. + [ $NEW_MODUTILS = 1 ] \ + && ref=`lsmod | awk "/^${mod}/ { print \\\$4; }" | tr ',' ' '` \ + || ref=`lsmod | grep ^${mod} | cut -d "[" -s -f 2 | cut -d "]" -s -f 1` + + # recursive call for all referring modules + for i in $ref; do + rmmod_r $i + let ret+=$?; + done + + # Unload module. + # The extra test is for 2.6: The module might have autocleaned, + # after all referring modules are unloaded. + if grep -q "^${mod}" /proc/modules ; then + modprobe -r $mod > /dev/null 2>&1 + let ret+=$?; + fi + + return $ret +} + +flush_n_delete() { + # Flush firewall rules and delete chains. + [ -e "$PROC_IPTABLES_NAMES" ] || return 1 + + # Check if firewall is configured (has tables) + tables=`cat $PROC_IPTABLES_NAMES 2>/dev/null` + [ -z "$tables" ] && return 1 + + log_daemon_msg "Flushing firewall rules" "ip6tables" + ret=0 + # For all tables + for i in $tables; do + # Flush firewall rules. + $IPTABLES -t $i -F; + let ret+=$?; + + # Delete firewall chains. + $IPTABLES -t $i -X; + let ret+=$?; + + # Set counter to zero. + $IPTABLES -t $i -Z; + let ret+=$?; + done + + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + return $ret +} + +set_policy() { + # Set policy for configured tables. + policy=$1 + + # Check if iptable module is loaded + [ ! -e "$PROC_IPTABLES_NAMES" ] && return 1 + + # Check if firewall is configured (has tables) + tables=`cat $PROC_IPTABLES_NAMES 2>/dev/null` + [ -z "$tables" ] && return 1 + + log_daemon_msg "Setting chains to policy $policy" + ret=0 + for i in $tables; do + echo -n " $i" + case "$i" in + security) + $IPTABLES -t filter -P INPUT $policy \ + && $IPTABLES -t filter -P OUTPUT $policy \ + && $IPTABLES -t filter -P FORWARD $policy \ + || let ret+=1 + ;; + raw) + $IPTABLES -t raw -P PREROUTING $policy \ + && $IPTABLES -t raw -P OUTPUT $policy \ + || let ret+=1 + ;; + filter) + $IPTABLES -t filter -P INPUT $policy \ + && $IPTABLES -t filter -P OUTPUT $policy \ + && $IPTABLES -t filter -P FORWARD $policy \ + || let ret+=1 + ;; + nat) + $IPTABLES -t nat -P PREROUTING $policy \ + && $IPTABLES -t nat -P POSTROUTING $policy \ + && $IPTABLES -t nat -P OUTPUT $policy \ + || let ret+=1 + ;; + mangle) + $IPTABLES -t mangle -P PREROUTING $policy \ + && $IPTABLES -t mangle -P POSTROUTING $policy \ + && $IPTABLES -t mangle -P INPUT $policy \ + && $IPTABLES -t mangle -P OUTPUT $policy \ + && $IPTABLES -t mangle -P FORWARD $policy \ + || let ret+=1 + ;; + *) + let ret+=1 + ;; + esac + done + + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + return $ret +} + +start() { + # Do not start if there is no config file. + [ -f "$IPTABLES_DATA" ] || return 1 + + log_daemon_msg "Applying $IPTABLES firewall rules" + + OPT= + [ "x$IPTABLES_SAVE_COUNTER" = "xyes" ] && OPT="-c" + + $IPTABLES-restore $OPT $IPTABLES_DATA + if [ $? -eq 0 ]; then + log_end_msg 0 + else + log_end_msg 1; return 1 + fi + + # Load additional modules (helpers) + if [ -n "$IPTABLES_MODULES" ]; then + echo -n "Loading additional $IPTABLES modules" + ret=0 + for mod in $IPTABLES_MODULES; do + echo -n "$mod " + modprobe $mod > /dev/null 2>&1 + let ret+=$?; + done + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + fi + + touch $VAR_SUBSYS_IPTABLES + return $ret +} + +stop() { + # Do not stop if iptables module is not loaded. + [ -e "$PROC_IPTABLES_NAMES" ] || return 1 + + flush_n_delete + set_policy ACCEPT + + if [ "x$IPTABLES_MODULES_UNLOAD" = "xyes" ]; then + echo -n "Unloading $IPTABLES modules" + ret=0 + rmmod_r ${IPV}_tables + let ret+=$?; + rmmod_r ${IPV}_conntrack + let ret+=$?; + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + fi + + rm -f $VAR_SUBSYS_IPTABLES + return $ret +} + +save() { + # Check if iptable module is loaded + [ ! -e "$PROC_IPTABLES_NAMES" ] && return 1 + + # Check if firewall is configured (has tables) + tables=`cat $PROC_IPTABLES_NAMES 2>/dev/null` + [ -z "$tables" ] && return 1 + + echo -n "Saving firewall rules to $IPTABLES_DATA" + + OPT= + [ "x$IPTABLES_SAVE_COUNTER" = "xyes" ] && OPT="-c" + + ret=0 + TMP_FILE=`/bin/mktemp -q /tmp/$IPTABLES.XXXXXX` \ + && chmod 600 "$TMP_FILE" \ + && $IPTABLES-save $OPT > $TMP_FILE 2>/dev/null \ + && size=`stat -c '%s' $TMP_FILE` && [ $size -gt 0 ] \ + || ret=1 + if [ $ret -eq 0 ]; then + if [ -e $IPTABLES_DATA ]; then + cp -f $IPTABLES_DATA $IPTABLES_DATA.save \ + && chmod 600 $IPTABLES_DATA.save \ + || ret=1 + fi + if [ $ret -eq 0 ]; then + cp -f $TMP_FILE $IPTABLES_DATA \ + && chmod 600 $IPTABLES_DATA \ + || ret=1 + fi + fi + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + echo + rm -f $TMP_FILE + return $ret +} + +status() { + tables=`cat $PROC_IPTABLES_NAMES 2>/dev/null` + + # Do not print status if lockfile is missing and iptables modules are not + # loaded. + # Check if iptable module is loaded + if [ ! -f "$VAR_SUBSYS_IPTABLES" -a -z "$tables" ]; then + echo "Firewall is stopped." + return 1 + fi + + # Check if firewall is configured (has tables) + if [ ! -e "$PROC_IPTABLES_NAMES" ]; then + echo "Firewall is not configured. " + return 1 + fi + if [ -z "$tables" ]; then + echo "Firewall is not configured. " + return 1 + fi + + NUM= + [ "x$IPTABLES_STATUS_NUMERIC" = "xyes" ] && NUM="-n" + VERBOSE= + [ "x$IPTABLES_STATUS_VERBOSE" = "xyes" ] && VERBOSE="--verbose" + COUNT= + [ "x$IPTABLES_STATUS_LINENUMBERS" = "xyes" ] && COUNT="--line-numbers" + + for table in $tables; do + echo "Table: $table" + $IPTABLES -t $table --list $NUM $VERBOSE $COUNT && echo + done + + return 0 +} + +restart() { + [ "x$IPTABLES_SAVE_ON_RESTART" = "xyes" ] && save + stop + start +} + +case "$1" in + start) + stop + start + RETVAL=$? + ;; + stop) + [ "x$IPTABLES_SAVE_ON_STOP" = "xyes" ] && save + stop + RETVAL=$? + ;; + restart) + restart + RETVAL=$? + ;; + condrestart) + [ -e "$VAR_SUBSYS_IPTABLES" ] && restart + ;; + status) + status + RETVAL=$? + ;; + panic) + flush_n_delete + set_policy DROP + RETVAL=$? + ;; + save) + save + RETVAL=$? + ;; + *) + echo "Usage: $0 {start|stop|restart|condrestart|status|panic|save}" + exit 1 + ;; +esac + +exit $RETVAL diff --git a/iredmail/samples/firewall/iptables/ip6tables.rules b/iredmail/samples/firewall/iptables/ip6tables.rules new file mode 100644 index 0000000..5a48912 --- /dev/null +++ b/iredmail/samples/firewall/iptables/ip6tables.rules @@ -0,0 +1,52 @@ +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +*filter +:INPUT DROP [0:0] +:FORWARD DROP [0:0] +:OUTPUT ACCEPT [0:0] + +# Keep state. +-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT + +# Loop device. +-A INPUT -i lo -j ACCEPT + +-A INPUT -p ipv6-icmp -j ACCEPT + +# ssh +-A INPUT -p tcp --dport 22 -j ACCEPT + +# http, https +-A INPUT -p tcp --dport 80 -j ACCEPT +-A INPUT -p tcp --dport 443 -j ACCEPT + +# smtp, submission +-A INPUT -p tcp --dport 25 -j ACCEPT +-A INPUT -p tcp --dport 587 -j ACCEPT + +# pop3, pop3s +-A INPUT -p tcp --dport 110 -j ACCEPT +-A INPUT -p tcp --dport 995 -j ACCEPT +#-A INPUT -p tcp --dport 10110 -j ACCEPT + +# imap, imaps +-A INPUT -p tcp --dport 143 -j ACCEPT +-A INPUT -p tcp --dport 993 -j ACCEPT + +COMMIT diff --git a/iredmail/samples/firewall/iptables/iptables.init.debian b/iredmail/samples/firewall/iptables/iptables.init.debian new file mode 100755 index 0000000..1e8ffab --- /dev/null +++ b/iredmail/samples/firewall/iptables/iptables.init.debian @@ -0,0 +1,363 @@ +#!/usr/bin/env bash + +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# +### BEGIN INIT INFO +# Provides: iptables +# Required-Start: $network $syslog +# Required-Stop: $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Control iptables firewall. +### END INIT INFO +# +# This init.d script is used to control iptables, based on +# /etc/init.d/iptables on Red Hat Enterprise Linux 5.3, modified +# by Zhang Huangbin (zhb _at_ iredmail.org), iRedMail project +# (http://www.iredmail.org/). +# + +# +# config: /etc/default/iptables +# config: /etc/default/iptables-config + +# Source function library. +. /lib/lsb/init-functions + +IPTABLES='iptables' +IPTABLES_DATA="/etc/default/$IPTABLES" +IPTABLES_CONFIG="/etc/default/${IPTABLES}-config" +IPV="${IPTABLES%tables}" # ip for ipv4 | ip6 for ipv6 +PROC_IPTABLES_NAMES="/proc/net/${IPV}_tables_names" +VAR_SUBSYS_IPTABLES="/var/lock/subsys/$IPTABLES" +[ -d $(dirname ${VAR_SUBSYS_IPTABLES}) ] || mkdir -p $(dirname ${VAR_SUBSYS_IPTABLES}) + +if [ ! -x /sbin/$IPTABLES ]; then + log_daemon_msg "/sbin/$IPTABLES does not exist." "iptables" + exit 0 +fi + +if lsmod 2>/dev/null | grep -q ipchains ; then + log_daemon_msg "ipchains and $IPTABLES can not be used together." "iptables" + exit 0 +fi + +# Old or new modutils +/sbin/modprobe --version 2>&1 | grep -q module-init-tools \ + && NEW_MODUTILS=1 \ + || NEW_MODUTILS=0 + +# Default firewall configuration: +IPTABLES_MODULES="" +IPTABLES_MODULES_UNLOAD="no" +IPTABLES_SAVE_ON_STOP="no" +IPTABLES_SAVE_ON_RESTART="no" +IPTABLES_SAVE_COUNTER="no" +IPTABLES_STATUS_NUMERIC="yes" + +# Load firewall configuration. +[ -f "$IPTABLES_CONFIG" ] && . "$IPTABLES_CONFIG" + +rmmod_r() { + # Unload module with all referring modules. + # At first all referring modules will be unloaded, then the module itself. + local mod=$1 + local ret=0 + local ref= + + # Get referring modules. + # New modutils have another output format. + [ $NEW_MODUTILS = 1 ] \ + && ref=`lsmod | awk "/^${mod}/ { print \\\$4; }" | tr ',' ' '` \ + || ref=`lsmod | grep ^${mod} | cut -d "[" -s -f 2 | cut -d "]" -s -f 1` + + # recursive call for all referring modules + for i in $ref; do + rmmod_r $i + let ret+=$?; + done + + # Unload module. + # The extra test is for 2.6: The module might have autocleaned, + # after all referring modules are unloaded. + if grep -q "^${mod}" /proc/modules ; then + modprobe -r $mod > /dev/null 2>&1 + let ret+=$?; + fi + + return $ret +} + +flush_n_delete() { + # Flush firewall rules and delete chains. + [ -e "$PROC_IPTABLES_NAMES" ] || return 1 + + # Check if firewall is configured (has tables) + tables=`cat $PROC_IPTABLES_NAMES 2>/dev/null` + [ -z "$tables" ] && return 1 + + log_daemon_msg "Flushing firewall rules" "iptables" + ret=0 + # For all tables + for i in $tables; do + # Flush firewall rules. + $IPTABLES -t $i -F; + let ret+=$?; + + # Delete firewall chains. + $IPTABLES -t $i -X; + let ret+=$?; + + # Set counter to zero. + $IPTABLES -t $i -Z; + let ret+=$?; + done + + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + return $ret +} + +set_policy() { + # Set policy for configured tables. + policy=$1 + + # Check if iptable module is loaded + [ ! -e "$PROC_IPTABLES_NAMES" ] && return 1 + + # Check if firewall is configured (has tables) + tables=`cat $PROC_IPTABLES_NAMES 2>/dev/null` + [ -z "$tables" ] && return 1 + + log_daemon_msg "Setting chains to policy $policy" + ret=0 + for i in $tables; do + echo -n " $i" + case "$i" in + security) + $IPTABLES -t filter -P INPUT $policy \ + && $IPTABLES -t filter -P OUTPUT $policy \ + && $IPTABLES -t filter -P FORWARD $policy \ + || let ret+=1 + ;; + raw) + $IPTABLES -t raw -P PREROUTING $policy \ + && $IPTABLES -t raw -P OUTPUT $policy \ + || let ret+=1 + ;; + filter) + $IPTABLES -t filter -P INPUT $policy \ + && $IPTABLES -t filter -P OUTPUT $policy \ + && $IPTABLES -t filter -P FORWARD $policy \ + || let ret+=1 + ;; + nat) + $IPTABLES -t nat -P PREROUTING $policy \ + && $IPTABLES -t nat -P POSTROUTING $policy \ + && $IPTABLES -t nat -P OUTPUT $policy \ + || let ret+=1 + ;; + mangle) + $IPTABLES -t mangle -P PREROUTING $policy \ + && $IPTABLES -t mangle -P POSTROUTING $policy \ + && $IPTABLES -t mangle -P INPUT $policy \ + && $IPTABLES -t mangle -P OUTPUT $policy \ + && $IPTABLES -t mangle -P FORWARD $policy \ + || let ret+=1 + ;; + *) + let ret+=1 + ;; + esac + done + + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + return $ret +} + +start() { + # Do not start if there is no config file. + [ -f "$IPTABLES_DATA" ] || return 1 + + log_daemon_msg "Applying $IPTABLES firewall rules" + + OPT= + [ "x$IPTABLES_SAVE_COUNTER" = "xyes" ] && OPT="-c" + + $IPTABLES-restore $OPT $IPTABLES_DATA + if [ $? -eq 0 ]; then + log_end_msg 0 + else + log_end_msg 1; return 1 + fi + + # Load additional modules (helpers) + if [ -n "$IPTABLES_MODULES" ]; then + echo -n "Loading additional $IPTABLES modules" + ret=0 + for mod in $IPTABLES_MODULES; do + echo -n "$mod " + modprobe $mod > /dev/null 2>&1 + let ret+=$?; + done + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + fi + + touch $VAR_SUBSYS_IPTABLES + return $ret +} + +stop() { + # Do not stop if iptables module is not loaded. + [ -e "$PROC_IPTABLES_NAMES" ] || return 1 + + flush_n_delete + set_policy ACCEPT + + if [ "x$IPTABLES_MODULES_UNLOAD" = "xyes" ]; then + echo -n "Unloading $IPTABLES modules" + ret=0 + rmmod_r ${IPV}_tables + let ret+=$?; + rmmod_r ${IPV}_conntrack + let ret+=$?; + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + fi + + rm -f $VAR_SUBSYS_IPTABLES + return $ret +} + +save() { + # Check if iptable module is loaded + [ ! -e "$PROC_IPTABLES_NAMES" ] && return 1 + + # Check if firewall is configured (has tables) + tables=`cat $PROC_IPTABLES_NAMES 2>/dev/null` + [ -z "$tables" ] && return 1 + + echo -n "Saving firewall rules to $IPTABLES_DATA" + + OPT= + [ "x$IPTABLES_SAVE_COUNTER" = "xyes" ] && OPT="-c" + + ret=0 + TMP_FILE=`/bin/mktemp -q /tmp/$IPTABLES.XXXXXX` \ + && chmod 600 "$TMP_FILE" \ + && $IPTABLES-save $OPT > $TMP_FILE 2>/dev/null \ + && size=`stat -c '%s' $TMP_FILE` && [ $size -gt 0 ] \ + || ret=1 + if [ $ret -eq 0 ]; then + if [ -e $IPTABLES_DATA ]; then + cp -f $IPTABLES_DATA $IPTABLES_DATA.save \ + && chmod 600 $IPTABLES_DATA.save \ + || ret=1 + fi + if [ $ret -eq 0 ]; then + cp -f $TMP_FILE $IPTABLES_DATA \ + && chmod 600 $IPTABLES_DATA \ + || ret=1 + fi + fi + [ $ret -eq 0 ] && log_end_msg 0 || log_end_msg 1 + echo + rm -f $TMP_FILE + return $ret +} + +status() { + tables=`cat $PROC_IPTABLES_NAMES 2>/dev/null` + + # Do not print status if lockfile is missing and iptables modules are not + # loaded. + # Check if iptable module is loaded + if [ ! -f "$VAR_SUBSYS_IPTABLES" -a -z "$tables" ]; then + echo "Firewall is stopped." + return 1 + fi + + # Check if firewall is configured (has tables) + if [ ! -e "$PROC_IPTABLES_NAMES" ]; then + echo "Firewall is not configured. " + return 1 + fi + if [ -z "$tables" ]; then + echo "Firewall is not configured. " + return 1 + fi + + NUM= + [ "x$IPTABLES_STATUS_NUMERIC" = "xyes" ] && NUM="-n" + VERBOSE= + [ "x$IPTABLES_STATUS_VERBOSE" = "xyes" ] && VERBOSE="--verbose" + COUNT= + [ "x$IPTABLES_STATUS_LINENUMBERS" = "xyes" ] && COUNT="--line-numbers" + + for table in $tables; do + echo "Table: $table" + $IPTABLES -t $table --list $NUM $VERBOSE $COUNT && echo + done + + return 0 +} + +restart() { + [ "x$IPTABLES_SAVE_ON_RESTART" = "xyes" ] && save + stop + start +} + +case "$1" in + start) + stop + start + RETVAL=$? + ;; + stop) + [ "x$IPTABLES_SAVE_ON_STOP" = "xyes" ] && save + stop + RETVAL=$? + ;; + restart) + restart + RETVAL=$? + ;; + condrestart) + [ -e "$VAR_SUBSYS_IPTABLES" ] && restart + ;; + status) + status + RETVAL=$? + ;; + panic) + flush_n_delete + set_policy DROP + RETVAL=$? + ;; + save) + save + RETVAL=$? + ;; + *) + echo "Usage: $0 {start|stop|restart|condrestart|status|panic|save}" + exit 1 + ;; +esac + +exit $RETVAL diff --git a/iredmail/samples/firewall/iptables/iptables.rules b/iredmail/samples/firewall/iptables/iptables.rules new file mode 100644 index 0000000..7d28a20 --- /dev/null +++ b/iredmail/samples/firewall/iptables/iptables.rules @@ -0,0 +1,53 @@ +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +*filter +:INPUT DROP [0:0] +:FORWARD DROP [0:0] +:OUTPUT ACCEPT [0:0] + +# Keep state. +-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT + +# Loop device. +-A INPUT -i lo -j ACCEPT + +# Allow PING from remote hosts. +-A INPUT -p icmp --icmp-type echo-request -j ACCEPT + +# ssh +-A INPUT -p tcp --dport 22 -j ACCEPT + +# http, https +-A INPUT -p tcp --dport 80 -j ACCEPT +-A INPUT -p tcp --dport 443 -j ACCEPT + +# smtp, submission +-A INPUT -p tcp --dport 25 -j ACCEPT +-A INPUT -p tcp --dport 587 -j ACCEPT + +# pop3, pop3s +-A INPUT -p tcp --dport 110 -j ACCEPT +-A INPUT -p tcp --dport 995 -j ACCEPT +#-A INPUT -p tcp --dport 10110 -j ACCEPT + +# imap, imaps +-A INPUT -p tcp --dport 143 -j ACCEPT +-A INPUT -p tcp --dport 993 -j ACCEPT + +COMMIT diff --git a/iredmail/samples/firewall/nftables.conf b/iredmail/samples/firewall/nftables.conf new file mode 100644 index 0000000..fc8c269 --- /dev/null +++ b/iredmail/samples/firewall/nftables.conf @@ -0,0 +1,57 @@ +#!/usr/sbin/nft -f + +flush ruleset + +# `inet` applies to both IPv4 and IPv6. +table inet filter { + chain input { + type filter hook input priority 0; + + # accept any localhost traffic + iif lo accept + + # no ping floods: + ip protocol icmp icmp type echo-request limit rate over 10/second burst 4 packets drop + ip6 nexthdr icmpv6 icmpv6 type echo-request limit rate over 10/second burst 4 packets drop + + # accept traffic originated from us + ct state established,related accept + + # accept ICMP & IGMP + ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, parameter-problem, mld-listener-query, mld-listener-report, mld-listener-reduction, nd-router-solicit, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert, ind-neighbor-solicit, ind-neighbor-advert, mld2-listener-report } accept + ip protocol icmp icmp type { destination-unreachable, router-solicitation, router-advertisement, time-exceeded, parameter-problem } accept + ip protocol igmp accept + + # ssh + tcp dport 22 accept + + # http/https + tcp dport 80 accept + tcp dport 443 accept + + # smtp/submission + tcp dport 25 accept + tcp dport 587 accept + + # pop3/pop3s + tcp dport 110 accept + tcp dport 995 accept + + # imap/imaps + tcp dport 143 accept + tcp dport 993 accept + + # count and drop any other traffic + counter drop + } + + chain output { + type filter hook output priority 0; + policy accept; + } + + chain forward { + type filter hook forward priority 0; + policy drop; + } +} diff --git a/iredmail/samples/freebsd/newsyslog.conf.d/dovecot b/iredmail/samples/freebsd/newsyslog.conf.d/dovecot new file mode 100644 index 0000000..7cc2d14 --- /dev/null +++ b/iredmail/samples/freebsd/newsyslog.conf.d/dovecot @@ -0,0 +1,3 @@ +PH_DOVECOT_LOG_FILE PH_SYS_USER_SYSLOG:PH_SYS_GROUP_SYSLOG 600 7 * 24 Z PH_DOVECOT_MASTER_PID +PH_DOVECOT_SIEVE_LOG_FILE PH_SYS_USER_SYSLOG:PH_SYS_GROUP_SYSLOG 600 7 * 24 Z PH_DOVECOT_MASTER_PID +PH_DOVECOT_LMTP_LOG_FILE PH_SYS_USER_SYSLOG:PH_SYS_GROUP_SYSLOG 600 7 * 24 Z PH_DOVECOT_MASTER_PID diff --git a/iredmail/samples/freebsd/newsyslog.conf.d/iredapd b/iredmail/samples/freebsd/newsyslog.conf.d/iredapd new file mode 100644 index 0000000..8bc1d03 --- /dev/null +++ b/iredmail/samples/freebsd/newsyslog.conf.d/iredapd @@ -0,0 +1 @@ +PH_IREDAPD_LOG_FILE PH_SYS_USER_SYSLOG:PH_SYS_GROUP_SYSLOG 600 7 * 24 Z PH_IREDAPD_PID_FILE diff --git a/iredmail/samples/freebsd/newsyslog.conf.d/mlmmjadmin b/iredmail/samples/freebsd/newsyslog.conf.d/mlmmjadmin new file mode 100644 index 0000000..97004ce --- /dev/null +++ b/iredmail/samples/freebsd/newsyslog.conf.d/mlmmjadmin @@ -0,0 +1 @@ +PH_MLMMJADMIN_LOG_FILE PH_SYS_USER_SYSLOG:PH_SYS_GROUP_SYSLOG 600 7 * 24 Z PH_MLMMJADMIN_PID_FILE diff --git a/iredmail/samples/freebsd/newsyslog.conf.d/php-fpm b/iredmail/samples/freebsd/newsyslog.conf.d/php-fpm new file mode 100644 index 0000000..c73e351 --- /dev/null +++ b/iredmail/samples/freebsd/newsyslog.conf.d/php-fpm @@ -0,0 +1,2 @@ +PH_PHP_FPM_LOG_MAIN PH_SYS_USER_SYSLOG:PH_SYS_GROUP_SYSLOG 600 7 * 24 Z PH_PHP_FPM_PID_FILE +PH_PHP_FPM_LOG_SLOW PH_SYS_USER_SYSLOG:PH_SYS_GROUP_SYSLOG 600 7 * 24 Z PH_PHP_FPM_PID_FILE diff --git a/iredmail/samples/freebsd/newsyslog.conf.d/slapd b/iredmail/samples/freebsd/newsyslog.conf.d/slapd new file mode 100644 index 0000000..8a9b675 --- /dev/null +++ b/iredmail/samples/freebsd/newsyslog.conf.d/slapd @@ -0,0 +1 @@ +PH_OPENLDAP_LOG_FILE PH_SYS_USER_SYSLOG:PH_SYS_GROUP_SYSLOG 640 7 * 24 Z diff --git a/iredmail/samples/freebsd/syslog.d/dovecot.conf b/iredmail/samples/freebsd/syslog.d/dovecot.conf new file mode 100644 index 0000000..c225ca2 --- /dev/null +++ b/iredmail/samples/freebsd/syslog.d/dovecot.conf @@ -0,0 +1,2 @@ +!dovecot +PH_IREDMAIL_SYSLOG_FACILITY.* PH_DOVECOT_LOG_FILE diff --git a/iredmail/samples/freebsd/syslog.d/fail2ban.conf b/iredmail/samples/freebsd/syslog.d/fail2ban.conf new file mode 100644 index 0000000..fc4a337 --- /dev/null +++ b/iredmail/samples/freebsd/syslog.d/fail2ban.conf @@ -0,0 +1,2 @@ +!fail2ban +PH_FAIL2BAN_SYSLOG_FACILITY.* PH_FAIL2BAN_LOG_FILE diff --git a/iredmail/samples/freebsd/syslog.d/iredapd.conf b/iredmail/samples/freebsd/syslog.d/iredapd.conf new file mode 100644 index 0000000..e7e3e32 --- /dev/null +++ b/iredmail/samples/freebsd/syslog.d/iredapd.conf @@ -0,0 +1,2 @@ +!iredapd +PH_IREDMAIL_SYSLOG_FACILITY.* PH_IREDAPD_LOG_FILE diff --git a/iredmail/samples/freebsd/syslog.d/mlmmjadmin.conf b/iredmail/samples/freebsd/syslog.d/mlmmjadmin.conf new file mode 100644 index 0000000..15974d1 --- /dev/null +++ b/iredmail/samples/freebsd/syslog.d/mlmmjadmin.conf @@ -0,0 +1,2 @@ +!mlmmjadmin +PH_IREDMAIL_SYSLOG_FACILITY.* PH_MLMMJADMIN_LOG_FILE diff --git a/iredmail/samples/freebsd/syslog.d/php-fpm.conf b/iredmail/samples/freebsd/syslog.d/php-fpm.conf new file mode 100644 index 0000000..d3f27b8 --- /dev/null +++ b/iredmail/samples/freebsd/syslog.d/php-fpm.conf @@ -0,0 +1,2 @@ +!php-fpm +local5.* PH_PHP_FPM_LOG_MAIN diff --git a/iredmail/samples/freebsd/syslog.d/slapd.conf b/iredmail/samples/freebsd/syslog.d/slapd.conf new file mode 100644 index 0000000..4954f97 --- /dev/null +++ b/iredmail/samples/freebsd/syslog.d/slapd.conf @@ -0,0 +1,2 @@ +!slapd +*.* PH_OPENLDAP_LOG_FILE diff --git a/iredmail/samples/iredmail/iredmail.mysql b/iredmail/samples/iredmail/iredmail.mysql new file mode 100644 index 0000000..a1f2f75 --- /dev/null +++ b/iredmail/samples/iredmail/iredmail.mysql @@ -0,0 +1,465 @@ +-- -------------------------------------------------------------------- +-- 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 . +-- -------------------------------------------------------------------- + +-- +-- Based on original postfixadmin template. +-- http://postfixadmin.sf.net +-- + +-- USE PH_VMAIL_DB_NAME; + +-- +-- Table structure for table admin +-- +CREATE TABLE IF NOT EXISTS admin ( + username VARCHAR(255) NOT NULL DEFAULT '', + password VARCHAR(255) NOT NULL DEFAULT '', + name VARCHAR(255) NOT NULL DEFAULT '', + language VARCHAR(5) NOT NULL DEFAULT '', + passwordlastchange DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + -- Store per-admin settings. Used in iRedAdmin-Pro. + settings TEXT, + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (username), + INDEX (passwordlastchange), + INDEX (expired), + INDEX (active) +) ENGINE=InnoDB; + +-- +-- Table structure for table alias +-- +CREATE TABLE IF NOT EXISTS alias ( + address VARCHAR(255) NOT NULL DEFAULT '', + name VARCHAR(255) NOT NULL DEFAULT '', + accesspolicy VARCHAR(30) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (address), + INDEX (domain), + INDEX (expired), + INDEX (active) +) ENGINE=InnoDB; + +-- Alias and mailing list moderators. +CREATE TABLE IF NOT EXISTS moderators ( + id BIGINT(20) UNSIGNED AUTO_INCREMENT, + address VARCHAR(255) NOT NULL DEFAULT '', + moderator VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + dest_domain VARCHAR(255) NOT NULL DEFAULT '', + PRIMARY KEY (id), + UNIQUE INDEX (address, moderator), + INDEX (domain), + INDEX (dest_domain) +) ENGINE=InnoDB; + +-- Forwardings. it contains +-- - members of mail alias account +-- - per-account alias addresses +-- - per-user mail forwarding addresses +CREATE TABLE IF NOT EXISTS forwardings ( + id BIGINT(20) UNSIGNED AUTO_INCREMENT, + address VARCHAR(255) NOT NULL DEFAULT '', + forwarding VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + dest_domain VARCHAR(255) NOT NULL DEFAULT '', + -- defines whether it's a standalone (mlmmj) mailing list account. 0=no, 1=yes. + is_maillist TINYINT(1) NOT NULL DEFAULT 0, + -- defines whether it's a standalone mail alias account. 0=no, 1=yes. + is_list TINYINT(1) NOT NULL DEFAULT 0, + -- defines whether it's a mail forwarding address of mail user. 0=no, 1=yes. + is_forwarding TINYINT(1) NOT NULL DEFAULT 0, + -- defines whether it's a per-account alias address. 0=no, 1=yes. + is_alias TINYINT(1) NOT NULL DEFAULT 0, + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (id), + UNIQUE INDEX (address, forwarding), + INDEX (domain), + INDEX (dest_domain), + INDEX (is_maillist), + INDEX (is_list), + INDEX (is_alias) +) ENGINE=InnoDB; + +-- +-- Table structure for table domain +-- +CREATE TABLE IF NOT EXISTS domain ( + -- mail domain name. e.g. iredmail.org. + domain VARCHAR(255) NOT NULL DEFAULT '', + description TEXT, + -- Disclaimer text. Used by Amavisd + AlterMIME. + disclaimer TEXT, + -- Max alias accounts in this domain. e.g. 10. + aliases INT(10) NOT NULL DEFAULT 0, + -- Max mail accounts in this domain. e.g. 100. + mailboxes INT(10) NOT NULL DEFAULT 0, + -- Max mailing list accounts in this domain. e.g. 10. + maillists INT(10) NOT NULL DEFAULT 0, + -- Max mailbox quota in this domain. e.g. 1073741824 (1GB). + maxquota BIGINT(20) NOT NULL DEFAULT 0, + -- Not used. Historical. + quota BIGINT(20) NOT NULL DEFAULT 0, + -- Per-domain transport. e.g. dovecot, smtp:[192.168.1.1]:25 + transport VARCHAR(255) NOT NULL DEFAULT 'dovecot', + backupmx TINYINT(1) NOT NULL DEFAULT 0, + -- Store per-domain settings. Used in iRedAdmin-Pro. + settings TEXT, + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (domain), + INDEX (backupmx), + INDEX (expired), + INDEX (active) +) ENGINE=InnoDB; + +CREATE TABLE IF NOT EXISTS `alias_domain` ( + alias_domain VARCHAR(255) NOT NULL, + target_domain VARCHAR(255) NOT NULL, + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (alias_domain), + INDEX (target_domain), + INDEX (active) +) ENGINE=InnoDB; + +-- +-- Table structure for table domain_admins +-- +CREATE TABLE IF NOT EXISTS domain_admins ( + username VARCHAR(255) CHARACTER SET ascii NOT NULL DEFAULT '', + domain VARCHAR(255) CHARACTER SET ascii NOT NULL DEFAULT '', + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (username,domain), + INDEX (username), + INDEX (domain), + INDEX (active) +) ENGINE=InnoDB; + +-- +-- Table structure for table mailbox +-- +CREATE TABLE IF NOT EXISTS mailbox ( + username VARCHAR(255) NOT NULL DEFAULT '', + password VARCHAR(255) NOT NULL DEFAULT '', + name VARCHAR(255) NOT NULL DEFAULT '', + language VARCHAR(5) NOT NULL DEFAULT '', + -- Mailbox format. + -- All formats supported by Dovecot are ok. e.g. maildir, mdbox. + -- FYI: https://wiki2.dovecot.org/MailboxFormat + mailboxformat VARCHAR(50) NOT NULL DEFAULT 'maildir', + -- mailbox folder name can be any folder name supported by Linux/BSD file + -- system. + mailboxfolder VARCHAR(50) NOT NULL DEFAULT 'Maildir', + storagebasedirectory VARCHAR(255) NOT NULL DEFAULT '', + storagenode VARCHAR(255) NOT NULL DEFAULT '', + maildir VARCHAR(255) NOT NULL DEFAULT '', + quota BIGINT(20) NOT NULL DEFAULT 0, -- Total mail quota size + domain VARCHAR(255) NOT NULL DEFAULT '', + transport VARCHAR(255) NOT NULL DEFAULT '', + department VARCHAR(255) NOT NULL DEFAULT '', + `rank` VARCHAR(255) NOT NULL DEFAULT 'normal', + employeeid VARCHAR(255) DEFAULT '', + isadmin TINYINT(1) NOT NULL DEFAULT 0, + isglobaladmin TINYINT(1) NOT NULL DEFAULT 0, + enablesmtp TINYINT(1) NOT NULL DEFAULT 1, + enablesmtpsecured TINYINT(1) NOT NULL DEFAULT 1, + enablepop3 TINYINT(1) NOT NULL DEFAULT 1, + enablepop3secured TINYINT(1) NOT NULL DEFAULT 1, + enablepop3tls TINYINT(1) NOT NULL DEFAULT 1, + enableimap TINYINT(1) NOT NULL DEFAULT 1, + enableimapsecured TINYINT(1) NOT NULL DEFAULT 1, + enableimaptls TINYINT(1) NOT NULL DEFAULT 1, + enabledeliver TINYINT(1) NOT NULL DEFAULT 1, + enablelda TINYINT(1) NOT NULL DEFAULT 1, + enablemanagesieve TINYINT(1) NOT NULL DEFAULT 1, + enablemanagesievesecured TINYINT(1) NOT NULL DEFAULT 1, + enablesieve TINYINT(1) NOT NULL DEFAULT 1, + enablesievesecured TINYINT(1) NOT NULL DEFAULT 1, + enablesievetls TINYINT(1) NOT NULL DEFAULT 1, + enableinternal TINYINT(1) NOT NULL DEFAULT 1, + enabledoveadm TINYINT(1) NOT NULL DEFAULT 1, + `enablelib-storage` TINYINT(1) NOT NULL DEFAULT 1, + `enablequota-status` TINYINT(1) NOT NULL DEFAULT 1, + `enableindexer-worker` TINYINT(1) NOT NULL DEFAULT 1, + enablelmtp TINYINT(1) NOT NULL DEFAULT 1, + enabledsync TINYINT(1) NOT NULL DEFAULT 1, + enablesogo TINYINT(1) NOT NULL DEFAULT 1, + -- Must be set to NULL if it's not restricted. + allow_nets TEXT DEFAULT NULL, + lastlogindate DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + lastloginipv4 INT(4) UNSIGNED NOT NULL DEFAULT 0, + lastloginprotocol CHAR(255) NOT NULL DEFAULT '', + disclaimer TEXT, + -- Below 4 columns are deprecated and will be removed in future release. + -- Don't use them. + allowedsenders TEXT, + rejectedsenders TEXT, + allowedrecipients TEXT, + rejectedrecipients TEXT, + -- Store per-user settings. Used in iRedAdmin-Pro. + settings TEXT, + passwordlastchange DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (username), + INDEX (domain), + INDEX (department), + INDEX (employeeid), + INDEX (isadmin), + INDEX (isglobaladmin), + INDEX (enablesmtp), + INDEX (enablesmtpsecured), + INDEX (enablepop3), + INDEX (enablepop3secured), + INDEX (enablepop3tls), + INDEX (enableimap), + INDEX (enableimapsecured), + INDEX (enableimaptls), + INDEX (enabledeliver), + INDEX (enablelda), + INDEX (enablemanagesieve), + INDEX (enablemanagesievesecured), + INDEX (enablesieve), + INDEX (enablesievesecured), + INDEX (enablesievetls), + INDEX (enablelmtp), + INDEX (enableinternal), + INDEX (enabledoveadm), + INDEX (`enablelib-storage`), + INDEX (`enablequota-status`), + INDEX (`enableindexer-worker`), + INDEX (enabledsync), + INDEX (enablesogo), + INDEX (passwordlastchange), + INDEX (expired), + INDEX (active) +) ENGINE=InnoDB; + +CREATE TABLE IF NOT EXISTS maillists ( + id BIGINT(20) UNSIGNED AUTO_INCREMENT, + address VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + -- Per mailing list transport. for example: 'mlmmj:example.com/listname'. + transport VARCHAR(255) NOT NULL DEFAULT '', + accesspolicy VARCHAR(30) NOT NULL DEFAULT '', + maxmsgsize BIGINT(20) NOT NULL DEFAULT 0, + -- name of the mailing list + name VARCHAR(255) NOT NULL DEFAULT '', + -- short introduction of the mailing list on subscription page + description TEXT, + -- a server-wide unique id (a 36-characters string) for each mailing list + mlid VARCHAR(36) NOT NULL DEFAULT '', + -- control whether newsletter-style subscription from website is enabled + -- 1 -> enabled, 0 -> disabled + is_newsletter TINYINT(1) NOT NULL DEFAULT 0, + settings TEXT, + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (id), + UNIQUE INDEX (address), + UNIQUE INDEX (mlid), + INDEX (is_newsletter), + INDEX (domain), + INDEX (active) +) ENGINE=InnoDB; + +-- +-- Table structure for table sender_bcc_domain +-- TODO Merge into table 'domain' (domain.sender_bcc) +-- +CREATE TABLE IF NOT EXISTS sender_bcc_domain ( + domain VARCHAR(255) NOT NULL DEFAULT '', + bcc_address VARCHAR(255) NOT NULL DEFAULT '', + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (domain), + INDEX (bcc_address), + INDEX (expired), + INDEX (active) +) ENGINE=InnoDB; + +-- +-- Table structure for table recipient_bcc_domain +-- TODO Merge into table 'domain' (domain.recipient_bcc) +-- +CREATE TABLE IF NOT EXISTS recipient_bcc_domain ( + domain VARCHAR(255) NOT NULL DEFAULT '', + bcc_address VARCHAR(255) NOT NULL DEFAULT '', + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (domain), + INDEX (bcc_address), + INDEX (expired), + INDEX (active) +) ENGINE=InnoDB; + +-- +-- Table structure for table sender_bcc_user +-- TODO Merge into table 'mailbox' (mailbox.sender_bcc) +-- +CREATE TABLE IF NOT EXISTS sender_bcc_user ( + username VARCHAR(255) NOT NULL DEFAULT '', + bcc_address VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (username), + INDEX (bcc_address), + INDEX (domain), + INDEX (expired), + INDEX (active) +) ENGINE=InnoDB; + +-- +-- Table structure for table recipient_bcc_user +-- TODO Merge into table 'mailbox' (mailbox.recipient_bcc) +-- +CREATE TABLE IF NOT EXISTS recipient_bcc_user ( + username VARCHAR(255) NOT NULL DEFAULT '', + bcc_address VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (username), + INDEX (bcc_address), + INDEX (expired), + INDEX (active) +) ENGINE=InnoDB; + +-- Sender dependent relayhost. +-- - per-user: account='user@domain.com' +-- - per-domain: account='@domain.com' +-- References: +-- - http://www.postfix.org/postconf.5.html#sender_dependent_relayhost_maps +-- - http://www.postfix.org/transport.5.html +CREATE TABLE IF NOT EXISTS sender_relayhost ( + id BIGINT(20) UNSIGNED AUTO_INCREMENT, + account VARCHAR(255) NOT NULL DEFAULT '', + relayhost VARCHAR(255) NOT NULL DEFAULT '', + PRIMARY KEY (id), + UNIQUE INDEX (account) +) ENGINE=InnoDB; + +-- Used to store basic info of deleted mailboxes. +CREATE TABLE IF NOT EXISTS deleted_mailboxes ( + id BIGINT(20) UNSIGNED AUTO_INCREMENT, + timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + -- Email address of deleted user + username VARCHAR(255) NOT NULL DEFAULT '', + -- Domain part of username + domain VARCHAR(255) NOT NULL DEFAULT '', + -- Absolute path of user's mailbox + maildir VARCHAR(255) NOT NULL DEFAULT '', + -- Deleted by which domain admin + admin VARCHAR(255) NOT NULL DEFAULT '', + -- The time scheduled to delete this mailbox. + -- NOTE: it requires cron job + script to actually delete the mailbox. + delete_date DATE DEFAULT NULL, + + KEY id (id), + INDEX (timestamp), + INDEX (username), + INDEX (domain), + INDEX (admin), + INDEX (delete_date) +) ENGINE=InnoDB; + +-- +-- 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(255) CHARACTER SET ascii NOT NULL, + to_user VARCHAR(255) CHARACTER SET ascii NOT NULL, + dummy CHAR(1), + PRIMARY KEY (from_user, to_user), + INDEX (from_user), + INDEX (to_user) +); + +CREATE TABLE IF NOT EXISTS anyone_shares ( + from_user VARCHAR(255) NOT NULL, + dummy CHAR(1) DEFAULT '1', + PRIMARY KEY (from_user) +); + +-- 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 ; + +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; diff --git a/iredmail/samples/iredmail/iredmail.pgsql b/iredmail/samples/iredmail/iredmail.pgsql new file mode 100644 index 0000000..77444d8 --- /dev/null +++ b/iredmail/samples/iredmail/iredmail.pgsql @@ -0,0 +1,467 @@ +-- --------------------------------------------------------------------- +-- 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 . +-- --------------------------------------------------------------------- + +-- Connect as vmailadmin +-- \c PH_VMAIL_DB_NAME PH_VMAIL_DB_ADMIN_USER; + +-- Required by PostgreSQL 8.x (RHEL/CentOS 6) +-- CREATE LANGUAGE plpgsql; + +-- Used to store domain admin accounts +CREATE TABLE admin ( + username VARCHAR(255) NOT NULL DEFAULT '', + password VARCHAR(255) NOT NULL DEFAULT '', + name VARCHAR(255) NOT NULL DEFAULT '', + language VARCHAR(5) NOT NULL DEFAULT '', + passwordlastchange TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + -- Store per-admin settings. Used in iRedAdmin-Pro. + settings TEXT NOT NULL DEFAULT '', + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (username) +); +CREATE INDEX idx_admin_passwordlastchange ON admin (passwordlastchange); +CREATE INDEX idx_admin_expired ON admin (expired); +CREATE INDEX idx_admin_active ON admin (active); + +-- Used to store mail alias accounts +CREATE TABLE alias ( + address VARCHAR(255) NOT NULL DEFAULT '', + name VARCHAR(255) NOT NULL DEFAULT '', + accesspolicy VARCHAR(30) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (address) +); +CREATE INDEX idx_alias_domain ON alias (domain); +CREATE INDEX idx_alias_expired ON alias (expired); +CREATE INDEX idx_alias_active ON alias (active); + +-- Alias and mailing list moderators. +CREATE TABLE moderators ( + id SERIAL PRIMARY KEY, + address VARCHAR(255) NOT NULL DEFAULT '', + moderator VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + dest_domain VARCHAR(255) NOT NULL DEFAULT '' +); + +CREATE INDEX idx_moderators_address ON moderators (address); +CREATE INDEX idx_moderators_moderator ON moderators (moderator); +CREATE UNIQUE INDEX idx_moderators_address_moderator ON moderators (address, moderator); +CREATE INDEX idx_moderators_domain ON moderators (domain); +CREATE INDEX idx_moderators_dest_domain ON moderators (dest_domain); + +-- Forwardings. it contains +-- - members of mail alias account +-- - per-account alias addresses +-- - per-user mail forwarding addresses +CREATE TABLE forwardings ( + id SERIAL PRIMARY KEY, + address VARCHAR(255) NOT NULL DEFAULT '', + forwarding VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + dest_domain VARCHAR(255) NOT NULL DEFAULT '', + -- defines whether it's a (mlmmj) mailing list account. 0=no, 1=yes. + is_maillist INT2 NOT NULL DEFAULT 0, + -- defines whether it's a standalone mail alias account. 0=no, 1=yes. + is_list INT2 NOT NULL DEFAULT 0, + -- defines whether it's a mail forwarding address of mail user. 0=no, 1=yes. + is_forwarding INT2 NOT NULL DEFAULT 0, + -- defines whether it's a per-account alias address. 0=no, 1=yes. + is_alias INT2 NOT NULL DEFAULT 0, + active INT2 NOT NULL DEFAULT 1 +); +CREATE INDEX idx_forwardings_address ON forwardings (address); +CREATE INDEX idx_forwardings_forwarding ON forwardings (forwarding); +CREATE UNIQUE INDEX idx_forwardings_address_forwarding ON forwardings (address, forwarding); +CREATE INDEX idx_forwardings_domain ON forwardings (domain); +CREATE INDEX idx_forwardings_dest_domain ON forwardings (dest_domain); +CREATE INDEX idx_forwardings_is_maillist ON forwardings (is_maillist); +CREATE INDEX idx_forwardings_is_list ON forwardings (is_list); +CREATE INDEX idx_forwardings_is_forwarding ON forwardings (is_forwarding); +CREATE INDEX idx_forwardings_is_alias ON forwardings (is_alias); + +-- Used to store virtual mail domains +CREATE TABLE domain ( + -- mail domain name. e.g. iredmail.org. + domain VARCHAR(255) NOT NULL DEFAULT '', + description TEXT NOT NULL DEFAULT '', + -- Disclaimer text. Used by Amavisd + AlterMIME. + disclaimer TEXT NOT NULL DEFAULT '', + -- Max alias accounts in this domain. e.g. 10. + aliases INT8 NOT NULL DEFAULT 0, + -- Max mail accounts in this domain. e.g. 100. + mailboxes INT8 NOT NULL DEFAULT 0, + -- Max mailing lists in this domain. e.g. 100. + maillists INT8 NOT NULL DEFAULT 0, + -- Max mailbox quota in this domain. e.g. 1073741824 (1GB). + maxquota INT8 NOT NULL DEFAULT 0, + -- Not used. Historical. + quota INT8 NOT NULL DEFAULT 0, + -- Per-domain transport. e.g. dovecot, smtp:[192.168.1.1]:25 + transport VARCHAR(255) NOT NULL DEFAULT 'dovecot', + -- Store per-domain settings. Used in iRedAdmin-Pro. + settings TEXT NOT NULL DEFAULT '', + backupmx INT2 NOT NULL DEFAULT 0, + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (domain) +); +CREATE INDEX idx_domain_backupmx ON domain (backupmx); +CREATE INDEX idx_domain_expired ON domain (expired); +CREATE INDEX idx_domain_active ON domain (active); + +-- Used to store alias domains +CREATE TABLE alias_domain ( + alias_domain VARCHAR(255) NOT NULL, + target_domain VARCHAR(255) NOT NULL, + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (alias_domain) +); +CREATE INDEX idx_alias_domain_target_domain ON alias_domain (target_domain); +CREATE INDEX idx_alias_domain_active ON alias_domain (active); + +-- Used to store domain <=> admin relationship +CREATE TABLE domain_admins ( + username VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (username,domain) +); +CREATE INDEX idx_domain_admins_username ON domain_admins (username); +CREATE INDEX idx_domain_admins_domain ON domain_admins (domain); +CREATE INDEX idx_domain_admins_active ON domain_admins (active); + +-- Used to store virtual mail accounts +CREATE TABLE mailbox ( + username VARCHAR(255) NOT NULL, + password VARCHAR(255) NOT NULL DEFAULT '', + name VARCHAR(255) NOT NULL DEFAULT '', + language VARCHAR(5) NOT NULL DEFAULT '', + -- Mailbox format. + -- All formats supported by Dovecot are ok. e.g. maildir, mdbox. + -- FYI: https://wiki2.dovecot.org/MailboxFormat + mailboxformat VARCHAR(50) NOT NULL DEFAULT 'maildir', + -- mailbox folder name can be any folder name supported by Linux/BSD file + -- system. + mailboxfolder VARCHAR(50) NOT NULL DEFAULT 'Maildir', + storagebasedirectory VARCHAR(255) NOT NULL DEFAULT '', + storagenode VARCHAR(255) NOT NULL DEFAULT '', + maildir VARCHAR(255) NOT NULL DEFAULT '', + quota INT8 NOT NULL DEFAULT 0, -- Total mail quota size + domain VARCHAR(255) NOT NULL DEFAULT '', + transport VARCHAR(255) NOT NULL DEFAULT '', + department VARCHAR(255) NOT NULL DEFAULT '', + rank VARCHAR(255) NOT NULL DEFAULT 'normal', + employeeid VARCHAR(255) DEFAULT '', + isadmin INT2 NOT NULL DEFAULT 0, + isglobaladmin INT2 NOT NULL DEFAULT 0, + enablesmtp INT2 NOT NULL DEFAULT 1, + enablesmtpsecured INT2 NOT NULL DEFAULT 1, + enablepop3 INT2 NOT NULL DEFAULT 1, + enablepop3secured INT2 NOT NULL DEFAULT 1, + enablepop3tls INT2 NOT NULL DEFAULT 1, + enableimap INT2 NOT NULL DEFAULT 1, + enableimapsecured INT2 NOT NULL DEFAULT 1, + enableimaptls INT2 NOT NULL DEFAULT 1, + enabledeliver INT2 NOT NULL DEFAULT 1, + enablelda INT2 NOT NULL DEFAULT 1, + enablemanagesieve INT2 NOT NULL DEFAULT 1, + enablemanagesievesecured INT2 NOT NULL DEFAULT 1, + enablesieve INT2 NOT NULL DEFAULT 1, + enablesievesecured INT2 NOT NULL DEFAULT 1, + enablesievetls INT2 NOT NULL DEFAULT 1, + enableinternal INT2 NOT NULL DEFAULT 1, + enabledoveadm INT2 NOT NULL DEFAULT 1, + "enablelib-storage" INT2 NOT NULL DEFAULT 1, + "enablequota-status" INT2 NOT NULL DEFAULT 1, + "enableindexer-worker" INT2 NOT NULL DEFAULT 1, + enablelmtp INT2 NOT NULL DEFAULT 1, + enabledsync INT2 NOT NULL DEFAULT 1, + enablesogo INT2 NOT NULL DEFAULT 1, + -- Must be set to NULL if it's not restricted. + allow_nets TEXT DEFAULT NULL, + lastlogindate TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + lastloginipv4 INET NOT NULL DEFAULT '0.0.0.0', + lastloginprotocol CHAR(255) NOT NULL DEFAULT '', + disclaimer TEXT NOT NULL DEFAULT '', + -- Below 4 columns are deprecated and will be removed in future release. + -- Don't use them. + allowedsenders TEXT NOT NULL DEFAULT '', + rejectedsenders TEXT NOT NULL DEFAULT '', + allowedrecipients TEXT NOT NULL DEFAULT '', + rejectedrecipients TEXT NOT NULL DEFAULT '', + -- Store per-user settings. Used in iRedAdmin-Pro. + settings TEXT NOT NULL DEFAULT '', + passwordlastchange TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (username) +); +CREATE INDEX idx_mailbox_domain ON mailbox (domain); +CREATE INDEX idx_mailbox_department ON mailbox (department); +CREATE INDEX idx_mailbox_employeeid ON mailbox (employeeid); +CREATE INDEX idx_mailbox_isadmin ON mailbox (isadmin); +CREATE INDEX idx_mailbox_isglobaladmin ON mailbox (isglobaladmin); +CREATE INDEX idx_mailbox_enablesmtp ON mailbox (enablesmtp); +CREATE INDEX idx_mailbox_enablesmtpsecured ON mailbox (enablesmtpsecured); +CREATE INDEX idx_mailbox_enablepop3 ON mailbox (enablepop3); +CREATE INDEX idx_mailbox_enablepop3secured ON mailbox (enablepop3secured); +CREATE INDEX idx_mailbox_enableimap ON mailbox (enableimap); +CREATE INDEX idx_mailbox_enableimapsecured ON mailbox (enableimapsecured); +CREATE INDEX idx_mailbox_enableimaptls ON mailbox (enableimaptls); +CREATE INDEX idx_mailbox_enablepop3tls ON mailbox (enablepop3tls); +CREATE INDEX idx_mailbox_enablesievetls ON mailbox (enablesievetls); +CREATE INDEX idx_mailbox_enabledeliver ON mailbox (enabledeliver); +CREATE INDEX idx_mailbox_enablelda ON mailbox (enablelda); +CREATE INDEX idx_mailbox_enablemanagesieve ON mailbox (enablemanagesieve); +CREATE INDEX idx_mailbox_enablemanagesievesecured ON mailbox (enablemanagesievesecured); +CREATE INDEX idx_mailbox_enablesieve ON mailbox (enablesieve); +CREATE INDEX idx_mailbox_enablesievesecured ON mailbox (enablesievesecured); +CREATE INDEX idx_mailbox_enablelmtp ON mailbox (enablelmtp); +CREATE INDEX idx_mailbox_enabledsync ON mailbox (enabledsync); +CREATE INDEX idx_mailbox_enableinternal ON mailbox (enableinternal); +CREATE INDEX idx_mailbox_enabledoveadm ON mailbox (enabledoveadm); +CREATE INDEX idx_mailbox_enablelib_storage ON mailbox ("enablelib-storage"); +CREATE INDEX idx_mailbox_enablequota_status ON mailbox ("enablequota-status"); +CREATE INDEX idx_mailbox_enableindexer_worker ON mailbox ("enableindexer-worker"); +CREATE INDEX idx_mailbox_enablesogo ON mailbox (enablesogo); +CREATE INDEX idx_mailbox_passwordlastchange ON mailbox (passwordlastchange); +CREATE INDEX idx_mailbox_expired ON mailbox (expired); +CREATE INDEX idx_mailbox_active ON mailbox (active); + + +CREATE TABLE maillists ( + id SERIAL PRIMARY KEY, + address VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + -- Per mailing list transport. for example: 'mlmmj:example.com/listname'. + transport VARCHAR(255) NOT NULL DEFAULT '', + accesspolicy VARCHAR(30) NOT NULL DEFAULT '', + maxmsgsize INT8 NOT NULL DEFAULT 0, + -- name of the mailing list + name VARCHAR(255) NOT NULL DEFAULT '', + -- short introduction of the mailing list on subscription page + description TEXT, + -- a server-wide unique id (a 36-characters string) for each mailing list + mlid VARCHAR(36) NOT NULL DEFAULT '', + -- control whether newsletter-style subscription from website is enabled + -- 1 -> enabled, 0 -> disabled + is_newsletter INT2 NOT NULL DEFAULT 0, + settings TEXT, + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1 +); +CREATE UNIQUE INDEX idx_maillists_address ON maillists (address); +CREATE INDEX idx_maillists_domain ON maillists (domain); +CREATE UNIQUE INDEX idx_maillists_mlid ON maillists (mlid); +CREATE INDEX idx_maillists_is_newsletter ON maillists (is_newsletter); +CREATE INDEX idx_maillists_active ON maillists (active); + +CREATE TABLE sender_bcc_domain ( + domain VARCHAR(255) NOT NULL DEFAULT '', + bcc_address VARCHAR(255) NOT NULL DEFAULT '', + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (domain) +); +CREATE INDEX idx_sender_bcc_domain_bcc_address ON sender_bcc_domain (bcc_address); +CREATE INDEX idx_sender_bcc_domain_expired ON sender_bcc_domain (expired); +CREATE INDEX idx_sender_bcc_domain_active ON sender_bcc_domain (active); + +CREATE TABLE sender_bcc_user ( + username VARCHAR(255) NOT NULL DEFAULT '', + bcc_address VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (username) +); +CREATE INDEX idx_sender_bcc_user_bcc_address ON sender_bcc_user (bcc_address); +CREATE INDEX idx_sender_bcc_user_domain ON sender_bcc_user (domain); +CREATE INDEX idx_sender_bcc_user_expired ON sender_bcc_user (expired); +CREATE INDEX idx_sender_bcc_user_active ON sender_bcc_user (active); + +-- +-- Table structure for table recipient_bcc_domain +-- +CREATE TABLE recipient_bcc_domain ( + domain VARCHAR(255) NOT NULL DEFAULT '', + bcc_address VARCHAR(255) NOT NULL DEFAULT '', + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (domain) +); +CREATE INDEX idx_recipient_bcc_domain_bcc_address ON recipient_bcc_domain (bcc_address); +CREATE INDEX idx_recipient_bcc_domain_expired ON recipient_bcc_domain (expired); +CREATE INDEX idx_recipient_bcc_domain_active ON recipient_bcc_domain (active); + +-- +-- Table structure for table recipient_bcc_user +-- +CREATE TABLE recipient_bcc_user ( + username VARCHAR(255) NOT NULL DEFAULT '', + bcc_address VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()::TIMESTAMP WITHOUT TIME ZONE, + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 01:01:01', + active INT2 NOT NULL DEFAULT 1, + PRIMARY KEY (username) +); +CREATE INDEX idx_recipient_bcc_user_bcc_address ON recipient_bcc_user (bcc_address); +CREATE INDEX idx_recipient_bcc_user_expired ON recipient_bcc_user (expired); +CREATE INDEX idx_recipient_bcc_user_active ON recipient_bcc_user (active); + +-- Sender dependent relayhost. +-- - per-user: account='user@domain.com' +-- - per-domain: account='@domain.com' +-- References: +-- - http://www.postfix.org/postconf.5.html#sender_dependent_relayhost_maps +-- - http://www.postfix.org/transport.5.html +CREATE TABLE sender_relayhost ( + id SERIAL PRIMARY KEY, + account VARCHAR(255) NOT NULL DEFAULT '', + relayhost VARCHAR(255) NOT NULL DEFAULT '' +); +CREATE UNIQUE INDEX idx_sender_relayhost_account ON sender_relayhost (account); + +-- Used to store basic info of deleted mailboxes. +CREATE TABLE deleted_mailboxes ( + id SERIAL PRIMARY KEY, + timestamp TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, + + -- Email address of deleted user + username VARCHAR(255) NOT NULL DEFAULT '', + + -- Domain part of username + domain VARCHAR(255) NOT NULL DEFAULT '', + + -- Absolute path of user's mailbox + maildir VARCHAR(255) NOT NULL DEFAULT '', + + -- Deleted by which domain admin + admin VARCHAR(255) NOT NULL DEFAULT '', + + -- The time scheduled to delete this mailbox. + -- NOTE: it requires cron job + script to actually delete the mailbox. + delete_date DATE DEFAULT NULL +); + +CREATE INDEX idx_deleted_mailboxes_timestamp ON deleted_mailboxes (timestamp); +CREATE INDEX idx_deleted_mailboxes_username ON deleted_mailboxes (username); +CREATE INDEX idx_deleted_mailboxes_domain ON deleted_mailboxes (domain); +CREATE INDEX idx_deleted_mailboxes_admin ON deleted_mailboxes (admin); +CREATE INDEX idx_delete_date ON deleted_mailboxes (delete_date); + +-- +-- IMAP shared folders. User 'from_user' shares folders to user 'to_user'. +-- WARNING: Works only with Dovecot 1.2+. +-- +CREATE TABLE share_folder ( + from_user VARCHAR(255) NOT NULL, + to_user VARCHAR(255) NOT NULL, + dummy CHAR(1), + PRIMARY KEY (from_user, to_user) +); +CREATE INDEX idx_share_folder_from_user ON share_folder (from_user); +CREATE INDEX idx_share_folder_to_user ON share_folder (to_user); + +CREATE TABLE anyone_shares ( + from_user VARCHAR(255) NOT NULL, + dummy CHAR(1), + PRIMARY KEY (from_user) +); + +-- 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 used_quota ( + username VARCHAR(255) NOT NULL, + bytes INT8 NOT NULL DEFAULT 0, + messages INT8 NOT NULL DEFAULT 0, + domain VARCHAR(255) NOT NULL DEFAULT '', + PRIMARY KEY (username) +); +CREATE INDEX idx_used_quota_domain ON used_quota (domain); + +-- Trigger required by quota dict +CREATE OR REPLACE FUNCTION merge_quota() RETURNS TRIGGER AS $$ +BEGIN + IF NEW.messages < 0 OR NEW.messages IS NULL THEN + -- ugly kludge: we came here from this function, really do try to insert + IF NEW.messages IS NULL THEN + NEW.messages = 0; + ELSE + NEW.messages = -NEW.messages; + END IF; + return NEW; + END IF; + + LOOP + UPDATE used_quota + SET bytes = bytes + NEW.bytes, messages = messages + NEW.messages, domain=split_part(NEW.username, '@', 2) + WHERE username = NEW.username; + IF found THEN + RETURN NULL; + END IF; + + BEGIN + IF NEW.messages = 0 THEN + INSERT INTO used_quota (bytes, messages, username, domain) + VALUES (NEW.bytes, NULL, NEW.username, split_part(NEW.username, '@', 2)); + ELSE + INSERT INTO used_quota (bytes, messages, username, domain) + VALUES (NEW.bytes, -NEW.messages, NEW.username, split_part(NEW.username, '@', 2)); + END IF; + return NULL; + EXCEPTION WHEN unique_violation THEN + -- someone just inserted the record, update it + END; + END LOOP; +END; +$$ LANGUAGE plpgsql; + +CREATE TRIGGER mergequota + BEFORE INSERT ON used_quota FOR EACH ROW + EXECUTE PROCEDURE merge_quota(); diff --git a/iredmail/samples/iredmail/iredmail.schema b/iredmail/samples/iredmail/iredmail.schema new file mode 100644 index 0000000..570b1be --- /dev/null +++ b/iredmail/samples/iredmail/iredmail.schema @@ -0,0 +1,452 @@ +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# +# This schema is shipped within iRedMail project: +# http://www.iredmail.org/ +# +# It should be localed at: +# - RHEL/CentOS: /etc/openldap/schema/iredmail.schema +# - Debian: /etc/ldap/schema/iredmail.schema +# - FreeBSD: /usr/local/etc/openldap/schema/ +# +#-------------------------------------------------------------------- +# The offical iRedMail OID assigned by IANA is 32349, you can find it in url: +# http://www.iana.org/assignments/enterprise-numbers +# +# 1.3.6.1.4.1.32349 OID of iRedMail.org +# 1.3.6.1.4.1.32349.1 iRedMail +# 1.3.6.1.4.1.32349.1.2 iRedMail LDAP Elements +# 1.3.6.1.4.1.32349.1.2.1 AttributeTypes +# 1.3.6.1.4.1.32349.1.2.2 ObjectClasses +#-------------------------------------------------------------------- +# +# This schema depends on: +# - core.schema +# - cosine.schema +# + +# +# Mail Service: Domain related attributes. +# +attributetype ( 1.3.6.1.4.1.32349.1.2.1.1 NAME 'domainName' + DESC 'Virtual Domain Name' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.2 NAME 'mtaTransport' + DESC 'Transport program for Postfix' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +# When updating 'accountStatus=' for mail domain, must update 'domainStatus' +# for all mail user/alias/list accounts. +attributetype ( 1.3.6.1.4.1.32349.1.2.1.3 NAME 'domainStatus' + DESC 'Domain status, used by mail user/alias/list, not by mail domain itself.' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.4 NAME 'domainAdmin' + DESC 'Domain admin' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.5 NAME 'domainGlobalAdmin' + DESC 'Site wide domin admin: yes' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.6 NAME 'domainBackupMX' + DESC 'Backup MX: yes, no' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.7 NAME 'domainSenderBccAddress' + DESC 'Sender BCC address for whole domain' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.8 NAME 'domainRecipientBccAddress' + DESC 'Recipient BCC address for whole domain' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.9 NAME 'domainMaxQuotaSize' + DESC 'Obsoleted. Max quota size limit for single domain' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.10 NAME 'domainCurrentQuotaSize' + DESC 'Current quota size limit for single domain' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.11 NAME 'domainMaxUserNumber' + DESC 'Obsoleted. Max user number limit for single domain' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.12 NAME 'domainCurrentUserNumber' + DESC 'Current user number limit for single domain' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.13 NAME 'domainMaxAliasNumber' + DESC 'Obsoleted. Max alias number limit for single domain' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.14 NAME 'domainCurrentAliasNumber' + DESC 'Current alias number limit for single domain' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.15 NAME 'domainMaxListNumber' + DESC 'Obsoleted. Max mail list number limit for single domain' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.16 NAME 'domainCurrentListNumber' + DESC 'Current mail list number limit for single domain' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.17 NAME 'disclaimer' + DESC 'Disclaimer text' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.18 NAME 'domainDefaultUserQuota' + DESC 'Default quota for new user' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.19 NAME 'domainAliasName' + DESC 'Domain Alias Name' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.20 NAME 'domainWhitelistIP' + DESC 'Whitelist IP address' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.21 NAME 'domainWhitelistSender' + DESC 'Whitelist sender address' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.22 NAME 'domainBlacklistIP' + DESC 'Blacklist IP address' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.23 NAME 'domainBlacklistSender' + DESC 'Blacklist sender address' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +attributetype ( 1.3.6.1.4.1.32349.1.2.1.24 NAME 'domainPendingAliasName' + DESC 'Pending alias domain name' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} ) + +# +# Mail Service: User related attributes. +# +attributetype ( 1.3.6.1.4.1.32349.1.2.2.1 NAME 'mailUID' + DESC 'UID of the user on the mailsystem' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.2 NAME 'mailGID' + DESC 'GID of the user on the mailsystem' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.3 NAME 'storageBaseDirectory' + DESC 'Path to mail storage base directory. Deprecated since iRedMail-0.9.8.' + EQUALITY caseExactIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.4 NAME 'mailMessageStore' + DESC 'Path to the maildir/mbox on the mail system. Deprecated since iRedMail-0.9.8.' + EQUALITY caseExactIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.5 NAME 'mailQuota' + DESC 'The amount of space the user can use until all further messages get bounced' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.6 NAME 'mailQuotaMessageLimit' + DESC 'Quota limit in number of messages, 0 means unlimited' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.7 NAME 'mailHost' + DESC 'On which mail server the messagestore of this user is located' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.8 NAME 'mailForwardingAddress' + DESC 'Address(es) to forward all incoming messages to.' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreIA5SubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.9 NAME 'accountStatus' + DESC 'The status of a user account: active, disabled' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.10 NAME 'userRecipientBccAddress' + DESC 'Recipient BCC address for single user: must be a valid email address' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.11 NAME 'userSenderBccAddress' + DESC 'Sender BCC address for single user: must be a valid email address' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.12 NAME 'backupMailAddress' + DESC 'Backup mail address, used to reset password or whatever' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.13 NAME 'enabledService' + DESC 'Enabled service: mail, smtp, imap, pop3, deliver, forward, senderbcc, recipientbcc, displayedInGlobalAddressBook' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.14 NAME 'memberOfGroup' + DESC 'Group/List name which user belong to, MUST be a valid email address' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.15 NAME 'lastLoginDate' + DESC 'Last login date.' + EQUALITY generalizedTimeMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.16 NAME 'lastLoginIP' + DESC 'Last login ip address.' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.17 NAME 'lastLoginProtocol' + DESC 'Mail protocol used in last login: pop3, imap' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.18 NAME 'expiredDate' + DESC 'Account expired date in YYYYMMDDHHMMSSZ format. Sample: 20180323142122Z' + EQUALITY generalizedTimeMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.19 NAME 'shadowAddress' + DESC 'Shadow address for mail user' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.20 NAME 'accountSetting' + DESC 'Account setting. Default format: var:value' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.21 NAME 'userManager' + DESC 'Mail address of manager' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.22 NAME 'mailWhitelistRecipient' + DESC 'Whitelist recipient' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.23 NAME 'mailBlacklistRecipient' + DESC 'Blacklist recipient' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +attributetype ( 1.3.6.1.4.1.32349.1.2.2.24 NAME 'disabledService' + DESC 'Disabled service names' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +# This is a comma separated list of IPs and/or networks where the user is +# allowed to log in from. If the user tries to log in elsewhere, the +# authentication will fail the same way as if a wrong password was given. +# Used in Dovecot LDAP query 'pass_attrs ='. +attributetype ( 1.3.6.1.4.1.32349.1.2.2.25 NAME 'allowNets' + DESC 'Allow user to log in from only specified IPs.' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.32349.1.2.2.26 NAME 'senderRelayHost' + DESC 'Sender dependent relayhost' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.32349.1.2.2.27 NAME 'maxMessageSize' + DESC 'Max message size (in bytes)' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) + +# Mailbox format. +# All formats supported by Dovecot are ok. e.g. maildir, mdbox. +# FYI: https://wiki2.dovecot.org/MailboxFormat +# Dovecot config file (/etc/dovecot/dovecot-ldap.conf) sets default value +# to 'maildir' if this attribute doesn't present. +attributetype ( 1.3.6.1.4.1.32349.1.2.2.28 NAME 'mailboxFormat' + DESC 'Mailbox format. All formats supported by Dovecot are ok. e.g. maildir, mdbox.' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{50} + SINGLE-VALUE ) + +# Mailbox folder name can be any folder name supported by Linux/BSD file system. +attributetype ( 1.3.6.1.4.1.32349.1.2.2.29 NAME 'mailboxFolder' + DESC 'Folder name appended to maildir path. e.g. Maildir, Mailbox.' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{50} + SINGLE-VALUE ) + +# +# Mail Service: Mail List related attributes. +# +attributetype ( 1.3.6.1.4.1.32349.1.2.3.1 NAME 'accessPolicy' + DESC 'Mail list access policy: open, domain, subdomain, moedratorsonly, memberOnly' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.3.2 NAME 'hasMember' + DESC 'Group has members: yes, no' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.32349.1.2.3.3 NAME 'listAllowedUser' + DESC 'Addresses which are ALWAYS allowed to send email to mailing list' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} ) +attributetype ( 1.3.6.1.4.1.32349.1.2.3.4 NAME 'listModerator' + DESC 'Moderator of mailing list' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{320} ) +attributetype ( 1.3.6.1.4.1.32349.1.2.3.5 NAME 'mailingListID' + DESC 'A server-wide unique id for each (mlmmj) mailing list' + EQUALITY caseIgnoreIA5Match + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{36} ) + +# +# Object Class Definitions +# +objectclass ( 1.3.6.1.4.1.32349.1.2.4.1 NAME 'mailDomain' + DESC 'Mail Domain' SUP top STRUCTURAL + MUST ( domainName ) + MAY ( cn $ mtaTransport $ domainAdmin $ + enabledService $ disabledService $ + domainBackupMX $ accountStatus $ mailHost $ + domainSenderBccAddress $ domainRecipientBccAddress $ + domainMaxQuotaSize $ domainCurrentQuotaSize $ + domainMaxUserNumber $ domainCurrentUserNumber $ + domainMaxAliasNumber $ domainCurrentAliasNumber $ + domainMaxListNumber $ domainCurrentListNumber $ + domainDefaultUserQuota $ domainAliasName $ domainPendingAliasName $ + disclaimer $ description $ street $ telephoneNumber $ + facsimileTelephoneNumber $ expiredDate $ accountSetting $ + domainWhitelistIP $ domainWhitelistSender $ + domainBlacklistIP $ domainBlacklistSender $ + preferredLanguage $ senderRelayHost ) ) +objectclass ( 1.3.6.1.4.1.32349.1.2.4.2 NAME 'mailAdmin' + DESC 'Mail Domain Admin' SUP top STRUCTURAL + MUST ( mail ) + MAY ( domainGlobalAdmin $ description $ + enabledService $ disabledService $ + userPassword $ accountStatus $ cn $ sn $ + preferredLanguage $ givenName $ expiredDate $ + mailHost $ lastLoginDate $ accountSetting $ shadowLastChange ) ) +objectclass ( 1.3.6.1.4.1.32349.1.2.4.3 NAME 'mailUser' + DESC 'Mail User' SUP top AUXILIARY + MUST ( mail $ uid ) + MAY ( storageBaseDirectory $ mailMessageStore $ homeDirectory $ + userPassword $ mailHost $ mailUID $ mailGID $ + mailQuota $ mailQuotaMessageLimit $ + mailForwardingAddress $ shadowAddress $ accountStatus $ + userRecipientBccAddress $ userSenderBccAddress $ + enabledService $ disabledService $ + telephoneNumber $ backupMailAddress $ + mtaTransport $ memberOfGroup $ expiredDate $ + lastLoginDate $ lastLoginIP $ lastLoginProtocol $ + preferredLanguage $ disclaimer $ accountSetting $ + title $ userManager $ + mailWhitelistRecipient $ mailBlacklistRecipient $ + domainGlobalAdmin $ allowNets $ senderRelayHost $ + domainStatus $ maxMessageSize $ mailboxFormat $ mailboxFolder ) ) +objectclass ( 1.3.6.1.4.1.32349.1.2.4.4 NAME 'mailAlias' + DESC 'Mail Alias Account' SUP top STRUCTURAL + MUST ( mail ) + MAY ( accountStatus $ description $ cn $ memberOfGroup $ + enabledService $ disabledService $ + mailForwardingAddress $ shadowAddress $ expiredDate $ + accountSetting $ mailHost $ domainStatus ) ) + +# Notes: +# - 'mtaTransport' and 'mailingListID' are used by mlmmj mailing list account +objectclass ( 1.3.6.1.4.1.32349.1.2.4.5 NAME 'mailList' + DESC 'Mailing List Account' SUP top STRUCTURAL + MUST ( mail ) + MAY ( cn $ accountStatus $ description $ accessPolicy $ shadowAddress $ + enabledService $ disabledService $ memberOfGroup $ hasMember $ + listAllowedUser $ expiredDate $ accountSetting $ mailHost $ + member $ uniqueMember $ memberUid $ gidNumber $ domainStatus $ + mtaTransport $ mailinglistID $ maxMessageSize ) ) +objectclass ( 1.3.6.1.4.1.32349.1.2.4.6 NAME 'mailExternalUser' + DESC 'Mail External User' SUP top STRUCTURAL + MUST ( memberOfGroup ) + MAY ( cn $ accountStatus $ mail $ enabledService $ disabledService $ + description $ mailHost $ accountSetting $ shadowAddress $ + domainStatus ) ) diff --git a/iredmail/samples/logrotate/dovecot b/iredmail/samples/logrotate/dovecot new file mode 100644 index 0000000..d1a07c8 --- /dev/null +++ b/iredmail/samples/logrotate/dovecot @@ -0,0 +1,13 @@ +PH_DOVECOT_LOG_DIR/*.log { + weekly + rotate 10 + missingok + compress + delaycompress + notifempty + sharedscripts + + postrotate + PH_SYSLOG_POSTROTATE_CMD + endscript +} diff --git a/iredmail/samples/logrotate/iredapd b/iredmail/samples/logrotate/iredapd new file mode 100644 index 0000000..aecaeca --- /dev/null +++ b/iredmail/samples/logrotate/iredapd @@ -0,0 +1,13 @@ +PH_IREDAPD_LOG_DIR/*.log { + weekly + rotate 10 + missingok + compress + delaycompress + notifempty + sharedscripts + + postrotate + PH_SYSLOG_POSTROTATE_CMD + endscript +} diff --git a/iredmail/samples/logrotate/mlmmjadmin b/iredmail/samples/logrotate/mlmmjadmin new file mode 100644 index 0000000..8524fb7 --- /dev/null +++ b/iredmail/samples/logrotate/mlmmjadmin @@ -0,0 +1,13 @@ +PH_MLMMJADMIN_LOG_DIR/*.log { + weekly + rotate 10 + missingok + compress + delaycompress + notifempty + sharedscripts + + postrotate + PH_SYSLOG_POSTROTATE_CMD + endscript +} diff --git a/iredmail/samples/logrotate/openldap b/iredmail/samples/logrotate/openldap new file mode 100644 index 0000000..bfd3a79 --- /dev/null +++ b/iredmail/samples/logrotate/openldap @@ -0,0 +1,19 @@ +PH_OPENLDAP_LOG_FILE { + compress + weekly + rotate 10 + create 0600 PH_SYS_USER_LDAP PH_SYS_GROUP_LDAP + missingok + notifempty + sharedscripts + + # Use bzip2 for compress. + #compresscmd bzip2 + #uncompresscmd bunzip2 + #compressoptions -9 + #compressext .bz2 + + postrotate + PH_SYSLOG_POSTROTATE_CMD + endscript +} diff --git a/iredmail/samples/logrotate/php-fpm b/iredmail/samples/logrotate/php-fpm new file mode 100644 index 0000000..14e2bc5 --- /dev/null +++ b/iredmail/samples/logrotate/php-fpm @@ -0,0 +1,13 @@ +PH_PHP_FPM_LOG_DIR/*.log { + weekly + rotate 10 + missingok + compress + delaycompress + notifempty + sharedscripts + + postrotate + /bin/kill -SIGUSR1 `cat PH_PHP_FPM_PID_FILE 2>/dev/null` 2>/dev/null || true + endscript +} diff --git a/iredmail/samples/mlmmj/mlmmj-amime-receive b/iredmail/samples/mlmmj/mlmmj-amime-receive new file mode 100755 index 0000000..4487a34 --- /dev/null +++ b/iredmail/samples/mlmmj/mlmmj-amime-receive @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +# File name: mlmmj-amime-receive +# Purpose: Read mail messages from stdin, pipe it to altermime to add footer +# in MIME-aware way, then pipe modified message to mlmmj-receive for +# final delivery. +# +# Requirements: +# - altermime: http://www.pldaniels.com/altermime/ +# +# Authors: +# - Original wrote by Gerd v. Egidy , MIT License. +# - Updated by Zhang Huangbin . + +export PATH="/usr/bin:/usr/local/bin:/bin:/sbin:/usr/sbin:/usr/local/sbin:$PATH" + +# All `mlmmj-*` programs must be ran with absolute path to the program. +if [[ -x /usr/local/bin/mlmmj-receive ]]; then + export CMD_MLMMJ_RECEIVE='/usr/local/bin/mlmmj-receive' +else + export CMD_MLMMJ_RECEIVE='/usr/bin/mlmmj-receive' +fi + +if [[ -x /usr/local/bin/altermime ]]; then + export CMD_ALTERMIME='/usr/local/bin/altermime' +else + export CMD_ALTERMIME='/usr/bin/altermime' +fi + +# File names used to store footer in different MIME types: +# plain text, html, base64 encoded. +# WARNING: both `footer_text` and `footer_html` must exist. +export FILE_FOOTER_TEXT='footer_text' +export FILE_FOOTER_HTML='footer_html' + +# Make sure command `mlmmj-receive` exist and executable +if [ ! -x ${CMD_MLMMJ_RECEIVE} ]; then + echo "Command ${CMD_MLMMJ_RECEIVE} doesn't exist or not executable, mail delivery aborted" + exit 1 +fi + +# Get mailing list directory passed to '-L' argument +ML_DIR='' +_has_L='NO' +for i in $@; do + if [ X"${_has_L}" == X'NO' ]; then + if [ X"$i" == X'-L' ]; then + _has_L='YES' + fi + else + ML_DIR="$i" + break + fi +done + +if [ X"${ML_DIR}" == X'' ]; then + echo "No mailing list directory specified (-L /path/to/listdir), mail delivery aborted" + exit 1 +fi + +if [ ! -d "${ML_DIR}" ]; then + echo "Mailing list directory (${ML_DIR}) does not exist or not a directory, mail delivery aborted" + exit 1 +fi + +# Mailing list sub-directory: control +ML_SUBDIR_CONTROL="${ML_DIR}/control" + +if [ ! -d "${ML_SUBDIR_CONTROL}" ]; then + echo "Mailing list control directory (${ML_SUBDIR_CONTROL}) does not exist or not a directory, mail delivery aborted" + exit 1 +fi + +# Path to footer files +PATH_FOOTER_TEXT="${ML_SUBDIR_CONTROL}/${FILE_FOOTER_TEXT}" +PATH_FOOTER_HTML="${ML_SUBDIR_CONTROL}/${FILE_FOOTER_HTML}" + +# go to a dir where altermime can write it's tmp-files safely +cd ${ML_DIR} + +if [[ -x ${CMD_ALTERMIME} ]] && [[ -f ${PATH_FOOTER_TEXT} ]] && [[ -f ${PATH_FOOTER_HTML} ]]; then + # pipe to altermime for MIME modification, then pipe to mlmmj-receive for final delivery. + ${CMD_ALTERMIME} --input=- \ + --altersigned \ + --log-syslog \ + --disclaimer=${PATH_FOOTER_TEXT} \ + --disclaimer-html=${PATH_FOOTER_HTML} \ + --htmltoo \ + --force-for-bad-html | ${CMD_MLMMJ_RECEIVE} "$@" +else + echo "Mail delivered without modificaiton." + ${CMD_MLMMJ_RECEIVE} "$@" +fi diff --git a/iredmail/samples/mlmmj/mlmmjadmin.settings.py b/iredmail/samples/mlmmj/mlmmjadmin.settings.py new file mode 100644 index 0000000..454d25c --- /dev/null +++ b/iredmail/samples/mlmmj/mlmmjadmin.settings.py @@ -0,0 +1,49 @@ +############################################################ +# DO NOT TOUCH THIS LINE. +from libs.default_settings import * +############################################################ + +# Listen address and port +listen_address = 'PH_MLMMJADMIN_BIND_HOST' +listen_port = PH_MLMMJADMIN_LISTEN_PORT + +# Run as a non-privileged user/group. +run_as_user = 'PH_SYS_USER_MLMMJ' +run_as_group = 'PH_SYS_GROUP_MLMMJ' + +# Pid file +pid_file = 'PH_MLMMJADMIN_PID_FILE' + +# Log level: info, debug. +log_level = 'info' + +# Specify the backend used to query/update meta data stored in SQL/LDAP. +# +# - `backend_api` is used when accessing RESTful API. +# - `backend_cli` is used when you're managing mailing list account with +# command line tool like `tools/maillist_admin.py`. +# +# Different backends may require different parameters in settings.py, please +# read the comment lines in `backends/bk_*.py`. +# +# Available backends: +# +# - bk_iredmail_ldap: for iRedMail with OpenLDAP backend +# - bk_iredmail_sql: for iRedMail with SQL backends (MySQL, MariaDB, PostgreSQL) +# - bk_none: pure mlmmj, no SQL/LDAP database. +# +# WARNING: For iRedMail users, if you don't have iRedAdmin-Pro, please enable +# proper backend below so that mlmmjadmin will store mailing list accounts in +# SQL/LDAP database. +backend_api = 'bk_none' +backend_cli = 'bk_none' + +# A list of API AUTH tokens (secret strings) used for authentication. +# It's strong recommended to use a long string as auth token, program will log +# first 8 characters to help you identity the client. +api_auth_tokens = ['PH_MLMMJADMIN_API_AUTH_TOKEN'] + +MLMMJ_SPOOL_DIR = 'PH_MLMMJ_SPOOL_DIR' +MLMMJ_ARCHIVE_DIR = 'PH_MLMMJ_ARCHIVE_DIR' +MLMMJ_SKEL_DIR = 'PH_MLMMJ_SKEL_DIR' +MLMMJ_DEFAULT_PROFILE_SETTINGS.update({'smtp_port': PH_AMAVISD_MLMMJ_PORT}) diff --git a/iredmail/samples/mysql/my.cnf b/iredmail/samples/mysql/my.cnf new file mode 100644 index 0000000..ec8d7a1 --- /dev/null +++ b/iredmail/samples/mysql/my.cnf @@ -0,0 +1,95 @@ +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# +# Sample MySQL configuration file. It should be located at: +# +# - RHEL/CentOS: /etc/my.cnf +# - FreeBSD (www/mysql56-server): /var/db/mysql/my.cnf +# +# Shipped within iRedMail project: +# http://www.iredmail.org/ +# + +[client] +default-character-set = utf8mb4 + +[mysqld] +#bind-address = 127.0.0.1 +port = 3306 +character-set-server = utf8mb4 +collation-server = utf8mb4_unicode_ci +#datadir = /var/lib/mysql +#socket = /var/lib/mysql/mysql.sock +#user = mysql + +#general_log = 1 +#general_log_file = /var/log/mysql.log + +#slow_query_log +#slow_query_log_file = /var/log/mysql_slow.log + +skip-external-locking +#skip-bdb +#skip-networking + +# Disable query cache +query-cache-type = 0 +query-cache-size = 0 + +thread_cache_size = 8 +open_files_limit = 65535 +max_connections = 1024 +#max_connect_errors = 150 + +# When a MySQL client or the mysqld server receives a packet bigger than +# max_allowed_packet bytes, it issues an ER_NET_PACKET_TOO_LARGE error and +# closes the connection. With some clients, you may also get a Lost connection +# to MySQL server during query error if the communication packet is too large. +max_allowed_packet = 64M + +# If you got error message like "The total number of locks exceeds the lock table size", +# please try to increase 'innodb_buffer_pool_size' to a reasonable value. +# Restarting MySQL server is required to make new value work. +# You can get current value with SQL command: +# +# mysql> SHOW ENGINE INNODB STATUS \G +# [...] +# Buffer pool size 512 +# [...] +# +#innodb_buffer_pool_size=512M + +# Creates each new table using its own .ibd file for storing data and indexes, +# rather than in the system tablespace (ibdata*). +# Reference: +# http://dev.mysql.com/doc/refman/5.5/en/innodb-parameters.html#sysvar_innodb_file_per_table +innodb_file_per_table + +#ssl-ca = +#ssl-cert = +#ssl-key = +#ssl-cipher = ALL + +#[mysql.server] +#user = mysql +#basedir = /var/lib + +#[mysqld_safe] +#log-error = /var/log/mysqld.log +#pid-file = /var/run/mysqld/mysqld.pid diff --git a/iredmail/samples/mysql/sql/add_first_domain_and_user.sql b/iredmail/samples/mysql/sql/add_first_domain_and_user.sql new file mode 100644 index 0000000..47b39c9 --- /dev/null +++ b/iredmail/samples/mysql/sql/add_first_domain_and_user.sql @@ -0,0 +1,32 @@ +USE PH_VMAIL_DB_NAME; + +-- Add your first domain +INSERT INTO domain (domain, transport, settings, created) + VALUES ('PH_FIRST_DOMAIN', 'PH_TRANSPORT', 'default_user_quota:1024;', NOW()); + +-- Add your first normal user +INSERT INTO mailbox (username, + password, + name, + maildir, + quota, + domain, + isadmin, + isglobaladmin, + created) + VALUES ('PH_DOMAIN_ADMIN_EMAIL', + 'PH_DOMAIN_ADMIN_PASSWD_HASH', + 'PH_DOMAIN_ADMIN_NAME', + 'PH_DOMAIN_ADMIN_MAILDIR_HASH_PART', + 1024, + 'PH_FIRST_DOMAIN', + 1, + 1, + NOW()); + +INSERT INTO forwardings (address, forwarding, domain, dest_domain, is_forwarding) + VALUES ('PH_DOMAIN_ADMIN_EMAIL', 'PH_DOMAIN_ADMIN_EMAIL', 'PH_FIRST_DOMAIN', 'PH_FIRST_DOMAIN', 1); + +-- Mark first mail user as global admin +INSERT INTO domain_admins (username, domain, created) + VALUES ('PH_DOMAIN_ADMIN_EMAIL', 'ALL', NOW()); diff --git a/iredmail/samples/mysql/sql/delete_anonymous_user.sql b/iredmail/samples/mysql/sql/delete_anonymous_user.sql new file mode 100644 index 0000000..d768cf0 --- /dev/null +++ b/iredmail/samples/mysql/sql/delete_anonymous_user.sql @@ -0,0 +1,7 @@ +-- Delete anonymouse user. +USE mysql; + +DELETE FROM user WHERE User=''; +DELETE FROM db WHERE User=''; + +FLUSH PRIVILEGES; diff --git a/iredmail/samples/mysql/sql/init_vmail_db.sql b/iredmail/samples/mysql/sql/init_vmail_db.sql new file mode 100644 index 0000000..21ff334 --- /dev/null +++ b/iredmail/samples/mysql/sql/init_vmail_db.sql @@ -0,0 +1,10 @@ +-- Create database for virtual hosts +CREATE DATABASE IF NOT EXISTS PH_VMAIL_DB_NAME CHARACTER SET utf8; + +-- Permissions +GRANT SELECT ON PH_VMAIL_DB_NAME.* TO 'PH_VMAIL_DB_BIND_USER'@'PH_MYSQL_GRANT_HOST' IDENTIFIED BY 'PH_VMAIL_DB_BIND_PASSWD'; +-- GRANT SELECT ON PH_VMAIL_DB_NAME.* TO 'PH_VMAIL_DB_BIND_USER'@'PH_HOSTNAME' IDENTIFIED BY 'PH_VMAIL_DB_BIND_PASSWD'; +GRANT SELECT,INSERT,DELETE,UPDATE ON PH_VMAIL_DB_NAME.* TO 'PH_VMAIL_DB_ADMIN_USER'@'PH_MYSQL_GRANT_HOST' IDENTIFIED BY 'PH_VMAIL_DB_ADMIN_PASSWD'; +-- GRANT SELECT,INSERT,DELETE,UPDATE ON PH_VMAIL_DB_NAME.* TO 'PH_VMAIL_DB_ADMIN_USER'@'PH_HOSTNAME' IDENTIFIED BY 'PH_VMAIL_DB_ADMIN_PASSWD'; + +FLUSH PRIVILEGES; diff --git a/iredmail/samples/mysql/sql/remote_grant_permission.sql b/iredmail/samples/mysql/sql/remote_grant_permission.sql new file mode 100644 index 0000000..589386f --- /dev/null +++ b/iredmail/samples/mysql/sql/remote_grant_permission.sql @@ -0,0 +1,9 @@ +-- Grant access privilege to ${MYSQL_ROOT_USER}@${MYSQL_GRANT_HOST} ...' + +USE mysql; + +-- Allow access from MYSQL_GRANT_HOST with password +GRANT ALL PRIVILEGES ON *.* TO 'PH_MYSQL_ROOT_USER'@'PH_MYSQL_GRANT_HOST' WITH GRANT OPTION; +-- GRANT ALL PRIVILEGES ON *.* TO 'PH_MYSQL_ROOT_USER'@'PH_HOSTNAME' WITH GRANT OPTION; + +FLUSH PRIVILEGES; diff --git a/iredmail/samples/netdata/go.d.conf b/iredmail/samples/netdata/go.d.conf new file mode 100644 index 0000000..3d555de --- /dev/null +++ b/iredmail/samples/netdata/go.d.conf @@ -0,0 +1,24 @@ +# netdata go.d.plugin configuration +# +# This file is in YaML format. + +# Enable/disable the whole go.d.plugin. +enabled: yes + +# Enable/disable default value for all modules. +default_run: yes + +# Maximum number of used CPUs. Zero means no limit. +max_procs: 0 + +# Enable/disable specific g.d.plugin module +modules: + apache: no + lighttpd: no + lighttpd2: no + energid: no + + web_log: yes + nginx: yes + phpfpm: yes + mysql: yes diff --git a/iredmail/samples/netdata/go.d/mysql.conf b/iredmail/samples/netdata/go.d/mysql.conf new file mode 100644 index 0000000..212ba5c --- /dev/null +++ b/iredmail/samples/netdata/go.d/mysql.conf @@ -0,0 +1,3 @@ +jobs: + - name: local + dsn: PH_NETDATA_DB_USER:PH_NETDATA_DB_PASSWD@tcp(PH_MYSQL_SERVER_ADDRESS:PH_MYSQL_SERVER_PORT)/ diff --git a/iredmail/samples/netdata/go.d/nginx.conf b/iredmail/samples/netdata/go.d/nginx.conf new file mode 100644 index 0000000..b0071bc --- /dev/null +++ b/iredmail/samples/netdata/go.d/nginx.conf @@ -0,0 +1,4 @@ +jobs: + - name: local + url: https://127.0.0.1/stub_status + tls_skip_verify: yes diff --git a/iredmail/samples/netdata/go.d/phpfpm.conf b/iredmail/samples/netdata/go.d/phpfpm.conf new file mode 100644 index 0000000..8f0c39d --- /dev/null +++ b/iredmail/samples/netdata/go.d/phpfpm.conf @@ -0,0 +1,4 @@ +jobs: + - name: local + url: https://127.0.0.1/status?full&json + tls_skip_verify: yes diff --git a/iredmail/samples/netdata/health_alarm_notify.conf b/iredmail/samples/netdata/health_alarm_notify.conf new file mode 100644 index 0000000..0b5f8bd --- /dev/null +++ b/iredmail/samples/netdata/health_alarm_notify.conf @@ -0,0 +1 @@ +SEND_EMAIL="NO" diff --git a/iredmail/samples/netdata/netdata.conf b/iredmail/samples/netdata/netdata.conf new file mode 100644 index 0000000..44b126c --- /dev/null +++ b/iredmail/samples/netdata/netdata.conf @@ -0,0 +1,63 @@ +# Get config from http://127.0.0.1:/netdata.conf +[registry] + # Disable public central registry and become registry locally + enabled = yes + + # Register to internal server instead + registry to announce = http://127.0.0.1:PH_NETDATA_PORT + +[global] + # The number of entries the netdata daemon will by default keep in memory + # for each chart dimension. This setting can also be configured per chart. + history = 172800 + + # memory mode + # - `save` is the default mode, data are maintained in memory and saved to + # disk when netdata exits. + # - `ram` data are exclusively on memory and never saved on disk. + # - `map` like swap, files are mapped to memory on demand. + # + # WARNING: We suggest not to use this mode on nodes that run other + # applications. + # + # - `none` no local database (used when data are streamed to a remote netdata). + # - `dbengine`: data are in database files. + # The Database Engine works like a traditional database. + memory mode = dbengine + + # + # dbengine. + # + # determines the amount of RAM in MiB that is dedicated to caching netdata + # metric values themselves. + page cache size = 32 + + # determines the amount of disk space in MiB that is dedicated to storing + # netdata metric values and all related metadata describing them. + dbengine disk space = 256 + + # Bind to 127.0.0.1 by default. + bind to = 127.0.0.1 + # Bind to all available network interfaces, but allow access from specified + # IP addresses or networks. + #bind to = * + #allow connections from = + + run as user = PH_SYS_USER_NETDATA + default port = PH_NETDATA_PORT + + # The frequency in seconds, for data collection. + update every = 3 + + # Log files + # Nginx logs access log, netdata no need to log it again. + access log = none + #error log = syslog + #debug log = syslog + +[plugin:proc] + # Disable IPVS check since iRedMail doesn't use ipvs by default + /proc/net/ip_vs/stats = no + + # inbound packets dropped + /proc/net/dev = no diff --git a/iredmail/samples/netdata/python.d.conf b/iredmail/samples/netdata/python.d.conf new file mode 100644 index 0000000..779cb6e --- /dev/null +++ b/iredmail/samples/netdata/python.d.conf @@ -0,0 +1,49 @@ +# netdata python.d.plugin configuration +# +# This file is in YaML format. +# Generally the format is: +# +# name: value +# + +# Enable / disable the whole python.d.plugin (all its modules) +enabled: yes + +# ---------------------------------------------------------------------- +# Enable / Disable python.d.plugin modules +#default_run: yes +# +# If "default_run" = "yes" the default for all modules is enabled (yes). +# Setting any of these to "no" will disable it. +# +# If "default_run" = "no" the default for all modules is disabled (no). +# Setting any of these to "yes" will enable it. + +# Enable / Disable explicit garbage collection (full collection run). Default is enabled. +gc_run: yes + +# Garbage collection interval in seconds. Default is 300. +gc_interval: 300 + +apache: no +# apache_cache has been replaced by web_log +apache_cache: no +chrony: no +energid: no +# this is just an example +example: no +go_expvar: no +# gunicorn_log has been replaced by web_log +gunicorn_log: no +logind: no +# nginx_log has been replaced by web_log +nginx_log: no +nginx_plus: no +exim: no + +# Use go.d for better performance since netdata-1.19.0. +web_log: no +nginx: no +phpfpm: no +mysql: no +bind: no diff --git a/iredmail/samples/netdata/python.d/openldap.conf b/iredmail/samples/netdata/python.d/openldap.conf new file mode 100644 index 0000000..9746e43 --- /dev/null +++ b/iredmail/samples/netdata/python.d/openldap.conf @@ -0,0 +1,8 @@ +update_every: 5 + +local: + username : "PH_LDAP_BINDDN" # The bind user with right to access monitor statistics + password : "PH_LDAP_BINDPW" # The password for the binded user + server : "localhost" # The listening address of the LDAP server + port : 389 # The listening port of the LDAP server + timeout : 1 diff --git a/iredmail/samples/netdata/python.d/postgres.conf b/iredmail/samples/netdata/python.d/postgres.conf new file mode 100644 index 0000000..ce5c0c2 --- /dev/null +++ b/iredmail/samples/netdata/python.d/postgres.conf @@ -0,0 +1,5 @@ +socket: + name : 'local' + user : 'PH_NETDATA_DB_USER' + password : 'PH_NETDATA_DB_PASSWD' + database : 'postgres' diff --git a/iredmail/samples/netdata/systemd-limits.conf b/iredmail/samples/netdata/systemd-limits.conf new file mode 100644 index 0000000..4f82fd3 --- /dev/null +++ b/iredmail/samples/netdata/systemd-limits.conf @@ -0,0 +1,2 @@ +[Service] +LimitNOFILE=30000 diff --git a/iredmail/samples/nginx/conf-available/0-general.conf b/iredmail/samples/nginx/conf-available/0-general.conf new file mode 100644 index 0000000..3fe949f --- /dev/null +++ b/iredmail/samples/nginx/conf-available/0-general.conf @@ -0,0 +1 @@ +map_hash_bucket_size 1024; diff --git a/iredmail/samples/nginx/conf-available/cache.conf b/iredmail/samples/nginx/conf-available/cache.conf new file mode 100644 index 0000000..4dd6942 --- /dev/null +++ b/iredmail/samples/nginx/conf-available/cache.conf @@ -0,0 +1,8 @@ +map $sent_http_content_type $expires { + default off; + application/x-javascript 1d; + text/css 1d; + ~image/ 1d; +} + +expires $expires; diff --git a/iredmail/samples/nginx/conf-available/client_max_body_size.conf b/iredmail/samples/nginx/conf-available/client_max_body_size.conf new file mode 100644 index 0000000..356bcf9 --- /dev/null +++ b/iredmail/samples/nginx/conf-available/client_max_body_size.conf @@ -0,0 +1 @@ +client_max_body_size 12m; diff --git a/iredmail/samples/nginx/conf-available/default_type.conf b/iredmail/samples/nginx/conf-available/default_type.conf new file mode 100644 index 0000000..29447da --- /dev/null +++ b/iredmail/samples/nginx/conf-available/default_type.conf @@ -0,0 +1 @@ +default_type application/octet-stream; diff --git a/iredmail/samples/nginx/conf-available/gzip.conf b/iredmail/samples/nginx/conf-available/gzip.conf new file mode 100644 index 0000000..ddb882a --- /dev/null +++ b/iredmail/samples/nginx/conf-available/gzip.conf @@ -0,0 +1,10 @@ +gzip on; +gzip_vary on; +gzip_http_version 1.0; +gzip_comp_level 2; +gzip_min_length 10240; + +gzip_proxied expired no-cache no-store private auth; +gzip_types text/plain text/css text/xml text/javascript text/json application/json application/x-javascript application/xml application/xml+rss; + +gzip_disable "MSIE [1-6]\."; diff --git a/iredmail/samples/nginx/conf-available/headers.conf b/iredmail/samples/nginx/conf-available/headers.conf new file mode 100644 index 0000000..27cb373 --- /dev/null +++ b/iredmail/samples/nginx/conf-available/headers.conf @@ -0,0 +1,7 @@ +add_header X-Frame-Options sameorigin; +add_header X-Content-Type-Options nosniff; +add_header X-XSS-Protection '1; mode=block'; +add_header X-Download-Options noopen; +add_header X-Permitted-Cross-Domain-Policies none; +add_header Content-Security-Policy "default-src https: data: 'unsafe-inline' 'unsafe-eval'"; +add_header Referrer-Policy strict-origin; diff --git a/iredmail/samples/nginx/conf-available/log.conf b/iredmail/samples/nginx/conf-available/log.conf new file mode 100644 index 0000000..76ce981 --- /dev/null +++ b/iredmail/samples/nginx/conf-available/log.conf @@ -0,0 +1,2 @@ +access_log PH_NGINX_LOG_ACCESSLOG; +error_log PH_NGINX_LOG_ERRORLOG; diff --git a/iredmail/samples/nginx/conf-available/mime_types.conf b/iredmail/samples/nginx/conf-available/mime_types.conf new file mode 100644 index 0000000..eadfdec --- /dev/null +++ b/iredmail/samples/nginx/conf-available/mime_types.conf @@ -0,0 +1 @@ +include PH_NGINX_MIME_TYPES; diff --git a/iredmail/samples/nginx/conf-available/php_fpm.conf b/iredmail/samples/nginx/conf-available/php_fpm.conf new file mode 100644 index 0000000..f17d9e0 --- /dev/null +++ b/iredmail/samples/nginx/conf-available/php_fpm.conf @@ -0,0 +1,3 @@ +upstream php_workers { + server PH_PHP_FPM_BIND_HOST:PH_PHP_FPM_PORT; +} diff --git a/iredmail/samples/nginx/conf-available/sendfile.conf b/iredmail/samples/nginx/conf-available/sendfile.conf new file mode 100644 index 0000000..af4702d --- /dev/null +++ b/iredmail/samples/nginx/conf-available/sendfile.conf @@ -0,0 +1 @@ +sendfile on; diff --git a/iredmail/samples/nginx/conf-available/server_tokens.conf b/iredmail/samples/nginx/conf-available/server_tokens.conf new file mode 100644 index 0000000..e0caf96 --- /dev/null +++ b/iredmail/samples/nginx/conf-available/server_tokens.conf @@ -0,0 +1,2 @@ +# Hide Nginx version number +server_tokens off; diff --git a/iredmail/samples/nginx/conf-available/types_hash_max_size.conf b/iredmail/samples/nginx/conf-available/types_hash_max_size.conf new file mode 100644 index 0000000..694e14d --- /dev/null +++ b/iredmail/samples/nginx/conf-available/types_hash_max_size.conf @@ -0,0 +1 @@ +types_hash_max_size 2048; diff --git a/iredmail/samples/nginx/nginx.conf b/iredmail/samples/nginx/nginx.conf new file mode 100644 index 0000000..4e7d111 --- /dev/null +++ b/iredmail/samples/nginx/nginx.conf @@ -0,0 +1,12 @@ +user PH_HTTPD_USER; +worker_processes 1; +pid PH_NGINX_PID; + +events { + worker_connections 1024; +} + +http { + include PH_HTTPD_CONF_DIR_ENABLED_CONF/*.conf; + include PH_HTTPD_CONF_DIR_ENABLED_SITES/*.conf; +} diff --git a/iredmail/samples/nginx/sites-available/00-default-ssl.conf b/iredmail/samples/nginx/sites-available/00-default-ssl.conf new file mode 100644 index 0000000..30eb92b --- /dev/null +++ b/iredmail/samples/nginx/sites-available/00-default-ssl.conf @@ -0,0 +1,21 @@ +# +# Note: This file must be loaded before other virtual host config files, +# +# HTTPS +server { + listen PH_HTTPS_PORT ssl; + #listen [::]:PH_HTTPS_PORT ssl; + server_name _; + + root PH_HTTPD_DOCUMENTROOT; + index index.php index.html; + + include PH_NGINX_CONF_TMPL_DIR/misc.tmpl; + include PH_NGINX_CONF_TMPL_DIR/ssl.tmpl; + include PH_NGINX_CONF_TMPL_DIR/iredadmin.tmpl; + include PH_NGINX_CONF_TMPL_DIR/roundcube.tmpl; + include PH_NGINX_CONF_TMPL_DIR/sogo.tmpl; + include PH_NGINX_CONF_TMPL_DIR/netdata.tmpl; + include PH_NGINX_CONF_TMPL_DIR/php-catchall.tmpl; + include PH_NGINX_CONF_TMPL_DIR/stub_status.tmpl; +} diff --git a/iredmail/samples/nginx/sites-available/00-default.conf b/iredmail/samples/nginx/sites-available/00-default.conf new file mode 100644 index 0000000..e929ebd --- /dev/null +++ b/iredmail/samples/nginx/sites-available/00-default.conf @@ -0,0 +1,14 @@ +# +# Note: This file must be loaded before other virtual host config files, +# +# HTTP +server { + # Listen on ipv4 + listen PH_PORT_HTTP; + #listen [::]:PH_PORT_HTTP; + + server_name _; + + # Redirect all insecure http:// requests to https:// + return 301 https://$host$request_uri; +} diff --git a/iredmail/samples/nginx/templates/adminer.tmpl b/iredmail/samples/nginx/templates/adminer.tmpl new file mode 100644 index 0000000..e4d5331 --- /dev/null +++ b/iredmail/samples/nginx/templates/adminer.tmpl @@ -0,0 +1,46 @@ +# Sample setting for Adminer: http://adminer.org/ + +# ----------------------------------------- +# How to get it working: +# +# mkdir PH_HTTPD_SERVERROOT/adminer +# cd PH_HTTPD_SERVERROOT/adminer +# wget http://www.adminer.org/latest.php +# chmod +x latest.php +# +# Warning: for security concern, it's recommended to change the URL '/adminer' +# to another random string to avoid login attempts from bad guys. +# for example, change the url to '^/HIoWCwogSHukIbGL'. +# +# ----------------------------------------- +# If you cannot login to MySQL server as root user: +# +# New MySQL or MariaDB support plugin authentication, by default, the root +# account has setting `user.plugin=unix_socket` (in `mysql` database). The +# `auth_socket` authentication plugin authenticates clients that connect from +# the local host through the Unix socket file, this prevents access via network +# connection, including Adminer. To make it working, please disable this +# authentication plugin with sql commands below: +# +# sql> USE mysql; +# sql> UPDATE user SET plugin='' WHERE User='root'; +# +# Refer to MySQL document for more details: +# https://dev.mysql.com/doc/refman/5.7/en/socket-authentication-plugin.html + +location ~ ^/adminer$ { + include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl; + include PH_NGINX_CONF_TMPL_DIR/fastcgi_php.tmpl; + + fastcgi_param SCRIPT_FILENAME PH_HTTPD_SERVERROOT/adminer/latest.php; + + # Access control + #allow 127.0.0.1; + #allow 192.168.1.10; + #allow 192.168.1.0/24; + #deny all; +} + +location ~ ^/adminer.css$ { + alias PH_HTTPD_SERVERROOT/adminer/adminer.css; +} diff --git a/iredmail/samples/nginx/templates/fastcgi_php.tmpl b/iredmail/samples/nginx/templates/fastcgi_php.tmpl new file mode 100644 index 0000000..d5033c5 --- /dev/null +++ b/iredmail/samples/nginx/templates/fastcgi_php.tmpl @@ -0,0 +1,17 @@ +# +# Template used to handle PHP fastcgi applications +# +# You still need to define `SCRIPT_FILENAME` for your PHP application, and +# probably `fastcgi_index` if your application use different index file. +# +include fastcgi_params; + +# Directory index file +fastcgi_index index.php; + +# Handle PHP files with upstream handler +fastcgi_pass php_workers; + +# Fix the HTTPROXY issue. +# Reference: https://httpoxy.org/ +fastcgi_param HTTP_PROXY ''; diff --git a/iredmail/samples/nginx/templates/hsts.tmpl b/iredmail/samples/nginx/templates/hsts.tmpl new file mode 100644 index 0000000..1274071 --- /dev/null +++ b/iredmail/samples/nginx/templates/hsts.tmpl @@ -0,0 +1,17 @@ +# Use HTTP Strict Transport Security to force client to use secure +# connections only. References: +# +# * RFC Document (6797): HTTP Strict Transport Security (HSTS) +# https://tools.ietf.org/html/rfc6797#section-6.1.2 +# +# * Short tutorial from Mozilla: +# https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security +# +# WARNING: According to RFC document, HSTS will fail with self-signed SSL +# certificate. +# https://tools.ietf.org/html/rfc6797#page-27 +# +# Syntax: +# +# Strict-Transport-Security: max-age=expireTime [; includeSubDomains] [; preload] +add_header Strict-Transport-Security "max-age=31536000"; diff --git a/iredmail/samples/nginx/templates/iredadmin-subdomain.tmpl b/iredmail/samples/nginx/templates/iredadmin-subdomain.tmpl new file mode 100644 index 0000000..2bf093f --- /dev/null +++ b/iredmail/samples/nginx/templates/iredadmin-subdomain.tmpl @@ -0,0 +1,16 @@ +# +# Run iRedAdmin as a sub-domain virtual host. +# +include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl; + +location / { + root PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK; + uwsgi_pass PH_IREDADMIN_BIND_ADDRESS:PH_IREDADMIN_LISTEN_PORT; + uwsgi_param UWSGI_CHDIR PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK; + uwsgi_param UWSGI_SCRIPT iredadmin; + include uwsgi_params; +} + +location /static { + alias PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK/static; +} diff --git a/iredmail/samples/nginx/templates/iredadmin.tmpl b/iredmail/samples/nginx/templates/iredadmin.tmpl new file mode 100644 index 0000000..29ce8e3 --- /dev/null +++ b/iredmail/samples/nginx/templates/iredadmin.tmpl @@ -0,0 +1,35 @@ +# Settings for iRedAdmin. + +# static files under /iredadmin/static +location ~ ^/iredadmin/static/(.*) { + alias PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK/static/$1; +} + +# Python scripts +location ~ ^/iredadmin(.*) { + rewrite ^/iredadmin(/.*)$ $1 break; + + include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl; + + include uwsgi_params; + uwsgi_pass PH_IREDADMIN_BIND_ADDRESS:PH_IREDADMIN_LISTEN_PORT; + uwsgi_param UWSGI_CHDIR PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK; + uwsgi_param UWSGI_SCRIPT iredadmin; + uwsgi_param SCRIPT_NAME /iredadmin; + + # Access control + #allow 127.0.0.1; + #allow 192.168.1.10; + #allow 192.168.1.0/24; + #deny all; +} + +# iRedAdmin: redirect /iredadmin to /iredadmin/ +location = /iredadmin { + rewrite ^ /iredadmin/; +} + +# Handle newsletter-style subscription/unsubscription supported in iRedAdmin-Pro. +location ~ ^/newsletter/ { + rewrite /newsletter/(.*) /iredadmin/newsletter/$1 last; +} diff --git a/iredmail/samples/nginx/templates/misc.tmpl b/iredmail/samples/nginx/templates/misc.tmpl new file mode 100644 index 0000000..e356af4 --- /dev/null +++ b/iredmail/samples/nginx/templates/misc.tmpl @@ -0,0 +1,15 @@ +# Allow access to '^/.well-known/' +location ~ ^/.well-known/ { + allow all; + access_log off; + log_not_found off; + autoindex off; + #root /var/www/html; +} + +# Deny all attempts to access hidden files such as .htaccess. +location ~ /\. { deny all; } + +# Handling noisy messages +location = /favicon.ico { access_log off; log_not_found off; } +location = /robots.txt { access_log off; log_not_found off; } diff --git a/iredmail/samples/nginx/templates/netdata-subdomain.tmpl b/iredmail/samples/nginx/templates/netdata-subdomain.tmpl new file mode 100644 index 0000000..11e1c7e --- /dev/null +++ b/iredmail/samples/nginx/templates/netdata-subdomain.tmpl @@ -0,0 +1,22 @@ +# +# Run netdata as a sub-domain virtual host. +# +# FYI: https://github.com/firehol/netdata/wiki/Running-behind-nginx + +location / { + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Server $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:PH_NETDATA_PORT; + proxy_http_version 1.1; + proxy_pass_request_headers on; + proxy_set_header Connection "keep-alive"; + proxy_store off; + + gzip on; + gzip_proxied any; + gzip_types *; + + auth_basic "Authentication Required"; + auth_basic_user_file PH_NETDATA_HTTPD_AUTH_FILE; +} diff --git a/iredmail/samples/nginx/templates/netdata.tmpl b/iredmail/samples/nginx/templates/netdata.tmpl new file mode 100644 index 0000000..0e387e3 --- /dev/null +++ b/iredmail/samples/nginx/templates/netdata.tmpl @@ -0,0 +1,27 @@ +# Running netdata as a subfolder to an existing virtual host +# FYI: https://github.com/firehol/netdata/wiki/Running-behind-nginx + +location = /netdata { + return 301 /netdata/; +} + +location ~ /netdata/(?.*) { + proxy_redirect off; + proxy_set_header Host $host; + + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Server $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_http_version 1.1; + proxy_pass_request_headers on; + proxy_set_header Connection "keep-alive"; + proxy_store off; + proxy_pass http://127.0.0.1:PH_NETDATA_PORT/$ndpath$is_args$args; + + gzip on; + gzip_proxied any; + gzip_types *; + + auth_basic "Authentication Required"; + auth_basic_user_file PH_NETDATA_HTTPD_AUTH_FILE; +} diff --git a/iredmail/samples/nginx/templates/php-catchall.tmpl b/iredmail/samples/nginx/templates/php-catchall.tmpl new file mode 100644 index 0000000..4449587 --- /dev/null +++ b/iredmail/samples/nginx/templates/php-catchall.tmpl @@ -0,0 +1,6 @@ +# Normal PHP scripts +location ~ \.php$ { + include PH_NGINX_CONF_TMPL_DIR/fastcgi_php.tmpl; + + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +} diff --git a/iredmail/samples/nginx/templates/redirect_to_https.tmpl b/iredmail/samples/nginx/templates/redirect_to_https.tmpl new file mode 100644 index 0000000..8017123 --- /dev/null +++ b/iredmail/samples/nginx/templates/redirect_to_https.tmpl @@ -0,0 +1,5 @@ +# Redirect webmail/SOGo/iredadmin to HTTPS +location ~ ^/mail { rewrite ^ https://$host$request_uri?; } +location ~ ^/mail/index.php$ { rewrite ^ https://$host/mail/; } +location ~* ^/sogo { rewrite ^ https://$host/SOGo; } +location ~ ^/iredadmin { rewrite ^ https://$host$request_uri?; } diff --git a/iredmail/samples/nginx/templates/roundcube-subdomain.tmpl b/iredmail/samples/nginx/templates/roundcube-subdomain.tmpl new file mode 100644 index 0000000..908f53d --- /dev/null +++ b/iredmail/samples/nginx/templates/roundcube-subdomain.tmpl @@ -0,0 +1,26 @@ +# +# Run Roundcube as a sub-domain virtual host. +# +# Block access to default directories and files under these directories +location ~ ^/(bin|config|installer|logs|SQL|temp|vendor)/.* { deny all; } + +# Block access to default files under top-directory and files start with same name. +location ~ ^/(CHANGELOG|composer.json|INSTALL|jsdeps.json|LICENSE|README|UPGRADING)$ { deny all; } + +# Block plugin config files and sample config files. +location ~ ^/plugins/.*/config.inc.php.* { deny all; } + +# Block access to plugin data +location ~ ^/plugins/enigma/home($|/.*) { deny all; } + +location / { + root PH_RCM_HTTPD_ROOT_SYMBOL_LINK; + index index.php index.html; + include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl; +} + +location ~ \.php$ { + root PH_RCM_HTTPD_ROOT_SYMBOL_LINK; + include PH_NGINX_CONF_TMPL_DIR/fastcgi_php.tmpl; + fastcgi_param SCRIPT_FILENAME PH_RCM_HTTPD_ROOT_SYMBOL_LINK$fastcgi_script_name; +} diff --git a/iredmail/samples/nginx/templates/roundcube.tmpl b/iredmail/samples/nginx/templates/roundcube.tmpl new file mode 100644 index 0000000..df0dfa8 --- /dev/null +++ b/iredmail/samples/nginx/templates/roundcube.tmpl @@ -0,0 +1,30 @@ +# +# Running Roundcube as a subfolder on an existing virtual host +# +# Block access to default directories and files under these directories +location ~ ^/mail/(bin|config|installer|logs|SQL|temp|vendor)($|/.*) { deny all; } + +# Block access to default files under top-directory and files start with same name. +location ~ ^/mail/(CHANGELOG|composer.json|INSTALL|jsdeps.json|LICENSE|README|UPGRADING)($|.*) { deny all; } + +# Block plugin config files and sample config files. +location ~ ^/mail/plugins/.*/config.inc.php.* { deny all; } + +# Block access to plugin data +location ~ ^/mail/plugins/enigma/home($|/.*) { deny all; } + +# Redirect URI `/mail` to `/mail/`. +location = /mail { + return 301 /mail/; +} + +location ~ ^/mail/(.*\.php)$ { + include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl; + include PH_NGINX_CONF_TMPL_DIR/fastcgi_php.tmpl; + fastcgi_param SCRIPT_FILENAME PH_RCM_HTTPD_ROOT_SYMBOL_LINK/$1; +} + +location ~ ^/mail/(.*) { + alias PH_RCM_HTTPD_ROOT_SYMBOL_LINK/$1; + index index.php; +} diff --git a/iredmail/samples/nginx/templates/sogo-subdomain.tmpl b/iredmail/samples/nginx/templates/sogo-subdomain.tmpl new file mode 100644 index 0000000..83116bf --- /dev/null +++ b/iredmail/samples/nginx/templates/sogo-subdomain.tmpl @@ -0,0 +1,65 @@ +# +# Run SOGo as a sub-domain virtual host. +# + +root PH_SOGO_GNUSTEP_DIR/WebServerResources; + +location / { + rewrite ^ https://$host/SOGo; +} + +# For Mac OS X and iOS devices. +rewrite ^/.well-known/caldav /SOGo/dav permanent; +rewrite ^/.well-known/carddav /SOGo/dav permanent; +rewrite ^/principals /SOGo/dav permanent; + +include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl; + +location ^~ /SOGo { + proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT; + + # forward user's IP address + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + + # always use https + proxy_set_header x-webobjects-server-port $server_port; + proxy_set_header x-webobjects-server-name $host; + proxy_set_header x-webobjects-server-url https://$host; + + proxy_set_header x-webobjects-server-protocol HTTP/1.0; +} + +location ^~ /Microsoft-Server-ActiveSync { + proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT/SOGo/Microsoft-Server-ActiveSync; + + proxy_connect_timeout PH_SOGO_PROXY_TIMEOUT; + proxy_send_timeout PH_SOGO_PROXY_TIMEOUT; + proxy_read_timeout PH_SOGO_PROXY_TIMEOUT; +} + +location ^~ /SOGo/Microsoft-Server-ActiveSync { + proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT/SOGo/Microsoft-Server-ActiveSync; + + proxy_connect_timeout PH_SOGO_PROXY_TIMEOUT; + proxy_send_timeout PH_SOGO_PROXY_TIMEOUT; + proxy_read_timeout PH_SOGO_PROXY_TIMEOUT; +} + +location /SOGo.woa/WebServerResources/ { + alias PH_SOGO_GNUSTEP_DIR/WebServerResources/; + expires max; +} +location /SOGo/WebServerResources/ { + alias PH_SOGO_GNUSTEP_DIR/WebServerResources/; + expires max; +} +location ^/SOGo/so/ControlPanel/Products/([^/]*)/Resources/(.*)$ { + alias PH_SOGO_GNUSTEP_DIR/$1.SOGo/Resources/$2; + expires max; +} +location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$) { + alias PH_SOGO_GNUSTEP_DIR/$1.SOGo/Resources/$2; + expires max; +} diff --git a/iredmail/samples/nginx/templates/sogo.tmpl b/iredmail/samples/nginx/templates/sogo.tmpl new file mode 100644 index 0000000..13ea177 --- /dev/null +++ b/iredmail/samples/nginx/templates/sogo.tmpl @@ -0,0 +1,60 @@ +# Settings for SOGo Groupware + +# SOGo +location ~ ^/sogo { rewrite ^ https://$host/SOGo; } +location ~ ^/SOGO { rewrite ^ https://$host/SOGo; } + +# Redirect /mail to /SOGo +#location ~ ^/mail { rewrite ^ https://$host/SOGo; } + +# For Mac OS X and iOS devices. +rewrite ^/.well-known/caldav /SOGo/dav permanent; +rewrite ^/.well-known/carddav /SOGo/dav permanent; +rewrite ^/principals /SOGo/dav permanent; + +location ^~ /SOGo { + include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl; + + proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT; + + # forward user's IP address + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + + # always use https + proxy_set_header x-webobjects-server-port $server_port; + proxy_set_header x-webobjects-server-name $host; + proxy_set_header x-webobjects-server-url https://$host; + + proxy_set_header x-webobjects-server-protocol HTTP/1.0; +} + +location ^~ /Microsoft-Server-ActiveSync { + proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT/SOGo/Microsoft-Server-ActiveSync; + + proxy_connect_timeout PH_SOGO_PROXY_TIMEOUT; + proxy_send_timeout PH_SOGO_PROXY_TIMEOUT; + proxy_read_timeout PH_SOGO_PROXY_TIMEOUT; +} + +location ^~ /SOGo/Microsoft-Server-ActiveSync { + proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT/SOGo/Microsoft-Server-ActiveSync; + + proxy_connect_timeout PH_SOGO_PROXY_TIMEOUT; + proxy_send_timeout PH_SOGO_PROXY_TIMEOUT; + proxy_read_timeout PH_SOGO_PROXY_TIMEOUT; +} + +location /SOGo.woa/WebServerResources/ { + alias PH_SOGO_GNUSTEP_DIR/WebServerResources/; + expires max; +} +location /SOGo/WebServerResources/ { + alias PH_SOGO_GNUSTEP_DIR/WebServerResources/; + expires max; +} +location ^/SOGo/so/ControlPanel/Products/([^/]*)/Resources/(.*)$ { + alias PH_SOGO_GNUSTEP_DIR/$1.SOGo/Resources/$2; + expires max; +} diff --git a/iredmail/samples/nginx/templates/ssl.tmpl b/iredmail/samples/nginx/templates/ssl.tmpl new file mode 100644 index 0000000..a4b8157 --- /dev/null +++ b/iredmail/samples/nginx/templates/ssl.tmpl @@ -0,0 +1,21 @@ +ssl_protocols TLSv1.2; + +# Fix 'The Logjam Attack'. +ssl_ciphers PH_SSL_CIPHERS; +ssl_prefer_server_ciphers on; +ssl_dhparam PH_SSL_DH1024_PARAM_FILE; + +# To use your own ssl cert (e.g. "Let's Encrypt"), please create symbol link to +# ssl cert/key used below, so that we can manage this config file with Ansible. +# +# For example: +# +# rm -f PH_SSL_KEY_FILE +# rm -f PH_SSL_CERT_FILE +# ln -s /etc/letsencrypt/live//privkey.pem PH_SSL_KEY_FILE +# ln -s /etc/letsencrypt/live//fullchain.pem PH_SSL_CERT_FILE +# +# To request free "Let's Encrypt" cert, please check our tutorial: +# https://docs.iredmail.org/letsencrypt.html +ssl_certificate PH_SSL_CERT_FILE; +ssl_certificate_key PH_SSL_KEY_FILE; diff --git a/iredmail/samples/nginx/templates/stub_status.tmpl b/iredmail/samples/nginx/templates/stub_status.tmpl new file mode 100644 index 0000000..b23fc9a --- /dev/null +++ b/iredmail/samples/nginx/templates/stub_status.tmpl @@ -0,0 +1,15 @@ +location = /stub_status { + stub_status on; + access_log off; + allow 127.0.0.1; + deny all; +} + +location = /status { + include fastcgi_params; + fastcgi_pass php_workers; + fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; + access_log off; + allow 127.0.0.1; + deny all; +} diff --git a/iredmail/samples/openbsd/ldapd.conf b/iredmail/samples/openbsd/ldapd.conf new file mode 100644 index 0000000..579ee61 --- /dev/null +++ b/iredmail/samples/openbsd/ldapd.conf @@ -0,0 +1,58 @@ +schema "/etc/ldap/core.schema" +schema "/etc/ldap/inetorgperson.schema" +schema "/etc/ldap/nis.schema" +schema "/etc/ldap/amavisd.schema" +schema "/etc/ldap/iredmail.schema" + +listen on lo0 secure +#listen on 127.0.0.1 secure +listen on "/var/run/ldapi" + +namespace "PH_LDAP_SUFFIX" { + rootdn "PH_LDAP_ROOTDN" + rootpw "PH_LDAP_ROOTPW" + + index objectClass + index accountStatus + + index sn + index givenName + index cn + index mail + index uid + index shadowLastChange + index userSenderBccAddress + index userRecipientBccAddress + + index domainName + index domainAliasName + index domainPendingAliasName + index domainAdmin + index domainGlobalAdmin + index domainBackupMX + index domainSenderBccAddress + index domainRecipientBccAddress + index domainStatus + + index accessPolicy + index memberOfGroup + index member + index uniqueMember + index mailingListID + + # + # Access policies + # + # Deny by default. + deny read,write access to subtree root by any + + # Allow bind/read/write by self + allow read,write access to subtree root by self + + # Read all mail accounts + allow read access to subtree "PH_LDAP_BASEDN" by "PH_LDAP_BINDDN" + + # Allow to manage (read+write) mail accounts + allow read,write access to subtree "PH_LDAP_BASEDN" by "PH_LDAP_ADMIN_DN" + allow read,write access to subtree "PH_LDAP_ADMIN_BASEDN" by "PH_LDAP_ADMIN_DN" +} diff --git a/iredmail/samples/openbsd/pf.conf b/iredmail/samples/openbsd/pf.conf new file mode 100644 index 0000000..1a63d0e --- /dev/null +++ b/iredmail/samples/openbsd/pf.conf @@ -0,0 +1,28 @@ +# Basic PF rules for mail server. + +mail_services="{www, https, smtp, submission, imap, imaps, pop3, pop3s, ssh}" + +#table persist +#table persist file "/etc/mail/nospamd" +#table persist + +# Options +set block-policy drop +set skip on lo + +# Block all +block log all + +# Fail2ban +#block in quick on egress proto tcp from to any + +pass out + +# rules for spamd(8) +#pass in on egress proto tcp from any to any port smtp \ +# divert-to 127.0.0.1 port spamd +#pass in on egress proto tcp from to any port smtp +#pass in log on egress proto tcp from to any port smtp + +# Access to other mail services +pass in on egress proto tcp from any to any port $mail_services diff --git a/iredmail/samples/openldap/calentry.schema b/iredmail/samples/openldap/calentry.schema new file mode 100644 index 0000000..461ecbb --- /dev/null +++ b/iredmail/samples/openldap/calentry.schema @@ -0,0 +1,105 @@ +# RFC2739 calEntry schema for OpenLDAP 2.x + +# Version of RFC 2739 schema translated by Terrelle Shaw (xytek@xytek.org) +# Nov. 7, 2002 +# Modifications by Peter Marschall +# Nov. 9, 2002 +# 20060322 changes as in http://www.openldap.org/lists/openldap-software/200211/msg00242.html + +# Notes: +# * RFC2739 seems to be a bit sloppy about attribute type and +# objectclass definitions syntax and also about attribute syntax +# and matching rules. +# (It even counts the attributes in the calEntry objectclass wrong ;-) +# * The following changes have been applied to correct the schema +# - added description to each attributetype definition +# - changed SYNTAX from 'String' to corresponding OID +# to make matching rules and syntax consistent +# - replaced illegal keyword SUBSTRING by SUBSTR +# - changed SUBSTR from caseIgnoreMatch to caseIgnoreSubstringsMatch +# - removed illegal keyword MULTI-VALUE +# - added keyword SINGLE-VALUE where appropriate +# - removed USAGE since cwuserApplications is the default +# - added description to the objectclass defintion +# - corrected typo in objectclass definition +# - added the attributetypes defined but not used to the objectclass + + +# 2.4.4.1 calCalURI +attributetype ( 1.2.840.113556.1.4.478 + NAME 'calCalURI' + DESC 'URI to a snapshot of the users entire default calendar' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +# 2.4.4.2 calFBURL +attributetype ( 1.2.840.113556.1.4.479 + NAME 'calFBURL' + DESC 'URI to the users default free/busy time data' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +# 2.4.4.3 calCAPURI +attributetype ( 1.2.840.113556.1.4.480 + NAME 'calCAPURI' + DESC 'URI used to communicate with the users calendar' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +# 2.4.4.4 calCalAdrURI +attributetype ( 1.2.840.113556.1.4.481 + NAME 'calCalAdrURI' + DESC 'URI to which event requests should be sent for the user' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +# 2.4.4.5 calOtherCalURIs +attributetype ( 1.2.840.113556.1.4.482 + NAME 'calOtherCalURIs' + DESC 'URIs to snapshots of non-default calendars belonging to the user' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +# 2.4.4.6 calOtherFBURLs +attributetype ( 1.2.840.113556.1.4.483 + NAME 'calOtherFBURLs' + DESC 'URIs to non-default free/busy data belonging to the user' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +# 2.4.4.7 calOtherCAPURIs +attributetype ( 1.2.840.113556.1.4.484 + NAME 'calOtherCAPURIs' + DESC 'URIs to non-default calendars belonging to the user' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +# 2.4.4.8 calOtherCalAdrURIs +attributetype ( 1.2.840.113556.1.4.485 + NAME 'calOtherCalAdrURIs' + DESC 'URIs of destinations for event requests to non-default calendars' + EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +# 2.4.3.1 calEntry +objectclass ( 1.2.840.113556.1.5.87 + NAME 'calEntry' + DESC 'Calendering and free/busy information' + SUP top AUXILIARY + MAY ( calCalURI $ calFBURL $ calCAPURI $ calCalAdrURI $ + calOtherCAPURIs $ calOtherCalURIs $ calOtherFBURLs $ + calOtherCalAdrURIs ) ) + +# EOF diff --git a/iredmail/samples/openldap/calresource.schema b/iredmail/samples/openldap/calresource.schema new file mode 100644 index 0000000..e46c4aa --- /dev/null +++ b/iredmail/samples/openldap/calresource.schema @@ -0,0 +1,184 @@ +# $Id: calresource.schema,v 1.2 2011/04/29 10:54:03 martin$ +# +# DRAFT only at the time of writing this schema! +# See: http://tools.ietf.org/html/draft-cal-resource-schema-03 +# +### +# +# This specification defines a schema for representing resources to +# ease the discovery and scheduling of resources between any calendar +# client and server. +# LDAP and vCard mappings of the schema are described in this +# document. The Object model chosen is the lowest common denominator +# to adapt for LDAP. +# +# This schema depends on: +# - calentry.schema +# +# New LDAP objectclasses and attributes defined in this document need +# to be registered by the Internet Assigned Numbers Authority (IANA) as +# requested in the following template. Once the assignment is done, +# this document needs to be updated with the right OID numbers for all +# the newly defined objectclasses and attributes. +# +# Temporary we replace "x" in OIDs with unused "5" +# Example: 1.3.6.1.1.x.1.1 with 1.3.6.1.1.5.1.1 + + +# Attribute Type Definitions + +# +# ERROR in draft! +# Same OID for 2 attributetypes so I changed 'Kind' +# to ...0.0 instead of ...0.1 +# + +attributetype ( 1.3.6.1.1.5.0.0 NAME 'Kind' + DESC 'Kind of Object' + EQUALITY caseIgnoreMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + + +attributetype ( 1.3.6.1.1.5.0.1 + NAME 'VcardUid' + DESC 'VCard UniqueID' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + + + +attributetype ( 1.3.6.1.1.5.0.2 NAME 'NickName' + DESC 'Nick Name' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.3 NAME 'Categories' + DESC 'Categories' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.4 NAME 'Restricted' + DESC 'Access Restricted' + EQUALITY booleanMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 ) + +attributetype ( 1.3.6.1.1.5.0.5 NAME 'AdmittanceURL' + DESC 'Cal Resource Admittance Info URL' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.6 NAME 'accessibilityURL' + DESC 'Cal Resource accessibility Info URL' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.7 NAME 'Capacity' + DESC 'Cal Resource Capacity' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 ) + +attributetype ( 1.3.6.1.1.5.0.8 NAME 'InventoryList' + DESC 'Inventory List' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.9 NAME 'InventoryURL' + DESC 'Cal Resource Inventory Info URL' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.10 NAME 'ResourceManager' + DESC 'Cal Resource Manager Info' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.11 NAME 'TimeZoneID' + DESC 'Cal Time Zone ID' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.12 NAME 'Multiplebookings' + DESC 'Cal Num Bookings Allowed' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 ) + +attributetype ( 1.3.6.1.1.5.0.13 NAME 'MaxInstances' + DESC 'Cal Maximum Instances allowed' + EQUALITY integerMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 ) + +attributetype ( 1.3.6.1.1.5.0.14 NAME 'BookingWindowStart' + DESC 'Cal Booking Window Start' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.15 NAME 'BookingWindowEnd' + DESC 'Cal Booking Window End' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.16 NAME 'Autoschedule' + DESC 'Cal Scheduling no approval required' + EQUALITY booleanMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 ) + +attributetype ( 1.3.6.1.1.5.0.17 NAME 'ApprovalInfoURL' + DESC 'Cal Sched Approval Info' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.18 NAME 'SchedAdmin' + DESC 'Cal Sched Admin Info' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.1.5.0.19 NAME 'Nocost' + DESC 'Free or Priced resource' + EQUALITY booleanMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 ) + +attributetype ( 1.3.6.1.1.5.0.20 NAME 'CostURL' + DESC 'Cal Resource Cost Info' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +# Object Class Definitions + + +objectclass ( 1.3.6.1.1.5.1.1 NAME 'CalendarResource' + DESC 'Calendar Resource Object Class' + SUP calEntry + AUXILIARY + MUST (cn) + MAY ( kind $ nickname $ description $ ou $ categories $ + member $ uniquemember $ accessibilityurl $ capacity $ + owner $ resourcemanager $ timezoneid $ + multiplebookings $ maxinstances $ + bookingwindowstart $ bookingwindowend $ vcarduid ) ) + + +objectclass ( 1.3.6.1.1.5.1.2 NAME 'AdmittanceInfo' + DESC 'Calendar Resource Admittance Info Class' + SUP CalendarResource + AUXILIARY + MAY ( admittanceurl ) ) + +objectclass ( 1.3.6.1.1.5.1.3 NAME 'InventoryInfo' + DESC 'Calendar Resource Inventory Info Class' + SUP CalendarResource + AUXILIARY + MAY ( inventorylist $ inventoryurl ) ) + +objectclass ( 1.3.6.1.1.5.1.4 NAME 'SchedApprovalInfo' + DESC 'Calendar Sched Approval Class' + SUP CalendarResource + AUXILIARY + MAY ( autoschedule $ approvalinfourl $ schedadmin ) ) + +objectclass ( 1.3.6.1.1.5.1.5 NAME 'CalendarResourceCost' + DESC 'Calendar Resource Cost Object Class' + SUP CalendarResource + AUXILIARY + MAY ( nocost $ costurl ) ) diff --git a/iredmail/samples/openldap/ldap.conf b/iredmail/samples/openldap/ldap.conf new file mode 100644 index 0000000..d7747cb --- /dev/null +++ b/iredmail/samples/openldap/ldap.conf @@ -0,0 +1,3 @@ +BASE PH_LDAP_SUFFIX +URI ldap://PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +TLS_CACERT PH_SSL_CERT_FILE diff --git a/iredmail/samples/openldap/slapd.conf b/iredmail/samples/openldap/slapd.conf new file mode 100644 index 0000000..7b80e26 --- /dev/null +++ b/iredmail/samples/openldap/slapd.conf @@ -0,0 +1,240 @@ +# Schemas. +include PH_OPENLDAP_SCHEMA_DIR/core.schema +include PH_OPENLDAP_SCHEMA_DIR/corba.schema +include PH_OPENLDAP_SCHEMA_DIR/cosine.schema +include PH_OPENLDAP_SCHEMA_DIR/inetorgperson.schema +include PH_OPENLDAP_SCHEMA_DIR/nis.schema + +# Include CalendarResource and calEntry object classes for resource management +# used in SOGo Groupware. +# FYI: https://docs.iredmail.org/sogo.manage.resources.html +#include PH_OPENLDAP_SCHEMA_DIR/calentry.schema +#include PH_OPENLDAP_SCHEMA_DIR/calresource.schema + +# Amavisd-new schema. +include PH_OPENLDAP_SCHEMA_DIR/PH_AMAVISD_LDAP_SCHEMA_NAME + +# iRedMail schema. +include PH_OPENLDAP_SCHEMA_DIR/iredmail.schema + +# Where the pid file is put. The init.d script will not stop the +# server if you change this. +pidfile PH_OPENLDAP_PID_FILE + +# List of arguments that were passed to the server +argsfile PH_OPENLDAP_ARGS_FILE + +#modulepath PH_OPENLDAP_MODULE_PATH +#moduleload back_PH_OPENLDAP_DEFAULT_DBTYPE +#moduleload back_monitor + +# Support password verification with SSHA512. Require OpenLDAP-2.4.32 or later. +#moduleload pw_sha2 + +# The syncprov overlay +#moduleload syncprov.la + +# SSL cert files. if no need to access OpenLDAP from another host, it's ok to +# disable TLS/SSL support. +#TLSCACertificateFile PH_SSL_CERT_FILE +#TLSCertificateFile PH_SSL_CERT_FILE +#TLSCertificateKeyFile PH_SSL_KEY_FILE + +# Disallow bind as anonymous. +disallow bind_anon + +# Uncomment below line to allow binding as anonymous. +#allow bind_anon_cred + +# Specify LDAP protocol version. +require LDAPv3 +#allow bind_v2 + +# Log level. +# -1: enable all debugging +# 0: no debugging +# 128: access control list processing +# 256: stats log connections/operations/results +loglevel 0 + +# Access Control +# Allow users to change their own passwords and mail forwarding addresses. +access to attrs="userPassword,mailForwardingAddress,employeeNumber" + by anonymous auth + by self write + by dn.exact="PH_LDAP_BINDDN" read + by dn.exact="PH_LDAP_ADMIN_DN" write + by users none + +# Allow to read others public info. +access to attrs="cn,sn,gn,givenName,telephoneNumber" + by anonymous auth + by self write + by dn.exact="PH_LDAP_BINDDN" read + by dn.exact="PH_LDAP_ADMIN_DN" write + by users read + +# Domain attrs. +access to attrs="objectclass,domainName,mtaTransport,enabledService,domainSenderBccAddress,domainRecipientBccAddress,domainBackupMX,domainMaxQuotaSize,domainMaxUserNumber,domainPendingAliasName" + by anonymous auth + by self read + by dn.exact="PH_LDAP_BINDDN" read + by dn.exact="PH_LDAP_ADMIN_DN" write + by users read + +access to attrs="domainAdmin,domainGlobalAdmin,domainSenderBccAddress,domainRecipientBccAddress" + by anonymous auth + by self read + by dn.exact="PH_LDAP_BINDDN" read + by dn.exact="PH_LDAP_ADMIN_DN" write + by users none + +# User attrs. +access to attrs="mail,accountStatus,domainStatus,userSenderBccAddress,userRecipientBccAddress,mailQuota,backupMailAddress,shadowAddress,memberOfGroup,member,uniqueMember,storageBaseDirectory,homeDirectory,mailMessageStore,mailingListID" + by anonymous auth + by self read + by dn.exact="PH_LDAP_BINDDN" read + by dn.exact="PH_LDAP_ADMIN_DN" write + by users read + +# +# Set ACL for vmail/vmailadmin. +# +access to dn="PH_LDAP_BINDDN" + by anonymous auth + by self write + by users none + +access to dn="PH_LDAP_ADMIN_DN" + by anonymous auth + by self write + by users none + +# +# Allow users to access their own domain subtree. +# Allow domain admin to modify accounts under same domain. +# +access to dn.regex="domainName=([^,]+),PH_LDAP_BASEDN$" + by anonymous auth + by self write + by dn.exact="PH_LDAP_BINDDN" read + by dn.exact="PH_LDAP_ADMIN_DN" write + by dn.regex="mail=[^,]+@$1,PH_LDAP_ADMIN_BASEDN$" write + by dn.regex="mail=[^,]+@$1,ou=Users,domainName=$1,PH_LDAP_BASEDN$" read + by users none + +# +# Grant correct privileges to vmail/vmailadmin. +# +access to dn.subtree="PH_LDAP_BASEDN" + by anonymous auth + by self write + by dn.exact="PH_LDAP_BINDDN" read + by dn.exact="PH_LDAP_ADMIN_DN" write + by users read + +access to dn.subtree="PH_LDAP_ADMIN_BASEDN" + by anonymous auth + by self write + by dn.exact="PH_LDAP_BINDDN" read + by dn.exact="PH_LDAP_ADMIN_DN" write + by users none + +# +# Set permission for "cn=*,PH_LDAP_SUFFIX". +# +access to dn.regex="cn=[^,]+,PH_LDAP_SUFFIX" + by anonymous auth + by self write + by users none + +# +# Set default permission. +# +access to * + by anonymous auth + by self write + by users read + +####################################################################### +# Databases +####################################################################### +database monitor +access to dn="cn=monitor" + by dn.exact="PH_LDAP_ROOTDN" read + by dn.exact="PH_LDAP_BINDDN" read + by * none + +# Database used to store mail accounts +database PH_OPENLDAP_DEFAULT_DBTYPE +suffix PH_LDAP_SUFFIX +directory PH_LDAP_DATA_DIR + +rootdn PH_LDAP_ROOTDN +rootpw PH_LDAP_ROOTPW_SSHA + +# Specify the maximum number of entries to return from a search operation. +# Defaults to 500. Use `unlimited` to specify no limits. +sizelimit unlimited + +# Specify the maximum size of the database in bytes for mdb backend database. +# A memory map of this size is allocated at startup time and the database will +# not be allowed to grow beyond this size. +# The default is 10485760 bytes (10 MB). +# This setting may be changed upward if the configured limit needs to be increased. +#maxsize 2147483648 + +# Specify that on-disk database contents should not be +# immediately synchronized with in memory changes. Enabling +# this option may improve performance at the expense of data +# security. In particular, if the operating system crashes +# before changes are flushed, some number of transactions may be +# lost. By default, a full data flush/sync is performed when +# each transaction is committed. +#dbnosync + +# Specify the frequency for flushing the database disk buffers. +# This directive specifies how often to checkpoint the BDB transaction log. +# This setting is only needed if the dbnosync option is used. +# +# The checkpoint will occur if either data has been +# written or minutes have passed since the last +# checkpoint. Both arguments default to zero, in which case +# they are ignored. When the argument is non-zero, an +# internal task will run every minutes to perform the +# checkpoint. +# Note: currently the setting (for mdb backend) is unimplemented. +checkpoint 128 3 + +# Set directory permission. +mode 0700 + +# +# Default indexes. +# +index objectclass,entryCSN,entryUUID eq +index uidNumber,gidNumber,uid,memberUid,loginShell eq,pres +index homeDirectory,mailMessageStore eq,pres +index ou,cn,mail,surname,givenname,telephoneNumber,displayName eq,pres,sub +index nisMapName,nisMapEntry eq,pres,sub +index shadowLastChange eq,pres +index member,uniqueMember eq,pres + +# +# Index for mail attrs. +# +# Domain object +index domainName,mtaTransport,accountStatus,enabledService,disabledService eq,pres,sub +index domainAliasName eq,pres,sub +index domainMaxUserNumber eq,pres +index domainAdmin,domainGlobalAdmin,domainBackupMX eq,pres,sub +index domainSenderBccAddress,domainRecipientBccAddress eq,pres,sub + +# Group object +index accessPolicy,hasMember,listAllowedUser,mailingListID eq,pres,sub + +# User object +index mailForwardingAddress,shadowAddress eq,pres,sub +index backupMailAddress,memberOfGroup eq,pres,sub +index userRecipientBccAddress,userSenderBccAddress eq,pres,sub +index mobile,departmentNumber eq,pres,sub diff --git a/iredmail/samples/php/fpm/pool.d/www.conf b/iredmail/samples/php/fpm/pool.d/www.conf new file mode 100755 index 0000000..613960d --- /dev/null +++ b/iredmail/samples/php/fpm/pool.d/www.conf @@ -0,0 +1,30 @@ +[inet] +user = PH_HTTPD_USER +group = PH_HTTPD_GROUP + +listen = PH_LOCAL_ADDRESS:PH_PHP_FPM_PORT +listen.owner = PH_HTTPD_USER +listen.group = PH_HTTPD_GROUP +listen.mode = 0660 + +; IP addresses must be separated by comma, and no space between comma and ip. +listen.allowed_clients = 127.0.0.1 + +pm = dynamic +pm.max_children = PH_PHP_FPM_POOL_MAX_CHILDREN +pm.start_servers = PH_PHP_FPM_POOL_START_SERVERS +pm.min_spare_servers = PH_PHP_FPM_POOL_MIN_SPARE_SERVERS +pm.max_spare_servers = PH_PHP_FPM_POOL_MAX_SPARE_SERVERS +pm.max_requests = PH_PHP_FPM_POOL_MAX_CHILDREN + +pm.status_path = /PH_PHP_FPM_URI_STATUS +ping.path = /PH_PHP_FPM_URI_PING + +request_terminate_timeout = PH_PHP_FPM_POOL_REQUEST_TERMINATE_TIMEOUT +request_slowlog_timeout = PH_PHP_FPM_REQUEST_SLOWLOG_TIMEOUT + +; +; Log files +; +access.log = PH_PHP_FPM_LOG_MAIN +slowlog = PH_PHP_FPM_LOG_SLOW diff --git a/iredmail/samples/postfix/command_filter.pcre b/iredmail/samples/postfix/command_filter.pcre new file mode 100644 index 0000000..5d03f1e --- /dev/null +++ b/iredmail/samples/postfix/command_filter.pcre @@ -0,0 +1,3 @@ +# Work around clients that send `RCPT TO:<'user@domain'>` (Outlook 2003/2007). +# WARNING: do not lose the parameters that follow the address. +/^(RCPT\s+TO:\s*<)'([^[:space:]]+)'(>.*)/ $1$2$3 diff --git a/iredmail/samples/postfix/freebsd/mailer.conf b/iredmail/samples/postfix/freebsd/mailer.conf new file mode 100644 index 0000000..9a80572 --- /dev/null +++ b/iredmail/samples/postfix/freebsd/mailer.conf @@ -0,0 +1,9 @@ +# +# /etc/mail/mailer.cf +# +# Execute the Postfix sendmail program, named /usr/local/sbin/sendmail +# +sendmail /usr/local/sbin/sendmail +send-mail /usr/local/sbin/sendmail +mailq /usr/local/sbin/sendmail +newaliases /usr/local/sbin/sendmail diff --git a/iredmail/samples/postfix/helo_access.pcre b/iredmail/samples/postfix/helo_access.pcre new file mode 100644 index 0000000..d9f2efa --- /dev/null +++ b/iredmail/samples/postfix/helo_access.pcre @@ -0,0 +1,182 @@ +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# +# Sample Postfix check_helo_access rule. It should be located at: +# /etc/postfix/check_helo_access.pcre +# +# Shipped within iRedMail project: +# * http://www.iredmail.org/ + +# Prepend HELO hostname of sender server +#/(.*)/ PREPEND X-Original-Helo: $1 (iRedMail: http://www.iredmail.org/) + +# No one will use these in helo command. +/^(localhost)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/^(localhost.localdomain)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(\.local)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) + +# Reject who use IP address as helo. +# Correct: [xxx.xxx.xxx.xxx] +# Incorrect: xxx.xxx.xxx.xxx +/^([0-9\.]+)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server sent non RFC compliant HELO identity (${1}) + +# +# This is the real HELO identify of these ISPs: +# sohu.com websmtp.sohu.com relay2nd.mail.sohu.com +# 126.com m15-78.126.com +# 163.com m31-189.vip.163.com m13-49.163.com +# sina.com mail2-209.sinamail.sina.com.cn +# gmail.com xx-out-NNNN.google.com +/^(126\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server seems to be impersonating another mail server (${1}) +/^(163\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server seems to be impersonating another mail server (${1}) +/^(163\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server seems to be impersonating another mail server (${1}) +/^(sohu\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server seems to be impersonating another mail server (${1}) +/^(gmail\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server seems to be impersonating another mail server (${1}) +/^(google\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server seems to be impersonating another mail server (${1}) +/^(yahoo\.com\.cn)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server seems to be impersonating another mail server (${1}) +/^(yahoo\.co\.jp)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server seems to be impersonating another mail server (${1}) + +# +# Spammers. +# +/^(728154EA470B4AA\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(taj-co\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(CF8D3DB045C1455\.net)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(dsgsfdg\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(se\.nit7-ngbo\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(mail\.goo\.ne\.jp)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(n-ong_an\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(meqail\.teamefs-ine5tl\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(zzg\.jhf-sp\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(din_glo-ng\.net)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(fda-cnc\.ie\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(yrtaj-yrco\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(m\.am\.biz\.cn)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(xr_haig\.roup\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(hjn\.cn)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(we_blf\.com\.cn)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(netvigator\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(mysam\.biz)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(mail\.teams-intl\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(seningbo\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(nblf\.com\.cn)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(kdn\.ktguide\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(zzsp\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(nblongan\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(dpu\.cn)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(nbalton\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(cncie\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(xinhaigroup\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/^(wz\.com)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/(\.zj\.cn)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) +/(\.kornet)$/ REJECT ACCESS DENIED. Your email was rejected because it appears to come from a known spamming mail server (${1}) + +/^(dsldevice\.lan)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/^(system\.mail)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/^(speedtouch\.lan)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/^(dsldevice\.lan)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) + +# +# Reject adsl spammers. +# +# match word `adsl` with word boundary `\b`. +/(\badsl\b)/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) + +# bypass "[IP_ADDRESS]" +/^\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]$/ DUNNO + +# bypass some HELOs which contains IP address +/^o\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3}\.outbound-mail\.sendgrid\.net$/ DUNNO +/^\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3}\.mail-mail\.facebook\.com$/ DUNNO +/^outbound-\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3}\.pinterestmail\.com$/ DUNNO + +# reject HELO which contains IP address +/(\d{1,3}[\.-]\d{1,3}[\.-]\d{1,3}[\.-]\d{1,3})/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(\d{1,3}\.ip\.-\d{1,3}-\d{1,3}-\d{1,3}\.eu)/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(pppoe)/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(dsl\.brasiltelecom\.net\.br)/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(dsl\.optinet\.hr)/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(dsl\.telesp\.net\.br)/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(dialup)/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(dhcp)/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(static-pool-[\d\.-]*\.flagman\.zp\.ua)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) + +/(speedy\.com\.ar)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(speedyterra\.com\.br)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(static\.sbb\.rs)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) +/(static\.vsnl\.net\.in)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1}) + +/(advance\.com\.ar)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(airtelbroadband\.in)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(bb\.netvision\.net\.il)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(broadband3\.iol\.cz)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(cable\.net\.co)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(catv\.broadband\.hu)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(chello\.nl)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(chello\.sk)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(client\.mchsi\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(comunitel\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(coprosys\.cz)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(dclient\.hispeed\.ch)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(dip0\.t-ipconnect\.de)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(domain\.invalid)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(dyn\.centurytel\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(embarqhsd\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(emcali\.net\.co)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(epm\.net\.co)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(fibertel\.com\.ar)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(freedom2surf\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(hgcbroadband\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(HINET-IP\.hinet\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(infonet\.by)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(is74\.ru)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(kievnet\.com\.ua)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(metrotel\.net\.co)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(nw\.nuvox\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(pldt\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(pool\.invitel\.hu)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(pool\.ukrtel\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(pools\.arcor-ip\.net)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(pppoe\.avangarddsl\.ru)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(retail\.telecomitalia\.it)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(revip2\.asianet\.co\.th)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(tim\.ro)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(tsi\.tychy\.pl)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(ttnet\.net\.tr)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(tttmaxnet\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(user\.veloxzone\.com\.br)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(utk\.ru)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(veloxzone\.com\.br)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(virtua\.com\.br)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(wanamaroc\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(wbt\.ru)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(wireless\.iaw\.on\.ca)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(business\.telecomitalia\.it)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(cotas\.com\.bo)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(marunouchi\.tokyo\.ocn\.ne\.jp)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(amedex\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/(aageneva\.com)$/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server does not identify itself correctly (${1}) +/^ylmf-pc/ REJECT ACCESS DENIED + +/(\.*wideragents\.com)$/ REJECT ACCESS DENIED (${1}) +/(\.*resumekeep\.net)$/ REJECT ACCESS DENIED (${1}) +/(\.*terracedrink\.com)$/ REJECT ACCESS DENIED (${1}) +/(\.*sincemessage\.com)$/ REJECT ACCESS DENIED (${1}) +/(\.*ordertranquility\.com)$/ REJECT ACCESS DENIED (${1}) +/(\.*terracedrink\.com)$/ REJECT ACCESS DENIED (${1}) diff --git a/iredmail/samples/postfix/ldap/catchall_maps.cf b/iredmail/samples/postfix/ldap/catchall_maps.cf new file mode 100644 index 0000000..1a80697 --- /dev/null +++ b/iredmail/samples/postfix/ldap/catchall_maps.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = sub +query_filter = (&(objectClass=mailUser)(accountStatus=active)(!(domainStatus=disabled))(|(mail=%s)(shadowAddress=%s))) +result_attribute= mailForwardingAddress +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/recipient_bcc_maps_domain.cf b/iredmail/samples/postfix/ldap/recipient_bcc_maps_domain.cf new file mode 100644 index 0000000..e3c3f4f --- /dev/null +++ b/iredmail/samples/postfix/ldap/recipient_bcc_maps_domain.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = one +query_filter = (&(objectClass=mailDomain)(|(domainName=%d)(domainAliasName=%d))(accountStatus=active)(enabledService=mail)(enabledService=recipientbcc)) +result_attribute= domainRecipientBccAddress +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/recipient_bcc_maps_user.cf b/iredmail/samples/postfix/ldap/recipient_bcc_maps_user.cf new file mode 100644 index 0000000..be82ffd --- /dev/null +++ b/iredmail/samples/postfix/ldap/recipient_bcc_maps_user.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = ou=PH_LDAP_ATTR_GROUP_USERS,domainName=%d,PH_LDAP_BASEDN +scope = one +query_filter = (&(|(mail=%s)(&(enabledService=shadowaddress)(shadowAddress=%s)))(objectClass=mailUser)(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)(enabledService=recipientbcc)) +result_attribute= userRecipientBccAddress +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/relay_domains.cf b/iredmail/samples/postfix/ldap/relay_domains.cf new file mode 100644 index 0000000..6934b0e --- /dev/null +++ b/iredmail/samples/postfix/ldap/relay_domains.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = one +query_filter = (&(objectClass=mailDomain)(|(domainName=%s)(&(enabledService=domainalias)(domainAliasName=%s)))(domainBackupMX=yes)(accountStatus=active)(enabledService=mail)) +result_attribute= domainName +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/sender_bcc_maps_domain.cf b/iredmail/samples/postfix/ldap/sender_bcc_maps_domain.cf new file mode 100644 index 0000000..07d9ce2 --- /dev/null +++ b/iredmail/samples/postfix/ldap/sender_bcc_maps_domain.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = one +query_filter = (&(objectClass=mailDomain)(|(domainName=%d)(domainAliasName=%d))(accountStatus=active)(enabledService=mail)(enabledService=senderbcc)) +result_attribute= domainSenderBccAddress +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/sender_bcc_maps_user.cf b/iredmail/samples/postfix/ldap/sender_bcc_maps_user.cf new file mode 100644 index 0000000..ed0ede5 --- /dev/null +++ b/iredmail/samples/postfix/ldap/sender_bcc_maps_user.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = ou=PH_LDAP_ATTR_GROUP_USERS,domainName=%d,PH_LDAP_BASEDN +scope = one +query_filter = (&(|(mail=%s)(&(enabledService=shadowaddress)(shadowAddress=%s)))(objectClass=mailUser)(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)(enabledService=senderbcc)) +result_attribute= userSenderBccAddress +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/sender_dependent_relayhost_maps_domain.cf b/iredmail/samples/postfix/ldap/sender_dependent_relayhost_maps_domain.cf new file mode 100644 index 0000000..dcd32d9 --- /dev/null +++ b/iredmail/samples/postfix/ldap/sender_dependent_relayhost_maps_domain.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = one +query_filter = (&(objectClass=mailDomain)(accountStatus=active)(enabledService=mail)(|(domainName=%d)(domainAliasName=%d))) +result_attribute= senderRelayHost +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/sender_dependent_relayhost_maps_user.cf b/iredmail/samples/postfix/ldap/sender_dependent_relayhost_maps_user.cf new file mode 100644 index 0000000..d1efbbe --- /dev/null +++ b/iredmail/samples/postfix/ldap/sender_dependent_relayhost_maps_user.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = ou=PH_LDAP_ATTR_GROUP_USERS,domainName=%d,PH_LDAP_BASEDN +scope = one +query_filter = (&(objectClass=mailUser)(mail=%s)(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)) +result_attribute= senderRelayHost +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/sender_login_maps.cf b/iredmail/samples/postfix/ldap/sender_login_maps.cf new file mode 100644 index 0000000..18329b9 --- /dev/null +++ b/iredmail/samples/postfix/ldap/sender_login_maps.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = sub +query_filter = (&(objectClass=mailUser)(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)(enabledService=smtp)(|(mail=%s)(&(enabledService=shadowaddress)(shadowAddress=%s)))) +result_attribute= mail +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/transport_maps_domain.cf b/iredmail/samples/postfix/ldap/transport_maps_domain.cf new file mode 100644 index 0000000..f6b69b8 --- /dev/null +++ b/iredmail/samples/postfix/ldap/transport_maps_domain.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = one +query_filter = (&(objectClass=mailDomain)(accountStatus=active)(enabledService=mail)(|(domainName=%s)(domainAliasName=%s))) +result_attribute= mtaTransport +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/transport_maps_user.cf b/iredmail/samples/postfix/ldap/transport_maps_user.cf new file mode 100644 index 0000000..9cc1125 --- /dev/null +++ b/iredmail/samples/postfix/ldap/transport_maps_user.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = domainName=%d,PH_LDAP_BASEDN +scope = sub +query_filter = (&(|(objectClass=mailUser)(&(objectClass=mailList)(enabledService=mlmmj)))(|(mail=%s)(shadowAddress=%s))(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)) +result_attribute= mtaTransport +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/virtual_alias_maps.cf b/iredmail/samples/postfix/ldap/virtual_alias_maps.cf new file mode 100644 index 0000000..f76f5ba --- /dev/null +++ b/iredmail/samples/postfix/ldap/virtual_alias_maps.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = sub +query_filter = (&(|(mail=%s)(shadowAddress=%s))(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)(enabledService=deliver)(|(objectClass=mailAlias)(&(objectClass=mailUser)(enabledService=forward)))) +result_attribute= mailForwardingAddress +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/virtual_group_maps.cf b/iredmail/samples/postfix/ldap/virtual_group_maps.cf new file mode 100644 index 0000000..8398541 --- /dev/null +++ b/iredmail/samples/postfix/ldap/virtual_group_maps.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = sub +query_filter = (&(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)(enabledService=deliver)(|(&(|(memberOfGroup=%s)(shadowAddress=%s))(|(objectClass=mailUser)(objectClass=mailExternalUser)))(&(memberOfGroup=%s)(!(shadowAddress=%s))(|(objectClass=mailAlias)(&(objectClass=mailList)(!(enabledService=mlmmj)))))(&(objectClass=mailList)(enabledService=mlmmj)(|(mail=%s)(shadowAddress=%s))))) +result_attribute= mail +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/virtual_group_members_maps.cf b/iredmail/samples/postfix/ldap/virtual_group_members_maps.cf new file mode 100644 index 0000000..f689ce0 --- /dev/null +++ b/iredmail/samples/postfix/ldap/virtual_group_members_maps.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = sub +query_filter = (&(objectClass=mailUser)(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)(enabledService=deliver)(|(mail=%s)(&(enabledService=shadowaddress)(shadowAddress=%s)))) +result_attribute= mail +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/virtual_mailbox_domains.cf b/iredmail/samples/postfix/ldap/virtual_mailbox_domains.cf new file mode 100644 index 0000000..d0fe3fd --- /dev/null +++ b/iredmail/samples/postfix/ldap/virtual_mailbox_domains.cf @@ -0,0 +1,11 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = one +query_filter = (&(objectClass=mailDomain)(|(domainName=%s)(&(enabledService=domainalias)(domainAliasName=%s)))(!(domainBackupMX=yes))(accountStatus=active)(enabledService=mail)) +result_attribute= domainName +debuglevel = 0 diff --git a/iredmail/samples/postfix/ldap/virtual_mailbox_maps.cf b/iredmail/samples/postfix/ldap/virtual_mailbox_maps.cf new file mode 100644 index 0000000..f735b57 --- /dev/null +++ b/iredmail/samples/postfix/ldap/virtual_mailbox_maps.cf @@ -0,0 +1,12 @@ +server_host = PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT +version = PH_LDAP_BIND_VERSION +bind = yes +start_tls = no +bind_dn = PH_LDAP_BINDDN +bind_pw = PH_LDAP_BINDPW +search_base = PH_LDAP_BASEDN +scope = sub +query_filter = (&(objectClass=mailUser)(|(mail=%s)(&(enabledService=shadowaddress)(shadowAddress=%s)))(accountStatus=active)(!(domainStatus=disabled))(enabledService=mail)(enabledService=deliver)) +result_attribute= mailMessageStore +result_format = %s/Maildir/ +debuglevel = 0 diff --git a/iredmail/samples/postfix/main.cf b/iredmail/samples/postfix/main.cf new file mode 100644 index 0000000..bb891d1 --- /dev/null +++ b/iredmail/samples/postfix/main.cf @@ -0,0 +1,274 @@ +# -------------------- +# INSTALL-TIME CONFIGURATION INFORMATION +# +# location of the Postfix queue. Default is /var/spool/postfix. +queue_directory = PH_QUEUE_DIRECTORY + +# location of all postXXX commands. Default is /usr/sbin. +command_directory = PH_COMMAND_DIRECTORY + +# location of all Postfix daemon programs (i.e. programs listed in the +# master.cf file). This directory must be owned by root. +# Default is /usr/libexec/postfix +daemon_directory = PH_DAEMON_DIRECTORY + +# location of Postfix-writable data files (caches, random numbers). +# This directory must be owned by the mail_owner account (see below). +# Default is /var/lib/postfix. +data_directory = PH_DATA_DIRECTORY + +# owner of the Postfix queue and of most Postfix daemon processes. +# Specify the name of a user account THAT DOES NOT SHARE ITS USER OR GROUP ID +# WITH OTHER ACCOUNTS AND THAT OWNS NO OTHER FILES OR PROCESSES ON THE SYSTEM. +# In particular, don't specify nobody or daemon. PLEASE USE A DEDICATED USER. +# Default is postfix. +mail_owner = PH_MAIL_OWNER + +# The following parameters are used when installing a new Postfix version. +# +# sendmail_path: The full pathname of the Postfix sendmail command. +# This is the Sendmail-compatible mail posting interface. +# +sendmail_path = PH_SENDMAIL_PATH + +# newaliases_path: The full pathname of the Postfix newaliases command. +# This is the Sendmail-compatible command to build alias databases. +# +newaliases_path = PH_NEWALIASES_PATH + +# full pathname of the Postfix mailq command. This is the Sendmail-compatible +# mail queue listing command. +mailq_path = PH_MAILQ_PATH + +# group for mail submission and queue management commands. +# This must be a group name with a numerical group ID that is not shared with +# other accounts, not even with the Postfix account. +setgid_group = PH_SETGID_GROUP + +# external command that is executed when a Postfix daemon program is run with +# the -D option. +# +# Use "command .. & sleep 5" so that the debugger can attach before +# the process marches on. If you use an X-based debugger, be sure to +# set up your XAUTHORITY environment variable before starting Postfix. +# +debugger_command = + PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin + ddd $daemon_directory/$process_name $process_id & sleep 5 + +debug_peer_level = 2 + +# -------------------- +# CUSTOM SETTINGS +# + +# SMTP server response code when recipient or domain not found. +unknown_local_recipient_reject_code = 550 + +# Do not notify local user. +biff = no + +# Disable the rewriting of "site!user" into "user@site". +swap_bangpath = no + +# Disable the rewriting of the form "user%domain" to "user@domain". +allow_percent_hack = no + +# Allow recipient address start with '-'. +allow_min_user = no + +# Disable the SMTP VRFY command. This stops some techniques used to +# harvest email addresses. +disable_vrfy_command = yes + +# Enable both IPv4 and/or IPv6: ipv4, ipv6, all. +inet_protocols = all + +# Enable all network interfaces. +inet_interfaces = all + +# +# TLS settings. +# +# SSL key, certificate, CA +# +smtpd_tls_key_file = PH_SSL_KEY_FILE +smtpd_tls_cert_file = PH_SSL_CERT_FILE +smtpd_tls_CAfile = PH_SSL_CERT_FILE +smtpd_tls_CApath = PH_SSL_CERT_DIR + +# +# Disable SSLv2, SSLv3 +# +smtpd_tls_protocols = !SSLv2 !SSLv3 +smtpd_tls_mandatory_protocols = !SSLv2 !SSLv3 +smtp_tls_protocols = !SSLv2 !SSLv3 +smtp_tls_mandatory_protocols = !SSLv2 !SSLv3 +lmtp_tls_protocols = !SSLv2 !SSLv3 +lmtp_tls_mandatory_protocols = !SSLv2 !SSLv3 + +# +# Fix 'The Logjam Attack'. +# +smtpd_tls_exclude_ciphers = aNULL, eNULL, EXPORT, DES, RC4, MD5, PSK, aECDH, EDH-DSS-DES-CBC3-SHA, EDH-RSA-DES-CDC3-SHA, KRB5-DE5, CBC3-SHA +smtpd_tls_dh512_param_file = PH_SSL_DH512_PARAM_FILE +smtpd_tls_dh1024_param_file = PH_SSL_DH1024_PARAM_FILE + +tls_random_source = dev:/dev/urandom + +# Log only a summary message on TLS handshake completion — no logging of client +# certificate trust-chain verification errors if client certificate +# verification is not required. With Postfix 2.8 and earlier, log the summary +# message, peer certificate summary information and unconditionally log +# trust-chain verification errors. +smtp_tls_loglevel = 1 +smtpd_tls_loglevel = 1 + +# Opportunistic TLS: announce STARTTLS support to remote SMTP clients, but do +# not require that clients use TLS encryption. +smtpd_tls_security_level = may + +# Produce `Received:` message headers that include information about the +# protocol and cipher used, as well as the remote SMTP client CommonName and +# client certificate issuer CommonName. +# This is disabled by default, as the information may be modified in transit +# through other mail servers. Only information that was recorded by the final +# destination can be trusted. +#smtpd_tls_received_header = yes + +# Opportunistic TLS, used when Postfix sends email to remote SMTP server. +# Use TLS if this is supported by the remote SMTP server, otherwise use +# plaintext. +# References: +# - http://www.postfix.org/TLS_README.html#client_tls_may +# - http://www.postfix.org/postconf.5.html#smtp_tls_security_level +smtp_tls_security_level = may + +# Use the same CA file as smtpd. +smtp_tls_CApath = PH_SSL_CERT_DIR +smtp_tls_CAfile = $smtpd_tls_CAfile +smtp_tls_note_starttls_offer = yes + +# Enable long, non-repeating, queue IDs (queue file names). +# The benefit of non-repeating names is simpler logfile analysis and easier +# queue migration (there is no need to run "postsuper" to change queue file +# names that don't match their message file inode number). +enable_long_queue_ids = yes + +# Reject unlisted sender and recipient +smtpd_reject_unlisted_recipient = yes +smtpd_reject_unlisted_sender = yes + +# Header and body checks with PCRE table +header_checks = pcre:PH_POSTFIX_FILE_HEADER_CHECKS +body_checks = pcre:PH_POSTFIX_FILE_BODY_CHECKS + +# A mechanism to transform commands from remote SMTP clients. +# This is a last-resort tool to work around client commands that break +# interoperability with the Postfix SMTP server. Other uses involve fault +# injection to test Postfix's handling of invalid commands. +# Requires Postfix-2.7+. +smtpd_command_filter = pcre:PH_POSTFIX_FILE_SMTPD_COMMAND_FILTER + +# HELO restriction +smtpd_helo_required = yes +smtpd_helo_restrictions = + permit_mynetworks + permit_sasl_authenticated + check_helo_access pcre:PH_POSTFIX_FILE_HELO_ACCESS + reject_non_fqdn_helo_hostname + reject_unknown_helo_hostname + +# Sender restrictions +smtpd_sender_restrictions = + reject_non_fqdn_sender + reject_unlisted_sender + permit_mynetworks + permit_sasl_authenticated + check_sender_access pcre:PH_POSTFIX_FILE_SENDER_ACCESS + reject_unknown_sender_domain + +# Recipient restrictions +smtpd_recipient_restrictions = + reject_non_fqdn_recipient + reject_unlisted_recipient + check_policy_service inet:PH_IREDAPD_SERVER_ADDRESS:PH_IREDAPD_LISTEN_PORT + permit_mynetworks + permit_sasl_authenticated + reject_unauth_destination + check_policy_service inet:127.0.0.1:PH_DOVECOT_SERVICE_QUOTA_STATUS_PORT + +# END-OF-MESSAGE restrictions +smtpd_end_of_data_restrictions = + check_policy_service inet:PH_IREDAPD_SERVER_ADDRESS:PH_IREDAPD_LISTEN_PORT + +# Data restrictions +smtpd_data_restrictions = reject_unauth_pipelining + +# SRS (Sender Rewriting Scheme) support +#sender_canonical_maps = tcp:PH_IREDAPD_SERVER_ADDRESS:PH_IREDAPD_SRS_FORWARD_PORT +#sender_canonical_classes = envelope_sender +#recipient_canonical_maps = tcp:PH_IREDAPD_SERVER_ADDRESS:PH_IREDAPD_SRS_REVERSE_PORT +#recipient_canonical_classes= envelope_recipient,header_recipient + +proxy_read_maps = $canonical_maps $lmtp_generic_maps $local_recipient_maps $mydestination $mynetworks $recipient_bcc_maps $recipient_canonical_maps $relay_domains $relay_recipient_maps $relocated_maps $sender_bcc_maps $sender_canonical_maps $smtp_generic_maps $smtpd_sender_login_maps $transport_maps $virtual_alias_domains $virtual_alias_maps $virtual_mailbox_domains $virtual_mailbox_maps $smtpd_sender_restrictions $sender_dependent_relayhost_maps + +# Avoid duplicate recipient messages. Default is 'yes'. +enable_original_recipient = no + +# Virtual support. +virtual_minimum_uid = PH_SYS_USER_VMAIL_UID +virtual_uid_maps = static:PH_SYS_USER_VMAIL_UID +virtual_gid_maps = static:PH_SYS_GROUP_VMAIL_GID +virtual_mailbox_base = PH_STORAGE_BASE_DIR + +# Do not set virtual_alias_domains. +virtual_alias_domains = + +# +# Enable SASL authentication on port 25 and force TLS-encrypted SASL authentication. +# WARNING: NOT RECOMMENDED to enable smtp auth on port 25, all end users should +# be forced to submit email through port 587 instead. +# +#smtpd_sasl_auth_enable = yes +#smtpd_sasl_security_options = noanonymous +#smtpd_tls_auth_only = yes + +# hostname +myhostname = PH_HOSTNAME +myorigin = PH_HOSTNAME +mydomain = PH_HOSTNAME + +# trusted SMTP clients which are allowed to relay mail through Postfix. +# +# Note: additional IP addresses/networks listed in mynetworks should be listed +# in iRedAPD setting 'MYNETWORKS' (in `/opt/iredapd/settings.py`) too. +# for example: +# +# MYNETWORKS = ['xx.xx.xx.xx', 'xx.xx.xx.0/24', ...] +# +mynetworks = 127.0.0.1 + +# Accepted local emails +mydestination = $myhostname, localhost, localhost.localdomain + +alias_maps = hash:PH_POSTFIX_FILE_ALIASES +alias_database = hash:PH_POSTFIX_FILE_ALIASES + +# Default message_size_limit. +message_size_limit = PH_MESSAGE_SIZE_LIMIT_BYTES + +# The set of characters that can separate a user name from its extension +# (example: user+foo), or a .forward file name from its extension (example: +# .forward+foo). +# Postfix 2.11 and later supports multiple characters. +recipient_delimiter = + + +# The time after which the sender receives a copy of the message headers of +# mail that is still queued. Default setting is disabled (0h) by Postfix. +#delay_warning_time = 1h + +# Do not display the name of the recipient table in the "User unknown" responses. +# The extra detail makes trouble shooting easier but also reveals information +# that is nobody elses business. +show_user_unknown_table_name = no diff --git a/iredmail/samples/postfix/main.cf.amavisd b/iredmail/samples/postfix/main.cf.amavisd new file mode 100644 index 0000000..446091e --- /dev/null +++ b/iredmail/samples/postfix/main.cf.amavisd @@ -0,0 +1,7 @@ +# +# Amavisd + SpamAssassin + ClamAV +# +content_filter = smtp-amavis:[PH_SMTP_SERVER]:10024 + +# Concurrency per recipient limit. +smtp-amavis_destination_recipient_limit = 1 diff --git a/iredmail/samples/postfix/main.cf.dovecot b/iredmail/samples/postfix/main.cf.dovecot new file mode 100644 index 0000000..7095bb0 --- /dev/null +++ b/iredmail/samples/postfix/main.cf.dovecot @@ -0,0 +1,8 @@ +# +# Dovecot SASL support. +# +smtpd_sasl_type = dovecot +smtpd_sasl_path = PH_DOVECOT_SASL_AUTH_SOCKET +virtual_transport = PH_TRANSPORT +dovecot_destination_recipient_limit = 1 + diff --git a/iredmail/samples/postfix/main.cf.ldap b/iredmail/samples/postfix/main.cf.ldap new file mode 100644 index 0000000..083fa22 --- /dev/null +++ b/iredmail/samples/postfix/main.cf.ldap @@ -0,0 +1,39 @@ +# +# Lookup virtual mail accounts +# +transport_maps = + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/transport_maps_user.cf + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/transport_maps_domain.cf + +sender_dependent_relayhost_maps = + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/sender_dependent_relayhost_maps_user.cf + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/sender_dependent_relayhost_maps_domain.cf + +# Lookup table with the SASL login names that own the sender (MAIL FROM) addresses. +smtpd_sender_login_maps = + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/sender_login_maps.cf + +virtual_mailbox_domains = + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/virtual_mailbox_domains.cf + +relay_domains = + $mydestination + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/relay_domains.cf + +virtual_mailbox_maps = + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/virtual_mailbox_maps.cf + +virtual_alias_maps = + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/virtual_alias_maps.cf + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/virtual_group_maps.cf + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/virtual_group_members_maps.cf + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/catchall_maps.cf + +sender_bcc_maps = + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/sender_bcc_maps_user.cf + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/sender_bcc_maps_domain.cf + +recipient_bcc_maps = + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/recipient_bcc_maps_user.cf + proxy:ldap:PH_POSTFIX_LOOKUP_DIR/recipient_bcc_maps_domain.cf + diff --git a/iredmail/samples/postfix/main.cf.mlmmj b/iredmail/samples/postfix/main.cf.mlmmj new file mode 100644 index 0000000..3b44766 --- /dev/null +++ b/iredmail/samples/postfix/main.cf.mlmmj @@ -0,0 +1,5 @@ +# +# mlmmj - mailing list manager +# +mlmmj_destination_recipient_limit = 1 + diff --git a/iredmail/samples/postfix/main.cf.mysql b/iredmail/samples/postfix/main.cf.mysql new file mode 100644 index 0000000..f0e1f62 --- /dev/null +++ b/iredmail/samples/postfix/main.cf.mysql @@ -0,0 +1,39 @@ +# +# Lookup virtual mail accounts +# +transport_maps = + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/transport_maps_user.cf + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/transport_maps_maillist.cf + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/transport_maps_domain.cf + +sender_dependent_relayhost_maps = + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/sender_dependent_relayhost_maps.cf + +# Lookup table with the SASL login names that own the sender (MAIL FROM) addresses. +smtpd_sender_login_maps = + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/sender_login_maps.cf + +virtual_mailbox_domains = + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/virtual_mailbox_domains.cf + +relay_domains = + $mydestination + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/relay_domains.cf + +virtual_mailbox_maps = + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/virtual_mailbox_maps.cf + +virtual_alias_maps = + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/virtual_alias_maps.cf + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/domain_alias_maps.cf + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/catchall_maps.cf + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/domain_alias_catchall_maps.cf + +sender_bcc_maps = + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/sender_bcc_maps_user.cf + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/sender_bcc_maps_domain.cf + +recipient_bcc_maps = + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/recipient_bcc_maps_user.cf + proxy:mysql:PH_POSTFIX_LOOKUP_DIR/recipient_bcc_maps_domain.cf + diff --git a/iredmail/samples/postfix/main.cf.pgsql b/iredmail/samples/postfix/main.cf.pgsql new file mode 100644 index 0000000..ef3e8a3 --- /dev/null +++ b/iredmail/samples/postfix/main.cf.pgsql @@ -0,0 +1,39 @@ +# +# Lookup virtual mail accounts +# +transport_maps = + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/transport_maps_user.cf + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/transport_maps_maillist.cf + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/transport_maps_domain.cf + +sender_dependent_relayhost_maps = + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/sender_dependent_relayhost_maps.cf + +# Lookup table with the SASL login names that own the sender (MAIL FROM) addresses. +smtpd_sender_login_maps = + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/sender_login_maps.cf + +virtual_mailbox_domains = + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/virtual_mailbox_domains.cf + +relay_domains = + $mydestination + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/relay_domains.cf + +virtual_mailbox_maps = + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/virtual_mailbox_maps.cf + +virtual_alias_maps = + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/virtual_alias_maps.cf + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/domain_alias_maps.cf + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/catchall_maps.cf + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/domain_alias_catchall_maps.cf + +sender_bcc_maps = + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/sender_bcc_maps_user.cf + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/sender_bcc_maps_domain.cf + +recipient_bcc_maps = + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/recipient_bcc_maps_user.cf + proxy:pgsql:PH_POSTFIX_LOOKUP_DIR/recipient_bcc_maps_domain.cf + diff --git a/iredmail/samples/postfix/main.cf.postscreen b/iredmail/samples/postfix/main.cf.postscreen new file mode 100644 index 0000000..a02d980 --- /dev/null +++ b/iredmail/samples/postfix/main.cf.postscreen @@ -0,0 +1,30 @@ +# +# Postscreen +# +postscreen_greet_action = drop +postscreen_blacklist_action = drop +postscreen_dnsbl_action = drop +postscreen_dnsbl_threshold = 2 + +# Attention: +# - zen.spamhaus.org free tire has 3 limits +# (https://www.spamhaus.org/organization/dnsblusage/): +# +# 1) Your use of the Spamhaus DNSBLs is non-commercial*, and +# 2) Your email traffic is less than 100,000 SMTP connections per day, and +# 3) Your DNSBL query volume is less than 300,000 queries per day. +# +# - FAQ: "Your DNSBL blocks nothing at all!" +# https://www.spamhaus.org/faq/section/DNSBL%20Usage#261 +# +# It's strongly recommended to use a local DNS server for cache. +postscreen_dnsbl_sites = + zen.spamhaus.org=127.0.0.[2..11]*3 + b.barracudacentral.org=127.0.0.2*2 + +postscreen_dnsbl_reply_map = texthash:PH_POSTSCREEN_FILE_DNSBL_REPLY +postscreen_access_list = permit_mynetworks cidr:PH_POSTSCREEN_FILE_ACCESS_CIDR + +# Require Postfix-2.11+ +#postscreen_dnsbl_whitelist_threshold = -2 + diff --git a/iredmail/samples/postfix/master.cf b/iredmail/samples/postfix/master.cf new file mode 100644 index 0000000..df21239 --- /dev/null +++ b/iredmail/samples/postfix/master.cf @@ -0,0 +1,76 @@ +# Submission, port 587, force TLS connection. +submission inet n - n - - smtpd + -o syslog_name=postfix/submission + -o smtpd_tls_security_level=encrypt + -o smtpd_sasl_auth_enable=yes + -o smtpd_client_restrictions=permit_sasl_authenticated,reject + -o content_filter=PH_AMAVISD_CONTENT_FILTER_ORIGINATING + +# Use dovecot's `deliver` program as LDA. +dovecot unix - n n - - pipe + flags=DRh user=PH_SYS_USER_VMAIL:PH_SYS_GROUP_VMAIL argv=PH_DOVECOT_DELIVER_BIN -f ${sender} -d ${user}@${domain} -m ${extension} + +# mlmmj - mailing list manager +# ${nexthop} is '%d/%u' in transport ('mlmmj:%d/%u') +mlmmj unix - n n - - pipe + flags=ORhu user=PH_SYS_USER_MLMMJ:PH_SYS_GROUP_MLMMJ argv=PH_CMD_MLMMJ_AMIME_RECEIVE -L PH_MLMMJ_SPOOL_DIR/${nexthop} + +# Amavisd integration. +smtp-amavis unix - - n - PH_AMAVISD_MAX_SERVERS smtp + -o syslog_name=postfix/amavis + -o smtp_data_done_timeout=1200 + -o smtp_send_xforward_command=yes + -o disable_dns_lookups=yes + -o max_use=20 + +# smtp port used by Amavisd to re-inject scanned email back to Postfix +PH_LOCAL_ADDRESS:PH_POSTFIX_MAIL_REINJECT_PORT inet n - n - - smtpd + -o syslog_name=postfix/PH_POSTFIX_MAIL_REINJECT_PORT + -o content_filter= + -o mynetworks_style=host + -o mynetworks=PH_AMAVISD_MYNETWORKS + -o local_recipient_maps= + -o relay_recipient_maps= + -o strict_rfc821_envelopes=yes + -o smtp_tls_security_level=none + -o smtpd_tls_security_level=none + -o smtpd_restriction_classes= + -o smtpd_delay_reject=no + -o smtpd_client_restrictions=permit_mynetworks,reject + -o smtpd_helo_restrictions= + -o smtpd_sender_restrictions= + -o smtpd_recipient_restrictions=permit_mynetworks,reject + -o smtpd_end_of_data_restrictions= + -o smtpd_error_sleep_time=0 + -o smtpd_soft_error_limit=1001 + -o smtpd_hard_error_limit=1000 + -o smtpd_client_connection_count_limit=0 + -o smtpd_client_connection_rate_limit=0 + -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_address_mappings + +# smtp port used by mlmmj to re-inject scanned email back to Postfix, with +# address mapping support +PH_LOCAL_ADDRESS:PH_POSTFIX_MLMMJ_REINJECT_PORT inet n - n - - smtpd + -o syslog_name=postfix/PH_POSTFIX_MLMMJ_REINJECT_PORT + -o content_filter= + -o mynetworks_style=host + -o mynetworks=PH_AMAVISD_MYNETWORKS + -o local_recipient_maps= + -o relay_recipient_maps= + -o strict_rfc821_envelopes=yes + -o smtp_tls_security_level=none + -o smtpd_tls_security_level=none + -o smtpd_restriction_classes= + -o smtpd_delay_reject=no + -o smtpd_client_restrictions=permit_mynetworks,reject + -o smtpd_helo_restrictions= + -o smtpd_sender_restrictions= + -o smtpd_recipient_restrictions=permit_mynetworks,reject + -o smtpd_end_of_data_restrictions= + -o smtpd_error_sleep_time=0 + -o smtpd_soft_error_limit=1001 + -o smtpd_hard_error_limit=1000 + -o smtpd_client_connection_count_limit=0 + -o smtpd_client_connection_rate_limit=0 + -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks + diff --git a/iredmail/samples/postfix/mysql/catchall_maps.cf b/iredmail/samples/postfix/mysql/catchall_maps.cf new file mode 100644 index 0000000..e063b4e --- /dev/null +++ b/iredmail/samples/postfix/mysql/catchall_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT forwardings.forwarding FROM forwardings,domain WHERE forwardings.address='%d' AND '%u' NOT LIKE '%%+%%' AND forwardings.address=domain.domain AND forwardings.active=1 AND domain.active=1 AND domain.backupmx=0 diff --git a/iredmail/samples/postfix/mysql/domain_alias_catchall_maps.cf b/iredmail/samples/postfix/mysql/domain_alias_catchall_maps.cf new file mode 100644 index 0000000..413071e --- /dev/null +++ b/iredmail/samples/postfix/mysql/domain_alias_catchall_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT forwardings.forwarding FROM forwardings,alias_domain,domain WHERE alias_domain.alias_domain='%d' AND forwardings.address=alias_domain.target_domain AND alias_domain.target_domain=domain.domain AND forwardings.active=1 AND alias_domain.active=1 diff --git a/iredmail/samples/postfix/mysql/domain_alias_maps.cf b/iredmail/samples/postfix/mysql/domain_alias_maps.cf new file mode 100644 index 0000000..2d9965e --- /dev/null +++ b/iredmail/samples/postfix/mysql/domain_alias_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT forwardings.forwarding FROM forwardings,alias_domain,domain WHERE alias_domain.alias_domain='%d' AND forwardings.address=CONCAT('%u', '@', alias_domain.target_domain) AND alias_domain.target_domain=domain.domain AND forwardings.active=1 AND alias_domain.active=1 AND domain.backupmx=0 diff --git a/iredmail/samples/postfix/mysql/recipient_bcc_maps_domain.cf b/iredmail/samples/postfix/mysql/recipient_bcc_maps_domain.cf new file mode 100644 index 0000000..fdb3974 --- /dev/null +++ b/iredmail/samples/postfix/mysql/recipient_bcc_maps_domain.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT bcc_address FROM recipient_bcc_domain WHERE domain='%d' AND active=1 diff --git a/iredmail/samples/postfix/mysql/recipient_bcc_maps_user.cf b/iredmail/samples/postfix/mysql/recipient_bcc_maps_user.cf new file mode 100644 index 0000000..b01b1bc --- /dev/null +++ b/iredmail/samples/postfix/mysql/recipient_bcc_maps_user.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT recipient_bcc_user.bcc_address FROM recipient_bcc_user,domain WHERE recipient_bcc_user.username='%s' AND recipient_bcc_user.domain='%d' AND recipient_bcc_user.domain=domain.domain AND domain.backupmx=0 AND domain.active=1 AND recipient_bcc_user.active=1 diff --git a/iredmail/samples/postfix/mysql/relay_domains.cf b/iredmail/samples/postfix/mysql/relay_domains.cf new file mode 100644 index 0000000..1d6ee90 --- /dev/null +++ b/iredmail/samples/postfix/mysql/relay_domains.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT domain FROM domain WHERE domain='%s' AND backupmx=1 AND active=1 LIMIT 1 diff --git a/iredmail/samples/postfix/mysql/sender_bcc_maps_domain.cf b/iredmail/samples/postfix/mysql/sender_bcc_maps_domain.cf new file mode 100644 index 0000000..03ca8f7 --- /dev/null +++ b/iredmail/samples/postfix/mysql/sender_bcc_maps_domain.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT bcc_address FROM sender_bcc_domain WHERE domain='%d' AND active=1 diff --git a/iredmail/samples/postfix/mysql/sender_bcc_maps_user.cf b/iredmail/samples/postfix/mysql/sender_bcc_maps_user.cf new file mode 100644 index 0000000..1f1adea --- /dev/null +++ b/iredmail/samples/postfix/mysql/sender_bcc_maps_user.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT sender_bcc_user.bcc_address FROM sender_bcc_user,domain WHERE sender_bcc_user.username='%s' AND sender_bcc_user.domain='%d' AND sender_bcc_user.domain=domain.domain AND domain.backupmx=0 AND domain.active=1 AND sender_bcc_user.active=1 diff --git a/iredmail/samples/postfix/mysql/sender_dependent_relayhost_maps.cf b/iredmail/samples/postfix/mysql/sender_dependent_relayhost_maps.cf new file mode 100644 index 0000000..329b6b9 --- /dev/null +++ b/iredmail/samples/postfix/mysql/sender_dependent_relayhost_maps.cf @@ -0,0 +1,6 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +# '%s' will be replaced by the envelope sender address or @domain. +query = SELECT relayhost FROM sender_relayhost WHERE account='%s' LIMIT 1 diff --git a/iredmail/samples/postfix/mysql/sender_login_maps.cf b/iredmail/samples/postfix/mysql/sender_login_maps.cf new file mode 100644 index 0000000..f396057 --- /dev/null +++ b/iredmail/samples/postfix/mysql/sender_login_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT mailbox.username FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.domain='%d' AND mailbox.domain=domain.domain AND mailbox.enablesmtp=1 AND mailbox.active=1 AND domain.backupmx=0 AND domain.active=1 diff --git a/iredmail/samples/postfix/mysql/transport_maps_domain.cf b/iredmail/samples/postfix/mysql/transport_maps_domain.cf new file mode 100644 index 0000000..6bdb19d --- /dev/null +++ b/iredmail/samples/postfix/mysql/transport_maps_domain.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT transport FROM domain WHERE domain='%s' AND active=1 LIMIT 1 diff --git a/iredmail/samples/postfix/mysql/transport_maps_maillist.cf b/iredmail/samples/postfix/mysql/transport_maps_maillist.cf new file mode 100644 index 0000000..bce7943 --- /dev/null +++ b/iredmail/samples/postfix/mysql/transport_maps_maillist.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT maillists.transport FROM maillists,domain WHERE maillists.address='%s' AND maillists.active=1 AND maillists.domain = domain.domain AND domain.active=1 diff --git a/iredmail/samples/postfix/mysql/transport_maps_user.cf b/iredmail/samples/postfix/mysql/transport_maps_user.cf new file mode 100644 index 0000000..8b6eee5 --- /dev/null +++ b/iredmail/samples/postfix/mysql/transport_maps_user.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT mailbox.transport FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.domain='%d' AND mailbox.domain=domain.domain AND mailbox.transport<>'' AND mailbox.active=1 AND mailbox.enabledeliver=1 AND domain.backupmx=0 AND domain.active=1 diff --git a/iredmail/samples/postfix/mysql/virtual_alias_maps.cf b/iredmail/samples/postfix/mysql/virtual_alias_maps.cf new file mode 100644 index 0000000..14314e0 --- /dev/null +++ b/iredmail/samples/postfix/mysql/virtual_alias_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT forwardings.forwarding FROM forwardings,domain WHERE forwardings.address='%s' AND forwardings.domain=domain.domain AND forwardings.active=1 AND domain.backupmx=0 AND domain.active=1 diff --git a/iredmail/samples/postfix/mysql/virtual_mailbox_domains.cf b/iredmail/samples/postfix/mysql/virtual_mailbox_domains.cf new file mode 100644 index 0000000..28c91ba --- /dev/null +++ b/iredmail/samples/postfix/mysql/virtual_mailbox_domains.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = (SELECT domain FROM domain WHERE domain='%s' AND backupmx=0 AND active=1 LIMIT 1) UNION (SELECT alias_domain.alias_domain FROM alias_domain,domain WHERE alias_domain.alias_domain='%s' AND alias_domain.active=1 AND alias_domain.target_domain=domain.domain AND domain.active=1 AND domain.backupmx=0 LIMIT 1) diff --git a/iredmail/samples/postfix/mysql/virtual_mailbox_maps.cf b/iredmail/samples/postfix/mysql/virtual_mailbox_maps.cf new file mode 100644 index 0000000..2ff6d4e --- /dev/null +++ b/iredmail/samples/postfix/mysql/virtual_mailbox_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT CONCAT(mailbox.storagenode, '/', mailbox.maildir, '/Maildir/') FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.active=1 AND mailbox.enabledeliver=1 AND domain.domain = mailbox.domain AND domain.active=1 diff --git a/iredmail/samples/postfix/pgsql/catchall_maps.cf b/iredmail/samples/postfix/pgsql/catchall_maps.cf new file mode 100644 index 0000000..e063b4e --- /dev/null +++ b/iredmail/samples/postfix/pgsql/catchall_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT forwardings.forwarding FROM forwardings,domain WHERE forwardings.address='%d' AND '%u' NOT LIKE '%%+%%' AND forwardings.address=domain.domain AND forwardings.active=1 AND domain.active=1 AND domain.backupmx=0 diff --git a/iredmail/samples/postfix/pgsql/domain_alias_catchall_maps.cf b/iredmail/samples/postfix/pgsql/domain_alias_catchall_maps.cf new file mode 100644 index 0000000..413071e --- /dev/null +++ b/iredmail/samples/postfix/pgsql/domain_alias_catchall_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT forwardings.forwarding FROM forwardings,alias_domain,domain WHERE alias_domain.alias_domain='%d' AND forwardings.address=alias_domain.target_domain AND alias_domain.target_domain=domain.domain AND forwardings.active=1 AND alias_domain.active=1 diff --git a/iredmail/samples/postfix/pgsql/domain_alias_maps.cf b/iredmail/samples/postfix/pgsql/domain_alias_maps.cf new file mode 100644 index 0000000..0f4c4f6 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/domain_alias_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT forwardings.forwarding FROM forwardings,alias_domain,domain WHERE alias_domain.alias_domain='%d' AND forwardings.address=('%u' || '@' || alias_domain.target_domain) AND alias_domain.target_domain=domain.domain AND forwardings.active=1 AND alias_domain.active=1 AND domain.backupmx=0 diff --git a/iredmail/samples/postfix/pgsql/recipient_bcc_maps_domain.cf b/iredmail/samples/postfix/pgsql/recipient_bcc_maps_domain.cf new file mode 100644 index 0000000..fdb3974 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/recipient_bcc_maps_domain.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT bcc_address FROM recipient_bcc_domain WHERE domain='%d' AND active=1 diff --git a/iredmail/samples/postfix/pgsql/recipient_bcc_maps_user.cf b/iredmail/samples/postfix/pgsql/recipient_bcc_maps_user.cf new file mode 100644 index 0000000..6c939d6 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/recipient_bcc_maps_user.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT recipient_bcc_user.bcc_address FROM recipient_bcc_user,domain WHERE recipient_bcc_user.username='%s' AND recipient_bcc_user.domain='%d' AND recipient_bcc_user.domain=domain.domain AND recipient_bcc_user.active=1 AND domain.backupmx=0 AND domain.active=1 diff --git a/iredmail/samples/postfix/pgsql/relay_domains.cf b/iredmail/samples/postfix/pgsql/relay_domains.cf new file mode 100644 index 0000000..1d6ee90 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/relay_domains.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT domain FROM domain WHERE domain='%s' AND backupmx=1 AND active=1 LIMIT 1 diff --git a/iredmail/samples/postfix/pgsql/sender_bcc_maps_domain.cf b/iredmail/samples/postfix/pgsql/sender_bcc_maps_domain.cf new file mode 100644 index 0000000..03ca8f7 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/sender_bcc_maps_domain.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT bcc_address FROM sender_bcc_domain WHERE domain='%d' AND active=1 diff --git a/iredmail/samples/postfix/pgsql/sender_bcc_maps_user.cf b/iredmail/samples/postfix/pgsql/sender_bcc_maps_user.cf new file mode 100644 index 0000000..ed65eea --- /dev/null +++ b/iredmail/samples/postfix/pgsql/sender_bcc_maps_user.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT sender_bcc_user.bcc_address FROM sender_bcc_user,domain WHERE sender_bcc_user.username='%s' AND sender_bcc_user.domain='%d' AND sender_bcc_user.domain=domain.domain AND sender_bcc_user.active=1 AND domain.backupmx=0 AND domain.active=1 diff --git a/iredmail/samples/postfix/pgsql/sender_dependent_relayhost_maps.cf b/iredmail/samples/postfix/pgsql/sender_dependent_relayhost_maps.cf new file mode 100644 index 0000000..329b6b9 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/sender_dependent_relayhost_maps.cf @@ -0,0 +1,6 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +# '%s' will be replaced by the envelope sender address or @domain. +query = SELECT relayhost FROM sender_relayhost WHERE account='%s' LIMIT 1 diff --git a/iredmail/samples/postfix/pgsql/sender_login_maps.cf b/iredmail/samples/postfix/pgsql/sender_login_maps.cf new file mode 100644 index 0000000..f396057 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/sender_login_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT mailbox.username FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.domain='%d' AND mailbox.domain=domain.domain AND mailbox.enablesmtp=1 AND mailbox.active=1 AND domain.backupmx=0 AND domain.active=1 diff --git a/iredmail/samples/postfix/pgsql/transport_maps_domain.cf b/iredmail/samples/postfix/pgsql/transport_maps_domain.cf new file mode 100644 index 0000000..6bdb19d --- /dev/null +++ b/iredmail/samples/postfix/pgsql/transport_maps_domain.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT transport FROM domain WHERE domain='%s' AND active=1 LIMIT 1 diff --git a/iredmail/samples/postfix/pgsql/transport_maps_maillist.cf b/iredmail/samples/postfix/pgsql/transport_maps_maillist.cf new file mode 100644 index 0000000..bce7943 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/transport_maps_maillist.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT maillists.transport FROM maillists,domain WHERE maillists.address='%s' AND maillists.active=1 AND maillists.domain = domain.domain AND domain.active=1 diff --git a/iredmail/samples/postfix/pgsql/transport_maps_user.cf b/iredmail/samples/postfix/pgsql/transport_maps_user.cf new file mode 100644 index 0000000..8b6eee5 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/transport_maps_user.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT mailbox.transport FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.domain='%d' AND mailbox.domain=domain.domain AND mailbox.transport<>'' AND mailbox.active=1 AND mailbox.enabledeliver=1 AND domain.backupmx=0 AND domain.active=1 diff --git a/iredmail/samples/postfix/pgsql/virtual_alias_maps.cf b/iredmail/samples/postfix/pgsql/virtual_alias_maps.cf new file mode 100644 index 0000000..14314e0 --- /dev/null +++ b/iredmail/samples/postfix/pgsql/virtual_alias_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT forwardings.forwarding FROM forwardings,domain WHERE forwardings.address='%s' AND forwardings.domain=domain.domain AND forwardings.active=1 AND domain.backupmx=0 AND domain.active=1 diff --git a/iredmail/samples/postfix/pgsql/virtual_mailbox_domains.cf b/iredmail/samples/postfix/pgsql/virtual_mailbox_domains.cf new file mode 100644 index 0000000..28c91ba --- /dev/null +++ b/iredmail/samples/postfix/pgsql/virtual_mailbox_domains.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = (SELECT domain FROM domain WHERE domain='%s' AND backupmx=0 AND active=1 LIMIT 1) UNION (SELECT alias_domain.alias_domain FROM alias_domain,domain WHERE alias_domain.alias_domain='%s' AND alias_domain.active=1 AND alias_domain.target_domain=domain.domain AND domain.active=1 AND domain.backupmx=0 LIMIT 1) diff --git a/iredmail/samples/postfix/pgsql/virtual_mailbox_maps.cf b/iredmail/samples/postfix/pgsql/virtual_mailbox_maps.cf new file mode 100644 index 0000000..765d93d --- /dev/null +++ b/iredmail/samples/postfix/pgsql/virtual_mailbox_maps.cf @@ -0,0 +1,5 @@ +hosts = PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT +user = PH_VMAIL_DB_BIND_USER +password = PH_VMAIL_DB_BIND_PASSWD +dbname = PH_VMAIL_DB_NAME +query = SELECT (mailbox.storagenode || '/' || mailbox.maildir || '/Maildir/') FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.active=1 AND mailbox.enabledeliver=1 AND domain.domain = mailbox.domain AND domain.active=1 diff --git a/iredmail/samples/postfix/postscreen_access.cidr b/iredmail/samples/postfix/postscreen_access.cidr new file mode 100644 index 0000000..20b00cc --- /dev/null +++ b/iredmail/samples/postfix/postscreen_access.cidr @@ -0,0 +1,6 @@ +# Rules are evaluated in the order as specified. +#1.2.3.4 permit +#2.3.4.5 reject + +# Permit local clients +127.0.0.0/8 permit diff --git a/iredmail/samples/postgresql/sql/add_first_domain_and_user.sql b/iredmail/samples/postgresql/sql/add_first_domain_and_user.sql new file mode 100644 index 0000000..3aa2a47 --- /dev/null +++ b/iredmail/samples/postgresql/sql/add_first_domain_and_user.sql @@ -0,0 +1,34 @@ +-- Connect as vmailadmin +-- \c PH_VMAIL_DB_NAME PH_VMAIL_DB_ADMIN_USER; +\c PH_VMAIL_DB_NAME; + +-- Add your first domain +INSERT INTO domain (domain, transport, settings, created) + VALUES ('PH_FIRST_DOMAIN', 'PH_TRANSPORT', 'default_user_quota:1024;', NOW()); + +-- Add your first normal user +INSERT INTO mailbox (username, + password, + name, + maildir, + quota, + domain, + isadmin, + isglobaladmin, + created) + VALUES ('PH_DOMAIN_ADMIN_EMAIL', + 'PH_DOMAIN_ADMIN_PASSWD_HASH', + 'PH_DOMAIN_ADMIN_NAME', + 'PH_DOMAIN_ADMIN_MAILDIR_HASH_PART', + 1024, + 'PH_FIRST_DOMAIN', + 1, + 1, + NOW()); + +INSERT INTO forwardings (address, forwarding, domain, dest_domain, is_forwarding) + VALUES ('PH_DOMAIN_ADMIN_EMAIL', 'PH_DOMAIN_ADMIN_EMAIL', 'PH_FIRST_DOMAIN', 'PH_FIRST_DOMAIN', 1); + +-- Mark first mail user as global admin +INSERT INTO domain_admins (username, domain, created) + VALUES ('PH_DOMAIN_ADMIN_EMAIL', 'ALL', NOW()); diff --git a/iredmail/samples/postgresql/sql/grant_permissions.sql b/iredmail/samples/postgresql/sql/grant_permissions.sql new file mode 100644 index 0000000..68add17 --- /dev/null +++ b/iredmail/samples/postgresql/sql/grant_permissions.sql @@ -0,0 +1,7 @@ +\c PH_VMAIL_DB_NAME; + +-- Set correct privilege for ROLE: vmail +GRANT SELECT ON admin, alias, alias_domain, domain, domain_admins, mailbox, maillists, recipient_bcc_domain, recipient_bcc_user, sender_bcc_domain, sender_bcc_user, anyone_shares, share_folder, deleted_mailboxes, sender_relayhost, forwardings, moderators TO PH_VMAIL_DB_BIND_USER; + +-- Update per-user real-time mailbox usage +GRANT SELECT, UPDATE, INSERT, DELETE ON used_quota TO PH_VMAIL_DB_BIND_USER; diff --git a/iredmail/samples/postgresql/sql/init_vmail_db.sql b/iredmail/samples/postgresql/sql/init_vmail_db.sql new file mode 100644 index 0000000..9c4489e --- /dev/null +++ b/iredmail/samples/postgresql/sql/init_vmail_db.sql @@ -0,0 +1,11 @@ +-- Crete role: vmail, read-only. +CREATE USER PH_VMAIL_DB_BIND_USER WITH ENCRYPTED PASSWORD 'PH_VMAIL_DB_BIND_PASSWD' NOSUPERUSER NOCREATEDB NOCREATEROLE; + +-- Create role: vmailadmin, read + write. +CREATE USER PH_VMAIL_DB_ADMIN_USER WITH ENCRYPTED PASSWORD 'PH_VMAIL_DB_ADMIN_PASSWD' NOSUPERUSER NOCREATEDB NOCREATEROLE; + +-- Create database to store mail accounts +CREATE DATABASE PH_VMAIL_DB_NAME WITH TEMPLATE template0 ENCODING 'UTF8'; + +-- Grant privilege +ALTER DATABASE PH_VMAIL_DB_NAME OWNER TO PH_VMAIL_DB_ADMIN_USER; diff --git a/iredmail/samples/roundcubemail/config.inc.php b/iredmail/samples/roundcubemail/config.inc.php new file mode 100644 index 0000000..485a60b --- /dev/null +++ b/iredmail/samples/roundcubemail/config.inc.php @@ -0,0 +1,71 @@ + array( + 'verify_peer' => false, + 'verify_peer_name' => false, + ), +); + +// SMTP +$config['smtp_server'] = 'tls://PH_SMTP_SERVER'; +$config['smtp_port'] = 587; +$config['smtp_user'] = '%u'; +$config['smtp_pass'] = '%p'; +$config['smtp_auth_type'] = 'LOGIN'; +// Required if you're running PHP 5.6 or later +$config['smtp_conn_options'] = array( + 'ssl' => array( + 'verify_peer' => false, + 'verify_peer_name' => false, + ), +); + +// Use user's identity as envelope sender for 'return receipt' responses, +// otherwise it will be rejected by iRedAPD plugin `reject_null_sender`. +$config['mdn_use_from'] = true; + +// SYSTEM +$config['force_https'] = true; +$config['login_autocomplete'] = 2; +$config['ip_check'] = true; +$config['des_key'] = 'PH_RCM_DES_KEY'; +$config['cipher_method'] = 'AES-256-CBC'; +$config['useragent'] = 'Roundcube Webmail'; // Hide version number +//$config['username_domain'] = 'PH_FIRST_DOMAIN'; +//$config['mime_types'] = '/etc/mime.types'; +$config['max_message_size'] = 'PH_MESSAGE_SIZE_LIMIT_MBM'; + +// USER INTERFACE +$config['create_default_folders'] = true; +$config['quota_zero_as_unlimited'] = true; +$config['spellcheck_engine'] = 'pspell'; + +// USER PREFERENCES +$config['default_charset'] = 'UTF-8'; +//$config['addressbook_sort_col'] = 'name'; +$config['draft_autosave'] = 60; +$config['default_list_mode'] = 'threads'; +$config['autoexpand_threads'] = 2; +$config['check_all_folders'] = true; +$config['default_font_size'] = '12pt'; +$config['message_show_email'] = true; +$config['layout'] = 'widescreen'; // three columns +//$config['skip_deleted'] = true; + +// PLUGINS +$config['plugins'] = array('managesieve', 'password'); + diff --git a/iredmail/samples/roundcubemail/global_ldap_address_book.inc.php b/iredmail/samples/roundcubemail/global_ldap_address_book.inc.php new file mode 100644 index 0000000..d76c299 --- /dev/null +++ b/iredmail/samples/roundcubemail/global_ldap_address_book.inc.php @@ -0,0 +1,58 @@ +// Global LDAP address book. +$config['ldap_public']["global_ldap_abook"] = array( + 'name' => 'Global LDAP Address Book', + 'hosts' => array('PH_LDAP_SERVER_HOST'), + 'port' => PH_LDAP_SERVER_PORT, + 'use_tls' => false, + 'ldap_version' => '3', + 'network_timeout' => 10, + 'user_specific' => true, + + // Search mail users under same domain. + 'base_dn' => 'domainName=%d,PH_LDAP_BASEDN', + 'bind_dn' => 'mail=%u@%d,ou=Users,domainName=%d,PH_LDAP_BASEDN', + + 'hidden' => false, + 'searchonly' => false, + 'writable' => false, + + 'search_fields' => array('mail', 'cn', 'sn', 'givenName', 'street', 'telephoneNumber', 'mobile', 'stree', 'postalCode'), + + // mapping of contact fields to directory attributes + 'fieldmap' => array( + 'name' => 'cn', + 'surname' => 'sn', + 'firstname' => 'givenName', + 'title' => 'title', + 'email' => 'mail:*', + 'phone:work' => 'telephoneNumber', + 'phone:mobile' => 'mobile', + 'phone:workfax' => 'facsimileTelephoneNumber', + 'street' => 'street', + 'zipcode' => 'postalCode', + 'locality' => 'l', + 'department' => 'departmentNumber', + 'notes' => 'description', + 'photo' => 'jpegPhoto', + ), + 'sort' => 'cn', + 'scope' => 'sub', + 'filter' => '(&(enabledService=mail)(enabledService=deliver)(enabledService=displayedInGlobalAddressBook)(|(objectClass=mailUser)(objectClass=mailList)(objectClass=mailAlias)))', + '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 + + 'group_filters' => array( + 'departments' => array( + 'name' => 'Mailing Lists', + 'scope' => 'sub', + 'base_dn' => 'domainName=%d,PH_LDAP_BASEDN', + 'filter' => '(&(|(objectclass=mailList)(objectClass=mailAlias))(accountStatus=active)(enabledService=displayedInGlobalAddressBook))', + 'name_attr' => 'cn', + 'email' => 'mail', + ), + ), +); +$config['autocomplete_addressbooks'] = array('sql', 'global_ldap_abook'); diff --git a/iredmail/samples/rsyslog.d/1-iredmail-dovecot.conf b/iredmail/samples/rsyslog.d/1-iredmail-dovecot.conf new file mode 100644 index 0000000..6571f7f --- /dev/null +++ b/iredmail/samples/rsyslog.d/1-iredmail-dovecot.conf @@ -0,0 +1,23 @@ +# Debug +if $syslogfacility-text == 'PH_IREDMAIL_SYSLOG_FACILITY' and ($msg contains ": Debug:") then -PH_DOVECOT_LOG_FILE +& stop + +# sieve and LMTP +if $syslogfacility-text == 'PH_IREDMAIL_SYSLOG_FACILITY' and ($msg contains "lmtp(" or $msg contains "lda(") then -PH_DOVECOT_SYSLOG_FILE_LDA +& stop + +# IMAP +if $syslogfacility-text == 'PH_IREDMAIL_SYSLOG_FACILITY' and ($msg contains "imap(" or $msg contains "imap-login:") then -PH_DOVECOT_SYSLOG_FILE_IMAP +& stop + +# POP3 +if $syslogfacility-text == 'PH_IREDMAIL_SYSLOG_FACILITY' and ($msg contains "pop3(" or $msg contains "pop3-login:") then -PH_DOVECOT_SYSLOG_FILE_POP3 +& stop + +# managesieve +if $syslogfacility-text == 'PH_IREDMAIL_SYSLOG_FACILITY' and ($msg contains "managesieve(" or $msg contains "managesieve-login:") then -PH_DOVECOT_SYSLOG_FILE_SIEVE +& stop + +# All other Dovecot log +if $syslogfacility-text == 'PH_IREDMAIL_SYSLOG_FACILITY' and $programname startswith "dovecot" then -PH_DOVECOT_LOG_FILE +& stop diff --git a/iredmail/samples/rsyslog.d/1-iredmail-fail2ban.conf b/iredmail/samples/rsyslog.d/1-iredmail-fail2ban.conf new file mode 100755 index 0000000..1c9361f --- /dev/null +++ b/iredmail/samples/rsyslog.d/1-iredmail-fail2ban.conf @@ -0,0 +1,2 @@ +if $programname startswith 'fail2ban' or ($programname == 'journal' and $msg startswith 'fail2ban') then -PH_FAIL2BAN_LOG_FILE +& stop diff --git a/iredmail/samples/rsyslog.d/1-iredmail-iredapd.conf b/iredmail/samples/rsyslog.d/1-iredmail-iredapd.conf new file mode 100644 index 0000000..8afcdd6 --- /dev/null +++ b/iredmail/samples/rsyslog.d/1-iredmail-iredapd.conf @@ -0,0 +1,12 @@ +# Log to /var/log/iredapd/iredapd.log +# +# Notes: +# +# - $syslogfacility-text must be same as value of parameter SYSLOG_FACILITY +# in iredapd config file. Defaults to 'local5' (defined in +# libs/default_settings.py). +# +# - Directory /var/log/iredapd/ must be owned by syslog daemon user/group. +# +if $syslogfacility-text == 'PH_IREDMAIL_SYSLOG_FACILITY' and ($syslogtag startswith 'iredapd' or $msg startswith 'iredapd') then -PH_IREDAPD_LOG_FILE +& stop diff --git a/iredmail/samples/rsyslog.d/1-iredmail-mlmmjadmin.conf b/iredmail/samples/rsyslog.d/1-iredmail-mlmmjadmin.conf new file mode 100644 index 0000000..88d239d --- /dev/null +++ b/iredmail/samples/rsyslog.d/1-iredmail-mlmmjadmin.conf @@ -0,0 +1,12 @@ +# Log to /var/log/mlmmjadmin/mlmmjadmin.log +# +# Notes: +# +# - $syslogfacility-text must be same as value of parameter SYSLOG_FACILITY +# in mlmmjadmin config file. Defaults to 'local5' (defined in +# libs/default_settings.py). +# +# - Directory /var/log/mlmmjadmin/ must be owned by syslog daemon user/group. +# +if $syslogfacility-text == 'PH_IREDMAIL_SYSLOG_FACILITY' and $programname startswith 'mlmmjadmin' then -PH_MLMMJADMIN_LOG_FILE +& stop diff --git a/iredmail/samples/rsyslog.d/1-iredmail-openldap.conf b/iredmail/samples/rsyslog.d/1-iredmail-openldap.conf new file mode 100644 index 0000000..880800d --- /dev/null +++ b/iredmail/samples/rsyslog.d/1-iredmail-openldap.conf @@ -0,0 +1,2 @@ +if $syslogfacility-text == 'PH_OPENLDAP_SYSLOG_FACILITY' and $programname == 'slapd' then -PH_OPENLDAP_LOG_FILE +& stop diff --git a/iredmail/samples/rsyslog.d/1-iredmail-phpfpm.conf b/iredmail/samples/rsyslog.d/1-iredmail-phpfpm.conf new file mode 100644 index 0000000..5791508 --- /dev/null +++ b/iredmail/samples/rsyslog.d/1-iredmail-phpfpm.conf @@ -0,0 +1,3 @@ +# php-fpm +if $syslogfacility-text == 'PH_IREDMAIL_SYSLOG_FACILITY' and $syslogtag startswith 'php-fpm' then -PH_PHP_FPM_LOG_MAIN +& stop diff --git a/iredmail/samples/sogo/sogo.conf b/iredmail/samples/sogo/sogo.conf new file mode 100644 index 0000000..6d7e64b --- /dev/null +++ b/iredmail/samples/sogo/sogo.conf @@ -0,0 +1,389 @@ +{ + // + // - Official SOGo document: http://sogo.nu/support/index.html#/documentation + // - Mailing list: http://sogo.nu/support/index.html#/community + // + + // Daemon address and port + WOPort = PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT; + + // PID file + //WOPidFile = PH_SOGO_PID_FILE; + + // Log file + //WOLogFile = PH_SOGO_LOG_FILE; + + // Enable verbose logging. Reference: + // http://www.sogo.nu/nc/support/faq/article/how-to-enable-more-verbose-logging-in-sogo.html + //SOGoDebugRequests = YES; + //SOGoEASDebugEnabled = YES; + //ImapDebugEnabled = YES; + //LDAPDebugEnabled = YES; + //MySQL4DebugEnabled = YES; + //PGDebugEnabled = YES; + + // Define the URL to online help for SOGo. When set, an additional icon + // will appear near the logout button in SOGo's web interface. The URL + // will always be open in a blank target. + //SOGoHelpURL = ''; + + // set the maximum allowed size for content being sent to SOGo, this can + // also limit the file attachment size being uploaded to SOGo when + // composing a mail. + // The value is in kilobyte. Default is 0 or disabled (unlimit). + WOMaxUploadSize = PH_MESSAGE_SIZE_LIMIT_KB; + + // Parameter used to set the maximum allowed email message size when + // composing a mail. + // The value is in kilobytes. By default, the value is 0, or disabled so + // no limit will be set. + SOGoMaximumMessageSizeLimit = PH_MESSAGE_SIZE_LIMIT_KB; + + // Performance Tuning + // + // The amount of instances of SOGo that will be spawned to handle multiple + // requests simultaneously. When started from the init script, that amount + // is overriden by the `PREFORK=` setting in /etc/sysconfig/sogo or + // /etc/default/sogo. A value of 3 is a reasonable default for low usage. + // The maximum value depends on the CPU and IO power provided by your + // machine: a value set too high will actually decrease performances under + // high load. + // + // You should have at least one child per EAS device configured to use + // "push". You must also have more children than you have EAS devices + // configured to use "push" - in order to handle normal SOGo requests to + // its Web or DAV interfaces. + // + // Defaults to 1 when unset, increase it if you see below error message in + // sogo log file: 'No child available to handle incoming request' + // + // WARNING: + // - on RHEL/CentOS, this setting is controlled by parameter + // 'PREFORK=' defined in /etc/sysconfig/sogo. + // - on Debian/Ubuntu, this setting is controlled by parameter + // 'PREFORK=' defined in /etc/default/sogo. + WOWorkersCount = 10; + + // Parameter used to set the maximum amount of time, in seconds, SOGo will + // wait before replying to a Ping command. + // If not set, it defaults to 10 seconds. + SOGoMaximumPingInterval = PH_SOGO_PROXY_TIMEOUT; + + // Parameter used to set the maximum amount of time, in seconds, SOGo will + // wait before replying to a Sync command. + // If not set, it defaults to 30 seconds. + SOGoMaximumSyncInterval = PH_SOGO_PROXY_TIMEOUT; + + // Parameter used to set the maximum amount of time, in seconds, SOGo will + // wait before doing an internal check for data changes (add, delete, and + // update). This parameter must be lower than SOGoMaximumSyncInterval and + // SOGoMaximumPingInterval. + // If not set, it defaults to 10 seconds. + SOGoInternalSyncInterval = 30; + + // Specifies the number of minutes after which a busy child process will be + // killed by the parent process. + // Defaults to 10 (minutes). + WOWatchDogRequestTimeout = PH_SOGO_WATCHDOG_REQUEST_TIMEOUT; + + // Overwrite the maximum number of items returned during a Sync operation. + // Defaults to 0, which means no overwrite is performed. + // Setting this parameter to a value greater than 512 will have unexpected + // behaviour with various ActiveSync clients. + //SOGoMaximumSyncWindowSize = 100; + + // Overwrite the maximum response size during a Sync operation. + // The value is in kilobytes. Setting this to 512 means the response size + // will be of 524288 bytes or less (or a bit greater if needed for syncing + // one item). Note that if you set the value too low and a mail message + // (or any other object like calendar events, tasks and contacts) surpasses + // it, it will still be synced but only this item will be. + // Defaults to 0, which means no overwrite is performed. + // + // Say you have these five mails and you set the limit to 512KB: + // 1. 250 KB + // 2. 250 KB + // 3. 25 KB + // 4. 750 KB + // 5. 10 KB + // Sync iteration no. 1 will pick message 1, 2 and 3. + // Sync iteration no. 2 will pick message 4. + // Sync iteration no. 3 will pick message 5. + SOGoMaximumSyncResponseSize = 2048; + + // The maximum amount of memory (in megabytes) that a child can use. + // Reaching that value will force children processes to restart, in order + // to preserve system memory. + // + // Error message when it reaches the value: + // "terminating app, vMem size limit (xxx MB) has been reached (currently xxx MB)" + // + // Defaults to 384. + SxVMemLimit = 500; + + // Enable XSRF (also known as CSRF) protection. + SOGoXSRFValidationEnabled = YES; + + // IMAP connection pool. + // Your performance will slightly increase, as you won't open a new + // connection for every access to your IMAP server. + // But you will get a lot of simultaneous open connections to your IMAP + // server, so make sure he can handle them. + // For debugging it is reasonable to turn pooling off. + NGImap4DisableIMAP4Pooling = NO; + + SOGoProfileURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_TABLE_USER_PROFILE"; + OCSFolderInfoURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_TABLE_FOLDER_INFO"; + OCSSessionsFolderURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_TABLE_SESSIONS_FOLDER"; + OCSEMailAlarmsFolderURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_TABLE_ALARMS"; + + // With 3 parameters below, SOGo requires only 9 SQL tables in total + // instead of creating 4 SQL tables for each user. + OCSCacheFolderURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_TABLE_CACHE_FOLDER"; + OCSStoreURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_TABLE_STORE"; + OCSAclURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_TABLE_ACL"; + + // Default language in the web interface + SOGoLanguage = English; + + // Specify which module to show after login: Calendar, Mail, Contacts. + SOGoLoginModule = Mail; + + // Must login with full email address + SOGoForceExternalLoginWithEmail = YES; + + // Allow user to change full name and email address. + SOGoMailCustomFromEnabled = NO; + + // IMAP server + // Local connection is considered as secure by Dovecot, so 'imap://' is fine. + // With remote IMAP server, use 'imaps://PH_IMAP_SERVER:143/?tls=YES' instead; + SOGoIMAPServer = "imap://PH_IMAP_SERVER:143/"; + + // Allow user to add other IMAP accounts that will be visible from the SOGo + // Webmail interface. + // Default is NO. + //SOGoMailAuxiliaryUserAccountsEnabled = YES; + + // SMTP server + SOGoSMTPServer = PH_SMTP_SERVER; + SOGoMailingMechanism = smtp; + //SOGoSMTPAuthenticationType = PLAIN; + + // Enable managesieve service + // + // WARNING: Sieve scripts generated by SOGo is not compatible with Roundcube + // webmail, don't use sieve service in both webmails, otherwise + // it will be messy. + // FYI: https://docs.iredmail.org/why.no.sieve.support.in.sogo.html + // + //SOGoSieveServer = "sieve://PH_MANAGESIEVE_SERVER:PH_MANAGESIEVE_PORT/?tls=YES"; + //SOGoSieveScriptsEnabled = YES; + //SOGoVacationEnabled = YES; + //SOGoForwardEnabled = YES; + SOGoSieveFolderEncoding = UTF-8; + + // Memcached + SOGoMemcachedHost = PH_MEMCACHED_BIND_ADDRESS; + + // Parameter used to set which usernames require administrative privileges + // over all the users tables. For example, this could be used to post + // events in the users calendar without requiring the user to configure + // his/her ACLs. In this case you will need to specify those superuser's + // usernames like this : + // SOGoSuperUsernames = ([,, ...]); + //SOGoSuperUsernames = (); + + SOGoTimeZone = "America/New_York"; + + SOGoFirstDayOfWeek = 1; + + SOGoRefreshViewCheck = every_5_minutes; + SOGoMailReplyPlacement = below; + + // Disable gravatar + SOGoExternalAvatarsEnabled = NO; + SOGoGravatarEnabled = NO; + + // Control WebDAV access to the Calendar / Contacts collections. + // This can be used to deny access to these resources from Thunderbird + // Lightning for example. + // Defaults to YES when unset. + //SOGoCalendarDAVAccessEnabled = NO; + //SOGoAddressBookDAVAccessEnabled = NO; + + // Allow users to share publicly (ie., requiring not authentication) their + // calendars and address books. + // Defaults to NO when unset. + //SOGoEnablePublicAccess = YES; + + // + // Notifications + // + // Enable email-based alarms on events and tasks. + SOGoEnableEMailAlarms = YES; + + // Notify meeting participants + SOGoAppointmentSendEMailNotifications = YES; + + // Notify if a calendar or an address book has been created. + SOGoFoldersSendEMailNotifications = NO; + + // Notify involved users of a calendar or address book's ACLs. + SOGoACLsSendEMailNotifications = YES; + + // Notify when a modification is being done to his/her own calendar by someone else. + SOGoNotifyOnExternalModifications = YES; + + // NOTE: PostgreSQL cannot update view in iRedMail + SOGoPasswordChangeEnabled = YES; + + // Authentication using SQL + /* SQL backend + SOGoUserSources = ( + { + type = sql; + id = users; + viewURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_VIEW_AUTH"; + canAuthenticate = YES; + + // The algorithm used for password encryption when changing + // passwords without Password Policies enabled. + // Possible values are: plain, crypt, md5-crypt, ssha, ssha512. + userPasswordAlgorithm = ssha512; + prependPasswordScheme = YES; + + // Use `vmail.mailbox` as per-domain address book. + isAddressBook = YES; + displayName = "Domain Address Book"; + SOGoEnableDomainBasedUID = YES; + DomainFieldName = "domain"; + + // Listing of this LDAP source is only possible when performing a + // search (respecting the SOGoSearchMinimumWordLength parameter) + // or when explicitely typing a single dot. + // Defaults to YES when unset. + // + // WARNING: if you have many accounts in this address book, it may + // reach server-side query size limit, or cause + // performance issue. + listRequiresDot = NO; + }, + + //{ + // displayName = "Global Address Book"; + // type = sql; + // id = global_address_book; + // viewURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_VIEW_AUTH"; + // canAuthenticate = NO; + // isAddressBook = YES; + // listRequiresDot = NO; + // SOGoEnableDomainBasedUID = YES; + // DomainFieldName = "domain"; + //}, + + // Display mailing aliases in address book. + // You need to create SQL view 'sogo.aliases' first. + // + // For MySQL: + // + // CREATE VIEW sogo.aliases (c_uid, c_name, c_password, c_cn, mail, domain) + // AS SELECT address, name, '', name, address, domain + // FROM vmail.alias WHERE active=1; + // + //{ + // displayName = "Mailing Lists"; + // type = sql; + // id = aliases; + // viewURL = "PH_SOGO_DB_TYPE://PH_SOGO_DB_USER:PH_SOGO_DB_PASSWD@PH_SQL_SERVER_ADDRESS:PH_SQL_SERVER_PORT/PH_SOGO_DB_NAME/PH_SOGO_DB_VIEW_ALIASES"; + // canAuthenticate = NO; + // isAddressBook = YES; + // listRequiresDot = NO; + // SOGoEnableDomainBasedUID = YES; + // DomainFieldName = "domain"; + //}, + ); + SQL backend */ + + // Authentication using LDAP + /* LDAP backend + SOGoUserSources = ( + { + // Used for user authentication + type = ldap; + id = users; + canAuthenticate = YES; + isAddressBook = NO; + displayName = "LDAP Authentication"; + + hostname = "PH_LDAP_URI"; + baseDN = "domainName=%d,PH_LDAP_BASEDN"; + bindDN = "PH_LDAP_BINDDN"; + bindPassword = "PH_LDAP_BINDPW"; + filter = "objectClass=mailUser AND accountStatus=active AND enabledService=mail AND enabledService=sogo"; + scope = SUB; + + // always keep binding to the LDAP server using the DN of the + // currently authenticated user. bindDN and bindPassword are still + // required to find DN of the user. + // Note: with default LDAP acl configured by iRedMail, user doesn't + // have privilege to query PH_LDAP_BASEDN. + // so this doesn't work. + bindAsCurrentUser = YES; + + // The algorithm used for password encryption when changing + // passwords without Password Policies enabled. + // Possible values are: plain, crypt, md5-crypt, ssha, ssha512. + userPasswordAlgorithm = ssha512; + + CNFieldName = cn; + IDFieldName = mail; + // value of UIDFieldName must be unique on entire server + UIDFieldName = mail; + IMAPLoginFieldName = mail; + MailFieldNames = (mail); + bindFields = (mail); + }, + { + // Used for global address book + type = ldap; + id = global_addressbook; + canAuthenticate = NO; + isAddressBook = YES; + displayName = "Global Address Book"; + bindAsCurrentUser = YES; + + // Listing of this LDAP source is only possible when performing a + // search (respecting the SOGoSearchMinimumWordLength parameter) + // or when explicitely typing a single dot. + // Defaults to YES when unset. + // + // WARNING: if you have many accounts in this address book, it may + // reach server-side query size limit, or cause + // performance issue. + listRequiresDot = NO; + + hostname = "PH_LDAP_URI"; + baseDN = "domainName=%d,PH_LDAP_BASEDN"; + bindDN = "PH_LDAP_BINDDN"; + bindPassword = "PH_LDAP_BINDPW"; + filter = "((enabledService=mail AND accountStatus=active AND enabledService=displayedInGlobalAddressBook) AND ((objectClass=mailUser AND enabledService=sogo) OR (objectClass=mailList) OR (objectClass=mailAlias)))"; + scope = SUB; + + IDFieldName = mail; + bindFields = (mail); + // value of UID field must be unique on whole server. + UIDFieldName = mail; + IMAPLoginFieldName = mail; + + CNFieldName = cn; + SearchFieldNames = (cn, sn, displayName, telephoneNumber, mail, shadowAddress, departmentNumber); + + // Resources management (Free/Busy) + // Reference: https://docs.iredmail.org/sogo.manage.resources.html + KindFieldName = "Kind"; + MultipleBookingsFieldName = "MultipleBookings"; + } + ); + LDAP backend */ +} diff --git a/iredmail/samples/sogo/sogo.cron b/iredmail/samples/sogo/sogo.cron new file mode 100644 index 0000000..282bd79 --- /dev/null +++ b/iredmail/samples/sogo/sogo.cron @@ -0,0 +1,6 @@ +# SOGo session cleanup and email reminder, should be run every minute. +* * * * * PH_SOGO_CMD_TOOL expire-sessions 30 >/dev/null 2>&1; PH_SOGO_CMD_EALARMS_NOTIFY >/dev/null 2>&1 + +# SOGo vacation messages expiration +# The credentials file should contain the sieve admin credentials (username:passwd) +0 0 * * * PH_SOGO_CMD_TOOL update-autoreply -p PH_SOGO_SIEVE_CREDENTIAL_FILE >/dev/null 2>&1 diff --git a/iredmail/samples/spamassassin/local.cf b/iredmail/samples/spamassassin/local.cf new file mode 100644 index 0000000..c2a3cad --- /dev/null +++ b/iredmail/samples/spamassassin/local.cf @@ -0,0 +1,186 @@ +#--------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------- + +# +# Sample SpamAssassin rules. It should be located at: +# /etc/mail/spamassassin/local.cf +# +# Shipped within iRedMail project: +# * http://iRedMail.googlecode.com/ +# +# See also: +# $ man Mail::SpamAssassin::Conf +# + + +# These two lines will not affect due to Amavisd use its +# own variables setting in /etc/amavisd.conf. +required_score 5.0 +rewrite_header subject [ SPAM ] + +report_safe 0 +lock_method flock + +# +# Bayesian support +# +# References: +# - http://wiki.apache.org/spamassassin/BayesInSpamAssassin +# - http://svn.apache.org/repos/asf/spamassassin/branches/3.3/sql/README.bayes +# Addition plugin for Roundcube webmail to call sa-learn +# - http://www.tehinterweb.co.uk/roundcube/#pimarkasjunk2 +# +use_bayes 1 +bayes_auto_learn 1 +bayes_auto_expire 1 + +# Store bayesian data in MySQL. +# Please make sure you have correct server address, port and database name. +#bayes_store_module Mail::SpamAssassin::BayesStore::MySQL +#bayes_sql_dsn DBI:mysql:sa_bayes:127.0.0.1:3306 + +# Store bayesian data in PostgreSQL. +# Please make sure you have correct server address, port and database name. +#bayes_store_module Mail::SpamAssassin::BayesStore::PgSQL +#bayes_sql_dsn DBI:Pg:database=sa_bayes;host=127.0.0.1;port=5432 + +# SQL username and password. +#bayes_sql_username db_username +#bayes_sql_password db_password + +# Override the username used for storing data in the database. +# This could be used to group users together to share bayesian filter data. +# You can also use this config option to trick sa-learn to learn data as a specific user. +#bayes_sql_override_username vmail + +# Increase score for message which contains blacklisted or phishing URI +# URIBL +#score URIBL_SBL 3 +# dbl.spamhaus.org +#score URIBL_DBL_SPAM 3 +#score URIBL_DBL_PHISH 3 +#score URIBL_DBL_MALWARE 3 +#score URIBL_DBL_BOTNETCC 3 +#score URIBL_DBL_ABUSE_SPAM 3 +#score URIBL_DBL_ABUSE_REDIR 3 +#score URIBL_DBL_ABUSE_PHISH 3 +#score URIBL_DBL_ABUSE_MALW 3 +#score URIBL_DBL_ABUSE_BOTCC 3 +#score URIBL_DBL_ERROR 0 +# multi.surbl.org +#score URIBL_WS_SURBL 3 +#score URIBL_PH_SURBL 3 +#score URIBL_MW_SURBL 3 +#score URIBL_CR_SURBL 3 +#score URIBL_ABUSE_SURBL 3 +#score SURBL_BLOCKED 0 +# multi.urlbl.com +#score URIBL_BLACK 3 +#score URIBL_RED 3 +#score URIBL_BLOCKED 0 + +# DNSBL +#score RCVD_IN_SBL 5 +#score RCVD_IN_XBL 5 +#score RCVD_IN_PBL 5 + +# Turn off ALL DNSBL (DNS Blocklists) +#skip_rbl_checks 1 +# Turn off DNSBL: rhsbl.ahbl.org. +# Check /usr/share/spamassassin/20_dnsbl_teest.cf to see the rule name. +score DNS_FROM_AHBL_RHSBL 0 + +score URIBL_AB_SURBL 0 0.3306 0 0.3812 +score URIBL_JP_SURBL 0 0.3360 0 0.4087 +score URIBL_OB_SURBL 0 0.2617 0 0.3008 +score URIBL_PH_SURBL 0 0.2240 0 0.2800 +score URIBL_SBL 0 0.1094 0 0.1639 +score URIBL_SC_SURBL 0 0.3600 0 0.4498 +score URIBL_WS_SURBL 0 0.1533 0 0.2140 + +# For SpamAssassin-3.2.x. Reference: +# http://spamassassin.apache.org/full/3.2.x/doc/Mail_SpamAssassin_Plugin_SPF.html +#do_not_use_mail_spf 0 +#do_not_use_mail_spf_query 1 +#ignore_received_spf_header 1 + +# Trusted networks. Examples: +# 192.168/16 # all in 192.168.*.* +# 212.17.35.15 # just that host +# !10.0.1.5 10.0.1/24 # all in 10.0.1.* but not 10.0.1.5 +# DEAD:BEEF::/32 # all in that ipv6 prefix +# Local host (127.0.0.1) will automatically be trusted implicitly. +#trusted_networks 192.168/16 + +# Whitelist from SPF. +#whitelist_from_spf joe@example.com fred@example.com +#whitelist_from_spf *@example.com + +# Whitelist from DKIM. +loadplugin Mail::SpamAssassin::Plugin::DKIM +whitelist_from_dkim *@paypal.com +whitelist_from_dkim *@linkedin.com +whitelist_from_dkim *@twitter.com +whitelist_from_dkim *@bounce.twitter.com + +# Whitelist domains. +# Reference: http://wiki.apache.org/spamassassin/ManualWhitelist +#whitelist_from *@gmail.com + +# Locales. +ok_locales all + +# Some sample custom file rules. Refer to SpamAssassin wiki site for more +# details: http://wiki.apache.org/spamassassin/WritingRules +# +# Filter Headers. +# -- Subject +#header LOCAL_DEMONSTRATION_SUBJECT Subject =~ /\btest\b/i +#score LOCAL_DEMONSTRATION_SUBJECT 0.1 +# -- From +#header LOCAL_DEMONSTRATION_FROM From =~ /test\.com/i +#score LOCAL_DEMONSTRATION_FROM 0.1 +# -- Look at all the headers and match if any of them contain the specified regex: +#header LOCAL_DEMONSTRATION_ALL ALL =~ /test\.com/i +#score LOCAL_DEMONSTRATION_ALL 0.1 +# +# Filter mail body. +#body LOCAL_DEMONSTRATION_RULE /test/ +#score LOCAL_DEMONSTRATION_RULE 0.1 +#describe LOCAL_DEMONSTRATION_RULE This is a simple test rule + +# Decrease score for authenticated senders. +# IMPORTANT NOTES: +# +# 1) Please replace 'your\.server\.com' by the value of Postfix parameter +# "myhostname". +# 2) Please set 'smtpd_sasl_authenticated_header = yes' in Postfix main.cf. +# +#header AUTHENTICATED_SENDER Received =~ /Authenticated\ sender\:.*by\ your\.server\.com/ +#describe AUTHENTICATED_SENDER Header 'Received:' contains 'Authenticated sender:' +#score AUTHENTICATED_SENDER -3 + +# Checks if domain name of an envelope sender address matches the domain name +# of the first untrusted relay (if any), or any trusted relay otherwise. +# https://wiki.apache.org/spamassassin/Rules/RP_MATCHES_RCVD +score RP_MATCHES_RCVD 0 + +# SPF mismatch +score SPF_FAIL 5 + +razor_config PH_SA_PLUGIN_RAZOR_CONF diff --git a/iredmail/samples/spamassassin/razor.conf b/iredmail/samples/spamassassin/razor.conf new file mode 100644 index 0000000..b6170a9 --- /dev/null +++ b/iredmail/samples/spamassassin/razor.conf @@ -0,0 +1 @@ +debuglevel = 0 diff --git a/iredmail/samples/systemd/clamd.service.d/override.conf b/iredmail/samples/systemd/clamd.service.d/override.conf new file mode 100644 index 0000000..931c2aa --- /dev/null +++ b/iredmail/samples/systemd/clamd.service.d/override.conf @@ -0,0 +1,2 @@ +[Service] +TimeoutSec = 600 diff --git a/iredmail/samples/systemd/mariadb.service.d/override.conf b/iredmail/samples/systemd/mariadb.service.d/override.conf new file mode 100644 index 0000000..7f64aab --- /dev/null +++ b/iredmail/samples/systemd/mariadb.service.d/override.conf @@ -0,0 +1,3 @@ +# Reference: https://mariadb.com/kb/en/the-mariadb-library/server-system-variables/#open_files_limit +[Service] +LimitNOFILE=infinity diff --git a/iredmail/samples/systemd/slapd.service.d/override.conf b/iredmail/samples/systemd/slapd.service.d/override.conf new file mode 100644 index 0000000..c71ea8f --- /dev/null +++ b/iredmail/samples/systemd/slapd.service.d/override.conf @@ -0,0 +1,6 @@ +[Service] +# Clean the ExecStart first +ExecStart= + +# Re-define ExecStart +ExecStart=/usr/sbin/slapd -u PH_SYS_USER_LDAP -h "ldapi:/// ldap://PH_LDAP_SERVER_HOST:PH_LDAP_SERVER_PORT/" -f PH_OPENLDAP_SLAPD_CONF diff --git a/iredmail/samples/yum/CentOS-AppStream.repo b/iredmail/samples/yum/CentOS-AppStream.repo new file mode 100644 index 0000000..76b9e3b --- /dev/null +++ b/iredmail/samples/yum/CentOS-AppStream.repo @@ -0,0 +1,6 @@ +[AppStream] +name=CentOS-$releasever - AppStream +baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/ +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial diff --git a/iredmail/samples/yum/CentOS-PowerTools.repo b/iredmail/samples/yum/CentOS-PowerTools.repo new file mode 100644 index 0000000..0ae734d --- /dev/null +++ b/iredmail/samples/yum/CentOS-PowerTools.repo @@ -0,0 +1,6 @@ +[PowerTools] +name=CentOS-$releasever - PowerTools +baseurl=http://mirror.centos.org/$contentdir/$releasever/PowerTools/$basearch/os/ +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial diff --git a/iredmail/samples/yum/symas-openldap.repo b/iredmail/samples/yum/symas-openldap.repo new file mode 100644 index 0000000..ee4b73a --- /dev/null +++ b/iredmail/samples/yum/symas-openldap.repo @@ -0,0 +1,6 @@ +[symas-openldap] +name=Symas OpenLDAP for Linux RPM repository +baseurl=https://repo.symas.com/repo/rpm/SOFL/rhel8 +gpgkey=https://repo.symas.com/repo/gpg/RPM-GPG-KEY-symas-com-signing-key +gpgcheck=1 +enabled=1 diff --git a/iredmail/tools/backup_mysql.sh b/iredmail/tools/backup_mysql.sh new file mode 100644 index 0000000..f5f4b15 --- /dev/null +++ b/iredmail/tools/backup_mysql.sh @@ -0,0 +1,227 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin (zhb@iredmail.org) +# Date: 16/09/2007 +# Purpose: Backup specified mysql databases with command 'mysqldump'. +# License: This shell script is part of iRedMail project, released under +# GPL v2. + +########################### +# REQUIREMENTS +########################### +# +# * Required commands: +# + mysqldump +# + du +# + bzip2 # If bzip2 is not available, change 'CMD_COMPRESS' +# # to use 'gzip'. +# + +########################### +# USAGE +########################### +# +# * It stores all backup copies in directory '/var/vmail/backup' by default, +# You can change it in variable $BACKUP_ROOTDIR below. +# +# * Set correct values for below variables: +# +# BACKUP_ROOTDIR +# MYSQL_ROOT_USER +# DATABASES +# DB_CHARACTER_SET +# +# * Add crontab job for root user (or whatever user you want): +# +# # crontab -e -u root +# 1 4 * * * bash /path/to/backup_mysql.sh +# +# * Make sure 'crond' service is running, and will start automatically when +# system startup: +# +# # ---- On RHEL/CentOS ---- +# # chkconfig --level 345 crond on +# # /etc/init.d/crond status +# +# # ---- On Debian/Ubuntu ---- +# # update-rc.d cron defaults +# # /etc/init.d/cron status +# + +######################################################### +# Modify below variables to fit your need ---- +######################################################### +# Keep backup for how many days. Default is 90 days. +KEEP_DAYS='90' + +# Where to store backup copies. +export BACKUP_ROOTDIR='/var/vmail/backup' + +# MySQL username. Root user is required to dump all databases. +export MYSQL_ROOT_USER='root' + +# ~/.my.cnf +export MYSQL_DOT_MY_CNF='/root/.my.cnf' + +# Databases we should backup. +# Multiple databases MUST be seperated by SPACE. +export DATABASES='mysql vmail roundcubemail amavisd iredadmin sogo iredapd sa_bayes' + +# Database character set for ALL databases. +# Note: Currently, it doesn't support to specify character set for each databases. +export DB_CHARACTER_SET="utf8" + +######################################################### +# You do *NOT* need to modify below lines. +######################################################### +export PATH='/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin' + +# Commands. +export CMD_DATE='/bin/date' +export CMD_DU='du -sh' +export CMD_COMPRESS='bzip2 -9' +export COMPRESS_SUFFIX='bz2' +export CMD_MYSQL="mysql --defaults-file=${MYSQL_DOT_MY_CNF} -u${MYSQL_ROOT_USER}" +export CMD_MYSQLDUMP="mysqldump --defaults-file=${MYSQL_DOT_MY_CNF} -u${MYSQL_ROOT_USER} --events --ignore-table=mysql.event --default-character-set=${DB_CHARACTER_SET} --skip-comments" + +# Date. +export YEAR="$(${CMD_DATE} +%Y)" +export MONTH="$(${CMD_DATE} +%m)" +export DAY="$(${CMD_DATE} +%d)" +export TIME="$(${CMD_DATE} +%H-%M-%S)" +export TIMESTAMP="${YEAR}-${MONTH}-${DAY}-${TIME}" + +# Pre-defined backup status +export BACKUP_SUCCESS='YES' + +# Define, check, create directories. +export BACKUP_DIR="${BACKUP_ROOTDIR}/mysql/${YEAR}/${MONTH}/${DAY}" + +# Find the old backup which should be removed. +export REMOVE_OLD_BACKUP='YES' + +export KERNEL="$(uname -s)" +if [[ X"${KERNEL}" == X'Linux' ]]; then + shift_year=$(date --date="${KEEP_DAYS} days ago" "+%Y") + shift_month=$(date --date="${KEEP_DAYS} days ago" "+%m") + shift_day=$(date --date="${KEEP_DAYS} days ago" "+%d") +elif [[ X"${KERNEL}" == X'FreeBSD' ]]; then + shift_year=$(date -j -v-${KEEP_DAYS}d "+%Y") + shift_month=$(date -j -v-${KEEP_DAYS}d "+%m") + shift_day=$(date -j -v-${KEEP_DAYS}d "+%d") +elif [[ X"${KERNEL}" == X'OpenBSD' ]]; then + epoch_seconds_now="$(date +%s)" + epoch_shift="$((${KEEP_DAYS} * 86400))" + epoch_seconds_old="$((epoch_seconds_now - epoch_shift))" + + shift_year=$(date -r ${epoch_seconds_old} "+%Y") + shift_month=$(date -r ${epoch_seconds_old} "+%m") + shift_day=$(date -r ${epoch_seconds_old} "+%d") +else + export REMOVE_OLD_BACKUP='NO' +fi + +export REMOVED_BACKUP_DIR="${BACKUP_ROOTDIR}/mysql/${shift_year}/${shift_month}/${shift_day}" +export REMOVED_BACKUP_MONTH_DIR="${BACKUP_ROOTDIR}/mysql/${shift_year}/${shift_month}" +export REMOVED_BACKUP_YEAR_DIR="${BACKUP_ROOTDIR}/mysql/${shift_year}" + +# Log file +export LOGFILE="${BACKUP_DIR}/${TIMESTAMP}.log" + +# Verify MySQL connection. +${CMD_MYSQL} -e "show databases" &>/dev/null +if [ X"$?" != X"0" ]; then + echo "[ERROR] MySQL username or password is incorrect in file ${0}." 1>&2 + echo "Please fix them first." 1>&2 + + exit 255 +fi + +# Check and create directories. +[ ! -d ${BACKUP_DIR} ] && mkdir -p ${BACKUP_DIR} 2>/dev/null +chown root ${BACKUP_DIR} +chmod 0400 ${BACKUP_DIR} + +# Initialize log file. +echo "* Starting backup: ${TIMESTAMP}." >${LOGFILE} +echo "* Backup directory: ${BACKUP_DIR}." >>${LOGFILE} +chmod 0400 ${LOGFILE} + +# Backup. +echo "* Backing up databases: ${DATABASES}." >> ${LOGFILE} +for db in ${DATABASES}; do + #backup_db ${db} >>${LOGFILE} + + #if [ X"$?" == X"0" ]; then + # echo " - ${db} [DONE]" >> ${LOGFILE} + #else + # [ X"${BACKUP_SUCCESS}" == X'YES' ] && export BACKUP_SUCCESS='NO' + #fi + output_sql="${BACKUP_DIR}/${db}-${TIMESTAMP}.sql" + + # Check database existence + ${CMD_MYSQL} -e "USE ${db}" &>/dev/null + + if [ X"$?" == X'0' ]; then + # Dump + ${CMD_MYSQLDUMP} ${db} > ${output_sql} + chmod 0400 ${output_sql} + + if [ X"$?" == X'0' ]; then + # Get original SQL file size + original_size="$(${CMD_DU} ${output_sql} | awk '{print $1}')" + + # Compress + ${CMD_COMPRESS} ${output_sql} >>${LOGFILE} + chmod 0400 ${output_sql}.* + + if [ X"$?" == X'0' ]; then + rm -f ${output_sql} >> ${LOGFILE} + fi + + # Get compressed file size + compressed_file_name="${output_sql}.${COMPRESS_SUFFIX}" + compressed_size="$(${CMD_DU} ${compressed_file_name} | awk '{print $1}')" + + sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'Database: ${db}, size: ${compressed_size} (original: ${original_size})', 'cron_backup_sql', '127.0.0.1', UTC_TIMESTAMP());" + else + # backup failed + export BACKUP_SUCCESS='NO' + sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'Database backup failed: ${db}. Log: $(cat ${LOGFILE})', 'cron_backup_sql', '127.0.0.1', UTC_TIMESTAMP());" + fi + + # Log to SQL table `iredadmin.log`, so that global domain admins can + # check backup status (System -> Admin Log) + ${CMD_MYSQL} iredadmin -e "${sql_log_msg}" + fi +done + +# Append file size of backup files. +echo -e "* File size:\n----" >>${LOGFILE} +cd ${BACKUP_DIR} && \ +${CMD_DU} *${TIMESTAMP}*sql* >>${LOGFILE} +echo "----" >>${LOGFILE} + +echo "* Backup completed (Success? ${BACKUP_SUCCESS})." >>${LOGFILE} + +if [ X"${BACKUP_SUCCESS}" == X'YES' ]; then + echo "==> Backup completed successfully." +else + echo -e "==> Backup completed with !!!ERRORS!!!.\n" 1>&2 +fi + +if [ X"${REMOVE_OLD_BACKUP}" == X'YES' -a -d ${REMOVED_BACKUP_DIR} ]; then + echo -e "* Old backup found. Deleting: ${REMOVED_BACKUP_DIR}." >>${LOGFILE} + rm -rf ${REMOVED_BACKUP_DIR} >> ${LOGFILE} 2>&1 + + # Try to remove empty directory. + rmdir ${REMOVED_BACKUP_MONTH_DIR} 2>/dev/null + rmdir ${REMOVED_BACKUP_YEAR_DIR} 2>/dev/null + + sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'Remove old backup: ${REMOVED_BACKUP_DIR}.', 'cron_backup_sql', '127.0.0.1', UTC_TIMESTAMP());" + ${CMD_MYSQL} iredadmin -e "${sql_log_msg}" +fi + +echo "==> Detailed log (${LOGFILE}):" +echo "=========================" +cat ${LOGFILE} diff --git a/iredmail/tools/backup_openldap.sh b/iredmail/tools/backup_openldap.sh new file mode 100755 index 0000000..aaea941 --- /dev/null +++ b/iredmail/tools/backup_openldap.sh @@ -0,0 +1,230 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin (zhb@iredmail.org) +# Date: Mar 15, 2012 +# Purpose: Dump whole LDAP tree with command 'slapcat'. +# License: This shell script is part of iRedMail project, released under +# GPL v2. + +########################### +# REQUIREMENTS +########################### +# +# * Required commands: +# + slapcat +# + du +# + bzip2 # If bzip2 is not available, change 'CMD_COMPRESS' to use 'gzip'. +# + +########################### +# USAGE +########################### +# +# * It stores all backup copies in directory '/var/vmail/backup' by default, +# You can change it with variable $BACKUP_ROOTDIR below. +# +# * Set correct values for below variables: +# +# BACKUP_ROOTDIR +# +# * Add crontab job for root user (or whatever user you want): +# +# # crontab -e -u root +# 1 4 * * * bash /path/to/backup_openldap.sh +# +# * Make sure 'crond' service is running, and will start automatically when +# system startup: +# +# # ---- On RHEL/CentOS ---- +# # chkconfig --level 345 crond on +# # /etc/init.d/crond status +# +# # ---- On Debian/Ubuntu ---- +# # update-rc.d cron defaults +# # /etc/init.d/cron status +# + +############################### +# How to restore backup file: +############################### +# Please refer to wiki tutorial for detail steps: +# http://www.iredmail.org/docs/backup.restore.html +# + +######################################################### +# Modify below variables to fit your need ---- +######################################################### +# Where to store backup copies. +export BACKUP_ROOTDIR='/var/vmail/backup' + +# Keep backup for how many days. Default is 90 days. +export KEEP_DAYS='90' + +######################################################### +# You do *NOT* need to modify below lines. +######################################################### + +export PATH="$PATH:/usr/sbin:/usr/local/sbin/" + +# Commands. +export CMD_DATE='/bin/date' +export CMD_DU='du -sh' +export CMD_COMPRESS='bzip2 -9' +export COMPRESS_SUFFIX='bz2' +export CMD_MYSQL='mysql' + +# MySQL user and password, used to log backup status to sql table `iredadmin.log`. +# You can find password of SQL user 'iredadmin' in iRedAdmin config file 'settings.py'. +# +# If MYSQL_PASSWD is empty, read password from /root/.my.cnf instead. +export MYSQL_USER='root' +export MYSQL_PASSWD='' +export MYSQL_DOT_MY_CNF='/root/.my.cnf' + +if [ -f /etc/ldap/slapd.conf ]; then + export CMD_SLAPCAT='slapcat -f /etc/ldap/slapd.conf' +elif [ -f /etc/openldap/slapd.conf ]; then + export CMD_SLAPCAT='slapcat -f /etc/openldap/slapd.conf' +elif [ -f /usr/local/etc/openldap/slapd.conf ]; then + export CMD_SLAPCAT='slapcat -f /usr/local/etc/openldap/slapd.conf' +else + export CMD_SLAPCAT='slapcat' +fi + +# Date. +export YEAR="$(${CMD_DATE} +%Y)" +export MONTH="$(${CMD_DATE} +%m)" +export DAY="$(${CMD_DATE} +%d)" +export TIME="$(${CMD_DATE} +%H-%M-%S)" +export TIMESTAMP="${YEAR}-${MONTH}-${DAY}-${TIME}" + +# Pre-defined backup status +export BACKUP_SUCCESS='NO' + +######### +# Define, check, create directories. +# +# Backup directory. +export BACKUP_DIR="${BACKUP_ROOTDIR}/ldap/${YEAR}/${MONTH}" +export BACKUP_FILE="${BACKUP_DIR}/${TIMESTAMP}.ldif" + +# Find the old backup which should be removed. +export REMOVE_OLD_BACKUP='YES' + +export KERNEL="$(uname -s)" +if [[ X"${KERNEL}" == X'Linux' ]]; then + shift_year=$(date --date="${KEEP_DAYS} days ago" "+%Y") + shift_month=$(date --date="${KEEP_DAYS} days ago" "+%m") + shift_day=$(date --date="${KEEP_DAYS} days ago" "+%d") +elif [[ X"${KERNEL}" == X'FreeBSD' ]]; then + shift_year=$(date -j -v-${KEEP_DAYS}d "+%Y") + shift_month=$(date -j -v-${KEEP_DAYS}d "+%m") + shift_day=$(date -j -v-${KEEP_DAYS}d "+%d") +elif [[ X"${KERNEL}" == X'OpenBSD' ]]; then + epoch_seconds_now="$(date +%s)" + epoch_shift="$((${KEEP_DAYS} * 86400))" + epoch_seconds_old="$((epoch_seconds_now - epoch_shift))" + + shift_year=$(date -r ${epoch_seconds_old} "+%Y") + shift_month=$(date -r ${epoch_seconds_old} "+%m") + shift_day=$(date -r ${epoch_seconds_old} "+%d") +else + export REMOVE_OLD_BACKUP='NO' +fi + +export REMOVED_BACKUP_DIR="${BACKUP_ROOTDIR}/ldap/${shift_year}/${shift_month}" +export REMOVED_BACKUP_MONTH_DIR="${BACKUP_ROOTDIR}/ldap/${shift_year}/${shift_month}" +export REMOVED_BACKUP_YEAR_DIR="${BACKUP_ROOTDIR}/ldap/${shift_year}" +export REMOVED_BACKUPS="${BACKUP_ROOTDIR}/ldap/${shift_year}/${shift_month}/${shift_year}-${shift_month}-${shift_day}-*" + +# Log file +export LOGFILE="${BACKUP_DIR}/${TIMESTAMP}.log" + +# Check and create directories. +[ -d ${BACKUP_DIR} ] || mkdir -p ${BACKUP_DIR} +chown root ${BACKUP_DIR} +chmod 0700 ${BACKUP_DIR} + +# Initialize log file. +echo "* Starting backup at ${TIMESTAMP}" >> ${LOGFILE} +echo "* Backup directory: ${BACKUP_DIR}." >> ${LOGFILE} + +# Backup +echo "* Dumping LDAP data into file: ${BACKUP_FILE}..." >> ${LOGFILE} +${CMD_SLAPCAT} > ${BACKUP_FILE} + +if [ X"$?" == X"0" ]; then + export BACKUP_SUCCESS='YES' + + # Get original backup file size + original_size="$(${CMD_DU} ${BACKUP_FILE} | awk '{print $1}')" + + # Compress backup file. + echo "* Compressing LDIF file with command: '${CMD_COMPRESS}' ..." >> ${LOGFILE} + ${CMD_COMPRESS} ${BACKUP_FILE} >> ${LOGFILE} 2>&1 + + echo "* [DONE]" >>${LOGFILE} + + # Get compressed file size + compressed_file_name="${BACKUP_FILE}.${COMPRESS_SUFFIX}" + compressed_size="$(${CMD_DU} ${compressed_file_name} | awk '{print $1}')" + + echo -n "* Removing plain LDIF file: ${BACKUP_FILE}..." >>${LOGFILE} + rm -f ${BACKUP_FILE} >> ${LOGFILE} 2>&1 + [ X"$?" == X"0" ] && echo -e "\t[DONE]" >>${LOGFILE} + + sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'Backup LDAP data, size: ${original_size}, compressed: ${compressed_size}', 'cron_backup_ldap', '127.0.0.1', UTC_TIMESTAMP());" +else + # Log failure + sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'Backup LDAP data failed, check log file ${LOGFILE} for more details.', 'cron_backup_ldap', '127.0.0.1', UTC_TIMESTAMP());" +fi + +# Log to SQL table `iredadmin.log`, so that global domain admins can +# check backup status (System -> Admin Log) +export LOG_BACKUP_STATUS='YES' +if [[ -n ${MYSQL_USER} ]]; then + if [[ -n ${MYSQL_PASSWD} ]]; then + export CMD_MYSQL_ROOT="${CMD_MYSQL} -u${MYSQL_USER} -p${MYSQL_PASSWD}" + else + export CMD_MYSQL_ROOT="${CMD_MYSQL} --defaults-file=${MYSQL_DOT_MY_CNF} -u${MYSQL_USER}" + fi + + ${CMD_MYSQL_ROOT} -e "USE iredadmin;" &>/dev/null + if [[ X"$?" != X'0' ]]; then + export LOG_BACKUP_STATUS='NO' + fi +fi + +if [[ X"${LOG_BACKUP_STATUS}" == X'YES' ]]; then + ${CMD_MYSQL_ROOT} iredadmin -e "${sql_log_msg}" >>${LOGFILE} 2>&1 +fi + +# Append file size of backup files to log file. +echo "* File size:" >>${LOGFILE} +echo "=================" >>${LOGFILE} +${CMD_DU} ${BACKUP_FILE}* >>${LOGFILE} +echo "=================" >>${LOGFILE} + +# Print some message. It will cause cron generates an email to root user. +if [ X"${BACKUP_SUCCESS}" == X'YES' ]; then + echo "* [ OK ] Backup completes successfully." >> ${LOGFILE} +else + echo "* <<< ERROR >>> Backup not successfully complete." >> ${LOGFILE} +fi + +if [ X"${REMOVE_OLD_BACKUP}" == X'YES' -a -d ${REMOVED_BACKUP_DIR} ]; then + echo -e "* Delete old backup under ${REMOVED_BACKUP_DIR}." >> ${LOGFILE} + echo -e "* Suppose to delete: ${REMOVED_BACKUPS}" >> ${LOGFILE} + rm -rf ${REMOVED_BACKUPS} >> ${LOGFILE} 2>&1 + + # Try to remove empty directory. + rmdir ${REMOVED_BACKUP_MONTH_DIR} 2>/dev/null + rmdir ${REMOVED_BACKUP_YEAR_DIR} 2>/dev/null + + if [[ X"${LOG_BACKUP_STATUS}" == X'YES' ]]; then + sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'Remove old backup: ${REMOVED_BACKUPS}.', 'cron_backup_sql', '127.0.0.1', UTC_TIMESTAMP());" + ${CMD_MYSQL_ROOT} iredadmin -e "${sql_log_msg}" + fi +fi + +cat ${LOGFILE} diff --git a/iredmail/tools/backup_pgsql.sh b/iredmail/tools/backup_pgsql.sh new file mode 100644 index 0000000..6dda1e1 --- /dev/null +++ b/iredmail/tools/backup_pgsql.sh @@ -0,0 +1,205 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin (zhb _at_ iredmail.org) +# Date: 2012-09-06 +# Purpose: Backup specified PostgreSQL databases with command 'pg_dump'. +# License: This shell script is part of iRedMail project, released under GPLv2. + +########################### +# REQUIREMENTS +########################### +# +# * Required commands: +# + pg_dump +# + du +# + bzip2 # If bzip2 is not available, change 'CMD_COMPRESS' +# # to use 'gzip'. +# + +########################### +# USAGE +########################### +# +# * It stores all backup copies in directory '/var/vmail/backup' by default, +# You can change it in variable $BACKUP_ROOTDIR below. +# +# * Set correct values for below variables: +# +# SYS_USER_PGSQL +# BACKUP_ROOTDIR +# DATABASES +# +# * Add crontab job for root user (or whatever user you want): +# +# # crontab -e -u root +# 1 4 * * * bash /path/to/backup_pgsql.sh +# +# * Make sure 'crond' service is running. +# + +######################################################### +# Modify below variables to fit your need ---- +######################################################### +# Keep backup for how many days. Default is 90 days. +KEEP_DAYS='90' + +# System user used to run PostgreSQL daemon. +# - On Linux, it's postgres. +# - On FreeBSD, it's pgsql. +# - On OpenBSD, it's _postgresql. +export SYS_USER_PGSQL='postgres' + +# Where to store backup copies. +export BACKUP_ROOTDIR='/var/vmail/backup' + +# Databases we should backup. +# Multiple databases MUST be seperated by SPACE. +# Your iRedMail server might have below databases: +# vmail, roundcubemail, cluebringer, amavisd, iredadmin. +export DATABASES='vmail roundcubemail amavisd iredadmin sogo iredapd sa_bayes' + +######################################################### +# You do *NOT* need to modify below lines. +######################################################### +export PATH='/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin' + +# Commands. +export CMD_DATE='/bin/date' +export CMD_DU='du -sh' +export CMD_COMPRESS='bzip2 -9' +export COMPRESS_SUFFIX='bz2' +export CMD_PG_DUMP='pg_dump' + +# Date. +export YEAR="$(${CMD_DATE} +%Y)" +export MONTH="$(${CMD_DATE} +%m)" +export DAY="$(${CMD_DATE} +%d)" +export TIME="$(${CMD_DATE} +%H-%M-%S)" +export TIMESTAMP="${YEAR}-${MONTH}-${DAY}-${TIME}" + +# Pre-defined backup status +export BACKUP_SUCCESS='YES' + +# Define, check, create directories. +export BACKUP_DIR="${BACKUP_ROOTDIR}/pgsql/${YEAR}/${MONTH}/${DAY}" + +# Find the old backup which should be removed. +export REMOVE_OLD_BACKUP='YES' + +export KERNEL="$(uname -s)" +if [[ X"${KERNEL}" == X'Linux' ]]; then + shift_year=$(date --date="${KEEP_DAYS} days ago" "+%Y") + shift_month=$(date --date="${KEEP_DAYS} days ago" "+%m") + shift_day=$(date --date="${KEEP_DAYS} days ago" "+%d") +elif [[ X"${KERNEL}" == X'FreeBSD' ]]; then + shift_year=$(date -j -v-${KEEP_DAYS}d "+%Y") + shift_month=$(date -j -v-${KEEP_DAYS}d "+%m") + shift_day=$(date -j -v-${KEEP_DAYS}d "+%d") +elif [[ X"${KERNEL}" == X'OpenBSD' ]]; then + epoch_seconds_now="$(date +%s)" + epoch_shift="$((${KEEP_DAYS} * 86400))" + epoch_seconds_old="$((epoch_seconds_now - epoch_shift))" + + shift_year=$(date -r ${epoch_seconds_old} "+%Y") + shift_month=$(date -r ${epoch_seconds_old} "+%m") + shift_day=$(date -r ${epoch_seconds_old} "+%d") +else + export REMOVE_OLD_BACKUP='NO' +fi + +export REMOVED_BACKUP_DIR="${BACKUP_ROOTDIR}/pgsql/${shift_year}/${shift_month}/${shift_day}" +export REMOVED_BACKUP_MONTH_DIR="${BACKUP_ROOTDIR}/pgsql/${shift_year}/${shift_month}" +export REMOVED_BACKUP_YEAR_DIR="${BACKUP_ROOTDIR}/pgsql/${shift_year}" + +# Log file +export LOGFILE="${BACKUP_DIR}/${TIMESTAMP}.log" + +# Check and create directories. +[ ! -d ${BACKUP_DIR} ] && mkdir -p ${BACKUP_DIR} 2>/dev/null +chown root ${BACKUP_DIR} +chmod 0700 ${BACKUP_DIR} + +# Get HOME directory of SYS_USER_PGSQL +export PGSQL_USER_HOMEDIR="$(su - ${SYS_USER_PGSQL} -c 'echo $HOME')" + +# Initialize log file. +echo "* Starting at: ${YEAR}-${MONTH}-${DAY}-${TIME}." >${LOGFILE} +echo "* Backup directory: ${BACKUP_DIR}." >>${LOGFILE} + +# Backup. +echo "* Backing up databases: ${DATABASES}." >> ${LOGFILE} +for db in ${DATABASES}; do + output_sql="${db}-${TIMESTAMP}.sql" + + # Check database existence + su - "${SYS_USER_PGSQL}" -c "psql -d ${db} -c '\q' >/dev/null 2>&1" + + # Dump + if [ X"$?" == X'0' ]; then + su - "${SYS_USER_PGSQL}" -c "${CMD_PG_DUMP} ${db} > ${PGSQL_USER_HOMEDIR}/${output_sql}" + + if [ X"$?" == X'0' ]; then + # Move to backup directory. + mv ${PGSQL_USER_HOMEDIR}/${output_sql} ${BACKUP_DIR} + + cd ${BACKUP_DIR} + + # Get original SQL file size + original_size="$(${CMD_DU} ${output_sql} | awk '{print $1}')" + + # Compress + ${CMD_COMPRESS} ${output_sql} >>${LOGFILE} + + rm -f ${output_sql} >> ${LOGFILE} + echo -e " + ${db} [DONE]" >> ${LOGFILE} + + # Get compressed file size + compressed_file_name="${output_sql}.${COMPRESS_SUFFIX}" + compressed_size="$(${CMD_DU} ${compressed_file_name} | awk '{print $1}')" + + # Log to SQL table `iredadmin.log`, so that global domain admins + # can check backup status + sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'Database: ${db}, size: ${compressed_size} (original: ${original_size})', 'cron_backup_sql', '127.0.0.1', NOW());" + else + export BACKUP_SUCCESS='NO' + sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'Database backup failed: ${db}, check log file ${LOGFILE} for more details.', 'cron_backup_sql', '127.0.0.1', NOW());" + fi + + su - "${SYS_USER_PGSQL}" >/dev/null <>${LOGFILE} +cd ${BACKUP_DIR} && \ +${CMD_DU} *${TIMESTAMP}*sql* >>${LOGFILE} +echo "----" >>${LOGFILE} + +echo "* Backup completed (Success? ${BACKUP_SUCCESS})." >>${LOGFILE} + +if [ X"${BACKUP_SUCCESS}" == X'YES' ]; then + echo -e "\n[OK] Backup successfully completed.\n" +else + echo -e "\n[ERROR] Backup completed with ERRORS.\n" 1>&2 +fi + +if [ X"${REMOVE_OLD_BACKUP}" == X'YES' -a -d ${REMOVED_BACKUP_DIR} ]; then + echo -e "* Old backup found. Deleting: ${REMOVED_BACKUP_DIR}." >>${LOGFILE} + rm -rf ${REMOVED_BACKUP_DIR} >> ${LOGFILE} 2>&1 + + # Try to remove empty directory. + rmdir ${REMOVED_BACKUP_MONTH_DIR} 2>/dev/null + rmdir ${REMOVED_BACKUP_YEAR_DIR} 2>/dev/null + + su - ${SYS_USER_PGSQL} -c "psql -d iredadmin" </dev/null + chown -R root ${BACKUP_DIR} + chmod -R 0700 ${BACKUP_DIR} +fi + +# Backup +echo "* Backup all users' data under ${BACKUP_DIR}" +${CMD_SOGO_TOOL} backup ${BACKUP_DIR} ALL + +dir_name="$(dirname ${BACKUP_DIR})" +base_name="$(basename ${BACKUP_DIR})" + +if ls ${BACKUP_DIR} | grep -i '[a-z0-9]' &>/dev/null; then + # Backup is not empty. + chown -R root ${BACKUP_DIR} + chmod -R 0700 ${BACKUP_DIR} + + # Get original size of backup files + original_size="$(${CMD_DU} ${BACKUP_DIR} | awk '{print $1}')" + + # Compress the directory. + echo "* Compress backup files." + cd ${dir_name} &&\ + tar cjf ${base_name}.tar.bz2 ${base_name} && \ + chown root ${base_name}.tar.bz2 && \ + chmod 0400 ${base_name}.tar.bz2 && \ + rm -rf ${base_name} + + compressed_size="$(${CMD_DU} ${base_name}.tar.bz2 | awk '{print $1}')" + if [ -n X"${MYSQL_USER}" -a -f ${MYSQL_DOT_MY_CNF} ]; then + sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'SOGo data. size: ${compressed_size} (original: ${original_size})', 'cron_backup_sogo', '127.0.0.1', UTC_TIMESTAMP());" + ${CMD_MYSQL} iredadmin -e "${sql_log_msg}" + fi +else + echo "* Backup is empty, remove temporary backup directory: ${BACKUP_DIR}." + rm -rf ${BACKUP_DIR} &>/dev/null +fi + +if [ X"${REMOVE_OLD_BACKUP}" == X'YES' -a -f ${REMOVED_BACKUP} ]; then + echo -e "* Old backup found. Deleting: ${REMOVED_BACKUP}." + rm -rf ${REMOVED_BACKUP} &>/dev/null + + # Try to remove empty directory. + rmdir ${REMOVED_BACKUP_MONTH_DIR} 2>/dev/null + rmdir ${REMOVED_BACKUP_YEAR_DIR} 2>/dev/null +fi + +exit 0 diff --git a/iredmail/tools/create_mail_user_OpenLDAP.py b/iredmail/tools/create_mail_user_OpenLDAP.py new file mode 100644 index 0000000..acc1e08 --- /dev/null +++ b/iredmail/tools/create_mail_user_OpenLDAP.py @@ -0,0 +1,283 @@ +#!/usr/bin/env python3 +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add new OpenLDAP user for postfix mail server. +# Project: iRedMail (http://www.iredmail.org/) + +# --------------------------- WARNING ------------------------------ +# This script only works under iRedMail >= 0.4.0 due to ldap schema +# changes. +# ------------------------------------------------------------------ + +# ---------------------------- USAGE ------------------------------- +# Put your user list in a csv format file, e.g. users.csv, and then +# import users listed in the file: +# +# $ python3 create_mail_user_OpenLDAP.py users.csv +# +# ------------------------------------------------------------------ + +# ------------------------- SETTINGS ------------------------------- +# LDAP server address. +LDAP_URI = 'ldap://127.0.0.1:389' + +# LDAP base dn. +BASEDN = 'o=domains,dc=example,dc=com' + +# Bind dn/password +BINDDN = 'cn=Manager,dc=example,dc=com' +BINDPW = 'password' + +# Storage base directory. +STORAGE_BASE_DIRECTORY = '/var/vmail/vmail1' + +# Append timestamp in maildir path. +APPEND_TIMESTAMP_IN_MAILDIR = True + +# Get base directory and storage node. +std = STORAGE_BASE_DIRECTORY.rstrip('/').split('/') +STORAGE_NODE = std.pop() +STORAGE_BASE = '/'.join(std) + +# Hashed maildir: True, False. +# Example: +# domain: domain.ltd, +# user: zhang (zhang@domain.ltd) +# +# - hashed: d/do/domain.ltd/z/zh/zha/zhang/ +# - normal: domain.ltd/zhang/ +HASHED_MAILDIR = True + +# Default password schemes. +# Multiple passwords are supported if you separate schemes with '+'. +# For example: 'SSHA+NTLM', 'CRAM-MD5+SSHA', 'CRAM-MD5+SSHA+MD5'. +DEFAULT_PASSWORD_SCHEME = 'SSHA512' + +# Do not prefix password scheme name in password hash. +HASHES_WITHOUT_PREFIXED_PASSWORD_SCHEME = ['NTLM'] +# ------------------------------------------------------------------ + +import os +import sys +import time +import datetime +from subprocess import Popen, PIPE +import re + +try: + #import ldap + import ldif +except ImportError: + print(""" + Error: You don't have python-ldap installed, Please install it first. + + You can install it like this: + + - On RHEL/CentOS 5.x: + + $ sudo yum install python-ldap + + - On Debian & Ubuntu: + + $ sudo apt install python-ldap + """) + sys.exit() + + +def usage(): + print(""" +CSV file format: + + domain name, username, password, [common name], [quota_in_bytes], [groups] + +Example #1: + iredmail.org, zhang, plain_password, Zhang Huangbin, 104857600, group1:group2 +Example #2: + iredmail.org, zhang, plain_password, Zhang Huangbin, , +Example #3: + iredmail.org, zhang, plain_password, , 104857600, group1:group2 + +Note: + - Domain name, username and password are REQUIRED, others are optional: + + common name. + * It will be the same as username if it's empty. + * Non-ascii character is allowed in this field, they will be + encoded automaticly. Such as Chinese, Korea, Japanese, etc. + + quota. It will be 0 (unlimited quota) if it's empty. + + groups. + * valid group name (hr@a.cn): hr + * incorrect group name: hr@a.cn + * Do *NOT* include domain name in group name, it will be + appended automaticly. + * Multiple groups must be seperated by colon. + - Leading and trailing Space will be ignored. + """) + +def mail_to_user_dn(mail): + """Convert email address to ldap dn of normail mail user.""" + if mail.count('@') != 1: + return '' + + user, domain = mail.split('@') + + # User DN format. + # mail=user@domain.ltd,domainName=domain.ltd,[LDAP_BASEDN] + dn = 'mail=%s,ou=Users,domainName=%s,%s' % (mail, domain, BASEDN) + + return dn + + +def generate_password_with_doveadmpw(plain_password, scheme=None): + """Generate password hash with `doveadm pw` command. + Return SSHA instead if no 'doveadm' command found or other error raised.""" + if not scheme: + scheme = DEFAULT_PASSWORD_SCHEME + + scheme = scheme.upper() + p = str(plain_password).strip() + + pp = Popen(['doveadm', 'pw', '-s', scheme, '-p', p], stdout=PIPE) + pw = pp.communicate()[0] + + if scheme in HASHES_WITHOUT_PREFIXED_PASSWORD_SCHEME: + pw.lstrip('{' + scheme + '}') + + # remove '\n' + pw = pw.strip() + + return pw + +def get_days_of_today(): + """Return number of days since 1970-01-01.""" + today = datetime.date.today() + + try: + return (datetime.date(today.year, today.month, today.day) - datetime.date(1970, 1, 1)).days + except: + return 0 + +def ldif_mailuser(domain, username, passwd, cn, quota, groups=''): + # Append timestamp in maildir path + DATE = time.strftime('%Y.%m.%d.%H.%M.%S') + TIMESTAMP_IN_MAILDIR = '' + if APPEND_TIMESTAMP_IN_MAILDIR: + TIMESTAMP_IN_MAILDIR = '-%s' % DATE + + if quota == '': + quota = '0' + + # Remove SPACE in username. + username = str(username).lower().strip().replace(' ', '') + + if cn == '': + cn = username + + mail = username + '@' + domain + dn = mail_to_user_dn(mail) + + # Get group list. + if groups.strip() != '': + groups = groups.strip().split(':') + for i in range(len(groups)): + groups[i] = groups[i] + '@' + domain + + maildir_domain = str(domain).lower() + if HASHED_MAILDIR is True: + str1 = str2 = str3 = username[0] + if len(username) >= 3: + str2 = username[1] + str3 = username[2] + elif len(username) == 2: + str2 = str3 = username[1] + + maildir_user = "%s/%s/%s/%s%s/" % (str1, str2, str3, username, TIMESTAMP_IN_MAILDIR, ) + mailMessageStore = maildir_domain + '/' + maildir_user + else: + mailMessageStore = "%s/%s%s/" % (domain, username, TIMESTAMP_IN_MAILDIR) + + homeDirectory = STORAGE_BASE_DIRECTORY + '/' + mailMessageStore + mailMessageStore = STORAGE_NODE + '/' + mailMessageStore + + ldif = [ + ('objectClass', ['inetOrgPerson', 'mailUser', 'shadowAccount', 'amavisAccount']), + ('mail', [mail]), + ('userPassword', generate_password_with_doveadmpw(passwd)), + ('mailQuota', [quota]), + ('cn', [cn]), + ('sn', [username]), + ('uid', [username]), + ('storageBaseDirectory', [STORAGE_BASE]), + ('mailMessageStore', [mailMessageStore]), + ('homeDirectory', [homeDirectory]), + ('accountStatus', ['active']), + ('enabledService', ['internal', 'doveadm', 'lib-storage', + 'indexer-worker', 'dsync', 'quota-status', + 'mail', + 'smtp', 'smtpsecured', 'smtptls', + 'pop3', 'pop3secured', 'pop3tls', + 'imap', 'imapsecured', 'imaptls', + 'deliver', 'lda', 'forward', 'senderbcc', 'recipientbcc', + 'managesieve', 'managesievesecured', + 'sieve', 'sievesecured', 'lmtp', 'sogo', + 'shadowaddress', + 'displayedInGlobalAddressBook']), + ('memberOfGroup', groups), + # shadowAccount integration. + ('shadowLastChange', [str(get_days_of_today())]), + # Amavisd integration. + ('amavisLocal', ['TRUE'])] + + return dn, ldif + + +if len(sys.argv) != 2 or len(sys.argv) > 2: + print("""Usage: $ python3 %s users.csv""" % sys.argv[0]) + usage() + sys.exit() +else: + CSV = sys.argv[1] + if not os.path.exists(CSV): + print("Error: file not exist:", CSV) + sys.exit() + +ldif_file = CSV + '.ldif' + +# Remove exist LDIF file. +if os.path.exists(ldif_file): + print("< INFO > Remove exist file:", ldif_file) + os.remove(ldif_file) + +# Read user list. +userList = open(CSV, 'rb') + +# Convert to LDIF format. +for entry in userList.readlines(): + entry = entry.rstrip() + domain, username, passwd, cn, quota, groups = re.split(r'\s?,\s?', entry) + dn, data = ldif_mailuser(domain, username, passwd, cn, quota, groups) + + # Write LDIF data. + result = open(ldif_file, 'a') + ldif_writer = ldif.LDIFWriter(result) + ldif_writer.unparse(dn, data) + + +ldif_file_path = os.path.abspath(ldif_file) +print("< INFO > User data are stored in %s, you can verify it before importing it." % ldif_file_path) +print("< INFO > You can import it with below command:") +print("ldapadd -x -D %s -W -f %s" % (BINDDN, ldif_file_path)) + +# Prompt to import user data. +""" +answer = raw_input("Would you like to import them now? [y|N]").lower().strip() + +if answer == 'y': + # Import data. + conn = ldap.initialize(LDAP_URI) + conn.set_option(ldap.OPT_PROTOCOL_VERSION, 3) # Use LDAP v3 + conn.bind_s(BINDDN, BINDPW) + conn.unbind() +else: + pass +""" diff --git a/iredmail/tools/create_mail_user_OpenLDAP.sh b/iredmail/tools/create_mail_user_OpenLDAP.sh new file mode 100644 index 0000000..8854887 --- /dev/null +++ b/iredmail/tools/create_mail_user_OpenLDAP.sh @@ -0,0 +1,312 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin (zhb _at_ iredmail.org) +# Purpose: Add new OpenLDAP user for postfix mail server. +# Project: iRedMail (http://www.iredmail.org/) + +# --------------------------- WARNING ------------------------------ +# This script only works under iRedMail >= 0.8.4 due to ldap schema +# changes. +# ------------------------------------------------------------------ + +# --------------------------- USAGE -------------------------------- +# 1) Please change variables below to fit your env: +# +# - In 'Global Setting' section: +# * STORAGE_BASE_DIRECTORY +# +# - In 'LDAP Setting' section: +# * LDAP_SUFFIX +# * BINDDN +# * BINDPW +# * QUOTA +# +# - In 'Virtual Domains & Users' section: +# * QUOTA +# * TRANSPORT +# * PASSWORD_SCHEME # SSHA is recommended. +# * DEFAULT_PASSWD +# * USE_DEFAULT_PASSWD +# +# - Pure-FTPd integration: +# * PUREFTPD_INTEGRATION # <- set to 'YES' if you want to integrate it. +# * FTP_BASE_DIRECTORY # <- directory used to store FTP data. +# +# - Optional variables: +# * SEND_WELCOME_MSG +# +# 2) Execute this script with domain name and username (without @domain) directly: +# +# shell# bash create_mail_user_OpenLDAP.sh example.com new_user +# +# It will create a mail user with mail address "new_user@example.com". +# To add multiple mail users, just list all usernames: +# +# shell# bash create_mail_user_OpenLDAP.sh example.com new_user new_user2 new_user3 +# +# ------------------------------------------------------------------ + +# Source functions. +. ../conf/global +. ../conf/core + +# ---------------------------------------------- +# ------------ Global Setting ------------------ +# ---------------------------------------------- +# Storage base directory used to store users' mail. +# mailbox of LDAP user will be: +# ${STORAGE_BASE_DIRECTORY}/${DOMAIN_NAME}/${USERNAME}/ +# Such as: +# /var/vmail/vmail1/iredmail.org/zhb/ +# -------------------|===========|-----| +# STORAGE_BASE_DIRECTORY|DOMAIN_NAME|USERNAME +# +STORAGE_BASE_DIRECTORY="/var/vmail/vmail1" + +# ------------------------------------------------------------------ +# -------------------------- LDAP Setting -------------------------- +# ------------------------------------------------------------------ +LDAP_SUFFIX="dc=example,dc=com" + +# Setting 'BASE_DN'. +BASE_DN="o=domains,${LDAP_SUFFIX}" + +# Setting 'DOMAIN_NAME' and DOMAIN_DN': +# * DOMAIN will be used in mail address: ${USERNAME}@${DOMAIN} +# * DOMAIN_DN will be used in LDAP dn. +DOMAIN_NAME="$1" +DOMAIN_DN="domainName=${DOMAIN_NAME}" +OU_USER_DN="ou=Users" + +# ---------- rootdn of LDAP Server ---------- +# Setting rootdn of LDAP. +BINDDN="cn=Manager,${LDAP_SUFFIX}" + +# Setting rootpw of LDAP. +BINDPW='passwd' + +# ---------- Virtual Domains & Users -------------- +# Set default quota for LDAP users: 104857600 = 100M +QUOTA='1048576000' + +# Default MTA Transport (Defined in postfix master.cf). +TRANSPORT='dovecot' + +# Password scheme. Support schemes: BCRYPT, SSHA512, SSHA, PLAIN. +PASSWORD_SCHEME='SSHA' +DEFAULT_PASSWD='888888' +USE_DEFAULT_PASSWD='NO' + +# ------------------------------------------------------------------ +# -------------------- Pure-FTPd Integration ----------------------- +# ------------------------------------------------------------------ +# Add objectClass and attributes for pure-ftpd integration. +# Note: You must inlucde pureftpd.schema in OpenLDAP slapd.conf first. +PUREFTPD_INTEGRATION='NO' +FTP_BASE_DIRECTORY='/home/ftp' + +# ------------------------------------------------------------------ +# ------------------------- Welcome Msg ---------------------------- +# ------------------------------------------------------------------ +# Send a welcome mail after user created. +SEND_WELCOME_MSG='NO' + +# Set welcome mail info. +WELCOME_MSG_SUBJECT="Welcome!" +WELCOME_MSG_BODY="Welcome, new user." + +# ------------------------------------------- +# ----------- End Global Setting ------------ +# ------------------------------------------- + +# Time stamp, will be appended in maildir. +DATE="$(date +%Y.%m.%d.%H.%M.%S)" + +STORAGE_BASE="$(dirname ${STORAGE_BASE_DIRECTORY})" +STORAGE_NODE="$(basename ${STORAGE_BASE_DIRECTORY})" + +# Get days since 1970-01-01 +EPOCH_SECONDS="$(date +%s)" +DAYS_SINCE_EPOCH="$((EPOCH_SECONDS / 24 / 60 / 60))" + +generate_password_hash() +{ + # Usage: generate_password_hash + _scheme="${1}" + _password="${2}" + + if [ X"${_scheme}" == X'BCRYPT' ]; then + _scheme='BLF-CRYPT' + fi + + doveadm pw -s "${_scheme}" -p "${_password}" +} + +add_new_domain() +{ + domain="$(echo ${1} | tr '[A-Z]' '[a-z]')" + ldapsearch -x -D "${BINDDN}" -w "${BINDPW}" -b "${BASE_DN}" | grep "domainName: ${domain}" >/dev/null + + if [ X"$?" != X"0" ]; then + echo "Add new domain: ${domain}." + + ldapadd -x -D "${BINDDN}" -w "${BINDPW}" < +# +# For example: +# +# bash create_mail_user_SQL.sh user@domain.ltd plain_password +# +# It will print SQL commands on console directly, you can redirect the +# output to a file for further use like this: +# +# bash create_mail_user_SQL.sh user@domain.ltd plain_password > output.sql +# +# * Import output.sql into SQL database like below: +# +# # mysql -uroot -p +# mysql> USE vmail; +# mysql> SOURCE /path/to/output.sql; +# +# # psql -d vmail +# sql> \i /path/to/output.sql; + +# --------- CHANGE THESE VALUES ---------- +# Storage base directory used to store users' mail. +STORAGE_BASE_DIRECTORY="/var/vmail/vmail1" + +########### +# Password +# +# Password scheme. Available schemes: BCRYPT, SSHA512, SSHA, PLAIN. +# Check file Available +PASSWORD_SCHEME='SSHA512' + +# Default mail quota (in MB). +DEFAULT_QUOTA='1024' + +# +# Maildir settings +# +# Maildir style: hashed, normal. +# Hashed maildir style, so that there won't be many large directories +# in your mail storage file system. Better performance in large scale +# deployment. +# Format: e.g. username@domain.td +# hashed -> domain.ltd/u/us/use/username/ +# normal -> domain.ltd/username/ +# Default hash level is 3. +MAILDIR_STYLE='hashed' # hashed, normal. + +if [ X"$#" != X'2' ]; then + echo "Invalid command arguments. Usage:" + echo "bash create_mail_user_SQL.sh user@domain.ltd plain_password" + exit 255 +fi + +# Time stamp, will be appended in maildir. +DATE="$(date +%Y.%m.%d.%H.%M.%S)" +WC_L='wc -L' +if [ X"$(uname -s)" == X'OpenBSD' ]; then + WC_L='wc -l' +fi + +STORAGE_BASE="$(dirname ${STORAGE_BASE_DIRECTORY})" +STORAGE_NODE="$(basename ${STORAGE_BASE_DIRECTORY})" + +generate_password_hash() +{ + # Usage: generate_password_hash + _scheme="${1}" + _password="${2}" + + if [ X"${_scheme}" == X'BCRYPT' ]; then + _scheme='BLF-CRYPT' + fi + + doveadm pw -s "${_scheme}" -p "${_password}" +} + +# Read input +mail="$1" +plain_password="$2" + +username="$(echo $mail | awk -F'@' '{print $1}')" +domain="$(echo $mail | awk -F'@' '{print $2}')" + +# Cyrpt default password. +export CRYPT_PASSWD="$(generate_password_hash ${PASSWORD_SCHEME} ${plain_password})" + +# Different maildir style: hashed, normal. +if [ X"${MAILDIR_STYLE}" == X"hashed" ]; then + length="$(echo ${username} | ${WC_L} )" + str1="$(echo ${username} | cut -c1)" + str2="$(echo ${username} | cut -c2)" + str3="$(echo ${username} | cut -c3)" + + test -z "${str2}" && str2="${str1}" + test -z "${str3}" && str3="${str2}" + + # Use mbox, will be changed later. + maildir="${domain}/${str1}/${str2}/${str3}/${username}-${DATE}/" +else + maildir="${domain}/${username}-${DATE}/" +fi + +cat < +# Purpose: Enable Postfix postscreen. +# Last update: Dec 1, 2015 + +export KERNEL_NAME="$(uname -s | tr '[a-z]' '[A-Z]')" +export DATE="$(/bin/date +%Y.%m.%d.%H.%M.%S)" +export SYS_GROUP_ROOT='root' + +export SYS_USER_POSTFIX='postfix' +export SYS_GROUP_POSTFIX='postfix' + +export POSTFIX_ROOT_DIR='/etc/postfix' +export POSTFIX_DATA_DIRECTORY='/var/lib/postfix' # postconf data_directory + +if [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then + export SYS_GROUP_ROOT='wheel' + export POSTFIX_ROOT_DIR='/usr/local/etc/postfix' + export POSTFIX_DATA_DIRECTORY='/var/db/postfix' +elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then + export SYS_GROUP_ROOT='wheel' + export SYS_USER_POSTFIX='_postfix' + export SYS_GROUP_POSTFIX='_postfix' + export POSTFIX_DATA_DIRECTORY='/var/postfix' +fi + +# path to some config files +export MAIN_CF="${POSTFIX_ROOT_DIR}/main.cf" +export MASTER_CF="${POSTFIX_ROOT_DIR}/master.cf" +export POSTSCREEN_DNSBL_REPLY="${POSTFIX_ROOT_DIR}/postscreen_dnsbl_reply" +export POSTSCREEN_ACCESS_CIDR="${POSTFIX_ROOT_DIR}/postscreen_access.cidr" + +# Get Postfix version number. +export POSTFIX_VERSION="$(postconf mail_version 2>/dev/null | awk '{print $NF}')" + +# postscreen requires Postfix 2.8 or later. +if echo ${POSTFIX_VERSION} | grep '^2\.[01234567]\.' &>/dev/null; then + echo " postscreen requires Postfix 2.8 or later, you're running ${POSTFIX_VERSION}." + exit 255 +fi + +backup_file() +{ + # Usage: backup_file file1 [file2 file3 ... fileN] + if [ X"$#" != X"0" ]; then + for f in $@; do + if [ -f ${f} ]; then + echo -e "* [BACKUP] ${f} -> ${f}.${DATE}." + cp -f ${f} ${f}.${DATE} + fi + done + fi +} + +backup_file ${MAIN_CF} ${MASTER_CF} ${POSTSCREEN_ACCESS_CIDR} ${POSTSCREEN_DNSBL_REPLY} + +echo "* Comment out 'smtp inet ... smtpd' service in ${MASTER_CF}." +perl -pi -e 's/^(smtp .*inet.*smtpd)$/#${1}/g' ${MASTER_CF} + +echo "* Uncomment the new 'smtpd pass ... smtpd' service in ${MASTER_CF}." +perl -pi -e 's/^#(smtpd.*pass.*smtpd)$/${1}/g' ${MASTER_CF} + +echo "* Uncomment the new "smtp inet ... postscreen" service in ${MASTER_CF}." +perl -pi -e 's/^#(smtp *.*inet.*postscreen)$/${1}/g' ${MASTER_CF} + +echo "* Uncomment the new 'tlsproxy unix ... tlsproxy' service in ${MASTER_CF}." +perl -pi -e 's/^#(tlsproxy.*unix.*tlsproxy)$/${1}/g' ${MASTER_CF} + +echo "* Uncomment the new 'dnsblog unix ... dnsblog' service in ${MASTER_CF}." +perl -pi -e 's/^#(dnsblog.*unix.*dnsblog)$/${1}/g' ${MASTER_CF} + +echo "* Update ${MAIN_CF} to enable postscreen." +postconf -e postscreen_dnsbl_threshold=2 +postconf -e postscreen_dnsbl_sites='zen.spamhaus.org=127.0.0.[2..11]*3 b.barracudacentral.org=127.0.0.2*2' + +postconf -e postscreen_dnsbl_reply_map="texthash:${POSTSCREEN_DNSBL_REPLY}" +cat > ${POSTSCREEN_DNSBL_REPLY} < ${POSTSCREEN_ACCESS_CIDR} </dev/null; then + postconf -e postscreen_dnsbl_whitelist_threshold='-2' +fi + +# From Postfix author Wietse Venema, posted in Postfix mailing list on Jul 14, 2015: +# ---- +# I would not enable the "after 220 greeting" protocol tests, because +# some senders that pass the tests will not retry (mail will never +# be delivered), and some will retry from a different client IP address +# (mail will be delayed). Whitelisting Google does not solve the +# problem because it also affects other senders. +# +# The amount of mail stopped by these tests is so small that it is not +# worth the trouble at this time. +# ---- +#postscreen_pipelining_enable=yes +#postscreen_pipelining_action= +# +#postscreen_non_smtp_command_enable=yes +#postscreen_non_smtp_command_action= +# +#postscreen_bare_newline_enable=yes +#postscreen_bare_newline_action= + +# Create directory inside chroot directory used to store file `postscreen_cache`. +# queue directory. Postfix will be chrooted to this directory. +queue_directory="$(postconf queue_directory | awk '{print $3}')" +# data directory. used to store additional files. +data_directory="$(postconf data_directory | awk '{print $3}')" +chrooted_data_directory="${queue_directory}/${data_directory}" + +echo "* Create ${chrooted_data_directory}/postscreen_cache.db." +mkdir -p ${chrooted_data_directory} +chown ${SYS_USER_POSTFIX}:${SYS_GROUP_ROOT} ${chrooted_data_directory} +chmod 0700 ${chrooted_data_directory} + +# 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 + +echo "* Reloading postfix service to read the new configuration." +postfix reload + +echo "* postscreen is now enabled." diff --git a/iredmail/tools/fail2ban_unban_ip.sh b/iredmail/tools/fail2ban_unban_ip.sh new file mode 100644 index 0000000..2a95ecc --- /dev/null +++ b/iredmail/tools/fail2ban_unban_ip.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Purpose: Unban specified IP address(es) from all Fail2ban jails. +# Author: Zhang Huangbin + +# Usage: +# +# bash fail2ban_unban_ip.sh 192.168.1.1 [192.168.2.2 ...] + +if [ X"$#" == X'0' ]; then + cat </dev/null + if [ X"$?" == X'0' ]; then + echo "Removed ${ip} from jail '${jail}'" + fi + done +done diff --git a/iredmail/tools/find_sasl_login_ip.sh b/iredmail/tools/find_sasl_login_ip.sh new file mode 100644 index 0000000..ab77c7c --- /dev/null +++ b/iredmail/tools/find_sasl_login_ip.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Purpose: Find login IP address of specified username which is used for smtp +# authentication. + +MAIL_LOG="$1" +USER="$2" + +if [ -z ${MAIL_LOG} -o -z ${USER} ]; then + echo "Please run script with a log file and email address: $0 /path/to/maillog mail_address" + exit 255 +fi + +tmpfile="/tmp/sasl_username_${RANDOM}" + +# extract 'client=xxx[__IP__]' lines +grep "sasl_username=${USER}" ${MAIL_LOG} | awk '{print $7}' | sort | uniq -c | sort -n > sort > ${tmpfile} + +cat ${tmpfile} + +rm -f ${tmpfile} diff --git a/iredmail/tools/find_top_sasl_usernames.sh b/iredmail/tools/find_top_sasl_usernames.sh new file mode 100644 index 0000000..f793c18 --- /dev/null +++ b/iredmail/tools/find_top_sasl_usernames.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Author: Zhang Huangbin +# Purpose: Find usernames used for smtp authentication in Postfix log file, +# sorted by login times. + +MAILLOG_FILE="$1" + +# Detect mail log file if not specified on command line. +if [ -z ${MAILLOG_FILE} ]; then + for f in /var/log/maillog /var/log/mail.log; do + if [ -f ${f} ]; then + MAILLOG_FILE="${f}" + break + fi + done +fi + +if [ -z ${MAILLOG_FILE} ]; then + echo "Please specify Postfix log file on command line: $0 /path/to/maillog" + exit 255 +fi + +grep 'sasl_username=' ${MAILLOG_FILE} \ + | awk -F'sasl_username=' '{print $2}' \ + | awk '{print $NF}' \ + | sort \ + | uniq -c \ + | sort -nr diff --git a/iredmail/tools/generate_ssl_keys.sh b/iredmail/tools/generate_ssl_keys.sh new file mode 100644 index 0000000..64d0a11 --- /dev/null +++ b/iredmail/tools/generate_ssl_keys.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +# Author: Zhang Huangbin (zhb _at_ iredmail.org) +# Purpose: Create new SSL keys. +# Project: iRedMail (http://www.iredmail.org/) + +# USAGE: +# 1) Edit variables which starts with TLS_ below, then save file. +# 2) Execute shell command: +# +# # bash generate_ssl_keys.sh +# +# It will create two new files under CURRENT directory: +# +# - certs/iRedMail.crt: Used to replace file on iRedMail server: +# + on RHEL/CentOS/Scientific Linux: /etc/pki/tls/certs/iRedMail.crt +# + on Debian/Ubuntu: /etc/ssl/certs/iRedMail.crt +# + on FreeBSD: /etc/ssl/certs/iRedMail.crt +# - private/iRedMail.key: Used to replace file on iRedMail server: +# + on RHEL/CentOS/Scientific Linux: /etc/pki/tls/private/iRedMail.key +# + on Debian/Ubuntu: /etc/ssl/private/iRedMail.key +# + on FreeBSD: /etc/ssl/private/iRedMail.key +# +# 3) Grant read access to all users. e.g. on RHEL/CentOS/Scientific Linux: +# +# # chmod +r /etc/ssl/certs/iRedMail.crt +# # chmod +r /etc/ssl/private/iRedMail.key +# +# If you need more restrict file permission, please use file system ACL instead. +# Refer to command 'setfacl' and 'getfacl' for more detail. +# +# 4) Restart all services which provides SSL secure connection. e.g. http, +# dovecot, postfix, etc. A system reboot should be easier if possible. +# + +export HOSTNAME="$(hostname -f)" + +# SSL key related settings. +# Country. +export TLS_COUNTRY='CN' + +# State. +export TLS_STATE='GuangDong' + +# City. +export TLS_CITY='ShenZhen' + +# Company name here, e.g. Apple Inc. +export TLS_COMPANY="${HOSTNAME}" + +# Department name. +export TLS_DEPARTMENT='IT' + +# Hostname of your mail server. +export TLS_HOSTNAME="${HOSTNAME}" + +# Server admininistrator's email address. +export TLS_ADMIN="root@${HOSTNAME}" + +# Do not edit below lines. +export ROOTDIR="$(pwd)" +export SSL_CERT_FILE="${ROOTDIR}/certs/iRedMail.crt" +export SSL_KEY_FILE="${ROOTDIR}/private/iRedMail.key" + +# Create SSL certs/private files. +generate_ssl_keys() +{ + # Create necessary directories. + mkdir -p {certs,private} 2>/dev/null + + openssl req \ + -x509 -nodes -days 3650 -newkey rsa:2048 \ + -subj "/C=${TLS_COUNTRY}/ST=${TLS_STATE}/L=${TLS_CITY}/O=${TLS_COMPANY}/OU=${TLS_DEPARTMENT}/CN=${TLS_HOSTNAME}/emailAddress=${TLS_ADMIN}/" \ + -out ${SSL_CERT_FILE} -keyout ${SSL_KEY_FILE} >/dev/null 2>&1 + + # Set correct file permission. + chmod 0444 ${SSL_CERT_FILE} + chmod 0444 ${SSL_KEY_FILE} +} + +generate_ssl_keys && cat < +# Purpose: Assign one user to specified groups. + +# USAGE +# +# * Set correct LDAP server address (LDAP_URI), LDAP suffix (LDAP_SUFFIX), +# bind dn (BINDDN) and password (BINDPW). +# +# * Run this script: +# +# $ python3 ldap_assign_user_to_groups.py [options] user@domain.com group@domain.com [group2@domain.com ...] + +# LDAP server address. +LDAP_URI = 'ldap://127.0.0.1:389' +LDAP_SUFFIX = 'dc=example,dc=com' + +# LDAP base dn, bind dn/password. +BASEDN = 'o=domains,%s' % LDAP_SUFFIX +BINDDN = 'cn=Manager,%s' % LDAP_SUFFIX +BINDPW = 'www' + + +import sys +import ldap + +def usage(): + print("""Usage: + +$ python3 ldap_assign_user_to_groups.py [options] user@domain.com new_group@domain.com [new_group_2@domain.com ...] + +Note: Non-existing group will be ignored. + +Optional arguments: + + --remove Remove memberships. If no mailing list specified, it will remove + ALL assigned mailing lists. + +Samples: + +*) Remove all memberships: + python3 ldap_assign_user_to_groups.py --remove user@domain.com + +*) Remove memberships of specified mailing lists: + python3 ldap_assign_user_to_groups.py --remove user@domain.com group1@domain.com group2@domain.com + +*) Assign user to new mailing lists: + python3 ldap_assign_user_to_groups.py user@domain.com group1@domain.com group2@domain.com +""") + + +if len(sys.argv) < 3: + usage() + sys.exit() + +args = sys.argv +args.pop(0) + +is_remove = False +if '--remove' in args: + args.remove('--remove') + is_remove = True + +user = args.pop(0) +groups = args + +if not groups and not is_remove: + print("<<< ERROR >>> No group specified.") + usage() + sys.exit() + +print("* Connecting to LDAP server: %s" % LDAP_URI) +conn = ldap.initialize(uri=LDAP_URI, trace_level=0) +conn.bind_s(BINDDN, BINDPW) + +if not is_remove: + print("* Querying existing mailing lists.") + + qr_filter = '(&(objectClass=mailList)(|' + for g in groups: + qr_filter += '(mail=%s)(shadowAddress=%s)' % (g, g) + qr_filter += '))' + + print("* Query filter:", qr_filter) + + qr = conn.search_s(BASEDN, + ldap.SCOPE_SUBTREE, + qr_filter, + ['mail']) + + if qr: + groups = [] + for (dn, entry) in qr: + groups += entry['mail'] + + print("* Found %d mailing list(s)." % len(groups)) + else: + sys.exit("* No specified groups found in LDAP.") + +print("* Get user's dn and membership of mailing list(s).") +(user_name, domain) = user.split('@', 1) +user_dn = 'mail=%s,ou=Users,domainName=%s,%s' % (user, domain, BASEDN) +try: + qr = conn.search_s(user_dn, + ldap.SCOPE_BASE, + '(mail=%s)' % user, + ['mail', 'memberOfGroup']) +except ldap.NO_SUCH_OBJECT: + print("* <<< ERROR >>> User doesn't exist: %s" % user) + sys.exit() + +(dn, entry) = qr[0] + +# Get existing, assigned mailing lists. +existing_groups = entry.get('memberOfGroup', []) +if existing_groups: + print("* Existing membership: %s" % ', '.join(existing_groups)) +else: + print("* User is not member of any mailing list.") + +# New groups +if is_remove: + if groups: + print("* Remove membership: %s" % ', '.join(groups)) + new_groups = list(set(existing_groups) - set(groups)) + else: + print("* Remove ALL memberships.") + new_groups = [] + + # Set to None to remove attribute `memberOfGroup` + if not new_groups: + print("* No membership left, remove attribute `memberOfGroup`.") + new_groups = None +else: + new_groups = list(set(existing_groups + groups)) + print("* New membership: %s" % ', '.join(new_groups)) + +mod_attrs = [(ldap.MOD_REPLACE, 'memberOfGroup', new_groups)] + +try: + print("* Updating membership.") + conn.modify_s(dn, mod_attrs) + print("* Updated.") + + # Unbind connection. + print("* Unbind LDAP server.") + conn.unbind() +except Exception as e: + print("<<< ERROR >>> %s" % repr(e)) diff --git a/iredmail/tools/ldap_move_members_to_another_group.py b/iredmail/tools/ldap_move_members_to_another_group.py new file mode 100644 index 0000000..db3dd6e --- /dev/null +++ b/iredmail/tools/ldap_move_members_to_another_group.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python3 +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Move or copy ALL members of specified mailing list to another +# mailing list. + +# USAGE +# +# * Set correct LDAP server address (LDAP_URI), LDAP suffix (LDAP_SUFFIX), +# bind dn (BINDDN) and password (BINDPW). +# +# * Run this script: +# +# $ python3 ldap_move_members_to_another_group.py [options] old_group@domain.com new_group@domain.com [new_group2@domain.com ...] + +# LDAP server address. +LDAP_URI = 'ldap://127.0.0.1:389' +LDAP_SUFFIX = 'dc=example,dc=com' + +# LDAP base dn, bind dn/password. +BASEDN = 'o=domains,%s' % LDAP_SUFFIX +BINDDN = 'cn=Manager,%s' % LDAP_SUFFIX +BINDPW = 'www' + + +import sys +import ldap + +def usage(): + print("""Usage: + +$ python3 ldap_move_members_to_another_group.py [options] old_group@domain.com [new_group@domain.com new_group_2@domain.com ...] + +Available optional options: + + --copy Assign members of old group to new groups without removing + membership of old group. That means user will be member of both + old and new groups. + + If no --copy specified, this script will remove membership of old + group. + +Samples: + +*) Copy all members of old_group@domain.com to new_group@domain.com + python3 ldap_move_members_to_another_group --copy old_group@domain.com new_group@domain.com + +*) Copy all members of old_group@domain.com to new_group@domain.com, and remove + ALL members of old_group@domain.com. + python3 ldap_move_members_to_another_group old_group@domain.com new_group@domain.com + +*) Remove all members (just remove membership, not remove mail accounts) of + old_group@domain.com. + python3 ldap_move_members_to_another_group old_group@domain.com +""") + + +if len(sys.argv) < 3: + usage() + sys.exit() + +args = sys.argv +args.pop(0) + +is_copy = False +if '--copy' in args: + is_copy = True + args.remove('--copy') + +old_group = args.pop(0) +new_groups = args + +# Initialize LDAP connection. +print("* Connecting to LDAP server: %s" % LDAP_URI) +conn = ldap.initialize(uri=LDAP_URI, trace_level=0) +conn.bind_s(BINDDN, BINDPW) + +# Get all members of old mailing list. +print("* Get all members of old mailing list: %s" % old_group) + +qr_filter = '(&(objectClass=mailUser)(memberOfGroup=%s))' % old_group +print("* Query filter:", qr_filter) + +qr = conn.search_s(BASEDN, + ldap.SCOPE_SUBTREE, + qr_filter, + ['memberOfGroup']) + +total = len(qr) + +if total: + print("* Old mailing list has %d member(s)." % total) +else: + sys.exit("* Old mailing list doesn't have any member. Exit.") + +# accumulate counter +count = 1 + +for user in qr: + (dn, entry) = user + + # Get all assigned mailing lists. + groups = entry['memberOfGroup'] + + if not is_copy: + # Remove old mailing list + groups.remove(old_group) + + # Assign to new mailing list + if new_groups: + groups = list(set(groups + new_groups)) + + # Use only value of rdn. + mod_attrs = [(ldap.MOD_REPLACE, 'memberOfGroup', groups)] + + try: + print("* (%d of %d) Updating object: %s" % (count, total, dn)) + conn.modify_s(dn, mod_attrs) + except Exception as e: + print("<<< ERROR >>> %s" % repr(e)) + + count += 1 + +# Unbind connection. +print("* Unbind LDAP server.") +conn.unbind() + +print("* Done.") diff --git a/iredmail/tools/migrate_sql_alias_table.py b/iredmail/tools/migrate_sql_alias_table.py new file mode 100644 index 0000000..a8aa7fb --- /dev/null +++ b/iredmail/tools/migrate_sql_alias_table.py @@ -0,0 +1,145 @@ +""" +This file is used to migrate SQL table `vmail.alias` for SQL backends. + +Requirements: + +* Make sure you have new SQL tables ready: alias_moderators, forwardings. +* For PostgreSQL, please make sure SQL user 'vmail' has 'SELECT' privilege on + newly created sql tables. +""" + +import sys +import web + +web.config.debug = False + +# Read iRedAdmin config file `settings.py` from one of expected paths +sys.path.insert(0, '/usr/local/www/iredadmin') # FreeBSD +sys.path.insert(0, '/opt/www/iredadmin') # Debian/Ubuntu +sys.path.insert(0, '/var/www/iredadmin') # CentOS/OpenBSD +sys.path.insert(0, '/usr/share/apache2/iredadmin') # Debian/Ubuntu (old iRedMail releases) + +import settings +print "* Read SQL username/password from iRedAdmin config file:", settings.__file__ +print "* Backend:", settings.backend + +if settings.backend in ['ldap', 'mysql']: + sql_dbn = 'mysql' +elif settings.backend in ['pgsql']: + sql_dbn = 'postgres' +else: + sys.exit('* << ERROR >>: Unsupported backend (%s).' % settings.backend) + +try: + if sql_dbn == 'postgres': + db = web.database(dbn=sql_dbn, + host=settings.vmail_db_host, + port=int(settings.vmail_db_port), + db=settings.vmail_db_name, + user=settings.vmail_db_user, + pw=settings.vmail_db_password) + else: + db = web.database(dbn=sql_dbn, + host=settings.vmail_db_host, + port=int(settings.vmail_db_port), + db=settings.vmail_db_name, + user=settings.vmail_db_user, + pw=settings.vmail_db_password, + charset='utf8', + use_unicode=False) + + db.supports_multiple_insert = True +except Exception as e: + print "<< ERROR >> Cannot connecting to SQL server:", e + sys.exit() + +# Check required tables +for tbl in ['forwardings', 'alias_moderators']: + try: + db.select(tbl, limit=1) + except Exception as e: + print "<<< ERROR >>> SQL table '%s' doesn't exist. Please create it first." % tbl + sys.exit() + +# Get all existing accounts +records = db.select('alias', what='address,goto,moderators,domain,active,islist,is_alias') + +total = len(records) +counter = 1 +for r in records: + # standard mail alias account + is_list = 0 + # per-account alias address + is_alias = 0 + # forwarding addresses of mail user + is_forwarding = 0 + + if r.islist == 1: + is_list = 1 + _type = 'mail alias' + elif r.is_alias == 1: + is_alias = 1 + _type = 'per-account alias address' + else: + is_forwarding = 1 + _type = 'mail user' + + account = str(r.address).lower() + active = int(r.active) + domain = str(r.domain).lower() + + goto = r.goto.strip(' ') + goto = goto.replace(' ', '') + goto = goto.replace(';', ',') + members = list(set([i.strip().lower() for i in goto.strip(' ').split(',')])) + + # Migrating forwardings + print "* [%d/%d] Migrating %s %s" % (counter, total, _type, account) + for m in members: + if m: + try: + dest_domain = m.split('@', 1)[-1] + + db.insert('forwardings', + address=account, + forwarding=m, + domain=domain, + dest_domain=dest_domain, + active=active, + is_list=is_list, + is_alias=is_alias, + is_forwarding=is_forwarding) + + except Exception as e: + if e[0] == 1062 or 'duplicate' in repr(e): + # Duplicate record + pass + else: + print "Error while migrating %s %s: %s" % (_type, m, repr(e)) + + # Migrating moderators of mail alias account + moderators = [] + if is_list == 1: + if r.moderators: + moderators = [i.lower() for i in set(r.moderators.strip(' ').split(','))] + + if moderators: + for m in moderators: + try: + dest_domain = m.split('@', 1)[-1] + + db.insert('alias_moderators', + address=account, + moderator=m, + domain=domain, + dest_domain=dest_domain) + except Exception as e: + if e[0] == 1062 or 'duplicate' in repr(e): + # Duplicate record + pass + else: + print "Error while migrating moderators of alias account %s: %s" % (m, repr(e)) + + counter += 1 + +print "* DONE." diff --git a/iredmail/update/0.9.8/amavisd.mysql b/iredmail/update/0.9.8/amavisd.mysql new file mode 100644 index 0000000..2ffa310 --- /dev/null +++ b/iredmail/update/0.9.8/amavisd.mysql @@ -0,0 +1,29 @@ +-- If subject contains emoji, varchar doesn't work well. +ALTER TABLE msgs MODIFY COLUMN subject VARBINARY(255) DEFAULT ''; +ALTER TABLE msgs MODIFY COLUMN from_addr VARBINARY(255) DEFAULT ''; + +-- mail address without address extension: user+abc@domain.com -> user@domain.com +ALTER TABLE maddr ADD COLUMN email_raw varbinary(255) NOT NULL DEFAULT ''; + +-- index +CREATE INDEX maddr_idx_email_raw ON maddr (email_raw); + +-- 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 ; + +-- Update all existing records. +UPDATE maddr SET email_raw=email WHERE email_raw=''; diff --git a/iredmail/update/0.9.8/amavisd.pgsql b/iredmail/update/0.9.8/amavisd.pgsql new file mode 100644 index 0000000..82fd5cb --- /dev/null +++ b/iredmail/update/0.9.8/amavisd.pgsql @@ -0,0 +1,39 @@ +-- If subject/from_addr contains emoji, varchar doesn't work well. +ALTER TABLE msgs ALTER COLUMN subject DROP DEFAULT; +ALTER TABLE msgs ALTER COLUMN subject TYPE bytea USING subject::bytea; +ALTER TABLE msgs ALTER COLUMN subject SET DEFAULT ''; + +ALTER TABLE msgs ALTER COLUMN from_addr DROP DEFAULT; +ALTER TABLE msgs ALTER COLUMN from_addr TYPE bytea USING subject::bytea; +ALTER TABLE msgs ALTER COLUMN from_addr SET DEFAULT ''; + +-- mail address without address extension: user+abc@domain.com -> user@domain.com +ALTER TABLE maddr ADD COLUMN email_raw VARCHAR(255) NOT NULL DEFAULT ''; + +-- index +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(); + +-- Update all existing records. +UPDATE maddr SET email_raw=email WHERE email_raw=''; diff --git a/iredmail/update/0.9.8/iredmail.mysql b/iredmail/update/0.9.8/iredmail.mysql new file mode 100644 index 0000000..2e0c491 --- /dev/null +++ b/iredmail/update/0.9.8/iredmail.mysql @@ -0,0 +1,53 @@ +-- USE vmail; + +-- DROP column +ALTER TABLE mailbox DROP COLUMN local_part; + +-- New SQL column +ALTER TABLE mailbox ADD COLUMN enableimaptls TINYINT(1) NOT NULL DEFAULT 1; +ALTER TABLE mailbox ADD INDEX (enableimaptls); +ALTER TABLE mailbox ADD COLUMN enablepop3tls TINYINT(1) NOT NULL DEFAULT 1; +ALTER TABLE mailbox ADD INDEX (enablepop3tls); +ALTER TABLE mailbox ADD COLUMN enablesievetls TINYINT(1) NOT NULL DEFAULT 1; +ALTER TABLE mailbox ADD INDEX (enablesievetls); + +-- Rename table +RENAME TABLE alias_moderators TO moderators; + +-- Column used to limit number of mailing lists a domain admin can create +ALTER TABLE domain ADD COLUMN maillists INT(10) NOT NULL DEFAULT 0; + +-- Column used to mark sql record is a mailing list +ALTER TABLE forwardings ADD COLUMN `is_maillist` TINYINT(1) NOT NULL DEFAULT 0; +ALTER TABLE forwardings ADD INDEX (`is_maillist`); + +-- Table used to store mailing list accounts +CREATE TABLE IF NOT EXISTS maillists ( + id BIGINT(20) UNSIGNED AUTO_INCREMENT, + address VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + -- Per mailing list transport. for example: 'mlmmj:example.com/listname'. + transport VARCHAR(255) NOT NULL DEFAULT '', + accesspolicy VARCHAR(30) NOT NULL DEFAULT '', + maxmsgsize BIGINT(20) NOT NULL DEFAULT 0, + -- name of the mailing list + name VARCHAR(255) NOT NULL DEFAULT '', + -- short introduction of the mailing list on subscription page + description TEXT, + -- a server-wide unique id (a 36-characters string) for each mailing list + mlid VARCHAR(36) NOT NULL DEFAULT '', + -- control whether newsletter-style subscription from website is enabled + -- 1 -> enabled, 0 -> disabled + is_newsletter TINYINT(1) NOT NULL DEFAULT 0, + settings TEXT, + created DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + modified DATETIME NOT NULL DEFAULT '1970-01-01 01:01:01', + expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00', + active TINYINT(1) NOT NULL DEFAULT 1, + PRIMARY KEY (id), + UNIQUE INDEX (address), + UNIQUE INDEX (mlid), + INDEX (is_newsletter), + INDEX (domain), + INDEX (active) +) ENGINE=InnoDB; diff --git a/iredmail/update/0.9.8/iredmail.pgsql b/iredmail/update/0.9.8/iredmail.pgsql new file mode 100644 index 0000000..82de5b4 --- /dev/null +++ b/iredmail/update/0.9.8/iredmail.pgsql @@ -0,0 +1,61 @@ +-- \c vmail; + +-- DROP column +ALTER TABLE mailbox DROP COLUMN local_part; + +-- New SQL column +ALTER TABLE mailbox ADD COLUMN enableimaptls INT2 NOT NULL DEFAULT 1; +CREATE INDEX idx_mailbox_enableimaptls ON mailbox (enableimaptls); +ALTER TABLE mailbox ADD COLUMN enablepop3tls INT2 NOT NULL DEFAULT 1; +CREATE INDEX idx_mailbox_enablepop3tls ON mailbox (enablepop3tls); +ALTER TABLE mailbox ADD COLUMN enablesievetls INT2 NOT NULL DEFAULT 1; +CREATE INDEX idx_mailbox_enablesievetls ON mailbox (enablesievetls); + +-- Rename table +ALTER TABLE alias_moderators RENAME TO moderators; + +-- Column used to limit number of mailing lists a domain admin can create +ALTER TABLE domain ADD COLUMN maillists INT8 NOT NULL DEFAULT 0; + +-- Column used to mark sql record is a mailing list +ALTER TABLE forwardings ADD COLUMN is_maillist INT2 NOT NULL DEFAULT 0; +CREATE INDEX idx_forwardings_is_maillist ON forwardings (is_maillist); + +CREATE TABLE maillists ( + id SERIAL PRIMARY KEY, + address VARCHAR(255) NOT NULL DEFAULT '', + domain VARCHAR(255) NOT NULL DEFAULT '', + -- Per mailing list transport. for example: 'mlmmj:example.com/listname'. + transport VARCHAR(255) NOT NULL DEFAULT '', + accesspolicy VARCHAR(30) NOT NULL DEFAULT '', + maxmsgsize INT8 NOT NULL DEFAULT 0, + -- name of the mailing list + name VARCHAR(255) NOT NULL DEFAULT '', + -- short introduction of the mailing list on subscription page + description TEXT, + -- a server-wide unique id (a 36-characters string) for each mailing list + mlid VARCHAR(36) NOT NULL DEFAULT '', + -- control whether newsletter-style subscription from website is enabled + -- 1 -> enabled, 0 -> disabled + is_newsletter INT2 NOT NULL DEFAULT 0, + settings TEXT, + created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '1970-01-01 00:00:00', + modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '1970-01-01 00:00:00', + expired TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '9999-12-31 00:00:00', + active INT2 NOT NULL DEFAULT 1 +); +CREATE UNIQUE INDEX idx_maillists_address ON maillists (address); +CREATE INDEX idx_maillists_domain ON maillists (domain); +CREATE UNIQUE INDEX idx_maillists_mlid ON maillists (mlid); +CREATE INDEX idx_maillists_is_newsletter ON maillists (is_newsletter); +CREATE INDEX idx_maillists_active ON maillists (active); + +GRANT SELECT ON maillists TO vmail; +GRANT SELECT ON maillists_id_seq TO vmail; +GRANT SELECT ON alias_moderators_id_seq TO vmail; +GRANT SELECT ON forwardings_id_seq TO vmail; + +GRANT ALL ON maillists TO vmailadmin; +GRANT ALL ON maillists_id_seq TO vmailadmin; +GRANT ALL ON alias_moderators_id_seq TO vmailadmin; +GRANT ALL ON forwardings_id_seq TO vmailadmin; diff --git a/iredmail/update/0.9.9/iredmail.mysql b/iredmail/update/0.9.9/iredmail.mysql new file mode 100644 index 0000000..57a70df --- /dev/null +++ b/iredmail/update/0.9.9/iredmail.mysql @@ -0,0 +1,2 @@ +ALTER TABLE mailbox ADD COLUMN mailboxformat VARCHAR(50) NOT NULL DEFAULT 'maildir'; +ALTER TABLE mailbox ADD COLUMN mailboxfolder VARCHAR(50) NOT NULL DEFAULT 'Maildir'; diff --git a/iredmail/update/0.9.9/iredmail.pgsql b/iredmail/update/0.9.9/iredmail.pgsql new file mode 100644 index 0000000..57a70df --- /dev/null +++ b/iredmail/update/0.9.9/iredmail.pgsql @@ -0,0 +1,2 @@ +ALTER TABLE mailbox ADD COLUMN mailboxformat VARCHAR(50) NOT NULL DEFAULT 'maildir'; +ALTER TABLE mailbox ADD COLUMN mailboxfolder VARCHAR(50) NOT NULL DEFAULT 'Maildir'; diff --git a/iredmail/update/1.0/iredmail.mysql b/iredmail/update/1.0/iredmail.mysql new file mode 100644 index 0000000..8f94518 --- /dev/null +++ b/iredmail/update/1.0/iredmail.mysql @@ -0,0 +1,2 @@ +ALTER TABLE mailbox ADD COLUMN `enablequota-status` TINYINT(1) NOT NULL DEFAULT 1; +CREATE INDEX `enablequota-status` ON mailbox (`enablequota-status`); diff --git a/iredmail/update/1.0/iredmail.pgsql b/iredmail/update/1.0/iredmail.pgsql new file mode 100644 index 0000000..8bb13ba --- /dev/null +++ b/iredmail/update/1.0/iredmail.pgsql @@ -0,0 +1,2 @@ +ALTER TABLE mailbox ADD COLUMN "enablequota-status" INT2 NOT NULL DEFAULT 1; +CREATE INDEX idx_mailbox_enablequota_status ON mailbox ("enablequota-status"); diff --git a/iredmail/update/1.2/last_login.mysql b/iredmail/update/1.2/last_login.mysql new file mode 100644 index 0000000..7e00d86 --- /dev/null +++ b/iredmail/update/1.2/last_login.mysql @@ -0,0 +1,16 @@ +-- For MySQL/MariaDB backends, please update database `vmail`. +-- For OpenLDAP backend, please update database `iredadmin`. +DROP TABLE `last_login`; + +CREATE TABLE `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 last_login_domain (`domain`), + INDEX last_login_imap (`imap`), + INDEX last_login_pop3 (`pop3`), + INDEX last_login_lda (`lda`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/iredmail/update/README.md b/iredmail/update/README.md new file mode 100644 index 0000000..becc24c --- /dev/null +++ b/iredmail/update/README.md @@ -0,0 +1 @@ +Please follow [iRedMail upgrade tutorials](https://docs.iredmail.org/iredmail.releases.html) to use SQL/Shell/Python scripts in this directory, do not run any of them blindly. diff --git a/iredmail/update/ldap/README.md b/iredmail/update/ldap/README.md new file mode 100644 index 0000000..59aab19 --- /dev/null +++ b/iredmail/update/ldap/README.md @@ -0,0 +1,40 @@ +# Update LDAP data + +[TOC] + +## Summary + +If you're restoring from an old iRedMail release, you need to add missing LDAP +attribute/values, which are introduced in new iRedMail releases, by running +Python scripts below: . + +For example: + +* If you're restoring iRedMail from `0.9.1` to `0.9.5`, you must run all update + scripts for iRedMail-0.9.1 and newer releases. In this case, only file + `updateLDAPValues_094_to_095.py` listed in above link is required. + +* If you're restoring iRedMail from `0.8.6` to `0.9.5`, you need 3 files: + + * `updateLDAPValues_086_to_087.py` + * `updateLDAPValues_087_to_090.py` + * `updateLDAPValues_094_to_095.py` + +## How to use those upgrade scripts + +Please open the file you need to run, for example, `updateLDAPValues_094_to_095.py`, +find parameters like below: + +``` +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' +``` + +Please update them with the correct LDAP prefix (`dc=xx,dc=xx`) and bind +password, then run it with `python` command: + +``` +python updateLDAPValues_094_to_095.py +``` diff --git a/iredmail/update/ldap/update-ldap-dovecot-2.3.py b/iredmail/update/ldap/update-ldap-dovecot-2.3.py new file mode 100644 index 0000000..e0301ba --- /dev/null +++ b/iredmail/update/ldap/update-ldap-dovecot-2.3.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# Author: Zhang Huangbin +# Purpose: Add missing attribute/value pairs required by Dovecot-2.3. +# Date: Apr 12, 2018. + +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'password' + +# Initialize LDAP connection. +print "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print "* Get mail accounts ..." +allUsers = conn.search_s(basedn, + ldap.SCOPE_SUBTREE, + "(&(objectClass=mailUser)(|(enabledService=imapsecured)(enabledService=pop3secured)(enabledService=smtpsecured)))", + ['mail', 'enabledService']) + +total = len(allUsers) +print "* Updating %d user(s)." % (total) + +# Counter. +count = 1 + +for (dn, entry) in allUsers: + mail = entry['mail'][0] + if 'enabledService' not in entry: + continue + + enabledService = entry['enabledService'] + + _update = False + if 'imaptls' not in enabledService: + enabledService += ['imaptls'] + _update = True + + if 'pop3tls' not in enabledService: + enabledService += ['pop3tls'] + _update = True + + if 'smtptls' not in enabledService: + enabledService += ['smtptls'] + _update = True + + if _update: + print "* (%d of %d) Updating user: %s" % (count, total, mail) + mod_attr = [(ldap.MOD_REPLACE, 'enabledService', enabledService)] + try: + conn.modify_s(dn, mod_attr) + except Exception, e: + print "Error while updating user:", mail, e + else: + print "* [SKIP] No update required for user:", mail + + count += 1 + +# Unbind connection. +print "* Unbind LDAP server." +conn.unbind() + +print "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_050_to_051.py b/iredmail/update/ldap/updateLDAPValues_050_to_051.py new file mode 100644 index 0000000..6b37be7 --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_050_to_051.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add three new services name in 'enabledService' attribute. +# Required in iRedMail-0.5.1. + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=iredmail,dc=org' +bind_dn = 'cn=Manager,dc=example,dc=com' +#bind_dn = 'cn=Manager,dc=iredmail,dc=org' +bind_pw = 'passwd' + +# Initialize LDAP connection. +conn = ldap.initialize(uri=uri, trace_level=0,) + +# Bind. +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +allUsers = conn.search_s( + basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['dn', 'mail', 'enabledService'], + ) + +# Debug. +#print >> sys.stderr, allUsers + +# Values which need to be added. +services = ['pop3secured', 'imapsecured', 'managesievesecured',] + +# Counter. +count = 1 + +for user in allUsers: + dn = user[0] + mail = user[1]['mail'][0] + enabledService = user[1]['enabledService'] + + # Get missing values. + values = [ s for s in services if s not in enabledService ] + + # Update it if there are something missed.. + if len(values) != 0: + print >> sys.stderr, """Updating user (%d): %s""" % (count, mail) + + mod_attrs = [ (ldap.MOD_ADD, 'enabledService', values) ] + conn.modify_s(dn, mod_attrs) + + count += 1 + +# Unbind connection. +conn.unbind() + +print >> sys.stderr, 'Updated.' diff --git a/iredmail/update/ldap/updateLDAPValues_051_to_060.py b/iredmail/update/ldap/updateLDAPValues_051_to_060.py new file mode 100644 index 0000000..750037a --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_051_to_060.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add three new services name in 'enabledService' attribute. +# Required in iRedMail-0.6.0. +# Date: 2010-05-31 + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=iredmail,dc=org' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print >> sys.stderr, "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print >> sys.stderr, "* Get all mail accounts..." +allUsers = conn.search_s( + basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['dn', 'mail', 'enabledService', 'objectClass',], + ) + +total = len(allUsers) +print >> sys.stderr, "* Total %d user(s)." % (total) + +# Values of 'enabledService' which need to be added. +services = ['sieve', 'sievesecured', 'internal',] + +# Counter. +count = 1 + +for user in allUsers: + dn = user[0] + mail = user[1]['mail'][0] + enabledService = user[1]['enabledService'] + objectClasses = user[1]['objectClass'] + + # Get missing values. + values = [s for s in services if s not in enabledService] + + mod_attrs = [] + + # Add missing values of 'enabledService'. + if len(values) > 0: + mod_attrs += [(ldap.MOD_ADD, 'enabledService', values)] + + # Add missing values of 'objectClass'. + if 'amavisAccount' not in objectClasses: + mod_attrs += [(ldap.MOD_ADD, 'objectClass', 'amavisAccount')] + + # Update. + if len(mod_attrs) > 0: + print >> sys.stderr, "* Updating user (%d/%d): %s" % (count, total, mail) + conn.modify_s(dn, mod_attrs) + else: + print >> sys.stderr, "* Updating user (%d/%d): %s. [SKIP. No update required.]" % (count, total, mail) + + count += 1 + +# Unbind connection. +print >> sys.stderr, "* Unbind LDAP server." +conn.unbind() + +print >> sys.stderr, "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_061_to_070.py b/iredmail/update/ldap/updateLDAPValues_061_to_070.py new file mode 100644 index 0000000..0a331b0 --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_061_to_070.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add three service name in 'enabledService' attribute. +# Required in iRedMail-0.7.0. +# Date: 2011-01-28 + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=iredmail,dc=org' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print >> sys.stderr, "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print >> sys.stderr, "* Get all mail accounts..." +allUsers = conn.search_s( + basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['dn', 'mail', 'enabledService', 'objectClass',], + ) + +total = len(allUsers) +print >> sys.stderr, "* Total %d user(s)." % (total) + +# Values of 'enabledService' which need to be added. +services = ['smtpsecured'] + +# Counter. +count = 1 + +for user in allUsers: + (dn, entry) = user + mail = entry['mail'][0] + if entry.has_key('enabledService'): + enabledService = entry['enabledService'] + else: + continue + objectClasses = entry['objectClass'] + + # Get missing values. + values = [str(s).lower() for s in services if s not in enabledService] + + mod_attrs = [] + + # Add missing values of 'enabledService'. + if len(values) > 0: + mod_attrs += [(ldap.MOD_ADD, 'enabledService', values)] + + # Add missing values of 'objectClass'. + if 'amavisAccount' not in objectClasses: + mod_attrs += [(ldap.MOD_ADD, 'objectClass', 'amavisAccount')] + + # Update. + if len(mod_attrs) > 0: + print >> sys.stderr, "* Updating user (%d/%d): %s" % (count, total, mail) + conn.modify_s(dn, mod_attrs) + else: + print >> sys.stderr, "* Updating user (%d/%d): %s. [SKIP. No update required.]" % (count, total, mail) + + count += 1 + +# Unbind connection. +print >> sys.stderr, "* Unbind LDAP server." +conn.unbind() + +print >> sys.stderr, "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_072_to_073.py b/iredmail/update/ldap/updateLDAPValues_072_to_073.py new file mode 100644 index 0000000..afb9d89 --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_072_to_073.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add enabledService=lda for all mail users. +# Required in iRedMail-0.7.3. +# Date: 2011-07-12 + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=iredmail,dc=org' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print >> sys.stderr, "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print >> sys.stderr, "* Get all mail accounts..." +allUsers = conn.search_s( + basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['dn', 'mail', 'enabledService', 'objectClass',], + ) + +total = len(allUsers) +print >> sys.stderr, "* Total %d user(s)." % (total) + +# Values of 'enabledService' which need to be added. +services = ['lda'] + +# Counter. +count = 1 + +for user in allUsers: + (dn, entry) = user + mail = entry['mail'][0] + if entry.has_key('enabledService'): + enabledService = entry['enabledService'] + else: + continue + objectClasses = entry['objectClass'] + + # Get missing values. + values = [str(s).lower() for s in services if s not in enabledService] + + mod_attrs = [] + + # Add missing values of 'enabledService'. + if len(values) > 0: + mod_attrs += [(ldap.MOD_ADD, 'enabledService', values)] + + # Update. + if len(mod_attrs) > 0: + print >> sys.stderr, "* (%d of %d) Updating user: %s" % (count, total, mail) + conn.modify_s(dn, mod_attrs) + else: + print >> sys.stderr, "* (%d of %d) [SKIP] No update required: %s" % (count, total, mail) + + count += 1 + +# Unbind connection. +print >> sys.stderr, "* Unbind LDAP server." +conn.unbind() + +print >> sys.stderr, "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_074_to_080.py b/iredmail/update/ldap/updateLDAPValues_074_to_080.py new file mode 100644 index 0000000..8b021b2 --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_074_to_080.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add enabledService=doveadm for all mail users. +# Required by command doveadm which provided by Dovecot-2.0. +# Date: 2012-04-19 + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print >> sys.stderr, "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print >> sys.stderr, "* Get all mail accounts..." +allUsers = conn.search_s( + basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['mail', 'enabledService'], + ) + +total = len(allUsers) +print >> sys.stderr, "* Total %d user(s)." % (total) + +# Values of 'enabledService' which need to be added. +services = ['doveadm'] + +# Counter. +count = 1 + +for user in allUsers: + (dn, entry) = user + mail = entry['mail'][0] + if not 'enabledService' in entry: + continue + + enabledService = entry['enabledService'] + # Get missing values. + values = [str(s).lower() for s in services if s not in enabledService] + + mod_attrs = [] + + # Add missing values of 'enabledService'. + if len(values) > 0: + mod_attrs += [(ldap.MOD_ADD, 'enabledService', values)] + + # Update. + if len(mod_attrs) > 0: + print >> sys.stderr, "* (%d of %d) Updating user: %s" % (count, total, mail) + conn.modify_s(dn, mod_attrs) + else: + print >> sys.stderr, "* (%d of %d) [SKIP] No update required: %s" % (count, total, mail) + + count += 1 + +# Unbind connection. +print >> sys.stderr, "* Unbind LDAP server." +conn.unbind() + +print >> sys.stderr, "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_080_to_081.py b/iredmail/update/ldap/updateLDAPValues_080_to_081.py new file mode 100644 index 0000000..a10c7a3 --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_080_to_081.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add enabledService=lib-storage for all mail users. +# Required by IMAP folder sharing in Dovecot-2.0. +# Date: 2012-05-18 + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print >> sys.stderr, "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print >> sys.stderr, "* Get all mail accounts..." +allUsers = conn.search_s( + basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['mail', 'enabledService'], + ) + +total = len(allUsers) +print >> sys.stderr, "* Total %d user(s)." % (total) + +# Values of 'enabledService' which need to be added. +services = ['lib-storage'] + +# Counter. +count = 1 + +for user in allUsers: + (dn, entry) = user + mail = entry['mail'][0] + if not 'enabledService' in entry: + continue + + enabledService = entry['enabledService'] + # Get missing values. + values = [str(s).lower() for s in services if s not in enabledService] + + mod_attrs = [] + + # Add missing values of 'enabledService'. + if len(values) > 0: + mod_attrs += [(ldap.MOD_ADD, 'enabledService', values)] + + # Update. + if len(mod_attrs) > 0: + print >> sys.stderr, "* (%d of %d) Updating user: %s" % (count, total, mail) + conn.modify_s(dn, mod_attrs) + else: + print >> sys.stderr, "* (%d of %d) [SKIP] No update required: %s" % (count, total, mail) + + count += 1 + +# Unbind connection. +print >> sys.stderr, "* Unbind LDAP server." +conn.unbind() + +print >> sys.stderr, "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_083_to_084.py b/iredmail/update/ldap/updateLDAPValues_083_to_084.py new file mode 100644 index 0000000..829907b --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_083_to_084.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Use shadowAddress instead of memberOfGroup for alias domains +# in objects objectClass=mailExternaluser. +# Date: 2013-03-25 + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print >> sys.stderr, "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print >> sys.stderr, "* Get all accounts with objectClass=mailExternalUser..." +allUsers = conn.search_s( + basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailExternalUser)", + ['memberOfGroup'], +) + +total = len(allUsers) +print >> sys.stderr, "* Total %d user(s)." % (total) + +# Counter. +count = 1 + +for user in allUsers: + (dn, entry) = user + + # Get all values in attribute memberOfGroup, they're value of shadowAddress + # we will set later. + shadow_addresses = entry['memberOfGroup'] + if len(shadow_addresses) > 1: + # Get memberOfGroup in dn + value_of_rdn = dn.split(',', 1)[0].split('=')[-1] + + # Use only value of rdn. + mod_attrs = [(ldap.MOD_REPLACE, 'memberOfGroup', [value_of_rdn])] + + # Add shadowAddress + shadow_addresses.remove(value_of_rdn) + mod_attrs += [(ldap.MOD_REPLACE, 'shadowAddress', shadow_addresses)] + + # Update. + print >> sys.stderr, "* (%d of %d) Updating object: %s" % (count, total, dn) + conn.modify_s(dn, mod_attrs) + else: + print >> sys.stderr, "* (%d of %d) [SKIP] No update required: %s" % (count, total, dn) + + count += 1 + +# Unbind connection. +print >> sys.stderr, "* Unbind LDAP server." +conn.unbind() + +print >> sys.stderr, "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_086_to_087.py b/iredmail/update/ldap/updateLDAPValues_086_to_087.py new file mode 100644 index 0000000..5a28543 --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_086_to_087.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add enabledService=lmtp for all mail users. +# Required by LMTP service used in Dovecot-2.x. +# Date: 2014-02-20 + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print >> sys.stderr, "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print >> sys.stderr, "* Get all mail accounts..." +allUsers = conn.search_s(basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['mail', 'enabledService']) + +total = len(allUsers) +print >> sys.stderr, "* Total %d user(s)." % (total) + +# Values of 'enabledService' which need to be added. +services = ['lmtp'] + +# Counter. +count = 1 + +for user in allUsers: + (dn, entry) = user + mail = entry['mail'][0] + if not 'enabledService' in entry: + continue + + enabledService = entry['enabledService'] + # Get missing values. + values = [str(s).lower() for s in services if s not in enabledService] + + mod_attrs = [] + + # Add missing values of 'enabledService'. + if len(values) > 0: + mod_attrs += [(ldap.MOD_ADD, 'enabledService', values)] + + # Update. + if len(mod_attrs) > 0: + print >> sys.stderr, "* (%d of %d) Updating user: %s" % (count, total, mail) + conn.modify_s(dn, mod_attrs) + else: + print >> sys.stderr, "* (%d of %d) [SKIP] No update required: %s" % (count, total, mail) + + count += 1 + +# Unbind connection. +print >> sys.stderr, "* Unbind LDAP server." +conn.unbind() + +print >> sys.stderr, "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_087_to_090.py b/iredmail/update/ldap/updateLDAPValues_087_to_090.py new file mode 100644 index 0000000..286646b --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_087_to_090.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add enabledService=indexer-worker for existing mail users. +# Required by Dovecot. +# Date: 2014-06-07 + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print >> sys.stderr, "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print >> sys.stderr, "* Get all mail accounts..." +allUsers = conn.search_s(basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['mail', 'enabledService']) + +total = len(allUsers) +print >> sys.stderr, "* Total %d user(s)." % (total) + +# Values of 'enabledService' which need to be added. +services = ['indexer-worker'] + +# Counter. +count = 1 + +for user in allUsers: + (dn, entry) = user + mail = entry['mail'][0] + if not 'enabledService' in entry: + continue + + enabledService = entry['enabledService'] + # Get missing values. + values = [str(s).lower() for s in services if s not in enabledService] + + mod_attrs = [] + + # Add missing values of 'enabledService'. + if len(values) > 0: + mod_attrs += [(ldap.MOD_ADD, 'enabledService', values)] + + # Update. + if len(mod_attrs) > 0: + print >> sys.stderr, "* (%d of %d) Updating user: %s" % (count, total, mail) + conn.modify_s(dn, mod_attrs) + else: + print >> sys.stderr, "* (%d of %d) [SKIP] No update required: %s" % (count, total, mail) + + count += 1 + +# Unbind connection. +print >> sys.stderr, "* Unbind LDAP server." +conn.unbind() + +print >> sys.stderr, "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_094_to_095.py b/iredmail/update/ldap/updateLDAPValues_094_to_095.py new file mode 100644 index 0000000..4692445 --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_094_to_095.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add enabledService=sogo for existing mail users. Used in SOGo to +# restrict who can access SOGo services (webmail, calendar, contacts). +# Date: Mar 23, 2016. + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print >> sys.stderr, "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print >> sys.stderr, "* Get all mail accounts..." +allUsers = conn.search_s(basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['mail', 'enabledService']) + +total = len(allUsers) +print >> sys.stderr, "* Total %d user(s)." % (total) + +# Values of 'enabledService' which need to be added. +services = ['sogo'] + +# Counter. +count = 1 + +for user in allUsers: + (dn, entry) = user + mail = entry['mail'][0] + if not 'enabledService' in entry: + continue + + enabledService = entry['enabledService'] + # Get missing values. + values = [str(s).lower() for s in services if s not in enabledService] + + mod_attrs = [] + + # Add missing values of 'enabledService'. + if len(values) > 0: + mod_attrs += [(ldap.MOD_ADD, 'enabledService', values)] + + # Update. + if len(mod_attrs) > 0: + print >> sys.stderr, "* (%d of %d) Updating user: %s" % (count, total, mail) + conn.modify_s(dn, mod_attrs) + else: + print >> sys.stderr, "* (%d of %d) [SKIP] No update required: %s" % (count, total, mail) + + count += 1 + +# Unbind connection. +print >> sys.stderr, "* Unbind LDAP server." +conn.unbind() + +print >> sys.stderr, "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_095_1_to_096.py b/iredmail/update/ldap/updateLDAPValues_095_1_to_096.py new file mode 100644 index 0000000..1013ae7 --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_095_1_to_096.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Author: Zhang Huangbin +# Purpose: Add `domainStatus=disabled` to all mail users/aliases/lists if +# domain is disabled. +# Date: Oct 21, 2016. + +import sys +import ldap + +# Note: +# * bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'password' + +# Initialize LDAP connection. +print "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) + +print "* Authenticate as dn: %s" % bind_dn +conn.bind_s(bind_dn, bind_pw) + +# Get all disabled domains. +print "* Get all disabled mail domains ..." + +qf = "(&(objectClass=mailDomain)(accountStatus=disabled))" +qr_domains = conn.search_s(basedn, + ldap.SCOPE_ONELEVEL, + qf, + ['dn', 'domainName']) + +if not qr_domains: + print "* No disabled domain. Exit." + sys.exit() + +print "* Found %d disabled domains." % len(qr_domains) + +qf = "(&" +qf += "(!(domainStatus=disabled))" +qf += "(|(objectClass=mailUser)(objectClass=mailAlias)(objectClass=mailList)(objectClass=mailExternalUser))" +qf += ")" + +mod_attr = [(ldap.MOD_ADD, 'domainStatus', ['disabled'])] + +for (dn, _ldif) in qr_domains: + domain = _ldif['domainName'][0] + + # Get all mail accounts which don't have required mod_attr. + qr_accounts = conn.search_s(dn, + ldap.SCOPE_SUBTREE, + qf, + ['objectClass', 'mail', 'domainStatus']) + + total = len(qr_accounts) + if total: + print "* Updating %d accounts(s) under domain %s." % (total, domain) + else: + print "* No update required for domain %s." % domain + + # Counter. + count = 1 + + for (_dn, _ldif2) in qr_accounts: + if 'mail' not in _ldif2: + continue + + mail = _ldif2['mail'][0] + + try: + print "* (%d of %d) Updating user: %s" % (count, total, mail) + conn.modify_s(_dn, mod_attr) + except Exception, e: + print "* (%d of %d) <<< ERROR >>> %s: %s" % (count, total, mail, repr(e)) + + count += 1 + +conn.unbind() + +print "* Update completed." diff --git a/iredmail/update/ldap/updateLDAPValues_099_to_1.py b/iredmail/update/ldap/updateLDAPValues_099_to_1.py new file mode 100644 index 0000000..a06e71b --- /dev/null +++ b/iredmail/update/ldap/updateLDAPValues_099_to_1.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python2 +# Author: Zhang Huangbin +# Purpose: Add enabledService=quota-status for existing mail users. +# Used by Dovecot quota-status service. +# Date: Jul 17, 2019. + +import ldap + +# Note: bind_dn must have write privilege on LDAP server. +uri = 'ldap://127.0.0.1:389' +basedn = 'o=domains,dc=example,dc=com' +bind_dn = 'cn=Manager,dc=example,dc=com' +bind_pw = 'passwd' + +# Initialize LDAP connection. +print "* Connecting to LDAP server: %s" % uri +conn = ldap.initialize(uri=uri, trace_level=0,) +conn.bind_s(bind_dn, bind_pw) + +# Get all mail users. +print "* Get all mail accounts..." +all_users = conn.search_s(basedn, + ldap.SCOPE_SUBTREE, + "(objectClass=mailUser)", + ['mail', 'enabledService']) + +total = len(all_users) +print "* Total %d user(s)." % (total) + +# New values of the 'enabledService' attribute. +new_services = ['quota-status'] + +# Counter. +count = 1 + +for user in all_users: + (dn, ldif) = user + mail = ldif['mail'][0] + if 'enabledService' not in ldif: + continue + + existing_services = ldif['enabledService'] + missed_services = [str(s).lower() for s in new_services if s not in existing_services] + + mod_attrs = [] + + if missed_services: + mod_attrs += [(ldap.MOD_ADD, 'enabledService', missed_services)] + + # Update. + print "* (%d of %d) Updating user: %s" % (count, total, mail) + conn.modify_s(dn, mod_attrs) + else: + print "* (%d of %d) [SKIP] No update required: %s" % (count, total, mail) + + count += 1 + +# Unbind connection. +print "* Unbind LDAP server." +conn.unbind() + +print "* Update completed." diff --git a/mariadb/master.cnf b/mariadb/master.cnf new file mode 100644 index 0000000..e69de29 diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..9a21a38 --- /dev/null +++ b/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +#if [[ ! -f ".configured" ]]; then +# touch .configured +#else +# while true; do sleep 1; done +#fi +: ${MYSQLEXIST:=NO} + + if [ X"${MYSQLEXIST}" == X'YES' ]; then + echo test + else + echo notest + fi + +cat < /root/testfile +export STORAGE_BASE_DIR=\'STORAGE_BASE_DIR\' +export WEB_SERVER=\'WEB_SERVER\' +EOF diff --git a/testfile b/testfile new file mode 100644 index 0000000..c766c8f --- /dev/null +++ b/testfile @@ -0,0 +1,25 @@ +export STORAGE_BASE_DIR='' +export WEB_SERVER='' +export BACKEND_ORIG='' +export BACKEND='' +export VMAIL_DB_BIND_PASSWD='' +export VMAIL_DB_ADMIN_PASSWD='' +export MLMMJADMIN_API_AUTH_TOKEN='' +export NETDATA_DB_PASSWD='' +export LDAP_SUFFIX='' +export LDAP_BINDPW='' +export LDAP_ADMIN_PW='' +export LDAP_ROOTPW='' +export MYSQL_ROOT_PASSWD='' +export FIRST_DOMAIN='' +export DOMAIN_ADMIN_PASSWD_PLAIN='' +export USE_IREDADMIN='' +export USE_ROUNDCUBE='' +export AMAVISD_DB_PASSWD='' +export IREDADMIN_DB_PASSWD='' +export RCM_DB_PASSWD='' +export SOGO_DB_PASSWD='' +export SOGO_SIEVE_MASTER_PASSWD='' +export IREDAPD_DB_PASSWD='' +export FAIL2BAN_DB_PASSWD='' +EOF