Source

iredmail / iRedMail / conf / global

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
#!/usr/bin/env bash

# Author:   Zhang Huangbin (zhb(at)iredmail.org)

#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail.  If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------

export PROG_NAME='iRedMail'
export PROG_NAME_LOWERCASE='iredmail'
export PROG_VERSION='0.8.0-beta2'

# -----------------
# ---- Generic ----
# -----------------

# Maildir format: Maildir. Mbox format was deprecated since version 0.7.3.
export MAILBOX_FORMAT='Maildir'

# Maildir style: hashed, normal.
export MAILDIR_STYLE='hashed'

# Current storage node.
export STORAGE_NODE='vmail1'

# For distribute deployment.
# MySQL server
export MYSQL_SERVER='127.0.0.1'
export MYSQL_SERVER_PORT='3306'
# PGSQL server
export PGSQL_SERVER='127.0.0.1'
export PGSQL_SERVER_PORT='5432'
# POP3/IMAP server (Dovecot)
export IMAP_SERVER='127.0.0.1'
# SMTP server (Postfix)
export SMTP_SERVER='127.0.0.1'
# Amavisd
export AMAVISD_SERVER='127.0.0.1'

# For managesieve service and software.
export USE_MANAGESIEVE='YES'    # Use managesieve service.

# vmail user. uid and gid should be export after user added. Reference:
# functions/user_vmail.sh
export VMAIL_USER_NAME='vmail'
export VMAIL_GROUP_NAME='vmail'
export VMAIL_DB_ADMIN_USER="${VMAIL_USER_NAME}admin"

# Default SQL database name used to store mail accounts.
export VMAIL_DB='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'

# Hostname.
export HOSTNAME="$(hostname -f)"

# ----------------------------------
# You do *NOT* need to modify them.
# ----------------------------------
export DATE="$(/bin/date +%Y.%m.%d.%H.%M.%S)"

# For perl and run-time locale setting.
export LC_ALL=C

# Debug mode: YES, NO.
if [ X"${DEBUG}" != X'YES' ]; then
    export DEBUG='NO'
fi

# Genrate a random string.
# Usage:
#   str="$(${RANDOM_STRING})"
export RANDOM_STRING='eval </dev/urandom tr -dc A-Za-z0-9| (head -c $1 > /dev/null 2>&1 || head -c 30)'

# 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 CONFIG_FILE="${ROOTDIR}/config"
export TIP_FILE="${ROOTDIR}/${PROG_NAME}.tips"
export DOC_FILE="${ROOTDIR}/Documentations"
export STATUS_FILE="${ROOTDIR}/.${PROG_NAME}.installation.status"

# Output flag.
export INFO_FLAG="< INFO >"
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:  http://www.iredmail.org/
#
# Community: http://www.iredmail.org/forum/
#
"

# TERM.
if [ X"${TERM}" == X"" ]; then
    export TERM='xterm'
fi

# Logrotate configuration directory.
export LOGROTATE_DIR='/etc/logrotate.d'

# Kernel name.
export KERNEL_NAME="$(uname -s)"

# command: dialog.
export BIN_DIALOG="dialog"
export PKG_DIALOG="dialog"

# command: bzip2.
export BIN_BZIP2='bzip2'
export PKG_BZIP2='bzip2'

# Shell: /sbin/nologin.
export SHELL_NOLOGIN='/sbin/nologin'

# Check hardware architecture.
arch="$(uname -m)"
case $arch in
    i[3456]86) export ARCH='i386' ;;
    x86_64|amd64) export ARCH='x86_64' ;;
    *)
        echo "Your architecture is not supported yet: ${arch}."
        echo "Both i386 and x86_64 are supported by ${PROG_NAME}."
        exit 255
        ;;
esac

