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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
#!/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.5'

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.
export IREDMAIL_DEBUG="${IREDMAIL_DEBUG:=NO}"

# -----------------
# ---- 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'

# Enabled backends.
export ENABLE_BACKEND_OPENLDAP='YES'
export ENABLE_BACKEND_MYSQL='YES'
export ENABLE_BACKEND_PGSQL='NO'
# OpenBSD built-in LDAP daemon
export ENABLE_BACKEND_LDAPD='NO'

# Enabled components.
export DIALOG_SELECTABLE_AWSTATS='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}"

# Hostname used in MySQL GRANT command.
# 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
    export SQL_HOSTNAME='localhost'
else
    export SQL_HOSTNAME="${LOCAL_ADDRESS}"
fi

# LDAP server
export LDAP_SERVER_HOST="${LOCAL_ADDRESS}"
# MySQL server
export MYSQL_SERVER="${LOCAL_ADDRESS}"
export MYSQL_SERVER_PORT='3306'
export MYSQL_ROOT_USER='root'
# PGSQL server
export PGSQL_SERVER="${LOCAL_ADDRESS}"
export PGSQL_SERVER_PORT='5432'
# Dovecot: POP3, IMAP, managesieve
export IMAP_SERVER="${LOCAL_ADDRESS}"
export MANAGESIEVE_BIND_HOST="${LOCAL_ADDRESS}"
export MANAGESIEVE_PORT='4190'
# SMTP server (Postfix)
export SMTP_SERVER="${LOCAL_ADDRESS}"
# Amavisd
export AMAVISD_SERVER="${LOCAL_ADDRESS}"
# Policyd or Cluebringer
export POLICYD_BIND_HOST="${LOCAL_ADDRESS}"
export CLUEBRINGER_BIND_HOST="${LOCAL_ADDRESS}"
# ClamAV
export CLAMD_BIND_HOST="${LOCAL_ADDRESS}"
# iRedAPD
export IREDAPD_BIND_HOST="${LOCAL_ADDRESS}"

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

# vmail user/group name, uid and gid.
export VMAIL_USER_NAME='vmail'
export VMAIL_GROUP_NAME='vmail'

# Specify UID/GID for system accounts: vmail, iredadmin, iredapd.
# Required by cluster environment. e.g. GlusterFS.
# Note: UID/GID of vmail will be 303 on openSUSE since package 'postfix-mysql'
#       will create it automatically.
export VMAIL_USER_UID='2000'
export VMAIL_USER_GID='2000'
export IREDADMIN_USER_UID='2001'
export IREDADMIN_USER_GID='2001'
export IREDAPD_DAEMON_USER_UID='2002'
export IREDAPD_DAEMON_USER_GID='2002'

# 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'

# 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="${ROOTDIR}/.status"

# 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:  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, in upper cases.
export KERNEL_NAME="$(uname -s | tr '[a-z]' '[A-Z]')"

# Hostname.
if [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
    export HOSTNAME="$(hostname)"
    export RANDOM_STRING='eval echo $RANDOM | md5'
else
    export HOSTNAME="$(hostname -f)"

    # 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 || head -c 30)'
fi

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

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

# Shells
export SHELL_NOLOGIN='/sbin/nologin'
export SHELL_BASH='/bin/bash'

# 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
#
# UNSUPPORTED_RELEASE will be set to 'YES' if current Linux/BSD release is
# an old release and unsupported anymore.
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 '\ 6' /etc/redhat-release &>/dev/null; then
            # version 6.x
            export DISTRO_VERSION='6'
        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

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

        # Enable PostgreSQL backend on RHEL/CentOS 6.
        if [ X"${DISTRO_VERSION}" == X'6' ]; then
            export ENABLE_BACKEND_PGSQL='YES'
        fi

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

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

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

        # Unsupported releases: 10.x, 11.x, 12.1 (asparagus), 12.2.
        if echo "${DISTRO_VERSION}" | grep '^1[01]' &>/dev/null ; then
            export UNSUPPORTED_RELEASE='YES'
        elif echo "${DISTRO_VERSION}" | grep '^12.[12]' &>/dev/null ; then
            export UNSUPPORTED_RELEASE='YES'
        fi

        export ENABLE_BACKEND_PGSQL='YES'

        # Override VMAIL uid/gid
        export VMAIL_USER_UID='303'
        export VMAIL_USER_GID='303'
    elif [ -f /etc/lsb-release ]; then
        # Ubuntu
        export DISTRO='UBUNTU'

        # Ubuntu version number and code name:
        #   - 12.04: precise (Long Term support by Ubuntu)
        #   - 13.04: raring
        export DISTRO_ID="$(grep 'DISTRIB_ID' /etc/lsb-release | awk -F'=' '{print $2}')"
        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}')"

        # Support PGSQL backend on Ubuntu 11.10 and later releases
        export ENABLE_BACKEND_PGSQL='YES'

        # Unsupported releases.
        #   - 8.04: hardy
        #   - 8.10: intrepid
        #   - 9.04: jaunty
        #   - 9.10: karmic
        #   - 10.04: lucid
        #   - 10.10: maverick
        #   - 11.04: natty
        #   - 11.10: oneiric
        #   - 12.10: quantal
        if [ X"${DISTRO_CODENAME}" == X'hardy' \
            -o X"${DISTRO_CODENAME}" == X'intrepid' \
            -o X"${DISTRO_CODENAME}" == X'jaunty' \
            -o X"${DISTRO_CODENAME}" == X'karmic' \
            -o X"${DISTRO_CODENAME}" == X'lucid' \
            -o X"${DISTRO_CODENAME}" == X'maverick' \
            -o X"${DISTRO_CODENAME}" == X'natty' \
            -o X"${DISTRO_CODENAME}" == X'oneiric' \
            -o X"${DISTRO_CODENAME}" == X'quantal' \
            ]; then
            export UNSUPPORTED_RELEASE='YES'
        fi
    elif [ -f /etc/debian_version ]; then
        # Debian
        export DISTRO='DEBIAN'

        # Get major release version number
        export DISTRO_VERSION="$(cat /etc/debian_version)"

        # Set distro code name and unsupported releases.
        if grep '^6' /etc/debian_version &>/dev/null; then
            export DISTRO_VERSION='6'
            export DISTRO_CODENAME='squeeze'
        elif grep '^7' /etc/debian_version &>/dev/null || \
            grep -i '^wheezy' /etc/debian_version &>/dev/null; then
            export DISTRO_VERSION='7'
            export DISTRO_CODENAME='wheezy'
            export ENABLE_BACKEND_PGSQL='YES'
        else
            export UNSUPPORTED_RELEASE='YES'
        fi

        # Override settings.
        export SHELL_NOLOGIN='/usr/sbin/nologin'

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

    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'

    # 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'
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
    export DISTRO='OPENBSD'
    export DISTRO_VERSION="$(uname -r)"

    # 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'

    # Unsupported release: 5.1, 5.2.
    if echo "${DISTRO_VERSION}" | grep '^5.[12]' &>/dev/null ; then
        export UNSUPPORTED_RELEASE='YES'
    fi
