This commit is contained in:
temasky
2020-07-31 12:45:56 +00:00
commit 5d419635ed
306 changed files with 26949 additions and 0 deletions
+144
View File
@@ -0,0 +1,144 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# Warning: Please source 'conf/postfix' first.
export SYS_USER_AMAVISD='amavis'
export SYS_GROUP_AMAVISD='amavis'
export AMAVISD_QUARANTINE_PORT='9998'
export AMAVISD_LOGFILE='/var/log/amavisd.log'
export AMAVISD_LOGROTATE_FILE="${LOGROTATE_DIR}/amavisd"
export AMAVISD_DKIM_SELECTOR='dkim'
export AMAVISD_RC_SCRIPT_NAME='amavisd'
export AMAVISD_SPOOL_DIR='/var/spool/amavisd'
export AMAVISD_DKIM_DIR="${AMAVISD_DKIM_DIR:=/var/lib/dkim}"
# Network ports
export AMAVISD_SMTP_PORT='10024'
export AMAVISD_ORIGINATING_PORT='10026'
export AMAVISD_MLMMJ_PORT='10027'
export AMAVISD_QUARANTINE_PORT='9998'
# Database used to store incoming & outgoing email related information.
export AMAVISD_DB_NAME='amavisd'
export AMAVISD_DB_USER='amavisd'
# Altermime.
export CMD_ALTERMIME='/usr/bin/altermime'
export DISCLAIMER_DIR="${POSTFIX_ROOTDIR}/disclaimer"
if [ X"${DISTRO}" == X'RHEL' ]; then
export AMAVISD_BIN='/usr/sbin/amavisd'
export AMAVISD_LDAP_SCHEMA_NAME='amavisd-new.schema'
export AMAVISD_VAR_RUN_DIR='/var/run/amavisd'
export AMAVISD_CONF='/etc/amavisd/amavisd.conf'
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
export AMAVISD_BIN='/usr/sbin/amavisd-new'
export AMAVISD_CONF_DIR='/etc/amavis/conf.d'
export AMAVISD_CONF='/etc/amavis/conf.d/50-user'
export AMAVISD_RC_SCRIPT_NAME='amavis'
export AMAVISD_LDAP_SCHEMA_NAME='amavis.schema'
export AMAVISD_SPOOL_DIR='/var/lib/amavis'
export AMAVISD_VAR_RUN_DIR='/var/run/amavis'
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
# Override global setting: user/group.
export SYS_USER_AMAVISD='vscan'
export SYS_GROUP_AMAVISD='vscan'
export AMAVISD_BIN='/usr/local/sbin/amavisd'
export AMAVISD_CONF='/usr/local/etc/amavisd.conf'
export AMAVISD_LDAP_SCHEMA_NAME='amavisd-new.schema'
export AMAVISD_SPOOL_DIR='/var/amavis'
export AMAVISD_VAR_RUN_DIR="${AMAVISD_SPOOL_DIR}/var"
# Override location of command 'altermime'
export CMD_ALTERMIME='/usr/local/bin/altermime'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export SYS_USER_AMAVISD='_vscan'
export SYS_GROUP_AMAVISD='_vscan'
export AMAVISD_BIN='/usr/local/sbin/amavisd'
export AMAVISD_CONF='/etc/amavisd.conf'
export AMAVISD_LDAP_SCHEMA_NAME='amavisd.schema'
export AMAVISD_SPOOL_DIR='/var/amavisd'
export AMAVISD_VAR_RUN_DIR="${AMAVISD_SPOOL_DIR}"
# Override location of command 'altermime'
export CMD_ALTERMIME='/usr/local/bin/altermime'
fi
export CRON_FILE_AMAVISD="${CRON_SPOOL_DIR}/${SYS_USER_AMAVISD}"
export AMAVISD_DB_DIR="${AMAVISD_SPOOL_DIR}/db"
export AMAVISD_QUARANTINE_DIR="${AMAVISD_SPOOL_DIR}/quarantine"
export AMAVISD_TEMP_DIR="${AMAVISD_SPOOL_DIR}/tmp"
if [ X"${DISTRO}" == X'RHEL' ]; then
export AMAVISD_VIRUSMAILS_DIR="${AMAVISD_QUARANTINE_DIR}"
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
export AMAVISD_VIRUSMAILS_DIR="${AMAVISD_SPOOL_DIR}/virusmails"
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export AMAVISD_VIRUSMAILS_DIR='/var/virusmails'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export AMAVISD_VIRUSMAILS_DIR='/var/virusmails'
fi
export AMAVISD_LOCK_FILE="${AMAVISD_VAR_RUN_DIR}/amavisd.lock"
export AMAVISD_PID_FILE="${AMAVISD_VAR_RUN_DIR}/amavisd.pid"
export AMAVISD_SOCKET_FILE="${AMAVISD_VAR_RUN_DIR}/amavisd.socket"
export AMAVISD_DB_MYSQL_TMPL="${SAMPLE_DIR}/amavisd/amavisd.mysql"
export AMAVISD_DB_PGSQL_TMPL="${SAMPLE_DIR}/amavisd/amavisd.pgsql"
# Value of Postfix parameter `content_filter=`.
export AMAVISD_CONTENT_FILTER_ORIGINATING="smtp-amavis:[${SMTP_SERVER}]:${AMAVISD_ORIGINATING_PORT}"
# mynetworks, inet_acl
export AMAVISD_MYNETWORKS='127.0.0.0/8'
export AMAVISD_INET_ACL='127.0.0.1 [::1]'
if [ X"${LOCAL_ADDRESS}" != X'127.0.0.1' ]; then
export AMAVISD_MYNETWORKS="${AMAVISD_MYNETWORKS},${LOCAL_ADDRESS}"
export AMAVISD_INET_ACL="${AMAVISD_INET_ACL} ${LOCAL_ADDRESS}"
fi
# Num of pre-forked children.
# Try to set it to memory size (in GB)
export AMAVISD_MAX_SERVERS='2'
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
_mem_size_gb="$(free -g | grep '^Mem:' | awk '{print $2}')"
export AMAVISD_MAX_SERVERS="$((${_mem_size_gb} + 1))"
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
_mem_size="$(sysctl hw.realmem | awk '{print $2}')"
export AMAVISD_MAX_SERVERS="$((${_mem_size} / 1024 / 1024 / 1024 + 1))"
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
_mem_size="$(sysctl hw.physmem | awk -F'=' '{print $2}')"
export AMAVISD_MAX_SERVERS="$((${_mem_size} / 1024 / 1024 / 1024 + 1))"
fi
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
export SYS_USER_CLAMAV='clamav'
export SYS_GROUP_CLAMAV='clamav'
export CLAMAV_CLAMD_SERVICE_NAME='clamd'
export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='freshclamd'
export CLAMD_CONF='/etc/clamd.conf'
export CLAMD_LOG_DIR='/var/log/clamav'
export CLAMD_LOGFILE="${CLAMD_LOG_DIR}/clamd.log"
# CLAMD_BIND_HOST is configured in conf/global
export CLAMD_LOCAL_SOCKET='/tmp/clamd.socket'
export FRESHCLAM_CONF='/etc/freshclam.conf'
export FRESHCLAM_LOGFILE="${CLAMD_LOG_DIR}/freshclam.log"
export FRESHCLAM_PID_FILE='/var/run/clamav/freshclam.pid'
# Update database immediately
export FRESHCLAM_UPDATE_IMMEDIATELY="${FRESHCLAM_UPDATE_IMMEDIATELY:=YES}"
# Clamav.
if [ X"${DISTRO}" == X'RHEL' ]; then
export SYS_USER_CLAMAV='amavis'
export SYS_GROUP_CLAMAV='amavis'
export CLAMD_CONF='/etc/clamd.d/amavisd.conf'
export CLAMD_LOCAL_SOCKET='/var/run/clamd.amavisd/clamd.socket'
export CLAMAV_CLAMD_SERVICE_NAME='clamd@amavisd'
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
export CLAMAV_CLAMD_SERVICE_NAME='clamav-daemon'
export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='clamav-freshclam'
export CLAMD_CONF='/etc/clamav/clamd.conf'
export FRESHCLAM_CONF='/etc/clamav/freshclam.conf'
export CLAMD_LOCAL_SOCKET='/var/run/clamav/clamd.ctl'
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export CLAMD_CONF='/usr/local/etc/clamd.conf'
export FRESHCLAM_CONF='/usr/local/etc/freshclam.conf'
export CLAMD_LOCAL_SOCKET='/var/run/clamav/clamd.sock'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export SYS_USER_CLAMAV='_clamav'
export SYS_GROUP_CLAMAV='_clamav'
export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='freshclam'
export FRESHCLAM_PID_FILE='/var/run/freshclam.pid'
fi
+624
View File
@@ -0,0 +1,624 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
ECHO_INFO()
{
if [ X"$1" == X"-n" ]; then
shift 1
echo -ne "${_INFO_FLAG} $@"
else
echo -e "${_INFO_FLAG} $@"
fi
echo -e "${_INFO_FLAG} $@" >> ${INSTALL_LOG}
}
ECHO_SKIP()
{
echo -e "${_SKIP_FLAG} $@"
echo -e "${_SKIP_FLAG} $@" >> ${INSTALL_LOG}
}
ECHO_QUESTION()
{
if [ X"$1" == X"-n" ]; then
shift 1
echo -ne "${_QUESTION_FLAG} $@"
else
echo -e "${_QUESTION_FLAG} $@"
fi
}
ECHO_ERROR()
{
echo -e "${_ERROR_FLAG} $@"
echo -e "${_ERROR_FLAG} $@" >> ${INSTALL_LOG}
}
ECHO_DEBUG()
{
echo -e "${_DEBUG_FLAG} $@" >> ${INSTALL_LOG}
}
read_setting()
{
answer="${1}"
if [ ! -z "${answer}" ]; then
ANSWER="${answer}"
echo ${ANSWER}
else
read ANSWER
fi
}
backup_file()
{
# Usage: backup_file file1 [file2 file3 ... fileN]
if [ X"$#" != X"0" ]; then
for f in $@; do
if [ -f ${f} ]; then
if [ X"${IREDMAIL_DEBUG}" == X'YES' ]; then
echo -e "${_BACKUP_FLAG} ${f} -> ${f}.${DATE}."
fi
cp -f ${f} ${f}.${DATE}
fi
done
fi
}
check_user()
{
# Check special user privilege to execute this script.
if [ X"$(id -u)" != X"$(id -u ${1})" ]; then
ECHO_ERROR "Please run this script as user: ${1}."
exit 255
else
if [ X"$(id -u)" == X"0" ]; then
export PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
else
:
fi
fi
}
check_hostname()
{
echo ${HOSTNAME} | grep '.\..*' &>/dev/null
[ X"$?" != X'0' ] && \
ECHO_ERROR "Please configure a fully qualified domain name (FQDN) in /etc/hosts before we go further.\n\nExample:\n\n127.0.0.1 mail.iredmail.org mail localhost\n" && \
exit 255
}
check_openbsd_install_url()
{
touch /etc/installurl
# Make sure it contains a http/ftp/scp URL
if ! grep -Ei '^(ftp|http|https|scp)://' /etc/installurl &>/dev/null; then
ECHO_INFO "No valid OpenBSD mirror server URL found in file /etc/installurl."
ECHO_INFO "We will use the fastly CDN for this iRedMail installation:"
ECHO_INFO ''
ECHO_INFO " - https://fastly.cdn.openbsd.org/pub/OpenBSD"
ECHO_INFO ''
ECHO_INFO "If you prefer a nearest mirror site, please check links below:"
ECHO_INFO ''
ECHO_INFO " - Mirror sites: http://www.openbsd.org/ftp.html"
ECHO_INFO " - installurl(5): http://man.openbsd.org/installurl.5"
ECHO_INFO ''
echo 'https://fastly.cdn.openbsd.org/pub/OpenBSD' >> /etc/installurl
fi
}
check_pkg()
{
# Usage: check_pkg <command> <package>
# It means: <package> owns <command>
cmd="$1"
pkg="$2"
for i in $(echo $PATH|sed 's/:/ /g'); do
[ -x $i/${cmd} ] && export HAS_CMD='YES' && break
done
if [ X"${HAS_CMD}" != X'YES' ]; then
ECHO_INFO "Install package: ${pkg}"
eval ${install_pkg} ${pkg}
if [ X"$?" != X"0" ]; then
ECHO_ERROR "Please install package ${pkg} first." && exit 255
fi
fi
unset HAS_CMD
}
check_runtime_dir() {
[ -d ${RUNTIME_DIR} ] || mkdir -p ${RUNTIME_DIR}
# Cleanup
rm -f ${RUNTIME_DIR}/.pkg_install_failed &>/dev/null
}
check_required_os_dirs() {
if [ X"${DISTRO}" == X'FREEBSD' ]; then
[ -d ${LOGROTATE_DIR} ] || mkdir -p ${LOGROTATE_DIR}
fi
}
# Check necessery privileges/files/dirs.
check_env()
{
check_runtime_dir
check_required_os_dirs
# Check user privilege.
check_user root
# Check FQDN hostname.
check_hostname
[ X"${DISTRO}" == X'OPENBSD' ] && check_openbsd_install_url
# Check config tool: dialog.
check_pkg ${BIN_DIALOG} ${PKG_DIALOG}
ECHO_INFO -n "Checking configuration file: ${IREDMAIL_CONFIG_FILE} ..."
if [ -f ${IREDMAIL_CONFIG_FILE} ]; then
if grep '^#EOF$' ${IREDMAIL_CONFIG_FILE} >/dev/null; then
echo -e " [FOUND]"
ECHO_QUESTION -n "Use it for mail server setting? [y|N]"
read_setting ${AUTO_USE_EXISTING_CONFIG_FILE}
case ${ANSWER} in
Y|y|[Yy][Ee][Ss] )
ECHO_INFO "Use config file: ${IREDMAIL_CONFIG_FILE} for mail server setting."
. ${IREDMAIL_CONFIG_FILE}
# Check installation status.
# After each component installation was completed, there
# should be a variable in ${STATUS_FILE}, e.g.
#
# export STATUS_PHP_INSTALLATION='DONE'
# export STATUS_PHP_CONFIGURATION='DONE'
#
if [ -f ${STATUS_FILE} ]; then
ECHO_INFO "Import installation process status from file: ${STATUS_FILE}."
. ${STATUS_FILE}
else
echo '' > ${STATUS_FILE}
fi
# Initialize tip file.
if [ ! -f ${TIP_FILE} ]; then
cat > ${TIP_FILE} <<EOF
${CONF_MSG}
EOF
chown ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${TIP_FILE}
chmod 0400 ${TIP_FILE}
fi
;;
N|n|* )
ECHO_INFO "Skip configuration file: ${IREDMAIL_CONFIG_FILE}."
backup_file ${IREDMAIL_CONFIG_FILE}
. ${CONFIG_VIA_DIALOG}
;;
esac
else
ECHO_INFO "Found, but not finished. Launching installation wizard."
. ${CONFIG_VIA_DIALOG}
fi
else
ECHO_INFO "NOT FOUND. Launching installation wizard."
. ${CONFIG_VIA_DIALOG}
fi
}
extract_pkg()
{
if [ X"$2" = X"" ]; then
DST='.'
else
DST="$2"
fi
if echo $1 | grep '.tar.gz$' &>/dev/null; then
ECHO_DEBUG "Extracting: $1 -> ${DST}"
tar zxf $1 -C $DST
elif echo $1 | grep '.tgz$' &>/dev/null; then
ECHO_DEBUG "Extracting: $1 -> ${DST}"
tar zxf $1 -C $DST
elif echo $1 | grep '.tar.bz2$' &>/dev/null; then
# Install bzip2 first.
check_pkg ${BIN_BZIP2} ${PKG_BZIP2}
ECHO_DEBUG "Extracting: $1 -> ${DST}"
tar xjf $1 -C $DST
else
ECHO_ERROR "Unknown archive format."
fi
}
check_status_before_run()
{
# If function was successfully executed, this function will write one line
# in $STATUS_FILE:
#
# export status_[function_name]='DONE'
#
function_name="${1}"
function_status_name="status_${function_name}"
function_status_value="$(eval echo \$${function_status_name})"
if [ X"${function_status_value}" == X"DONE" ]; then
ECHO_SKIP "Function: $1."
else
$function_name
fi
}
# Hash maildir string.
hash_maildir()
{
# Usage:
#
# hash_maildir username
# hash_maildir --no-timestamp username
#
# With '--no-timestamp', the maildir path will not contain timestamp string
if [ X"$1" == X'--no-timestamp' ]; then
_timestamp=''
shift 1
else
_timestamp="-${DATE}"
fi
username="$( echo $1 | tr '[A-Z]' '[a-z]' )"
# Different maildir style: hashed, normal.
if [ X"${MAILDIR_STYLE}" == X"hashed" ]; then
str1="$(echo ${username} | cut -c1)"
str2="$(echo ${username} | cut -c2)"
str3="$(echo ${username} | cut -c3)"
if [ X"${username}" == X"${str1}" ]; then
# Username has only one character
str2="${str1}"
str3="${str1}"
elif [ X"${username}" == X"${str1}${str2}" ]; then
str3="${str2}"
else
:
fi
maildir="${str1}/${str2}/${str3}/${username}${_timestamp}/"
else
maildir="${username}${_timestamp}/"
fi
echo ${maildir}
}
# All Linux/BSD distributions: for one service:
# service_control [enable|disable|start|stop|restart] <service>
# Linux: for multiple services:
# service_control [enable|disable|start|stop|restart] <service1> <service2> <service3> ...
# FreeBSD: for one service:
# service_control enable '<service>_enable' 'YES'
service_control()
{
action="$1" # enable, disable, start, stop, restart
shift 1
service="$1" # first service name
services="$@" # all service names
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
ECHO_DEBUG "Service control: ${action} ${services}."
if [ X"${USE_SYSTEMD}" == X'YES' ]; then
service ${services} ${action}
else
for srv in ${services}; do
rc_script="${DIR_RC_SCRIPTS}/$srv"
${rc_script} $action
done
fi
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
if [ X"${action}" == X'enable' ]; then
if [ X"$#" == X'2' ]; then
${SYSRC} -f ${RC_CONF_LOCAL} ${1}="${2}" >> ${INSTALL_LOG} 2>&1
fi
elif [ X"${action}" == X'disable' ]; then
# Already handled in functions/*.sh.
:
else
${DIR_RC_SCRIPTS}/${service} $action >/dev/null
fi
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
for srv in ${services}; do
rcctl ${action} ${srv} >> ${INSTALL_LOG} 2>&1
done
fi
}
generate_password_hash()
{
_scheme="${1}"
_password="${2}"
if [ X"${_scheme}" == X'BCRYPT' ]; then
_scheme='BLF-CRYPT'
fi
doveadm pw -s "${_scheme}" -p "${_password}"
}
# Create SSL certs/private files.
generate_ssl_keys()
{
ECHO_INFO "Generate self-signed SSL cert (${SSL_KEY_SIZE} bits, expire in 10 years)."
# Create necessary directories.
mkdir -p ${SSL_KEY_DIR} ${SSL_CERT_DIR} &>/dev/null
openssl req \
-x509 \
-nodes \
-days 3650 \
-sha256 \
-subj "/C=${TLS_COUNTRY}/ST=${TLS_STATE}/L=${TLS_CITY}/O=${TLS_COMPANY}/OU=${TLS_DEPARTMENT}/CN=${TLS_HOSTNAME}/emailAddress=${TLS_ADMIN}/" \
-newkey rsa:${SSL_KEY_SIZE} \
-out ${SSL_CERT_FILE} \
-keyout ${SSL_KEY_FILE} &>/dev/null
# Set correct file permission.
chmod +r ${SSL_CERT_FILE}
chmod +r ${SSL_KEY_FILE}
# Fix 'The Logjam Attack'. References:
# - https://weakdh.org/
# - https://weakdh.org/sysadmin.html
ECHO_INFO "Generate Diffie Hellman Group with openssl, please wait."
openssl dhparam -out ${SSL_DH512_PARAM_FILE} 512 5>&1 &>/dev/null
openssl dhparam -out ${SSL_DH1024_PARAM_FILE} 2048 5>&1 &>/dev/null
cat >> ${TIP_FILE} <<EOF
SSL cert keys (size: ${SSL_KEY_SIZE}):
- ${SSL_CERT_FILE}
- ${SSL_KEY_FILE}
EOF
echo 'export status_generate_ssl_keys="DONE"' >> ${STATUS_FILE}
}
# Add alias entry in Postfix /etc/postfix/aliases.
add_postfix_alias()
{
# Usage: add_postfix_alias [src_username] [dest_username or email address]
# File ${POSTFIX_FILE_ALIASES} will be created if not exist.
export alias_src="${1}"
export alias_dest="${2}"
if [ ! -f ${POSTFIX_FILE_ALIASES} ]; then
if [ -f /etc/aliases ]; then
cp -f /etc/aliases ${POSTFIX_FILE_ALIASES}
else
# Create an empty file
touch ${POSTFIX_FILE_ALIASES}
fi
fi
# If alias_src exists, comment it out
if grep "^${alias_src}:" ${POSTFIX_FILE_ALIASES} &>/dev/null; then
perl -pi -e 's/^($ENV{alias_src}:.*)/#${1}/' ${POSTFIX_FILE_ALIASES}
fi
# Add new alias
echo "${alias_src}: ${alias_dest}" >> ${POSTFIX_FILE_ALIASES}
postalias hash:${POSTFIX_FILE_ALIASES} &>/dev/null
unset alias_src
unset alias_dest
}
# Install/Remove binary packages on RHEL/CentOS.
install_pkg_rhel()
{
ECHO_INFO "Installing package(s): $@"
${YUM} -y --disablerepo=rpmforge,ius,remi,atrpms install $@
# Leave a mark if package installation failed.
if [ X"$?" != X'0' ]; then
echo '' > ${RUNTIME_DIR}/.pkg_install_failed
fi
}
remove_pkg_rhel()
{
ECHO_INFO "Removing package(s): $@"
${YUM} remove -y $@
if [ X"$?" != X"0" ]; then
ECHO_ERROR "Package removed failed, please check the terminal output."
echo '' > ${RUNTIME_DIR}/.pkg_remove_failed
fi
}
# Install/Remove binary packages on Debian/Ubuntu.
install_pkg_debian()
{
ECHO_INFO "Installing package(s): $@"
${APTGET} install -y $@
# Leave a mark if package installation failed.
if [ X"$?" != X"0" ]; then
echo '' > ${RUNTIME_DIR}/.pkg_install_failed
fi
}
remove_pkg_debian()
{
ECHO_INFO "Removing package(s): $@"
${APTGET} purge -y $@
if [ X"$?" != X"0" ]; then
ECHO_ERROR "Package removed failed, please check the terminal output."
echo '' > ${RUNTIME_DIR}/.pkg_remove_failed
fi
}
install_pkg_openbsd()
{
ECHO_INFO "Installing packages (pkg_add -i -m): $@"
pkg_add -i -m $@
# Leave a mark if package installation failed.
if [ X"$?" != X"0" ]; then
echo '' > ${RUNTIME_DIR}/.pkg_install_failed
fi
}
freebsd_make_conf_add()
{
# USAGE: freebsd_make_conf_add VAR VALUE
[ -f ${FREEBSD_MAKE_CONF} ] || touch ${FREEBSD_MAKE_CONF}
if [ X"$#" == X'2' ]; then
var="${1}"
value="${2}"
final_option="${1}=${2}"
comment_mark="# ${PROG_NAME}-${var}"
if ! grep "^${comment_mark}$" ${FREEBSD_MAKE_CONF} &>/dev/null; then
ECHO_DEBUG "Update ${FREEBSD_MAKE_CONF}: ${final_option}"
echo "${comment_mark}" >> ${FREEBSD_MAKE_CONF}
echo "${final_option}" >> ${FREEBSD_MAKE_CONF}
else
ECHO_DEBUG "Skip adding option in ${FREEBSD_MAKE_CONF}: ${final_option}"
fi
fi
}
freebsd_make_conf_plus_option()
{
# USAGE: freebsd_make_conf_plus_option VAR VALUE
[ -f ${FREEBSD_MAKE_CONF} ] || touch ${FREEBSD_MAKE_CONF}
if [ X"$#" == X'2' ]; then
var="${1}"
value="${2}"
final_option="${1}+=${2}"
comment_mark="# ${PROG_NAME}-${var}-${value}"
if ! grep "^${comment_mark}$" ${FREEBSD_MAKE_CONF} &>/dev/null; then
ECHO_DEBUG "Update ${FREEBSD_MAKE_CONF}: ${final_option}"
echo "${comment_mark}" >> ${FREEBSD_MAKE_CONF}
echo "${final_option}" >> ${FREEBSD_MAKE_CONF}
else
ECHO_DEBUG "Skip adding option in ${FREEBSD_MAKE_CONF}: ${final_option}"
fi
fi
}
ask_confirm()
{
# Usage: ask_confirm 'prompt text'
prompt_text="${1}"
echo -ne "${prompt_text} [y|N]"
read ANSWER
case ${ANSWER} in
Y|y ) : ;;
N|n|* ) echo "Exit." && exit ;;
esac
}
add_sys_user_group()
{
_user="$1"
_group="$2"
_uid="$3"
_gid="$4"
_home="$5"
_shell="$6"
_args_u="-m -g ${_group}"
_args_g=''
if [ X"${_uid}" != X'' ]; then
_args_u="${_args_u} -u ${_uid}"
fi
if [ X"${_gid}" != X'' ]; then
_args_g="${_args_g} -g ${_gid}"
fi
if [ X"${_home}" != X'' ]; then
_args_u="${_args_u} -d ${_home}"
fi
if [ X"${_shell}" == X'' ]; then
_shell="${SHELL_NOLOGIN}"
fi
_args_u="${_args_u} -s ${_shell}"
ECHO_DEBUG "Create system account: ${_user}:${_group}."
if [ X"${DISTRO}" == X'FREEBSD' ]; then
pw groupadd ${_args_g} -n ${_group} >> ${INSTALL_LOG} 2>&1
pw useradd ${_args_u} -n ${_user} >> ${INSTALL_LOG} 2>&1
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
groupadd ${_args_g} ${_user} >> ${INSTALL_LOG} 2>&1
useradd \
-u ${_uid} \
-g ${_group} \
-s ${_shell} \
${_user} >> ${INSTALL_LOG} 2>&1
else
groupadd ${_args_g} ${_group} >> ${INSTALL_LOG} 2>&1
useradd ${_args_u} ${_user} >> ${INSTALL_LOG} 2>&1
fi
}
update_sysctl_param()
{
export _param="$1"
export _value="$2"
if grep "^${_param}\>" ${SYSCTL_CONF} &>/dev/null; then
# param exists, updating it.
perl -pi -e 's#^($ENV{_param})[ =].*#${1}=$ENV{_value}#' ${SYSCTL_CONF}
else
# param doesn't exist. add a new one.
echo "${_param}=${_value}" >> ${SYSCTL_CONF}
fi
unset _param _value
}
write_iredmail_kv()
{
# usage: write_iredmail_kv <param> <value>
# Storage value to file /root/.iredmail/kv/<param>.
param="$1"
value="$2"
[[ -f ${IREDMAIL_KV_DIR} ]] || mkdir -p ${IREDMAIL_KV_DIR}
f="${IREDMAIL_KV_DIR}/${param}"
echo "${value}" > ${f}
chown -R ${SYS_USER_ROOT}:${SYS_GROUP_ROOT} ${IREDMAIL_KV_DIR}
chmod -R 0400 ${IREDMAIL_KV_DIR}
}
+152
View File
@@ -0,0 +1,152 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# ----------------------------------------
# For Dovecot and dovecot-sieve.
# ----------------------------------------
# Major version number of Dovecot package: 2.2, 2.3.
export DOVECOT_VERSION='2.3'
# Dovecot user & group.
export SYS_USER_DOVECOT='dovecot'
export SYS_GROUP_DOVECOT='dovecot'
export DOVECOT_RC_SCRIPT_NAME='dovecot'
export DOVECOT_BIN='/usr/sbin/dovecot'
export DOVECOT_DOVEADM_BIN='/usr/bin/doveadm'
export DOVECOT_SIEVEC='/usr/libexec/dovecot/sievec'
# Dovecot running directory, required by dovecot-2.x.
export DOVECOT_BASE_DIR='/var/run/dovecot'
# Enabled plugins for protocol 'lda' and 'imap'.
export DOVECOT_LDA_PLUGINS='quota sieve autocreate'
export DOVECOT_IMAP_PLUGINS='quota imap_quota autocreate'
# Default quota type: maildir, dict:user::proxy::quotadict (quotadict).
export DOVECOT_QUOTA_TYPE='dict:user::proxy::quotadict'
# Do not starts with dot (.).
export SIEVE_RULE_FILENAME='dovecot.sieve'
export DOVECOT_GLOBAL_SIEVE_FILE="${SIEVE_DIR}/${SIEVE_RULE_FILENAME}"
# Directory used to store Dovecot config files
export DOVECOT_CONF_DIR='/etc/dovecot'
export DOVECOT_CONF_INCLUDE_DIR='/etc/dovecot/iredmail'
# Path to Dovecot deliver agant
export DOVECOT_DELIVER_BIN='/usr/libexec/dovecot/deliver'
# main log file
export DOVECOT_LOG_DIR='/var/log/dovecot'
export DOVECOT_LOG_FILE="${DOVECOT_LOG_DIR}/dovecot.log"
# Log files when we use Dovecot internal log system
export DOVECOT_SIEVE_LOG_FILE="${DOVECOT_LOG_DIR}/sieve.log"
export DOVECOT_LMTP_LOG_FILE="${DOVECOT_LOG_DIR}/lmtp.log"
# Log files when we use syslog
export DOVECOT_SYSLOG_FILE_LDA="${DOVECOT_LOG_DIR}/lda.log"
export DOVECOT_SYSLOG_FILE_IMAP="${DOVECOT_LOG_DIR}/imap.log"
export DOVECOT_SYSLOG_FILE_POP3="${DOVECOT_LOG_DIR}/pop3.log"
export DOVECOT_SYSLOG_FILE_SIEVE="${DOVECOT_LOG_DIR}/sieve.log"
# Log rotate config file
export DOVECOT_LOGROTATE_FILE="${LOGROTATE_DIR}/dovecot"
if [ X"${DISTRO}" == X'RHEL' ]; then
if [ X"${DISTRO_VERSION}" == X'7' ]; then
export DOVECOT_VERSION='2.2'
fi
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
export DOVECOT_DELIVER_BIN='/usr/lib/dovecot/deliver'
# Debian 9, Ubuntu 18.04.
if [ X"${DISTRO_CODENAME}" == X'stretch' -o X"${DISTRO_CODENAME}" == X'bionic' ]; then
export DOVECOT_VERSION='2.2'
fi
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export DOVECOT_CONF_DIR='/usr/local/etc/dovecot'
export DOVECOT_DELIVER_BIN='/usr/local/libexec/dovecot/deliver'
export DOVECOT_DOVEADM_BIN='/usr/local/bin/doveadm'
export DOVECOT_CONF_INCLUDE_DIR='/usr/local/etc/dovecot/iredmail'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export SYS_USER_DOVECOT='_dovecot'
export SYS_GROUP_DOVECOT='_dovecot'
export DOVECOT_DELIVER_BIN='/usr/local/libexec/dovecot/deliver'
export DOVECOT_DOVEADM_BIN='/usr/local/bin/doveadm'
fi
# Dovecot config files
export DOVECOT_CONF="${DOVECOT_CONF_DIR}/dovecot.conf"
export DOVECOT_LDAP_CONF="${DOVECOT_CONF_DIR}/dovecot-ldap.conf"
export DOVECOT_MYSQL_CONF="${DOVECOT_CONF_DIR}/dovecot-mysql.conf"
export DOVECOT_PGSQL_CONF="${DOVECOT_CONF_DIR}/dovecot-pgsql.conf"
export DOVECOT_REALTIME_QUOTA_CONF="${DOVECOT_CONF_DIR}/dovecot-used-quota.conf"
export DOVECOT_SHARE_FOLDER_CONF="${DOVECOT_CONF_DIR}/dovecot-share-folder.conf"
export DOVECOT_LAST_LOGIN_CONF="${DOVECOT_CONF_DIR}/dovecot-last-login.conf"
export DOVECOT_MASTER_USER_PASSWORD_FILE="${DOVECOT_CONF_DIR}/dovecot-master-users"
export DOVECOT_MASTER_USER_DOMAIN="${DOVECOT_MASTER_USER_DOMAIN:=not-exist.com}"
# Dovecot auth socket and pid file.
# Relative path of Dovecot auth socket under Postfix chroot directory.
export DOVECOT_SASL_AUTH_SOCKET='private/dovecot-auth'
export DOVECOT_AUTH_MASTER_PATH="${DOVECOT_BASE_DIR}/auth-master"
export DOVECOT_MASTER_PID="${DOVECOT_BASE_DIR}/master.pid"
# Protocols.
export DOVECOT_PROTOCOLS="pop3 imap sieve lmtp"
# Plugin: Expire.
# NOTE: dict process currently runs as root, so this file will be owned as root.
export DOVECOT_EXPIRE_DICT_BDB='/var/lib/dovecot/expire/expire.db'
# Plugin: quota warning.
export DOVECOT_QUOTA_WARNING_SCRIPT='/usr/local/bin/dovecot-quota-warning.sh'
# Plugin: share folder.
export DOVECOT_SHARE_FOLDER_DB_TABLE='share_folder'
export DOVECOT_SHARE_FOLDER_ANYONE_DB_TABLE='anyone_shares'
export DOVECOT_REALTIME_QUOTA_TABLE='used_quota'
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
export DOVECOT_SQL_DBN='mysql'
elif [ X"${BACKEND}" == X'PGSQL' ]; then
export DOVECOT_SQL_DBN='pgsql'
fi
# Plugin: stats
export DOVECOT_SERVICE_STATS_USER="${SYS_USER_VMAIL}"
export DOVECOT_SERVICE_STATS_GROUP="${SYS_GROUP_VMAIL}"
export DOVECOT_SERVICE_STATS_PORT='24242'
# FYI: https://wiki.dovecot.org/Quota#Quota_service
export DOVECOT_SERVICE_QUOTA_STATUS_PORT='12340'
# Local (Mail) Delivery Agent
# - dovecot
# - lmtp:unix:private/dovecot-lmtp
# - lmtp:inet:<ip>:<port>
export DOVECOT_LDA_DELIVER='dovecot'
# Directory used to store mailbox INDEX files
# - '' (empty value): use mailbox as index directory.
# - '/path/to/dir': specify an absolute path as index directory.
export MAILBOX_INDEX_DIR="${MAILBOX_INDEX_DIR:=}"
+69
View File
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# Variables for Fail2ban and related.
export FAIL2BAN_CONF_ROOT='/etc/fail2ban'
if [ X"${DISTRO}" == X"FREEBSD" ]; then
export FAIL2BAN_CONF_ROOT='/usr/local/etc/fail2ban'
export FAIL2BAN_SOCKET='/var/run/fail2ban.sock'
fi
export FAIL2BAN_MAIN_CONF="${FAIL2BAN_CONF_ROOT}/fail2ban.local"
export FAIL2BAN_JAIL_CONF="${FAIL2BAN_CONF_ROOT}/jail.conf"
export FAIL2BAN_JAIL_LOCAL_CONF="${FAIL2BAN_CONF_ROOT}/jail.local"
export FAIL2BAN_JAIL_CONF_DIR="${FAIL2BAN_CONF_ROOT}/jail.d"
export FAIL2BAN_FILTER_DIR="${FAIL2BAN_CONF_ROOT}/filter.d"
export FAIL2BAN_ACTION_DIR="${FAIL2BAN_CONF_ROOT}/action.d"
export FAIL2BAN_FILTER_POSTFIX="postfix.iredmail"
export FAIL2BAN_FILTER_ROUNDCUBE="roundcube.iredmail"
export FAIL2BAN_FILTER_DOVECOT="dovecot.iredmail"
export FAIL2BAN_DISABLED_SERVICES="${PORT_HTTP},${HTTPS_PORT},25,587,465,110,995,143,993,${MANAGESIEVE_PORT}"
export FAIL2BAN_LOG_FILE='/var/log/fail2ban.log'
export FAIL2BAN_SYSLOG_FACILITY='daemon'
# Firewall command (fail2ban/action.d/[NAME].conf)
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
export FAIL2BAN_ACTION='iptables-multiport'
if [ X"${DISTRO_CODENAME}" == X'buster' ]; then
export FAIL2BAN_ACTION='nftables-multiport'
fi
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
# Use ipfw by default
export FAIL2BAN_ACTION='ipfw'
# Use pf if it's loaded.
if grep '^pf_load=.YES' /boot/defaults/loader.conf >/dev/null; then
export FAIL2BAN_ACTION='pf'
fi
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
export FAIL2BAN_ACTION='pf'
fi
# SQL db.
export FAIL2BAN_DB_NAME='fail2ban'
export FAIL2BAN_DB_USER='fail2ban'
+724
View File
@@ -0,0 +1,724 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
export PROG_NAME='iRedMail'
export PROG_NAME_LOWERCASE='iredmail'
export PROG_VERSION='1.3.1'
export DATE="$(/bin/date +%Y.%m.%d.%H.%M.%S)"
# For perl and run-time locale setting.
export LC_ALL=C
export LC_CTYPE=C
export LANG=C
# Tells ncurses (dialog) to use Unicode values which correspond to the VT100
# line-drawing glyphs.
export NCURSES_NO_UTF8_ACS=1
# Debug mode: YES, NO.
export IREDMAIL_DEBUG="${IREDMAIL_DEBUG:=NO}"
# -----------------
# ---- Generic ----
# -----------------
# Maildir style: hashed, normal.
export MAILDIR_STYLE='hashed'
# Mailboxes will be stored under sub-directory ${STORAGE_NODE} of vmail user's
# home directory. e.g. home directory is /var/vmail, the mailboxes will be
# /var/vmail/vmail1.
export STORAGE_NODE="${STORAGE_NODE:=vmail1}"
# Enabled backends.
export ENABLE_BACKEND_OPENLDAP='YES'
export ENABLE_BACKEND_PGSQL='YES'
export ENABLE_BACKEND_MARIADB='YES'
# For better distributed deployment
#
# IP address of localhost.
# Usually it's 127.0.0.1, but not in FreeBSD Jail.
export LOCAL_ADDRESS="${LOCAL_ADDRESS:=127.0.0.1}"
# LDAP server
export LDAP_SERVER_HOST="${LDAP_SERVER_HOST:=${LOCAL_ADDRESS}}"
export LDAP_SERVER_PORT="${LDAP_SERVER_PORT:=389}"
# MySQL server
export MYSQL_SERVER_ADDRESS="${MYSQL_SERVER_ADDRESS:=${LOCAL_ADDRESS}}"
export MYSQL_SERVER_PORT="${MYSQL_SERVER_PORT:=3306}"
export MYSQL_ROOT_USER="${MYSQL_ROOT_USER:=root}"
# Use existing MySQL server, no matter it's local or remote.
export USE_EXISTING_MYSQL="${USE_EXISTING_MYSQL:=NO}"
# Create required SQL databases and records for applications
# Should be set to NO if you're installing iRedMail with a MySQL cluster, and
# you're installing on second or later nodes.
export INITIALIZE_SQL_DATA="${INITIALIZE_SQL_DATA:=YES}"
# PGSQL server
export PGSQL_SERVER_ADDRESS="${PGSQL_SERVER_ADDRESS:=${LOCAL_ADDRESS}}"
export PGSQL_SERVER_PORT="${PGSQL_SERVER_PORT:=5432}"
# host address used in ~postgres/.pgpass
export PGSQL_PGPASS_HOST='localhost'
if [ X"${LOCAL_ADDRESS}" != X'127.0.0.1' ]; then
export PGSQL_PGPASS_HOST="${LOCAL_ADDRESS}"
fi
# Dovecot: POP3, IMAP, managesieve
export IMAP_SERVER="${IMAP_SERVER:=${LOCAL_ADDRESS}}"
export LMTP_BIND_ADDRESS="${LMTP_BIND_ADDRESS:=${LOCAL_ADDRESS}}"
export LMTP_BIND_PORT="${LMTP_BIND_PORT:=24}"
export MANAGESIEVE_BIND_HOST="${MANAGESIEVE_BIND_HOST:=${LOCAL_ADDRESS}}"
export MANAGESIEVE_BIND_PORT="${MANAGESIEVE_BIND_PORT:=4190}"
export MANAGESIEVE_SERVER="${MANAGESIEVE_SERVER:=${LOCAL_ADDRESS}}"
export MANAGESIEVE_PORT="${MANAGESIEVE_PORT:=4190}"
export DOVECOT_SERVICE_QUOTA_STATUS_BIND_ADDRESS="${DOVECOT_QUOTA_STATUS_BIND_ADDRESS:=127.0.0.1}"
# SMTP server (Postfix)
export SMTP_SERVER="${SMTP_SERVER:=${LOCAL_ADDRESS}}"
# php-fpm
export PHP_FPM_BIND_HOST="${PHP_FPM_BIND_HOST:=${LOCAL_ADDRESS}}"
export PHP_FPM_PORT="${PHP_FPM_PORT:=9999}"
# Amavisd
export AMAVISD_SERVER="${LOCAL_ADDRESS}"
# ClamAV
export CLAMD_BIND_HOST="${LOCAL_ADDRESS}"
# iRedAPD
export IREDAPD_BIND_HOST="${LOCAL_ADDRESS}"
export IREDAPD_SERVER_ADDRESS="${IREDAPD_SERVER_ADDRESS:=${IREDAPD_BIND_HOST}}"
# mlmmjadmin
export MLMMJADMIN_BIND_HOST="${LOCAL_ADDRESS}"
export MLMMJADMIN_SERVER_ADDRESS="${MLMMJADMIN_SERVER_ADDRESS:=${MLMMJADMIN_BIND_HOST}}"
# For managesieve service and software.
export USE_MANAGESIEVE='YES'
# vmail user/group name, uid and gid.
export SYS_USER_VMAIL='vmail'
export SYS_GROUP_VMAIL='vmail'
# netdata
export SYS_USER_NETDATA='netdata'
export SYS_GROUP_NETDATA='netdata'
# Specify UID/GID for system accounts. Required if you have multiple LDA/LMTP
# servers access same mailbox storage. e.g. cluster environment.
# vmail
export SYS_USER_VMAIL_UID='2000'
export SYS_GROUP_VMAIL_GID='2000'
# iredadmin
export SYS_USER_IREDADMIN_UID='2001'
export SYS_GROUP_IREDADMIN_GID='2001'
# netdata
export SYS_USER_IREDAPD_UID='2002'
export SYS_GROUP_IREDAPD_GID='2002'
# mlmmj
export SYS_USER_MLMMJ_UID='2003'
export SYS_GROUP_MLMMJ_GID='2003'
# netdata
export SYS_USER_NETDATA_UID='2004'
export SYS_GROUP_NETDATA_GID='2004'
# Default SQL database name used to store mail accounts.
export VMAIL_DB_NAME='vmail'
export VMAIL_DB_BIND_USER='vmail'
export VMAIL_DB_ADMIN_USER='vmailadmin'
# Default virtual domain admin name without domain name (@example.com).
export DOMAIN_ADMIN_NAME='postmaster'
# Directory used to store mailboxes
export STORAGE_BASE_DIR="${STORAGE_BASE_DIR:=/var/vmail}"
# Tools.
export CONFIG_VIA_DIALOG="${DIALOG_DIR}/config_via_dialog.sh"
# Note: config file will be sourced in file 'conf/core', function 'check_env()'.
export IREDMAIL_CONFIG_FILE="${ROOTDIR}/config"
export TIP_FILE="${ROOTDIR}/${PROG_NAME}.tips"
export DOC_FILE="${ROOTDIR}/Documentations"
export STATUS_FILE="${RUNTIME_DIR}/install.status"
export INSTALL_LOG="${RUNTIME_DIR}/install.log"
export PKG_INSTALL_LOG="${RUNTIME_DIR}/pkg.install.log"
# Directory used to store kv files (one value in one file).
export IREDMAIL_KV_DIR='/root/.iredmail/kv'
# Output flag.
export _INFO_FLAG="[ INFO ]"
export _SKIP_FLAG="< SKIP >"
export _ERROR_FLAG="<< ERROR >>"
export _QUESTION_FLAG="< Question >"
export _BACKUP_FLAG=" + < Backup >"
export _DEBUG_FLAG=" + < DEBUG >"
export CONF_MSG="#
# File generated by ${PROG_NAME} (${DATE}):
#
# Version: ${PROG_VERSION}
# Project: https://www.iredmail.org/
#
# Community: https://forum.iredmail.org/
#
"
# TERM.
if [ X"${TERM}" == X"" ]; then
export TERM='xterm'
fi
# Logrotate configuration directory.
export LOGROTATE_DIR='/etc/logrotate.d'
# Kernel name, in upper cases.
export KERNEL_NAME="$(uname -s | tr '[a-z]' '[A-Z]')"
# Command used to genrate a random string.
# Usage: str="$(${RANDOM_STRING})"
if [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
export RANDOM_STRING='eval </dev/random tr -cd [:alnum:] | fold -w 32 | head -1'
else
# Linux/FreeBSD
export RANDOM_STRING='eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 32)'
fi
# command: dialog.
export BIN_DIALOG="dialog"
export PKG_DIALOG="dialog"
# command: bzip2.
export BIN_BZIP2='bzip2'
export PKG_BZIP2='bzip2'
# Shells
export SHELL_NOLOGIN='/sbin/nologin'
export SHELL_BASH='/bin/bash'
# Path to some programs
export CMD_PYTHON2='python2'
export CMD_PYTHON3='python3'
export CMD_PIP2='pip2'
export CMD_PIP3='pip3'
# Default password scheme for SQL backends.
# LDAP backend will use SSHA instead (defined in file
# dialog/config_via_dialog.sh), because many applications need to bind as user.
export DEFAULT_PASSWORD_SCHEME='SSHA512'
# Check distribution.
# - DISTRO
# - DISTRO_VERSION
# - DISTRO_CODENAME
#
# UNSUPPORTED_RELEASE will be set to 'YES' if current Linux/BSD release is
# an old release and unsupported anymore.
export UNSUPPORTED_RELEASE='NO'
# Detect distro name and release version.
if [ X"${KERNEL_NAME}" == X'LINUX' ]; then
# Directory of RC scripts.
export DIR_RC_SCRIPTS='/etc/init.d'
if [ -f /etc/redhat-release ]; then
# RHEL/CentOS
export DISTRO='RHEL'
# Get distribution version
if grep '\ 7\.' /etc/redhat-release &>/dev/null; then
# version 7.x
export DISTRO_VERSION='7'
elif grep '\ 8\.' /etc/redhat-release &>/dev/null; then
# version 8.x
export DISTRO_VERSION='8'
else
export UNSUPPORTED_RELEASE='YES'
fi
# Get distribution name as DISTRO_CODENAME
if grep '^Red' /etc/redhat-release &>/dev/null; then
# RHEL
export DISTRO_CODENAME='rhel'
elif grep '^CentOS' /etc/redhat-release &>/dev/null; then
# CentOS
export DISTRO_CODENAME='centos'
elif grep '^Scientific' /etc/redhat-release &>/dev/null; then
# Scientific Linux
export DISTRO_CODENAME='scientific'
else
export UNSUPPORTED_RELEASE='YES'
fi
if [ X"${DISTRO_VERSION}" == X'8' ]; then
# CentOS 8: Installed with pip2.
export CMD_UWSGI='/usr/bin/uwsgi'
# Installed with pip3.
export CMD_UWSGI_PY3='/usr/local/bin/uwsgi'
fi
elif [ -f /etc/lsb-release ] && grep -i 'DISTRIB_ID=Ubuntu' /etc/lsb-release &>/dev/null; then
# Ubuntu
export DISTRO='UBUNTU'
# Ubuntu version number and code name:
# - 18.04: bionic
# - 20.04: focal
export DISTRO_VERSION="$(awk -F'=' '/^DISTRIB_RELEASE/ {print $2}' /etc/lsb-release)"
export DISTRO_CODENAME="$(awk -F'=' '/^DISTRIB_CODENAME/ {print $2}' /etc/lsb-release)"
# Unsupported releases: 16.x, 17.x, 18.10, 19.x
if echo "${DISTRO_VERSION}" | grep -E '^(16|17|18\.10|19\.)' &>/dev/null ; then
export UNSUPPORTED_RELEASE='YES'
fi
export UWSGI_PY2_PLUGIN_NAME='python27'
if [ X"${DISTRO_CODENAME}" == X'bionic' ]; then
# Ubuntu 18.04
export UWSGI_PY3_PLUGIN_NAME='python36'
elif [ X"${DISTRO_CODENAME}" == X'focal' ]; then
# Ubuntu 20.04: Installed with pip2.
export CMD_UWSGI='/usr/local/bin/uwsgi'
export UWSGI_PY3_PLUGIN_NAME='python38'
fi
elif [ -f /etc/debian_version ]; then
# Debian
export DISTRO='DEBIAN'
# Set distro code name and unsupported releases.
if grep -i '^10' /etc/debian_version &>/dev/null; then
export DISTRO_VERSION='10'
export DISTRO_CODENAME='buster'
export UWSGI_PY3_PLUGIN_NAME='python37'
elif grep '^9' /etc/debian_version &>/dev/null || \
grep -i '^stretch' /etc/debian_version &>/dev/null; then
export DISTRO_VERSION='9'
export DISTRO_CODENAME='stretch'
export UWSGI_PY3_PLUGIN_NAME='python35'
else
export UNSUPPORTED_RELEASE='YES'
fi
else
export UNSUPPORTED_RELEASE='YES'
fi
elif [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
export DISTRO='FREEBSD'
export DISTRO_VERSION="$(uname -r |awk -F'[.-]' '{print $1}')"
# Directory of RC scripts.
export DIR_RC_SCRIPTS='/usr/local/etc/rc.d'
export RC_CONF_LOCAL='/etc/rc.conf.local'
export CMD_PYTHON2='/usr/local/bin/python2'
export CMD_PYTHON3='/usr/local/bin/python3'
# Unsupported releases: 7, 8.
if echo "${DISTRO_VERSION}" | grep '^[78]' &>/dev/null ; then
export UNSUPPORTED_RELEASE='YES'
fi
export SHELL_BASH='/usr/local/bin/bash'
# Default password scheme.
export DEFAULT_PASSWORD_SCHEME='BCRYPT'
elif [ X"${KERNEL_NAME}" == X'OPENBSD' ]; then
export DISTRO='OPENBSD'
export DISTRO_VERSION="$(uname -r)"
# Default password scheme.
export DEFAULT_PASSWORD_SCHEME='BCRYPT'
# Directory of RC scripts.
export DIR_RC_SCRIPTS='/etc/rc.d'
export RC_CONF_LOCAL='/etc/rc.conf.local'
export SHELL_BASH='/usr/local/bin/bash'
export CMD_PYTHON2='/usr/local/bin/python2'
export CMD_PYTHON3='/usr/local/bin/python3'
export CMD_PIP2='pip2.7'
export CMD_PIP3='pip3.7'
# Unsupported release: 6.6 and earlier versions.
if echo "${DISTRO_VERSION}" | grep '^6.[0123456]' &>/dev/null ; then
export UNSUPPORTED_RELEASE='YES'
fi
else
# Not support *BSD and other distrobutions yet.
echo "Error: Your OS is not supported yet."
exit 255
fi
# Exit and prompt to use a supported Linux/BSD distribution
if [ X"${UNSUPPORTED_RELEASE}" == X'YES' ]; then
cat <<EOF
********* ERROR *********
Release version of the operating system on this server is unsupported by
iRedMail, please access below link to get the latest iRedMail and a list
of supported Linux/BSD distributions and release versions.
http://www.iredmail.org/download.html
*************************
EOF
exit 255
fi
# Check processor type.
if [ X"${DISTRO}" == X'DEBIAN' ]; then
arch="$(uname -m)"
else
arch="$(uname -p)"
fi
case $arch in
i[3456]86) export OS_ARCH='i386' ;;
x86_64|amd64) export OS_ARCH='x86_64' ;;
*) export OS_ARCH="${arch}" ;;
esac
# Hostname.
if [ X"${IREDMAIL_HOSTNAME}" != X'' ]; then
# Read from 'IREDMAIL_HOSTNAME'
export HOSTNAME="${IREDMAIL_HOSTNAME}"
else
if [ X"${DISTRO}" == X'OPENBSD' ]; then
export HOSTNAME="$(hostname)"
else
export HOSTNAME="$(hostname -f)"
fi
fi
# root user/group name. Note: not all OSes have group 'root'.
export SYS_USER_ROOT='root'
export SYS_GROUP_ROOT='root'
# Syslog
export USE_RSYSLOG='YES'
export USE_BSD_SYSLOG='NO'
export SYS_USER_SYSLOG='root'
export SYS_GROUP_SYSLOG='root'
export SYSLOG_POSTROTATE_CMD=''
export SYSLOG_SOCKET='/dev/log'
export IREDMAIL_SYSLOG_FACILITY='local5'
# rsyslog
export SYSLOG_CONF_DIR='/etc/rsyslog.d'
# Use systemd
export USE_SYSTEMD='YES'
export SYSTEMD_SERVICE_DIR='/lib/systemd/system'
# install_pkg: function used to install packages without confirm.
# remove_pkg: function used to remove packages without confirm.
# LIST_ALL_PKGS: command used to list all installed packages.
# LIST_FILES_IN_PKG: command used to list files installed by special package.
if [ X"${DISTRO}" == X'RHEL' ]; then
# RHEL/CentOS.
# Package management.
if [ X"${YUM}" != X"" ]; then
export YUM="${YUM}"
else
export YUM="yum -d 2"
fi
export install_pkg='install_pkg_rhel'
export remove_pkg="remove_pkg_rhel"
export LIST_ALL_PKGS='rpm -qa'
export LIST_FILES_IN_PKG='rpm -ql'
# Directory /etc/sysconfig/ on RHEL/CentOS.
export ETC_SYSCONFIG_DIR='/etc/sysconfig'
# Firewalld
export USE_FIREWALLD='YES'
export FIREWALLD_CONF_DIR='/etc/firewalld'
export FIREWALLD_CONF='/etc/firewalld/firewalld.conf'
export FIREWALL_RULE_CONF="${FIREWALLD_CONF_DIR}/zones/iredmail.xml"
# main config file
export SYSLOG_CONF='/etc/rsyslog.conf'
export SYSLOG_POSTROTATE_CMD='/bin/kill -HUP $(cat /var/run/syslogd.pid 2>/dev/null) 2>/dev/null || true'
# SSHD log file
export SSHD_LOGFILE='/var/log/secure'
# Crontab related.
export CRON_SPOOL_DIR='/var/spool/cron'
# Directory used to store SSL/TLS key/cert file.
export SSL_FILE_DIR="/etc/pki/tls"
# Yum repository related.
export YUM_REPOS_DIR='/etc/yum.repos.d'
export LOCAL_REPO_NAME="${PROG_NAME}"
export LOCAL_REPO_FILE="${YUM_REPOS_DIR}/${LOCAL_REPO_NAME}.repo"
# Override default value.
export PKG_DIALOG="dialog"
export PKG_BZIP2="bzip2"
if [ X"${DISTRO_VERSION}" == X'7' ]; then
export UWSGI_PY3_PLUGIN_NAME='python36'
fi
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
# Ubuntu & Debian.
export DEBIAN_FRONTEND='noninteractive'
export SHELL_NOLOGIN='/usr/sbin/nologin'
# Package management.
if [ X"${APTGET}" != X"" ]; then
export APTGET="${APTGET}"
else
# "WARNING: apt does not have a stable CLI interface. Use with caution in scripts."
export APTGET='apt-get'
fi
# Package management.
export install_pkg='install_pkg_debian'
export remove_pkg='remove_pkg_debian'
export LIST_ALL_PKGS="dpkg -l |awk '{print $2}'"
export LIST_FILES_IN_PKG='dpkg -L'
# Syslog
export SYS_GROUP_SYSLOG='adm'
if [ X"${DISTRO}" == X'DEBIAN' ]; then
export SYSLOG_CONF='/etc/rsyslog.conf'
elif [ X"${DISTRO}" == X'UBUNTU' ]; then
export SYS_USER_SYSLOG='syslog'
export SYSLOG_CONF='/etc/rsyslog.d/iredmail.conf'
fi
# SSHD log file
export SSHD_LOGFILE='/var/log/auth.log'
# Crontab related.
export CRON_SPOOL_DIR='/var/spool/cron/crontabs'
# Directory /etc/default/ on Debian/Ubuntu.
export ETC_SYSCONFIG_DIR='/etc/default'
# iptables rule file.
export FIREWALL_RULE_CONF="${ETC_SYSCONFIG_DIR}/iptables"
export FIREWALL_RULE_CONF6="${ETC_SYSCONFIG_DIR}/ip6tables"
if [ X"${DISTRO_CODENAME}" == X'buster' ]; then
export USE_NFTABLES='YES'
export NFTABLES_CONF='/etc/nftables.conf'
export FIREWALL_RULE_CONF="${NFTABLES_CONF}"
fi
# Directory used to store SSL/TLS key/cert file.
export SSL_FILE_DIR="/etc/ssl"
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export USE_SYSTEMD='NO'
export SYS_GROUP_ROOT='wheel'
export SYSLOG_SOCKET='/var/run/log'
# sysrc: safely edit system rc files
export SYSRC='/usr/sbin/sysrc'
# Package management.
if [ X"${PKGADD}" != X"" ]; then
export PKGADD="${PKGADD}"
else
export PKGADD="pkg_add"
fi
if [ X"${DISTRO_VERSION}" == X'9' ]; then
export LIST_ALL_PKGS="pkg_info | awk '{print $1}'"
export LIST_FILES_IN_PKG='pkg_info -L'
else
# use pkgng on FreeBSD 10 and later releases.
export LIST_ALL_PKGS="pkg info | awk '{print $1}'"
export LIST_FILES_IN_PKG='pkg query "%Fp"'
fi
# Port directory
export PORT_WORKDIRPREFIX='/usr/ports'
# Syslog (newsyslog)
export USE_RSYSLOG='NO'
export USE_BSD_SYSLOG='YES'
export SYS_GROUP_SYSLOG='wheel'
export SYSLOG_CONF='/etc/syslog.conf'
export SYSLOG_CONF_DIR='/usr/local/etc/syslog.d'
# SSHD log file
export SSHD_LOGFILE='/var/log/auth.log'
# Crontab related.
export CRON_SPOOL_DIR='/var/cron/tabs'
export ETC_SYSCONFIG_DIR='/etc/defaults'
export FREEBSD_MAKE_CONF='/etc/make.conf'
# IPFW rule file.
export FIREWALL_RULE_CONF="${ETC_SYSCONFIG_DIR}/ipfw.rules"
# Directory used to store SSL/TLS key/cert file.
export SSL_FILE_DIR="/etc/ssl"
# Logrotate directory.
export LOGROTATE_DIR='/usr/local/etc/newsyslog.conf.d'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export USE_SYSTEMD='NO'
export SYS_GROUP_ROOT='wheel'
# Package management.
export install_pkg='install_pkg_openbsd'
export remove_pkg='pkg_delete'
export LIST_ALL_PKGS="pkg_info -a | awk '{print $1}'"
export LIST_FILES_IN_PKG='pkg_info -L'
# Syslog (newsyslog)
export USE_RSYSLOG='NO'
export USE_BSD_SYSLOG='YES'
export SYS_GROUP_SYSLOG='wheel'
export SYSLOG_CONF='/etc/syslog.conf'
# SSHD log file
export SSHD_LOGFILE='/var/log/authlog'
# Crontab related.
export CRON_SPOOL_DIR='/var/cron/tabs'
# PF rule file.
export FIREWALL_RULE_CONF="/etc/pf.conf"
# Directory used to store SSL/TLS key/cert file.
export SSL_FILE_DIR="/etc/ssl"
else
# Not support yet.
echo "Your distrobution is not supported yet."
exit 255
fi
# Use a seperated directory to store iRedMail certs/keys.
if [ X"${DISTRO}" == X'OPENBSD' ]; then
export SSL_CERT_DIR="${SSL_FILE_DIR}"
export SSL_KEY_DIR="${SSL_FILE_DIR}"
else
export SSL_CERT_DIR="${SSL_FILE_DIR}/certs"
export SSL_KEY_DIR="${SSL_FILE_DIR}/private"
fi
# Root's cron file
export CRON_FILE_ROOT="${CRON_SPOOL_DIR}/${SYS_USER_ROOT}"
# dhparam file required to fix 'The Logjam Attack'.
export SSL_DH512_PARAM_FILE="${SSL_FILE_DIR}/dh512_param.pem"
export SSL_DH1024_PARAM_FILE="${SSL_FILE_DIR}/dh2048_param.pem"
# use of the most secure ciphers first and gradually fall back to
# less-preferred ciphers should the client not support them.
export SSL_CIPHERS='EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'
# SSL key.
export OPENSSL_CONF="${SSL_FILE_DIR}/openssl.cnf"
export SSL_CERT_FILE="${SSL_CERT_DIR}/iRedMail.crt"
export SSL_KEY_FILE="${SSL_KEY_DIR}/iRedMail.key"
export TLS_COUNTRY='CN'
export TLS_STATE='GuangDong'
export TLS_CITY='ShenZhen'
export TLS_COMPANY="${HOSTNAME}"
export TLS_DEPARTMENT='IT'
export TLS_HOSTNAME="${HOSTNAME}"
export TLS_ADMIN="root@${HOSTNAME}"
# Default SSL key size in bits
export SSL_KEY_SIZE='4096'
default_ssl_key_size="$(awk '/^default_bits/ {print $3}' ${OPENSSL_CONF} 2>/dev/null)"
if [ -z ${default_ssl_key_size} ]; then
:
elif [ ${default_ssl_key_size} -ge ${SSL_KEY_SIZE} ]; then
export SSL_KEY_SIZE="${default_ssl_key_size}"
fi
# Location of sshd_config
export SSHD_CONFIG='/etc/ssh/sshd_config'
if [[ -f ${SSHD_CONFIG} ]]; then
export SSHD_PORT="$(awk '/^Port/ {print $2}' ${SSHD_CONFIG} | head -1)"
export SSHD_PORT2="$(awk '/^Port/ {print $2}' ${SSHD_CONFIG} | tail -1)"
fi
if [ X"${SSHD_PORT}" == X'' ]; then
# No port number defined, use default port number (22).
export SSHD_PORT='22'
export SSHD_PORT2='22'
fi
export SSHD_PORTS_WITH_COMMA="${SSHD_PORT}"
export SSHD_PORTS_WITH_SPACE="${SSHD_PORT}"
if [ X"${SSHD_PORT}" != X'' -a X"${SSHD_PORT2}" != X'' -a X"${SSHD_PORT}" != X"${SSHD_PORT2}" ]; then
export SSHD_PORTS_WITH_COMMA="${SSHD_PORT},${SSHD_PORT2}"
export SSHD_PORTS_WITH_SPACE="${SSHD_PORT} ${SSHD_PORT2}"
fi
# sysctl.conf
export SYSCTL_CONF='/etc/sysctl.conf'
# Command use to fetch source tarballs.
if [ X"${DISTRO}" == X'FREEBSD' ]; then
if [ -f /usr/local/etc/ssl/cert.pem ]; then
# require package/port 'security/ca_root_nss'
FETCH_CMD='fetch'
else
FETCH_CMD='fetch --no-verify-hostname --no-verify-peer'
fi
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
# -i: Turns off interactive prompting during multiple file transfers.
# -V: Disable verbose and progress
FETCH_CMD='ftp -iV'
else
# -c: Continue getting a partially-downloaded file.
# -q: Turn off Wget's output.
FETCH_CMD="wget -cq --timeout=30"
if [ X"${DISTRO}" == X'RHEL' ]; then
FETCH_CMD="${FETCH_CMD} --ca-certificate=${SSL_CERT_DIR}/ca-bundle.crt"
fi
fi
# Detect IPv6 support with `ping6`.
export IREDMAIL_HAS_IPV6='NO'
ping6 -c 1 ::1 &>/dev/null
if [ X"$?" == X'0' ]; then
IREDMAIL_HAS_IPV6='YES'
fi
# Backup script file names.
export BACKUP_SCRIPT_LDAP_NAME='backup_openldap.sh'
export BACKUP_SCRIPT_MYSQL_NAME='backup_mysql.sh'
export BACKUP_SCRIPT_PGSQL_NAME='backup_pgsql.sh'
#
# Mirror sites
#
# Where to fetch/store binary packages and source tarball.
export IREDMAIL_MIRROR="${IREDMAIL_MIRROR:=https://dl.iredmail.org}"
# Ubuntu mirror site. For example: https://archive.ubuntu.com/ubuntu
export UBUNTU_MIRROR_SITE="${UBUNTU_MIRROR_SITE:=}"
# pip mirror site. Use `pypi.org` if not set.
export PIP_MIRROR_SITE="${PIP_MIRROR_SITE:=}"
export PIP_TRUSTED_HOST="${PIP_TRUSTED_HOST:=}"
# URL to download `get-pip.py`, used to install `pip2`.
export URL_GET_PIP_PY="${URL_GET_PIP_PY:=https://bootstrap.pypa.io/get-pip.py}"
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
export IREDADMIN_VERSION='1.0'
export IREDADMIN_TARBALL="iRedAdmin-${IREDADMIN_VERSION}.tar.bz2"
export IREDADMIN_HTTPD_ROOT="${HTTPD_SERVERROOT}/iRedAdmin-${IREDADMIN_VERSION}"
export IREDADMIN_HTTPD_ROOT_SYMBOL_LINK="${HTTPD_SERVERROOT}/iredadmin"
export IREDADMIN_HOME_DIR='/home/iredadmin'
export SYS_USER_IREDADMIN='iredadmin'
export SYS_GROUP_IREDADMIN="${SYS_USER_IREDADMIN}"
# MySQL database name, username and password.
export IREDADMIN_DB_NAME="${SYS_USER_IREDADMIN}"
export IREDADMIN_DB_USER="${SYS_USER_IREDADMIN}"
export IREDADMIN_BIND_ADDRESS='127.0.0.1'
export IREDADMIN_LISTEN_PORT='7791'
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
export IREDAPD_VERSION='4.3'
export SYS_USER_IREDAPD='iredapd'
export SYS_GROUP_IREDAPD='iredapd'
export IREDAPD_TARBALL="iRedAPD-${IREDAPD_VERSION}.tar.gz"
export IREDAPD_PARENT_DIR='/opt'
export IREDAPD_ROOT_DIR="${IREDAPD_PARENT_DIR}/iRedAPD-${IREDAPD_VERSION}"
export IREDAPD_ROOT_DIR_SYMBOL_LINK="${IREDAPD_PARENT_DIR}/iredapd"
export IREDAPD_CONF="${IREDAPD_ROOT_DIR_SYMBOL_LINK}/settings.py"
# IREDAPD_BIND_HOST is configured in conf/global
export IREDAPD_LISTEN_PORT='7777'
export IREDAPD_SRS_FORWARD_PORT='7778'
export IREDAPD_SRS_REVERSE_PORT='7779'
export IREDAPD_SRS_SECRET="$(${RANDOM_STRING})"
export IREDAPD_PID_FILE='/var/run/iredapd.pid'
export IREDAPD_LOG_DIR='/var/log/iredapd'
export IREDAPD_LOG_FILE="${IREDAPD_LOG_DIR}/iredapd.log"
export IREDAPD_LOGROTATE_FILE="${LOGROTATE_DIR}/iredapd"
# Database
# IREDAPD_DB_PASSWD is generated in dialog/optional_components.sh.
export IREDAPD_DB_NAME='iredapd'
export IREDAPD_DB_USER='iredapd'
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# Memcached
export MEMCACHED_BIND_ADDRESS="${MEMCACHED_BIND_ADDRESS:=${LOCAL_ADDRESS}}"
export MEMCACHED_RC_SCRIPT_NAME='memcached'
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
export MEMCACHED_CONF='/etc/memcached.conf'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export MEMCACHED_DAEMIN_USER='_memcached'
fi
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# mlmmj user/group name
export SYS_USER_MLMMJ='mlmmj'
export SYS_GROUP_MLMMJ='mlmmj'
# Directory used to store mailing list accounts and archive of in/out mails
export MLMMJ_SPOOL_DIR="${STORAGE_BASE_DIR}/mlmmj"
export MLMMJ_HOME_DIR="${MLMMJ_SPOOL_DIR}"
# Directory used to store archived mailing list accounts and data.
export MLMMJ_ARCHIVE_DIR="${STORAGE_BASE_DIR}/mlmmj-archive"
# Directory which stores skel files (templates in different languages)
export MLMMJ_SKEL_DIR='/usr/share/mlmmj/text.skel'
export CMD_MLMMJ_RECEIVE='/usr/bin/mlmmj-receive'
export CMD_MLMMJ_MAINTD='/usr/bin/mlmmj-maintd'
export CMD_MLMMJ_AMIME_RECEIVE='/usr/bin/mlmmj-amime-receive'
export CRON_FILE_MLMMJ="${CRON_SPOOL_DIR}/${SYS_USER_MLMMJ}"
if [ X"${DISTRO}" == X'FREEBSD' -o X"${DISTRO}" == X'OPENBSD' ]; then
export CMD_MLMMJ_RECEIVE='/usr/local/bin/mlmmj-receive'
export CMD_MLMMJ_MAINTD='/usr/local/bin/mlmmj-maintd'
export CMD_MLMMJ_AMIME_RECEIVE='/usr/local/bin/mlmmj-amime-receive'
export MLMMJ_SKEL_DIR='/usr/local/share/mlmmj/text.skel'
fi
#
# mlmmjadmin: RESTful API server used to manage mlmmj mailing lists
#
export MLMMJADMIN_RC_SCRIPT_NAME='mlmmjadmin'
export MLMMJADMIN_RC_SCRIPT_PATH="${DIR_RC_SCRIPTS}/${MLMMJADMIN_RC_SCRIPT_NAME}"
export MLMMJADMIN_LISTEN_PORT='7790'
export MLMMJADMIN_PID_FILE='/var/run/mlmmjadmin/mlmmjadmin.pid'
export MLMMJADMIN_VERSION='3.0'
export MLMMJADMIN_TARBALL="mlmmjadmin-${MLMMJADMIN_VERSION}.tar.gz"
export MLMMJADMIN_PARENT_DIR='/opt'
export MLMMJADMIN_ROOT_DIR="${MLMMJADMIN_PARENT_DIR}/mlmmjadmin-${MLMMJADMIN_VERSION}"
export MLMMJADMIN_ROOT_DIR_SYMBOL_LINK="${MLMMJADMIN_PARENT_DIR}/mlmmjadmin"
export MLMMJADMIN_CONF="${MLMMJADMIN_ROOT_DIR_SYMBOL_LINK}/settings.py"
export MLMMJADMIN_LOG_DIR='/var/log/mlmmjadmin'
export MLMMJADMIN_LOG_FILE="${MLMMJADMIN_LOG_DIR}/mlmmjadmin.log"
export MLMMJADMIN_LOGROTATE_FILE="${LOGROTATE_DIR}/mlmmjadmin"
+76
View File
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# Variables for MySQL database server and related.
# MYSQL_SERVER_ADDRESS and MYSQL_SERVER_PORT are defined in conf/global.
# SQL_SERVER_ADDRESS and SQL_SERVER_PORT are defined in dialog/config_via_dialog.sh.
export MYSQL_MY_CNF='/etc/my.cnf'
export MYSQL_MY_CNF_SAMPLE="${SAMPLE_DIR}/mysql/my.cnf"
export MYSQL_RC_SCRIPT_NAME='mysql'
# MySQL config file.
if [ X"${DISTRO}" == X'RHEL' ]; then
export MYSQL_RC_SCRIPT_NAME='mariadb'
elif [ X"${DISTRO}" == X'UBUNTU' -o X"${DISTRO}" == X'DEBIAN' ]; then
export MYSQL_MY_CNF='/etc/mysql/my.cnf'
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export MYSQL_RC_SCRIPT_NAME='mysql-server'
export MYSQL_MY_CNF='/usr/local/etc/mysql/conf.d/server.cnf'
export MYSQL_MY_CNF_SAMPLE='/usr/local/share/mysql/my-large.cnf'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export MYSQL_RC_SCRIPT_NAME='mysqld'
fi
export MYSQLD_RC_SCRIPT="${DIR_RC_SCRIPTS}/${MYSQL_RC_SCRIPT_NAME}"
export MYSQL_INIT_SQL="${RUNTIME_DIR}/mysql_init.sql"
export MYSQL_VMAIL_SQL="${RUNTIME_DIR}/mysql_vmail.sql"
# SQL structure of MySQL vmail database.
export MYSQL_VMAIL_STRUCTURE_SAMPLE="${SAMPLE_DIR}/iredmail/iredmail.mysql"
# File used to stores MySQL root password to avoid warning:
# "Using a password on the command line interface can be insecure."
# File will be copied to /root/.my.cnf after iRedMail installation.
# WARNING: Do NOT set it to /root/.my.cnf here.
export MYSQL_DEFAULTS_FILE_ROOT="/root/.my.cnf"
export MYSQL_CLIENT_ROOT="mysql --defaults-file=${MYSQL_DEFAULTS_FILE_ROOT}"
# Hostname or IP address used in MySQL GRANT command (allow remote access from
# this hostname/IP).
# Usually it's 'localhost', but not in FreeBSD Jail (use ${LOCAL_ADDRESS} or
# hostname of Jail instead).
if [ X"${LOCAL_ADDRESS}" == X'127.0.0.1' ]; then
# Pre-define MYSQL_GRANT_HOST while running iRedMail to use a remote MySQL
# server. For example:
# MYSQL_GRANT_HOST='192.168.1.2' bash iRedMail.sh
export MYSQL_GRANT_HOST="${MYSQL_GRANT_HOST:=localhost}"
else
export MYSQL_GRANT_HOST="${LOCAL_ADDRESS}"
fi
# Custom settings
export MYSQL_MAX_CONNECTIONS="${MYSQL_MAX_CONNECTIONS:=1024}"
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
#
# netdata: https://my-netdata.io
#
export NETDATA_VERSION='1.23.1'
export NETDATA_PKG_NAME="netdata-v${NETDATA_VERSION}.gz.run"
# iRedMail install netdata with the '.bin' package on Linux, it installs
# netdata application files under '/opt/netdata' by default.
# Directory contains all config files
export NETDATA_CONF_DIR="/opt/netdata/etc/netdata"
# Log directory
export NETDATA_LOG_DIR="/opt/netdata/var/log/netdata"
if [ X"${KERNEL_NAME}" == X'FREEBSD' ]; then
export NETDATA_CONF_DIR='/usr/local/etc/netdata'
export NETDATA_LOG_DIR='/var/log/netdata'
fi
export NETDATA_PORT='19999'
export NETDATA_RC_SCRIPT_NAME='netdata'
# Main config file.
export NETDATA_CONF="${NETDATA_CONF_DIR}/netdata.conf"
export NETDATA_HEALTH_ALARM_NOTIFY_CONF="${NETDATA_CONF_DIR}/health_alarm_notify.conf"
export NETDATA_PYTHON_D_CONF="${NETDATA_CONF_DIR}/python.d.conf"
export NETDATA_GO_D_CONF="${NETDATA_CONF_DIR}/go.d.conf"
# web auth file
export NETDATA_HTTPD_AUTH_FILE="${HTTPD_CONF_ROOT}/netdata.users"
# .my.cnf used to access MySQL db.
export NETDATA_DOT_MY_CNF="${NETDATA_CONF_DIR}/my.cnf"
# Modular config files.
export NETDATA_CONF_HEALTH_ALARM_NOTIFY="${NETDATA_CONF_DIR}/health_alarm_notify.conf"
export NETDATA_GO_D_CONF_DIR="${NETDATA_CONF_DIR}/go.d"
export NETDATA_GO_D_CONF_PHPFPM="${NETDATA_GO_D_CONF_DIR}/phpfpm.conf"
export NETDATA_GO_D_CONF_NGINX="${NETDATA_GO_D_CONF_DIR}/nginx.conf"
export NETDATA_GO_D_CONF_MYSQL="${NETDATA_GO_D_CONF_DIR}/mysql.conf"
# Plugin config files.
export NETDATA_PYTHON_D_CONF_DIR="${NETDATA_CONF_DIR}/python.d"
export NETDATA_PYTHON_D_CONF_PGSQL="${NETDATA_PYTHON_D_CONF_DIR}/postgres.conf"
export NETDATA_PYTHON_D_CONF_OPENLDAP="${NETDATA_PYTHON_D_CONF_DIR}/openldap.conf"
# Database
# NETDATA_DB_PASSWD is generated in dialog/optional_components.sh.
export NETDATA_DB_USER='netdata'
+69
View File
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# RC scripts
export NGINX_RC_SCRIPT_NAME='nginx'
# Configuration files
export HTTPD_CONF_ROOT='/etc/nginx'
# Log directory.
export NGINX_LOG_DIR='/var/log/nginx'
# PID file
export NGINX_PID='/var/run/nginx.pid'
# Directory for storing temporary files holding client request bodies.
export NGINX_CLIENT_BODY_TEMP_PATH='/var/lib/nginx_tmp_client_body'
if [ X"${DISTRO}" == X'RHEL' ]; then
# Daemon user.
export HTTPD_USER='nginx'
export HTTPD_GROUP='nginx'
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export HTTPD_CONF_ROOT="/usr/local/etc/nginx"
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export NGINX_LOG_DIR='/var/www/logs'
fi
# Log files.
export NGINX_LOG_ACCESSLOG="${NGINX_LOG_DIR}/access.log"
export NGINX_LOG_ERRORLOG="${NGINX_LOG_DIR}/error.log"
export HTTPD_CONF_DIR_AVAILABLE_CONF="${HTTPD_CONF_ROOT}/conf-available"
export HTTPD_CONF_DIR_ENABLED_CONF="${HTTPD_CONF_ROOT}/conf-enabled"
# Directory used to store all sites. Note: not loaded by default.
export HTTPD_CONF_DIR_AVAILABLE_SITES="${HTTPD_CONF_ROOT}/sites-available"
# Directory used to store site config files which will be loaded by default.
# Usually we just create a symbol link to file under ${HTTPD_CONF_DIR_AVAILABLE_SITES}
export HTTPD_CONF_DIR_ENABLED_SITES="${HTTPD_CONF_ROOT}/sites-enabled"
export NGINX_CONF="${HTTPD_CONF_ROOT}/nginx.conf"
export NGINX_CONF_SITE_DEFAULT="${HTTPD_CONF_DIR_AVAILABLE_SITES}/00-default.conf"
export NGINX_CONF_SITE_DEFAULT_SSL="${HTTPD_CONF_DIR_AVAILABLE_SITES}/00-default-ssl.conf"
export NGINX_CONF_TMPL_DIR="${HTTPD_CONF_ROOT}/templates"
export NGINX_MIME_TYPES="${HTTPD_CONF_ROOT}/mime.types"
+168
View File
@@ -0,0 +1,168 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# Variables for OpenLDAP and related. Refer to 'dialog/ldap_config.sh'.
# OpenLDAP version number.
export OPENLDAP_VERSION='2.4'
# Support password verification with SSHA512. Require OpenLDAP-2.4.32 or later.
export OPENLDAP_HAS_SHA2='YES'
# Module name
export OPENLDAP_MOD_PW_SHA2='pw-sha2'
# LDAP service info.
# LDAP_SERVER_HOST, LDAP_SERVER_PORT are defined in conf/global
export LDAP_USE_TLS='NO'
export LDAP_BIND='yes'
export LDAP_BIND_VERSION='3'
# OpenLDAP daemon user and group name.
export SYS_USER_LDAP='ldap'
export SYS_GROUP_LDAP='ldap'
export OPENLDAP_RC_SCRIPT_NAME='slapd'
# Configuration files.
export OPENLDAP_CONF_ROOT='/etc/openldap'
# Database backend type.
export OPENLDAP_DEFAULT_DBTYPE='mdb'
# Default LDAP data directory.
export OPENLDAP_DATA_DIR='/var/lib/ldap' # Do *NOT* end with '/'.
export OPENLDAP_PID_FILE='/var/run/openldap/slapd.pid'
export OPENLDAP_ARGS_FILE='/var/run/openldap/slapd.args'
# Configure.
if [ X"${DISTRO}" == X'RHEL' ]; then
export OPENLDAP_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/slapd"
# Module related.
export OPENLDAP_MODULE_PATH='/usr/lib/openldap'
if [ X"${OS_ARCH}" == X'x86_64' ]; then
export OPENLDAP_MODULE_PATH='/usr/lib64/openldap'
fi
export OPENLDAP_HAS_SHA2='NO'
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
# LDAP daemon user & group.
export SYS_USER_LDAP='openldap'
export SYS_GROUP_LDAP='openldap'
# Configuration files.
export OPENLDAP_CONF_ROOT="/etc/ldap"
export OPENLDAP_PID_FILE='/var/run/slapd/slapd.pid'
export OPENLDAP_ARGS_FILE='/var/run/slapd/slapd.args'
export OPENLDAP_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/slapd"
# Module related.
export OPENLDAP_MODULE_PATH='/usr/lib/ldap'
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
# Configuration files.
export OPENLDAP_CONF_ROOT='/usr/local/etc/openldap'
# Module related.
export OPENLDAP_MODULE_PATH='/usr/local/libexec/openldap'
# Override default setting.
export OPENLDAP_DATA_DIR='/var/db/openldap-data' # Do *NOT* end with '/'.
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
# LDAP daemon user & group.
export SYS_USER_LDAP='_openldap'
export SYS_GROUP_LDAP='_openldap'
# mdb is not available on OpenBSD.
export OPENLDAP_DEFAULT_DBTYPE='hdb'
export OPENLDAP_DB_CONFIG_SAMPLE='/usr/local/share/examples/openldap/DB_CONFIG'
# Module related.
export OPENLDAP_HAS_SHA2='NO'
export OPENLDAP_MODULE_PATH='/usr/local/libexec/openldap'
fi
# RC script.
export OPENLDAP_RC_SCRIPT="${DIR_RC_SCRIPTS}/${OPENLDAP_RC_SCRIPT_NAME}"
export OPENLDAP_SCHEMA_DIR="${OPENLDAP_CONF_ROOT}/schema"
export OPENLDAP_SLAPD_CONF="${OPENLDAP_CONF_ROOT}/slapd.conf"
export OPENLDAP_LDAP_CONF="${OPENLDAP_CONF_ROOT}/ldap.conf"
# Log
# OpenLDAP logs to local4 by default.
export OPENLDAP_SYSLOG_FACILITY='local4'
export OPENLDAP_LOG_DIR='/var/log/openldap'
export OPENLDAP_LOG_FILE="${OPENLDAP_LOG_DIR}/openldap.log"
export OPENLDAP_LOGROTATE_FILE="${LOGROTATE_DIR}/openldap"
# LDAP data directory.
export ldap_suffix_to_domain_name="$(echo ${LDAP_SUFFIX} | sed -e 's/dc=//g' -e 's/,/./g')"
export LDAP_DATA_DIR="${OPENLDAP_DATA_DIR}/${ldap_suffix_to_domain_name}"
# Setting for one instance. You can edit ${OPENLDAP_SLAPD_CONF} manually to hold
# multi instances.
export LDAP_INIT_LDIF="${RUNTIME_DIR}/ldap_init.ldif"
##################################################
# iRedMail LDAP schema related
#
export LDAP_IREDMAIL_SCHEMA="${SAMPLE_DIR}/iredmail/iredmail.schema"
# Domain admin related.
export LDAP_ATTR_DOMAINADMIN_DN_NAME='domainAdmins'
# Container which includes all mail accounts: o=domains,dc=xx,dc=xx
export LDAP_BASEDN_NAME='domains'
# Domain related attributes.
export LDAP_ATTR_DOMAIN_RDN='domainName'
# Group related.
export LDAP_ATTR_GROUP_RDN='ou'
export LDAP_ATTR_GROUP_USERS='Users'
export LDAP_ATTR_GROUP_GROUPS='Groups'
export LDAP_ATTR_GROUP_ALIASES='Aliases'
export LDAP_ATTR_GROUP_EXTERNALS='Externals'
# Attributes of user object.
export LDAP_ATTR_USER_RDN='mail'
##################################################
# Password scheme
#
# If no pw-sha2 support, use SSHA instead.
if [ X"${BACKEND}" == X'OPENLDAP' -a X"${OPENLDAP_HAS_SHA2}" != X'YES' ]; then
export DEFAULT_PASSWORD_SCHEME='SSHA'
fi
export LDAP_BINDDN="cn=${SYS_USER_VMAIL},${LDAP_SUFFIX}"
export LDAP_ADMIN_DN="cn=${VMAIL_DB_ADMIN_USER},${LDAP_SUFFIX}"
export LDAP_ROOTDN="cn=Manager,${LDAP_SUFFIX}"
export LDAP_BASEDN="o=${LDAP_BASEDN_NAME},${LDAP_SUFFIX}"
export LDAP_ADMIN_BASEDN="o=${LDAP_ATTR_DOMAINADMIN_DN_NAME},${LDAP_SUFFIX}"
+103
View File
@@ -0,0 +1,103 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# path to php program
export PHP_BIN='/usr/bin/php'
# Path used to store php sessions (session.save_path)
export PHP_SESSION_SAVE_PATH='/var/lib/php/sessions'
# php-fpm
export PHP_FPM_RC_SCRIPT_NAME='php-fpm'
export PHP_FPM_CONF='/etc/php-fpm.conf'
export PHP_FPM_POOL_DIR='/etc/php-fpm.d'
export PHP_FPM_LOGROTATE_CONF='/etc/logrotate.d/php-fpm'
# Disabled PHP functions.
# - Roundcube requires: proc_open, proc_close, escapeshellarg.
export PHP_DISABLE_FUNCTIONS='posix_uname,eval,pcntl_wexitstatus,posix_getpwuid,xmlrpc_entity_decode,pcntl_wifstopped,pcntl_wifexited,pcntl_wifsignaled,phpAds_XmlRpc,pcntl_strerror,ftp_exec,pcntl_wtermsig,mysql_pconnect,proc_nice,pcntl_sigtimedwait,posix_kill,pcntl_sigprocmask,fput,phpinfo,system,phpAds_remoteInfo,ftp_login,inject_code,posix_mkfifo,highlight_file,escapeshellcmd,show_source,pcntl_wifcontinued,fp,pcntl_alarm,pcntl_wait,ini_alter,posix_setpgid,parse_ini_file,ftp_raw,pcntl_waitpid,pcntl_getpriority,ftp_connect,pcntl_signal_dispatch,pcntl_wstopsig,ini_restore,ftp_put,passthru,proc_terminate,posix_setsid,pcntl_signal,pcntl_setpriority,phpAds_xmlrpcEncode,pcntl_exec,ftp_nb_fput,ftp_get,phpAds_xmlrpcDecode,pcntl_sigwaitinfo,shell_exec,pcntl_get_last_error,ftp_rawlist,pcntl_fork,posix_setuid'
if [ X"${DISTRO}" == X'RHEL' ]; then
export PHP_INI='/etc/php.ini'
export PHP_FPM_PID_FILE='/run/php-fpm/php-fpm.pid'
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
if [ X"${DISTRO_CODENAME}" == X'stretch' ]; then
# Debian 9
export PHP_VERSION='7.0'
elif [ X"${DISTRO_CODENAME}" == X'buster' ]; then
# Debian 10
export PHP_VERSION='7.3'
elif [ X"${DISTRO_CODENAME}" == X'bionic' ]; then
# Ubuntu 18.04
export PHP_VERSION='7.2'
else
# Ubuntu 20.04
export PHP_VERSION='7.4'
fi
export PHP_INI="/etc/php/${PHP_VERSION}/fpm/php.ini"
export PHP_FPM_CONF="/etc/php/${PHP_VERSION}/fpm/php-fpm.conf"
export PHP_FPM_PID_FILE='/run/php/php-fpm.pid'
export PHP_FPM_LOGROTATE_CONF="${LOGROTATE_DIR}/php${PHP_VERSION}-fpm"
export PHP_FPM_POOL_DIR="/etc/php/${PHP_VERSION}/fpm/pool.d"
export PHP_FPM_RC_SCRIPT_NAME="php${PHP_VERSION}-fpm"
export PHPENMOD_BIN='phpenmod'
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export PHP_BIN='/usr/local/bin/php'
# Copy from example: /usr/local/etc/php.ini-production
export PHP_INI='/usr/local/etc/php.ini'
export PHP_FPM_CONF='/usr/local/etc/php-fpm.conf'
export PHP_FPM_POOL_DIR='/usr/local/etc/php-fpm.d'
export PHP_FPM_LOGROTATE_CONF="${LOGROTATE_DIR}/php-fpm"
export PHP_FPM_PID_FILE='/var/run/php-fpm.pid'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export OB_PHP_VERSION='7.4'
export PHP_FPM_RC_SCRIPT_NAME='php74_fpm'
export PHP_BIN="/usr/local/bin/php-${OB_PHP_VERSION}"
export PHP_INI="/etc/php-${OB_PHP_VERSION}.ini"
export PHP_FPM_PID_FILE='/var/run/php-fpm.pid'
fi
# PHP-FPM
export PHP_FPM_POOL_WWW_CONF="${PHP_FPM_POOL_DIR}/www.conf"
# log
export PHP_FPM_LOG_DIR='/var/log/php-fpm'
export PHP_FPM_LOG_MAIN="${PHP_FPM_LOG_DIR}/php-fpm.log"
export PHP_FPM_LOG_SLOW="${PHP_FPM_LOG_DIR}/slow.log"
# parameters
export PHP_FPM_REQUEST_SLOWLOG_TIMEOUT='10s'
export PHP_FPM_URI_STATUS='status'
export PHP_FPM_URI_PING='ping'
export PHP_FPM_POOL_MAX_CHILDREN=100
export PHP_FPM_POOL_START_SERVERS=5
export PHP_FPM_POOL_MIN_SPARE_SERVERS=5
export PHP_FPM_POOL_MAX_SPARE_SERVERS=10
export PHP_FPM_POOL_MAX_REQUESTS=100
export PHP_FPM_POOL_REQUEST_TERMINATE_TIMEOUT='60s'
# connection type: mysql, mysqli (recommended for MySQL/MariaDB), pgsql.
export PHP_CONN_TYPE='mysqli'
[ X"${BACKEND}" == X'PGSQL' ] && export PHP_CONN_TYPE='pgsql'
+91
View File
@@ -0,0 +1,91 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin <zhb _at_ iredmail.org>
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# Variables for Postfix and related.
#
# You do *NOT* need to modify them.
#
# ---- Postfix ----
export SYS_USER_POSTFIX='postfix'
export SYS_GROUP_POSTFIX='postfix'
export POSTFIX_ROOTDIR='/etc/postfix'
export POSTFIX_RC_SCRIPT_NAME='postfix'
# Log file
export MAILLOG='/var/log/maillog'
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
export MAILLOG='/var/log/mail.log'
export MAILLOG_INFO='/var/log/mail.info'
export MAILLOG_ERROR='/var/log/mail.err'
export MAILLOG_WARN='/var/log/mail.warn'
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export POSTFIX_ROOTDIR='/usr/local/etc/postfix'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export SYS_USER_POSTFIX='_postfix'
export SYS_GROUP_POSTFIX='_postfix'
fi
# You do *NOT* need to modify them.
export POSTFIX_CHROOT_DIR='/var/spool/postfix'
export POSTFIX_FILE_MAIN_CF="${POSTFIX_ROOTDIR}/main.cf"
export POSTFIX_FILE_MASTER_CF="${POSTFIX_ROOTDIR}/master.cf"
export POSTFIX_FILE_ALIASES="${POSTFIX_ROOTDIR}/aliases"
export POSTFIX_FILE_HELO_ACCESS="${POSTFIX_ROOTDIR}/helo_access.pcre"
export POSTFIX_FILE_SMTPD_COMMAND_FILTER="${POSTFIX_ROOTDIR}/command_filter.pcre"
export POSTFIX_FILE_HEADER_CHECKS="${POSTFIX_ROOTDIR}/header_checks"
export POSTFIX_FILE_BODY_CHECKS="${POSTFIX_ROOTDIR}/body_checks.pcre"
# used for sender white/blacklist with pcre support
export POSTFIX_FILE_SENDER_ACCESS="${POSTFIX_ROOTDIR}/sender_access.pcre"
export POSTSCREEN_FILE_DNSBL_REPLY="${POSTFIX_ROOTDIR}/postscreen_dnsbl_reply"
export POSTSCREEN_FILE_ACCESS_CIDR="${POSTFIX_ROOTDIR}/postscreen_access.cidr"
# Default transport or LDA (local deliver agent).
export TRANSPORT="${TRANSPORT:=${DOVECOT_LDA_DELIVER}}"
# Set 'message_size_limit', in 'byte' and 'kilobytes'.
# Default is 15M (final message will be slight larger after encoding).
export MESSAGE_SIZE_LIMIT_MB="${MESSAGE_SIZE_LIMIT_MB:=15}"
export MESSAGE_SIZE_LIMIT_BYTES="$((MESSAGE_SIZE_LIMIT_MB * 1024 * 1024))"
export MESSAGE_SIZE_LIMIT_KB="$((MESSAGE_SIZE_LIMIT_MB * 1024))"
# LDAP/MYSQL/PGSQL lookup configuration files.
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
export POSTFIX_LOOKUP_DB='ldap'
elif [ X"${BACKEND}" == X'MYSQL' ]; then
export POSTFIX_LOOKUP_DB='mysql'
elif [ X"${BACKEND}" == X'PGSQL' ]; then
export POSTFIX_LOOKUP_DB='pgsql'
else
export POSTFIX_LOOKUP_DIR="${POSTFIX_ROOTDIR}/lookups"
fi
export POSTFIX_LOOKUP_DIR="${POSTFIX_ROOTDIR}/${POSTFIX_LOOKUP_DB}"
export POSTFIX_MAIL_REINJECT_PORT='10025'
export POSTFIX_MLMMJ_REINJECT_PORT='10028'
+98
View File
@@ -0,0 +1,98 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# Variables for PostgreSQL database server and related.
# PGSQL_SERVER_ADDRESS and PGSQL_SERVER_PORT are defined in conf/global.
# SQL_SERVER_ADDRESS and SQL_SERVER_PORT are defined in dialog/config_via_dialog.sh.
export SYS_USER_PGSQL='postgres'
export SYS_GROUP_PGSQL='postgres'
export PGSQL_RC_SCRIPT_NAME='postgresql'
export PGSQL_INIT_SQL_SAMPLE="${RUNTIME_DIR}/pgsql_init.pgsql"
if [ X"${DISTRO}" == X'RHEL' ]; then
export PGSQL_USER_HOMEDIR='/var/lib/pgsql'
export PGSQL_DATA_DIR="${PGSQL_USER_HOMEDIR}/data"
export PGSQL_CONF_POSTGRESQL="${PGSQL_DATA_DIR}/postgresql.conf"
export PGSQL_CONF_PG_HBA="${PGSQL_DATA_DIR}/pg_hba.conf"
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
if [ X"${DISTRO_CODENAME}" == X'stretch' ]; then
# Debian 9
export PGSQL_VERSION='9.6'
elif [ X"${DISTRO_CODENAME}" == X'bionic' ]; then
# Ubuntu 18.04
export PGSQL_VERSION='10'
elif [ X"${DISTRO_CODENAME}" == X'buster' ]; then
# Debian 10
export PGSQL_VERSION='11'
else
# Ubuntu 20.04
export PGSQL_VERSION='12'
fi
export PGSQL_USER_HOMEDIR='/var/lib/postgresql'
export PGSQL_DATA_DIR="/var/lib/postgresql/${PGSQL_VERSION}/main"
export PGSQL_CONF_DIR="/etc/postgresql/${PGSQL_VERSION}/main"
export PGSQL_CONF_POSTGRESQL="${PGSQL_CONF_DIR}/postgresql.conf"
export PGSQL_CONF_PG_HBA="${PGSQL_CONF_DIR}/pg_hba.conf"
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export SYS_USER_PGSQL='postgres'
export SYS_GROUP_PGSQL='postgres'
export PGSQL_USER_HOMEDIR='/var/db/postgres'
export PGSQL_VERSION='12'
export PGSQL_DATA_DIR="${PGSQL_USER_HOMEDIR}/data${PGSQL_VERSION}"
export PGSQL_CONF_POSTGRESQL="${PGSQL_DATA_DIR}/postgresql.conf"
export PGSQL_CONF_PG_HBA="${PGSQL_DATA_DIR}/pg_hba.conf"
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export SYS_USER_PGSQL='_postgresql'
export SYS_GROUP_PGSQL='_postgresql'
export PGSQL_USER_HOMEDIR='/var/postgresql'
export PGSQL_DATA_DIR="${PGSQL_USER_HOMEDIR}/data"
export PGSQL_CONF_POSTGRESQL="${PGSQL_DATA_DIR}/postgresql.conf"
export PGSQL_CONF_PG_HBA="${PGSQL_DATA_DIR}/pg_hba.conf"
fi
export PGSQL_ROOT_USER="${SYS_USER_PGSQL}"
export PGSQL_RC_SCRIPT="${DIR_RC_SCRIPTS}/${PGSQL_RC_SCRIPT_NAME}"
# ~/.pgpass
export PGSQL_DOT_PGPASS="${PGSQL_USER_HOMEDIR}/.pgpass"
# SSL cert/key
export PGSQL_SSL_CERT="${SSL_CERT_DIR}/iRedMail_CA_PostgreSQL.pem"
export PGSQL_SSL_KEY="${SSL_KEY_DIR}/iRedMail_PostgreSQL.key"
# Commands
export PGSQL_BIN_PG_DUMP='/usr/bin/pg_dump'
export PGSQL_BIN_PG_DUMPALL='/usr/bin/pg_dumpall'
if [ X"${DISTRO}" == X"FREEBSD" -o X"${DISTRO}" == X'OPENBSD' ]; then
export PGSQL_BIN_PG_DUMP='/usr/local/bin/pg_dump'
export PGSQL_BIN_PG_DUMPALL='/usr/local/bin/pg_dumpall'
fi
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# ---------------------------------------
# RoundcubeMail. http://roundcube.net
# ---------------------------------------
export RCM_VERSION='1.4.7'
export RCM_TARBALL="roundcubemail-${RCM_VERSION}-complete.tar.gz"
export RCM_USE_SOURCE='YES'
if [ X"${DISTRO}" == X'FREEBSD' ]; then
# Install via ports tree
export RCM_USE_SOURCE='NO'
fi
if [ X"${RCM_USE_SOURCE}" == X'YES' ]; then
export RCM_HTTPD_ROOT="${HTTPD_SERVERROOT}/roundcubemail-${RCM_VERSION}"
export RCM_HTTPD_ROOT_SYMBOL_LINK="${HTTPD_SERVERROOT}/roundcubemail"
else
if [ X"${DISTRO}" == X'FREEBSD' ]; then
export RCM_HTTPD_ROOT="${HTTPD_SERVERROOT}/roundcube"
export RCM_HTTPD_ROOT_SYMBOL_LINK="${RCM_HTTPD_ROOT}"
fi
fi
export RCM_CONF_DIR="${RCM_HTTPD_ROOT}/config"
export RCM_CONF="${RCM_CONF_DIR}/config.inc.php"
# Syslog log file.
export RCM_LOGFILE="${MAILLOG}"
# Database setting.
export RCM_DB_NAME="roundcubemail"
export RCM_DB_USER="roundcube"
# this key is used to encrypt the users imap password which is stored
# in the session record (and the client cookie if remember password is enabled).
# please provide a string of exactly 24 chars.
export tmp_rcm_des_key="$(${RANDOM_STRING} | cut -c-24)"
export RCM_DES_KEY="${tmp_rcm_des_key}"
# Directory used to store PGP keys generated with Roundcube plugin `enigma`
export RCM_PLUGIN_ENIGMA_PGP_HOMEDIR="${RCM_PLUGIN_ENIGMA_PGP_HOMEDIR:=${STORAGE_BASE_DIR}/pgp-keys}"
+109
View File
@@ -0,0 +1,109 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# Official SOGo package repo.
export SOGO_PKG_MIRROR="${SOGO_PKG_MIRROR:=https://packages.inverse.ca}"
# APT key of SOGo official apt repo: 0x810273C4.
export SOGO_PKG_MIRROR_APT_KEY="${SOGO_PKG_MIRROR_APT_KEY:=0x810273C4}"
# Major SOGo version number: 3, 4.
export SOGO_VERSION='4'
export SYS_USER_SOGO='sogo'
export SYS_GROUP_SOGO='sogo'
export SOGO_PID_FILE='/var/run/sogo/sogo.pid'
export SOGO_LOG_FILE='/var/log/sogo/sogo.log'
export SOGO_CONF_DIR='/etc/sogo'
export SOGO_SIEVE_MASTER_USER="${SOGO_SIEVE_MASTER_USER:=sogo_sieve_master}"
export SOGO_RC_SCRIPT_NAME='sogod'
# SOGo deamon listens on port 127.0.0.1:20000 by default.
export SOGO_BIND_ADDRESS="${LOCAL_ADDRESS:=127.0.0.1}"
export SOGO_BIND_PORT='20000'
# SMTP port used by SOGo for smtp auth without SSL/TLS support.
#
# SOGo doesn't support SMTP auth over TLS or SSL, so if SOGo and Postfix are
# running on different servers, SOGo needs another smtp port to send email.
export SOGO_SMTP_PORT="${SOGO_SMTP_PORT:=1025}"
# SOGo proxy timeout (in seconds)
export SOGO_PROXY_TIMEOUT='3540'
# SOGo SQL database.
export SOGO_DB_NAME='sogo'
export SOGO_DB_USER='sogo'
export SOGO_DB_VIEW_AUTH='users'
export SOGO_DB_VIEW_ALIASES='aliases'
export SOGO_DB_TABLE_USER_PROFILE='sogo_user_profile'
export SOGO_DB_TABLE_FOLDER_INFO='sogo_folder_info'
export SOGO_DB_TABLE_SESSIONS_FOLDER='sogo_sessions_folder'
export SOGO_DB_TABLE_ALARMS='sogo_alarms_folder'
export SOGO_DB_TABLE_STORE='sogo_store'
export SOGO_DB_TABLE_ACL='sogo_acl'
export SOGO_DB_TABLE_CACHE_FOLDER='sogo_cache_folder'
export SOGO_CMD_TOOL='/usr/sbin/sogo-tool'
export SOGO_CMD_EALARMS_NOTIFY='/usr/sbin/sogo-ealarms-notify'
export SOGO_GNUSTEP_DIR="/usr/lib/GNUstep/SOGo"
if [ X"${DISTRO}" == X'RHEL' ]; then
if [ X"${OS_ARCH}" == X'x86_64' ]; then
export SOGO_GNUSTEP_DIR="/usr/lib64/GNUstep/SOGo"
fi
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
export SOGO_RC_SCRIPT_NAME='sogo'
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
export SYS_USER_SOGO='sogod'
export SYS_GROUP_SOGO='sogod'
export SOGO_GNUSTEP_DIR='/usr/local/GNUstep/Local/Library/SOGo'
export SOGO_RC_SCRIPT_NAME='sogod'
export SOGO_CONF_DIR='/usr/local/etc/sogo'
export SOGO_CMD_TOOL='/usr/local/GNUstep/Local/Tools/Admin/sogo-tool'
export SOGO_CMD_EALARMS_NOTIFY='/usr/local/GNUstep/Local/Tools/Admin/sogo-ealarms-notify'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
export SYS_USER_SOGO='_sogo'
export SYS_GROUP_SOGO='_sogo'
export SOGO_GNUSTEP_DIR='/usr/local/lib/GNUstep/SOGo'
export SOGO_CMD_TOOL='/usr/local/sbin/sogo-tool'
export SOGO_CMD_EALARMS_NOTIFY='/usr/local/sbin/sogo-ealarms-notify'
fi
export SOGO_CONF="${SOGO_CONF_DIR}/sogo.conf"
export SOGO_SIEVE_CREDENTIAL_FILE="${SOGO_CONF_DIR}/sieve.cred"
export CRON_FILE_SOGO="${CRON_SPOOL_DIR}/${SYS_USER_SOGO}"
if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
export SOGO_DB_TYPE='mysql'
elif [ X"${BACKEND}" == X'PGSQL' ]; then
export SOGO_DB_TYPE='postgresql'
fi
# Script used to backup SOGo data.
export BACKUP_SCRIPT_SOGO="${BACKUP_DIR}/backup_sogo.sh"
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# For SpamAssassin.
export SA_CONF_DIR='/etc/mail/spamassassin'
export SA_RULES_DIR='/usr/share/spamassassin'
export BIN_SA_UPDATE='sa-update'
export BIN_SA_COMPILE='sa-compile'
if [ X"${DISTRO}" == X'FREEBSD' ]; then
export SA_CONF_DIR='/usr/local/etc/mail/spamassassin'
export SA_RULES_DIR='/usr/local/share/spamassassin'
export BIN_SA_UPDATE='/usr/local/bin/sa-update'
export BIN_SA_COMPILE='/usr/local/bin/sa-compile'
fi
export SA_INIT_PRE="${SA_CONF_DIR}/init.pre"
export SA_LOCAL_CF="${SA_CONF_DIR}/local.cf"
export SA_PLUGIN_RAZOR_CONF="${SA_CONF_DIR}/razor.conf"
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# Author: Zhang Huangbin (zhb _at_ iredmail.org)
#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------
# web servers and PHP
export PORT_HTTP="${PORT_HTTP:=80}"
export HTTPS_PORT="${HTTPS_PORT:=443}"
# store extra web applications
export HTTPD_SERVERROOT='/opt/www'
if [ X"${DISTRO}" == X'RHEL' ]; then
# Web data.
export HTTPD_DOCUMENTROOT='/var/www/html'
elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
# Web data.
export HTTPD_DOCUMENTROOT='/var/www/html'
# Daemon user.
export HTTPD_USER='www-data'
export HTTPD_GROUP='www-data'
elif [ X"${DISTRO}" == X'FREEBSD' ]; then
# Daemon user.
export HTTPD_USER='www'
export HTTPD_GROUP='www'
# Web data.
export HTTPD_SERVERROOT='/usr/local/www'
export HTTPD_DOCUMENTROOT='/usr/local/www/htdocs'
elif [ X"${DISTRO}" == X'OPENBSD' ]; then
# Daemon user.
export HTTPD_USER='www'
export HTTPD_GROUP='www'
# Web data.
export HTTPD_DOCUMENTROOT="/var/www/htdocs"
fi
[ X"${WEB_SERVER}" == X'NGINX' ] && . ${CONF_DIR}/nginx
. ${CONF_DIR}/php