# Check distribution.
#   - DISTRO
#   - DISTRO_VERSION
#   - DISTRO_CODENAME
if [ X"${KERNEL_NAME}" == X"Linux" ]; then
    # Directory of RC scripts.
    export DIR_RC_SCRIPTS='/etc/init.d'

    if [ -f /etc/redhat-release ]; then
        # RHEL/CentOS
        export DISTRO='RHEL'

        # Get distribution version
        if grep '\ 5' /etc/redhat-release &>/dev/null; then
            # version 5.x
            export DISTRO_VERSION='5'
        elif grep '\ 6' /etc/redhat-release &>/dev/null; then
            # version 6.x
            export DISTRO_VERSION='6'
        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'
        fi

        export PKG_ARCH=".${ARCH}"
        if [ X"${DISTRO_VERSION}" == X"6" -a X"${ARCH}" == X"i386" ]; then
            export PKG_ARCH=''
        fi

    elif [ -f /etc/SuSE-release ]; then
        # SLES/OpenSuSE
        export DISTRO='SUSE'

        # SuSE version number. e.g. 11.3, 11.4.
        export DISTRO_VERSION="$(grep 'VERSION' /etc/SuSE-release | awk '{print $3}')"

        # SuSE code name.
        #   - 11.3:
        #   - 11.4: celadon
        export DISTRO_CODENAME="$(grep 'CODENAME' /etc/SuSE-release | awk '{print $3}' |tr [A-Z] [a-z])"

    elif [ -f /etc/lsb-release ]; then
        # Ubuntu
        export DISTRO='UBUNTU'

        # Ubuntu version number. e.g. 11.10.

        # Ubuntu version number and code name:
        #   - 8.04: hardy
        #   - 8.10: intrepid
        #   - 9.04: jaunty
        #   - 9.10: karmic
        #   - 10.04: lucid
        #   - 10.10: maverick
        #   - 11.04: natty
        #   - 11.10: oneiric
        export DISTRO_VERSION="$(grep 'DISTRIB_RELEASE' /etc/lsb-release | awk -F'=' '{print $2}')"
        export DISTRO_CODENAME="$(grep 'DISTRIB_CODENAME' /etc/lsb-release | awk -F'=' '{print $2}')"

        # Mark 10.10 (maverick) as 10.04 (lucid).
        if [ X"${DISTRO_CODENAME}" == X"maverick" ]; then
            export DISTRO_CODENAME='lucid'
        fi

    elif [ -f /etc/debian_version ]; then
        # Debian
        export DISTRO='DEBIAN'

        # Detect release version: 5.x, 6.x.
        if grep '^5\.' /etc/debian_version &>/dev/null; then
            # Debian 5
            export DISTRO_VERSION='5'
            export DISTRO_CODENAME='lenny'
        elif grep '^6\.' /etc/debian_version &>/dev/null; then
            # Debian 6
            export DISTRO_VERSION='6'
            export DISTRO_CODENAME='squeeze'
        fi

        # Override settings.
        if [ X"${DISTRO_CODENAME}" == X"squeeze" ]; then
            export SHELL_NOLOGIN='/usr/sbin/nologin'
        fi

    elif [ -f /etc/gentoo-release ]; then
        # Gentoo
        export DISTRO='GENTOO'

    else
        # Not support yet.
        echo "Your distrobution is not supported yet."
        exit 255
    fi
elif [ X"${KERNEL_NAME}" == X"FreeBSD" ]; then
    export DISTRO='FREEBSD'
    export DISTRO_VERSION="$(uname -r)"

    # Directory of RC scripts.
    export DIR_RC_SCRIPTS='/usr/local/etc/rc.d'
else
    # Not support *BSD and other distrobutions yet.
    echo "Error: Your OS is not supported yet."
    exit 255
fi

# install_pkg: function used to install packages without confirm.
# remove_pkg: function used to remove packages without confirm.
# LIST_ALL_PKGS: command used to list all installed packages.
# LIST_FILES_IN_PKG: command used to list files installed by special package.
# enable_service: function (defined in conf/core) used to enable services.
# disable_service: function (defined in conf/core) used to disable services.
if [ X"${DISTRO}" == X"RHEL" ]; then
    # RHEL/CentOS.
    # System user: root. Note: not all OSes have group 'root'.
    export SYS_ROOT_USER='root'
    export SYS_ROOT_GROUP='root'

    # Package management.
    if [ X"${YUM}" != X"" ]; then
        export YUM="${YUM}"
    else
        export YUM="yum -d 2"
    fi
    export install_pkg='install_pkg_rhel'
    export remove_pkg="remove_pkg_rhel"
    export LIST_ALL_PKGS='rpm -qa'
    export LIST_FILES_IN_PKG='rpm -ql'

    # Service control. Defined in file: conf/core.
    export enable_service='enable_service_rh'
    export disable_service='disable_service_rh'

    # Syslog config file: syslog.
    if [ X"${DISTRO_VERSION}" == X"5" ]; then
        export SYSLOG_CONF='/etc/syslog.conf'
    else
        export SYSLOG_CONF='/etc/rsyslog.conf'
    fi
    export SYSLOG_POSTROTATE_CMD='/bin/kill -HUP $(cat /var/run/syslogd.pid 2> /dev/null) 2> /dev/null || true'

    # Crontab related.
    export CRON_SPOOL_DIR='/var/spool/cron'

    # Directory /etc/sysconfig/ on RHEL/CentOS.
    export ETC_SYSCONFIG_DIR='/etc/sysconfig'

    # Iptables rule file.
    export IPTABLES_CONFIG="${ETC_SYSCONFIG_DIR}/iptables"

    # Directory used to store SSL/TLS key/cert file.
    export SSL_FILE_DIR="/etc/pki/tls"

    # Yum repository related.
    export YUM_REPOS_DIR='/etc/yum.repos.d'
    export LOCAL_REPO_NAME="${PROG_NAME}"
    export LOCAL_REPO_FILE="${YUM_REPOS_DIR}/${LOCAL_REPO_NAME}.repo"

    # Override default value.
    export PKG_DIALOG="dialog${PKG_ARCH}"
    export PKG_BZIP2="bzip2${PKG_ARCH}"