else
    # Not support *BSD and other distrobutions yet.
    echo "Error: Your OS is not supported yet."
    exit 255
fi

# Exit and prompt to use a supported Linux/BSD distribution
if [ X"${UNSUPPORTED_RELEASE}" == X'YES' ]; then
    cat <<EOF
********* ERROR *********
Release version of the operating system on this server is unsupported by
iRedMail, please access below link to get the latest iRedMail and a list
of supported Linux/BSD distributions and release versions.

http://www.iredmail.org/download.html

*************************
EOF

    exit 255
fi

# 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: rsyslog.
    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'

    # 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 FIREWALL_RULE_CONF="${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_suse'
    export disable_service='disable_service_suse'

    # 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/openSUSE.
    export ETC_SYSCONFIG_DIR='/etc/sysconfig'

    # iptables rule file.
    export FIREWALL_RULE_CONF="${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
        # Ubuntu >= 9.10
        export SYSLOG_CONF='/etc/rsyslog.d/iredmail.conf'
        export SYSLOG_POSTROTATE_CMD='reload rsyslog >/dev/null 2>&1 || true'
    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 FIREWALL_RULE_CONF="${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 FIREWALL_RULE_CONF="/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"

    # make.conf
    export GENTOO_CONF_MAKE_CONF='/etc/portage/make.conf'

    # Options used for install package
    export GENTOO_EMERGE_INSTALL_OPTIONS='--binpkg-respect-use --buildpkg'
    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
    export ENABLE_BACKEND_PGSQL='YES'

    # 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'

    # Port directory
    export PORT_WRKDIRPREFIX='/usr/ports'

    # 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'
    export FREEBSD_MAKE_CONF='/etc/make.conf'

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

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

elif [ X"${DISTRO}" == X'OPENBSD' ]; then
    export ENABLE_BACKEND_PGSQL='YES'
    export ENABLE_BACKEND_LDAPD='YES'

    # System user: root.
    export SYS_ROOT_USER='root'
    export SYS_ROOT_GROUP='wheel'

    # Package management.
    if [ X"${PKG_PATH}" == X"" ]; then
        # Reference: http://www.openbsd.org/faq/faq15.html#Easy
        export PKG_PATH="ftp://ftp.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(machine -a)/"
    fi

    # Package management.
    export install_pkg='pkg_add -i'
    export remove_pkg='pkg_delete'
    export LIST_ALL_PKGS="pkg_info -a | awk '{print $1}'"
    export LIST_FILES_IN_PKG='pkg_info -L'

    # Service control.
    export enable_service="enable_service_openbsd"
    export disable_service="disable_service_openbsd"

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

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

    # PF rule file.
    export FIREWALL_RULE_CONF="/etc/pf.conf"

    # Directory used to store SSL/TLS key/cert file.
    export SSL_FILE_DIR="/etc/ssl"
else
    # Not support yet.
    echo "Your distrobution is not supported yet."
    exit 255
fi

# Use a seperated directory to store iRedMail certs/keys.
if [ X"${DISTRO}" == X'OPENBSD' ]; then
    export SSL_CERT_DIR="${SSL_FILE_DIR}"
    export SSL_KEY_DIR="${SSL_FILE_DIR}"
else
    export SSL_CERT_DIR="${SSL_FILE_DIR}/certs"
    export SSL_KEY_DIR="${SSL_FILE_DIR}/private"
fi

# 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=''
export PGSQL_BACKUP_DATABASES=''

# Command use to fetch source tarballs.
if [ X"${DISTRO}" == X'FREEBSD' -o X"${DISTRO}" == X'OPENBSD' ]; then
    # -i: Turns off interactive prompting during multiple file transfers.
    # -V: Disable verbose and progress
    FETCH_CMD='ftp -iV'
else
    # -c: Continue getting a partially-downloaded file.
    # -q: Turn off Wget's output.
    FETCH_CMD="wget -cq"
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.