elif [ X"${DISTRO}" == X"SUSE" ]; then
    # OpenSuSE.
    # System user: root. Note: not all OSes have group 'root'.
    export SYS_ROOT_USER='root'
    export SYS_ROOT_GROUP='root'

    # Package management.
    export install_pkg='install_pkg_suse'
    export remove_pkg="remove_pkg_suse"
    export LIST_ALL_PKGS='rpm -qa'
    export LIST_FILES_IN_PKG='rpm -ql'

    # Service control.
    export enable_service='enable_service_rh'
    export disable_service='disable_service_rh'

    # Syslog config file: syslog.
    export SYSLOG_CONF='/etc/rsyslog.conf'
    #export SYSLOG_POSTROTATE_CMD='/bin/kill -HUP $(cat /var/run/syslogd.pid 2> /dev/null) 2> /dev/null || true'
    export SYSLOG_POSTROTATE_CMD=''

    # Crontab related.
    export CRON_SPOOL_DIR='/var/spool/cron/tabs'

    # Directory /etc/sysconfig/ on RHEL/CentOS/SuSE.
    export ETC_SYSCONFIG_DIR='/etc/sysconfig'

    # Iptables rule file.
    export IPTABLES_CONFIG="${ETC_SYSCONFIG_DIR}/SuSEfirewall2"

    # Directory used to store SSL/TLS key/cert file.
    export SSL_FILE_DIR="/etc/ssl"

    # Yum repository related.
    export ZYPPER_REPOS_DIR='/etc/zypp/repos.d'
    export LOCAL_REPO_NAME="${PROG_NAME}"
    export LOCAL_REPO_FILE="${YUM_REPOS_DIR}/${LOCAL_REPO_NAME}.repo"

    # Override default value.
    export PKG_DIALOG="dialog"
    export PKG_BZIP2="bzip2"

elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
    # Ubuntu & Debian.
    export DEBIAN_FRONTEND='noninteractive'

    # System user: root. Note: not all OSes have group 'root'.
    export SYS_ROOT_USER='root'
    export SYS_ROOT_GROUP='root'

    # Package management.
    if [ X"${APTGET}" != X"" ]; then
        export APTGET="${APTGET}"
    else
        export APTGET="apt-get"
    fi
    # Package management.
    export install_pkg='install_pkg_debian'
    export remove_pkg='remove_pkg_debian'
    export LIST_ALL_PKGS="dpkg -l |awk '{print $2}'"
    export LIST_FILES_IN_PKG='dpkg -L'

    # Service control.
    export enable_service="enable_service_debian"
    export disable_service="disable_service_debian"

    # Syslog config: rsyslog.
    if [ X"${DISTRO}" == X"UBUNTU" ]; then
        if [ X"${DISTRO_CODENAME}" == X"hardy" \
            -o X"${DISTRO_CODENAME}" == X"intrepid" \
            -o X"${DISTRO_CODENAME}" == X"jaunty" ]; then
            export SYSLOG_CONF='/etc/syslog.conf'
            export SYSLOG_POSTROTATE_CMD='invoke-rc.d sysklogd reload > /dev/null'
        else
            # Ubuntu >= 9.10
            export SYSLOG_CONF='/etc/rsyslog.d/iredmail.conf'
            export SYSLOG_POSTROTATE_CMD='reload rsyslog >/dev/null 2>&1 || true'
        fi
    fi

    if [ X"${DISTRO}" == X"DEBIAN" ]; then
        export SYSLOG_CONF='/etc/rsyslog.conf'
        export SYSLOG_POSTROTATE_CMD='invoke-rc.d rsyslog reload > /dev/null'
    fi

    # Crontab related.
    export CRON_SPOOL_DIR='/var/spool/cron/crontabs'

    # Directory /etc/default/ on Debian/Ubuntu.
    export ETC_SYSCONFIG_DIR='/etc/default'

    # Iptables rule file.
    export IPTABLES_CONFIG="${ETC_SYSCONFIG_DIR}/iptables"

    # Directory used to store SSL/TLS key/cert file.
    export SSL_FILE_DIR="/etc/ssl"

elif [ X"${DISTRO}" == X"GENTOO" ]; then
    # Gentoo
    # System user: root. Note: not all OSes have group 'root'.
    export SYS_ROOT_USER='root'
    export SYS_ROOT_GROUP='root'

    export install_pkg='install_pkg_gentoo'
    export remove_pkg="remove_pkg_gentoo"
    export LIST_ALL_PKGS='qlist --installed'
    export LIST_FILES_IN_PKG='equery files'

    # Service control. Defined in file: conf/core.
    export enable_service='enable_service_gentoo'
    export disable_service='disable_service_gentoo'

    # Syslog config file: syslog-ng.
    export SYSLOG_CONF='/etc/syslog-ng/syslog-ng.conf'
    export SYSLOG_POSTROTATE_CMD=''

    # Crontab related.
    export CRON_SPOOL_DIR='/var/spool/cron/crontabs'

    # Directory /etc/sysconfig/ on RHEL/CentOS.
    export ETC_SYSCONFIG_DIR='/etc/conf.d'

    # Iptables rule file.
    export IPTABLES_CONFIG="/var/lib/iptables/rules-save"

    # Directory used to store SSL/TLS key/cert file.
    export SSL_FILE_DIR="/etc/ssl"

    # Override default value.
    export VMAIL_GROUP_NAME='mail'
    export PKG_DIALOG="dialog"
    export PKG_BZIP2="bzip2"

    # Options used for install package
    export GENTOO_EMERGE_INSTALL_OPTIONS='--usepkg --binpkg-respect-use --buildpkg --quiet-build'
    export GENTOO_CONF_PACKAGE_USE='/etc/portage/package.use'
    export GENTOO_CONF_PACKAGE_MASK='/etc/portage/package.mask'
    export GENTOO_CONF_PACKAGE_UNMASK='/etc/portage/package.unmask'

elif [ X"${DISTRO}" == X"FREEBSD" ]; then
    # System user: root.
    export SYS_ROOT_USER='root'
    export SYS_ROOT_GROUP='wheel'

    # Package management.
    if [ X"${PKGADD}" != X"" ]; then
        export PKGADD="${PKGADD}"
    else
        export PKGADD="pkg_add"
    fi

    # Package management.
    export install_pkg='install_pkg_freebsd'
    export remove_pkg='remove_pkg_freebsd'
    export LIST_ALL_PKGS="pkg_info | awk '{print $1}'"
    export LIST_FILES_IN_PKG='pkg_info -L'

    # Service control.
    export enable_service="enable_service_freebsd"
    export disable_service="disable_service_freebsd"

    # Syslog config: rsyslog.
    export SYSLOG_CONF='/etc/syslog.conf'
    export SYSLOG_POSTROTATE_CMD=''

    # Crontab related.
    export CRON_SPOOL_DIR='/var/cron/tabs'

    export ETC_SYSCONFIG_DIR='/etc/defaults'

    # IPFW rule file.
    export IPTABLES_CONFIG="${ETC_SYSCONFIG_DIR}/ipfw.rules"

    # Directory used to store SSL/TLS key/cert file.
    export SSL_FILE_DIR="/etc/ssl"

else
    # Not support yet.
    echo "Your distrobution is not supported yet."
    exit 255
fi

# Use a seperated directory to store iRedMail certs/keys.
export SSL_CERT_DIR="${SSL_FILE_DIR}/certs"
export SSL_KEY_DIR="${SSL_FILE_DIR}/private"

# SSL key.
export OPENSSL_CONF="${SSL_FILE_DIR}/openssl.cnf"
export SSL_CERT_FILE="${SSL_CERT_DIR}/iRedMail_CA.pem"
export SSL_KEY_FILE="${SSL_KEY_DIR}/iRedMail.key"
export TLS_COUNTRY='CN'
export TLS_STATE='GuangDong'
export TLS_CITY='ShenZhen'
export TLS_COMPANY="${HOSTNAME}"
export TLS_DEPARTMENT='IT'
export TLS_HOSTNAME="${HOSTNAME}"
export TLS_ADMIN="root@${HOSTNAME}"

# Default SSL key size in bits
export SSL_KEY_SIZE='2048'
default_ssl_key_size="$(grep '^default_bits' ${OPENSSL_CONF} 2>/dev/null | awk -F'=' '{print $2}' | awk '{print $1}')"
if [ -z ${default_ssl_key_size} ]; then
    :
elif [ ${default_ssl_key_size} -ge ${SSL_KEY_SIZE} ]; then
    export SSL_KEY_SIZE="${default_ssl_key_size}"
fi

# Location of sshd_config
export SSHD_CONFIG='/etc/ssh/sshd_config'

# SQL databases which need to be backed up.
export MYSQL_BACKUP_DATABASES=''

# Command use to fetch source tarballs.
if [ X"${DISTRO}" == X"FREEBSD" ]; then
    # -i: Turns off interactive prompting during multiple file transfers.
    # -V: Disable verbose and progress
    FETCH_CMD='ftp -iV'
else
    # -c: Continue getting a partially-downloaded file.
    # -q: Turn off Wget's output.
    FETCH_CMD="wget -cq"
fi
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.