Commits

Zhang Huangbin committed 12efb11

Initially import OpenBSD support. Not finished yet.

Comments (0)

Files changed (34)

iRedMail/conf/amavisd

 
     # Override location of command 'altermime'
     export ALTERMIME_BIN='/usr/local/bin/altermime'
+
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export AMAVISD_VERSION='2.7'
+    export AMAVISD_SYS_USER='_vscan'
+    export AMAVISD_SYS_GROUP='_vscan'
+
+    export AMAVISD_BIN='/usr/local/sbin/amavisd'
+    export AMAVISD_CONF='/etc/amavisd.conf'
+    export AMAVISD_DKIM_CONF='/etc/amavisd.conf'
+    export AMAVISD_LDAP_SCHEMA_NAME='amavisd.schema'
+    export AMAVISD_VIRUSMAILS_DIR='/var/virusmails'
+
+    export AMAVISD_DKIM_DIR='/var/amavisd/dkim'
+
+    # Override location of command 'altermime'
+    export ALTERMIME_BIN='/usr/local/bin/altermime'
+
 fi
 
 if [ X"${AMAVISD_VERSION}" == X'2.7' ]; then

iRedMail/conf/apache_php

     # ---- PHP ----
     # Copy from example: /usr/local/etc/php.ini-production
     export PHP_INI='/usr/local/etc/php.ini'
+
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export HTTPD_RC_SCRIPT_NAME='httpd'
+
+    # Apache configuration files.
+    export HTTPD_CONF_ROOT="/var/www/conf"
+    export HTTPD_CONF="${HTTPD_CONF_ROOT}/httpd.conf"
+    export HTTPD_CONF_DIR="${HTTPD_CONF_ROOT}/modules"
+    export HTTPD_SSL_CONF="${HTTPD_CONF}"
+
+    # Web data.
+    export HTTPD_SERVERROOT='/var/www'
+    export HTTPD_DOCUMENTROOT="${HTTPD_SERVERROOT}/htdocs"
+
+    # Daemon user.
+    export HTTPD_USER='www'
+    export HTTPD_GROUP='www'
+
+    # Log file location.
+    export HTTPD_LOG_ACCESSLOG="${HTTPD_SERVERROOT}/logs/access_log"
+    export HTTPD_LOG_ERRORLOG="${HTTPD_SERVERROOT}/logs/error_log"
+
+    # ---- PHP ----
+    export PHP_VERSION='5.3'
+    export PHP_INI="/etc/php-${PHP_VERSION}.ini"
 fi
 
 export HTTPD_CGIBIN_DIR="${HTTPD_SERVERROOT}/cgi-bin"

iRedMail/conf/clamav

 export CLAMAV_CLAMD_RC_SCRIPT_NAME='clamd'
 export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='freshclamd'
 
+export CLAMD_CONF='/etc/clamd.conf'
+export FRESHCLAM_CONF='/etc/freshclam.conf'
+
+export CLAMD_LOGFILE='/var/log/clamav/clamd.log'
+export FRESHCLAM_LOGFILE='/var/log/clamav/freshclam.log'
+
 # Clamav.
 if [ X"${DISTRO}" == X"RHEL" ]; then
-    export CLAMD_CONF='/etc/clamd.conf'
-
     # Freshclam.
-    export FRESHCLAM_CONF='/etc/freshclam.conf'
     export FRESHCLAM_INIT_FILE_SAMPLE="${SAMPLE_DIR}/freshclam.init"
 
 elif [ X"${DISTRO}" == X"SUSE" ]; then
     export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='freshclam'
 
-    export CLAMD_CONF='/etc/clamd.conf'
-    export FRESHCLAM_CONF='/etc/freshclam.conf'
-
 elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
     export CLAMAV_CLAMD_RC_SCRIPT_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'
 
-elif [ X"${DISTRO}" == X"GENTOO" ]; then
-    export CLAMD_CONF='/etc/clamd.conf'
-    export FRESHCLAM_CONF='/etc/freshclam.conf'
-
 elif [ X"${DISTRO}" == X"FREEBSD" ]; then
     export CLAMD_CONF='/usr/local/etc/clamd.conf'
     export FRESHCLAM_CONF='/usr/local/etc/freshclam.conf'
-else
-    :
+
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export CLAMAV_USER='_clamav'
+    export CLAMAV_GROUP='_clamav'
+    export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='freshclam'
 fi
 
 # Clamd.
 else
     export CLAMD_LOCAL_SOCKET='/tmp/clamd.socket'   # Used to override default setting.
 fi
-export CLAMD_LOGFILE='/var/log/clamav/clamd.log'
-export FRESHCLAM_LOGFILE='/var/log/clamav/freshclam.log'
 
 # Freshclam.
 export FRESHCLAM_PID_FILE='/var/run/clamav/freshclam.pid'   # Used to override default setting.

iRedMail/conf/core

     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
 
     # Different maildir style: hashed, normal.
     if [ X"${MAILDIR_STYLE}" == X"hashed" ]; then
-        length="$(echo ${username} | wc -L)"
         str1="$(echo ${username} | cut -c1)"
         str2="$(echo ${username} | cut -c2)"
         str3="$(echo ${username} | cut -c3)"
 
-        if [ X"${length}" == X"1" ]; then
+        if [ X"${username}" == X"${str1}" ]; then
+            # Username has only one character
             str2="${str1}"
             str3="${str1}"
-        elif [ X"${length}" == X"2" ]; then
+        elif [ X"${username}" == X"${str1}${str2}" ]; then
             str3="${str2}"
         else
             :
 
 gen_ldap_passwd()
 {
-    if [ X"${DISTRO}" == X"FREEBSD" ]; then
+    if [ X"${DISTRO}" == X'FREEBSD' -o X"${DISTRO}" == X'OPENBSD' ]; then
         SLAPPASSWD='/usr/local/sbin/slappasswd'
     else
         SLAPPASSWD='/usr/sbin/slappasswd'
     fi
 }
 
+enable_service_openbsd()
+{
+    # USAGE: enable_service_openbsd flag value
+    # For example: enable_service_openbsd sendmail_flags ''
+    [ -f ${RC_CONF_LOCAL} ] || touch ${RC_CONF_LOCAL}
+    if [ X"$#" == X'2' ]; then
+        flag="${1}"
+        value="${2}"
+        comment_mark="# ${PROG_NAME}-${flag}"
+        if ! grep "^${comment_mark}$" ${RC_CONF_LOCAL} &>/dev/null; then
+            ECHO_DEBUG "Add flag in ${RC_CONF_LOCAL}: ${flag}='${value}'"
+            echo "${comment_mark}" >> ${RC_CONF_LOCAL}
+            echo "${flag}='${value}'" >> ${RC_CONF_LOCAL}
+        else
+            ECHO_DEBUG "Skip adding flag in ${RC_CONF_LOCAL}: ${pkg}='${value}'"
+        fi
+    fi
+}
+disable_service_openbsd()
+{
+    :
+}
 enable_service_freebsd()
 {
     :

iRedMail/conf/dovecot

 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'
+if [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export DOVECOT_QUOTA_TYPE='maildir'
+else
+    export DOVECOT_QUOTA_TYPE='dict:user::proxy::quotadict'
+fi
 
 # Do not starts with dot (.).
 export SIEVE_RULE_FILENAME='dovecot.sieve'
     export DOVECOT_REALTIME_QUOTA_CONF='/usr/local/etc/dovecot/dovecot-used-quota.conf'
     export DOVECOT_SHARE_FOLDER_CONF='/usr/local/etc/dovecot/dovecot-share-folder.conf'
     export DOVECOT_DELIVER='/usr/local/libexec/dovecot/deliver'
-fi
 
-# Override enabled plugins for dovecot-1.1.
-if [ X"${DOVECOT_VERSION}" == X"1.1" ]; then
-    export DOVECOT_LDA_PLUGINS='cmusieve quota'
-    export DOVECOT_IMAP_PLUGINS='quota imap_quota'
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export DOVECOT_USER='_dovecot'
+    export DOVECOT_GROUP='_dovecot'
+    export DOVECOT_DELIVER='/usr/local/libexec/dovecot/deliver'
+
 fi
 
 # Log & logrotate files.
     export DOVECOT_REALTIME_QUOTA_SQLTYPE='pgsql'
 fi
 
-if [ X"${DOVECOT_VERSION}" == X"1.1" -o X"${DOVECOT_VERSION}" == X"1.2" ]; then
+if [ X"${DOVECOT_VERSION}" == X"1.2" ]; then
     export DOVECOT_PROTOCOLS="pop3 pop3s imap imaps managesieve"
 else
     export DOVECOT_PROTOCOLS="pop3 imap sieve"

iRedMail/conf/global

 # Default virtual domain admin name without domain name (@example.com).
 export DOMAIN_ADMIN_NAME='postmaster'
 
-# Hostname.
-export HOSTNAME="$(hostname -f)"
-
 # ----------------------------------
 # You do *NOT* need to modify them.
 # ----------------------------------
     export _DEBUG='NO'
 fi
 
-# Genrate a random string.
-# Usage:
-#   str="$(${RANDOM_STRING})"
-export RANDOM_STRING='eval </dev/urandom tr -dc A-Za-z0-9| (head -c $1 > /dev/null 2>&1 || head -c 30)'
-
 # Tools.
 export CONFIG_VIA_DIALOG="${DIALOG_DIR}/config_via_dialog.sh"
 # Note: config file will be sourced in file 'conf/core', function 'check_env()'.
 # Kernel name.
 export KERNEL_NAME="$(uname -s)"
 
+# Hostname.
+if [ X"${KERNEL_NAME}" == X'OpenBSD' ]; then
+    export HOSTNAME="$(hostname)"
+    export RANDOM_STRING='eval echo $RANDOM | md5'
+else
+    export HOSTNAME="$(hostname -f)"
+
+    # Genrate a random string.
+    # Usage:
+    #   str="$(${RANDOM_STRING})"
+    export RANDOM_STRING='eval </dev/urandom tr -dc A-Za-z0-9 | (head -c $1 &>/dev/null || head -c 30)'
+fi
+
 # command: dialog.
 export BIN_DIALOG="dialog"
 export PKG_DIALOG="dialog"
     if echo "${DISTRO_VERSION}" | grep '^7' &>/dev/null ; then
         export UNSUPPORTED_RELEASE='YES'
     fi
+elif [ X"${KERNEL_NAME}" == X'OpenBSD' ]; then
+    export DISTRO='OPENBSD'
+    export DISTRO_VERSION="$(uname -r)"
+
+    # Directory of RC scripts.
+    export DIR_RC_SCRIPTS='/etc/rc.d'
+
+    export RC_CONF_LOCAL='/etc/rc.conf.local'
 else
     # Not support *BSD and other distrobutions yet.
     echo "Error: Your OS is not supported yet."
     # Directory used to store SSL/TLS key/cert file.
     export SSL_FILE_DIR="/etc/ssl"
 
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export ENABLE_BACKEND_MYSQL='NO'
+    export ENABLE_BACKEND_PGSQL='NO'
+
+    # System user: root.
+    export SYS_ROOT_USER='root'
+    export SYS_ROOT_GROUP='wheel'
+
+    # Package management.
+    if [ X"${PKG_PATH}" == X"" ]; then
+        # Reference: http://www.openbsd.org/faq/faq15.html#Easy
+        export PKG_PATH="ftp://ftp.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(machine -a)/"
+    fi
+
+    # Package management.
+    export install_pkg='pkg_add -i'
+    export remove_pkg='pkg_delete'
+    export LIST_ALL_PKGS="pkg_info -a | awk '{print $1}'"
+    export LIST_FILES_IN_PKG='pkg_info -L'
+
+    # Service control.
+    export enable_service="enable_service_openbsd"
+    export disable_service="disable_service_openbsd"
+
+    # Syslog config: rsyslog.
+    export SYSLOG_CONF='/etc/syslog.conf'
+    export SYSLOG_POSTROTATE_CMD=''
+
+    # Crontab related.
+    export CRON_SPOOL_DIR='/var/cron/tabs'
+
+    # PF rule file.
+    export IPTABLES_CONFIG="/etc/pf.rules"
+
+    # Directory used to store SSL/TLS key/cert file.
+    export SSL_FILE_DIR="/etc/ssl"
+
 else
     # Not support yet.
     echo "Your distrobution is not supported yet."
 fi
 
 # Use a seperated directory to store iRedMail certs/keys.
-export SSL_CERT_DIR="${SSL_FILE_DIR}/certs"
-export SSL_KEY_DIR="${SSL_FILE_DIR}/private"
+if [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export SSL_CERT_DIR="${SSL_FILE_DIR}"
+    export SSL_KEY_DIR="${SSL_FILE_DIR}"
+else
+    export SSL_CERT_DIR="${SSL_FILE_DIR}/certs"
+    export SSL_KEY_DIR="${SSL_FILE_DIR}/private"
+fi
 
 # SSL key.
 export OPENSSL_CONF="${SSL_FILE_DIR}/openssl.cnf"
 export MYSQL_BACKUP_DATABASES=''
 
 # Command use to fetch source tarballs.
-if [ X"${DISTRO}" == X"FREEBSD" ]; then
+if [ X"${DISTRO}" == X'FREEBSD' -o X"${DISTRO}" == X'OPENBSD' ]; then
     # -i: Turns off interactive prompting during multiple file transfers.
     # -V: Disable verbose and progress
     FETCH_CMD='ftp -iV'

iRedMail/conf/mysql

     export MYSQL_RC_SCRIPT_NAME='mysql-server'
     export MYSQL_SOCKET='/tmp/mysql.sock'
     export MYSQL_MY_CNF="/var/db/mysql/my.cnf"
+
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export MYSQL_RC_SCRIPT_NAME='mysqld'
+    export MYSQL_SOCKET='/var/run/mysql/mysql.sock'
+    export MYSQL_MY_CNF="/etc/my.cnf"
 fi
 
 export MYSQLD_RC_SCRIPT="${DIR_RC_SCRIPTS}/${MYSQL_RC_SCRIPT_NAME}"

iRedMail/conf/openldap

 
     # Override default setting.
     export OPENLDAP_DATA_DIR='/var/db/openldap-data'    # Do *NOT* end with '/'.
+
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    # OpenLDAP version.
+    export OPENLDAP_VERSION='2.4'
+
+    # LDAP daemon user & group.
+    export LDAP_USER='_openldap'
+    export LDAP_GROUP='_openldap'
+
+    # Configuration files.
+    export OPENLDAP_CONF_ROOT='/etc/openldap'
+    export OPENLDAP_DB_CONFIG_SAMPLE="/usr/local/share/examples/openldap/DB_CONFIG"
+
+    # Module related.
+    export OPENLDAP_MODULE_PATH='/usr/local/libexec/openldap'
 else
     :
 fi

iRedMail/conf/phpldapadmin

 # Install phpLDAPadmin with source tarball.
 export PHPLDAPADMIN_USE_SOURCE='YES'
 
-if [ X"${DISTRO}" == X"FREEBSD" ]; then
+if [ X"${DISTRO}" == X"FREEBSD" -o X"${DISTRO}" == X'OPENBSD' ]; then
     # Install phpLDAPadmin via ports tree.
     export PHPLDAPADMIN_USE_SOURCE='NO'
 

iRedMail/conf/phpmyadmin

 export PHPMYADMIN_HTTPD_ROOT_SYMBOL_LINK="${HTTPD_SERVERROOT}/phpmyadmin"
 
 # Install phpMyAdmin with binary packages.
-if [ X"${DISTRO}" == X"FREEBSD" ]; then
+if [ X"${DISTRO}" == X"FREEBSD" -o X"${DISTRO}" == X'OPENBSD' ]; then
+    export PHPMYADMIN_USE_SOURCE='NO'
     export PHPMYADMIN_HTTPD_ROOT="${HTTPD_SERVERROOT}/phpMyAdmin"
     export PHPMYADMIN_HTTPD_ROOT_SYMBOL_LINK="${PHPMYADMIN_HTTPD_ROOT}"
-    export PHPMYADMIN_USE_SOURCE='NO'
 fi
 
 if [ X"${DISTRO_CODENAME}" == X"lucid" -o X"${DISTRO_CODENAME}" == X"squeeze" ]; then

iRedMail/conf/policy_server

         export USE_CLUEBRINGER='YES'
         export USE_POLICYD='NO'
     fi
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export USE_CLUEBRINGER='NO'
+    export USE_POLICYD='NO'
 fi
 
 if [ X"${USE_POLICYD}" == X'YES' ]; then

iRedMail/conf/postfix

     export MAILLOG_ERROR='/var/log/mail.err'
     export MAILLOG_WARN='/var/log/mail.warn'
     export POSTFIX_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/postfix"
+
 elif [ 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 POSTFIX_DAEMON_USER='_postfix'
+    export POSTFIX_DAEMON_GROUP='_postfix'
 fi
 
 # You do *NOT* need to modify them.

iRedMail/conf/postgresql

     export PGSQL_CONF_POSTGRESQL="${PGSQL_CONF_DIR}/postgresql.conf"
     export PGSQL_CONF_PG_HBA="${PGSQL_CONF_DIR}/pg_hba.conf"
     export PGSQL_DATA_DIR="${PGSQL_CONF_DIR}"
+
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export PGSQL_SYS_USER='_postgresql'
+    export PGSQL_SYS_GROUP='_postgresql'
+    export PGSQL_ROOT_USER='_postgresql'
+    export PGSQL_SYS_USER_HOME='/var/postgresql'
+
+    export PGSQL_CONF_DIR="${PGSQL_SYS_USER_HOME}/data"
+    export PGSQL_CONF_POSTGRESQL="${PGSQL_CONF_DIR}/postgresql.conf"
+    export PGSQL_CONF_PG_HBA="${PGSQL_CONF_DIR}/pg_hba.conf"
+    export PGSQL_DATA_DIR="${PGSQL_CONF_DIR}"
 else
     export PGSQL_CONF_DIR="/etc/postgresql/${PGSQL_VERSION}/main"
     export PGSQL_CONF_POSTGRESQL="${PGSQL_CONF_DIR}/postgresql.conf"
 # Commands
 export PGSQL_BIN_PG_DUMP='/usr/bin/pg_dump'
 export PGSQL_BIN_PG_DUMPALL='/usr/bin/pg_dumpall'
-if [ X"${DISTRO}" == X"FREEBSD" ]; then
+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

iRedMail/conf/roundcube

 if [ X"${DISTRO}" == X"FREEBSD" ]; then
     export RCM_HTTPD_ROOT="${HTTPD_SERVERROOT}/roundcube"
     export RCM_HTTPD_ROOT_SYMBOL_LINK="${RCM_HTTPD_ROOT}"
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    export RCM_HTTPD_ROOT="${HTTPD_SERVERROOT}/roundcubemail"
+    export RCM_HTTPD_ROOT_SYMBOL_LINK="${RCM_HTTPD_ROOT}"
 else
     export RCM_HTTPD_ROOT="${HTTPD_SERVERROOT}/roundcubemail-${RCM_VERSION}"
     export RCM_HTTPD_ROOT_SYMBOL_LINK="${HTTPD_SERVERROOT}/roundcubemail"
 # 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})"
-export RCM_DES_KEY="$(echo ${tmp_rcm_des_key} | head -c 24)"
+export RCM_DES_KEY="$(echo ${tmp_rcm_des_key} | cut -c-24)"

iRedMail/functions/apache_php.sh

     # SSL
     #
     ECHO_DEBUG "Set correct SSL Cert/Key file location."
-    if [ X"${DISTRO}" == X"RHEL" -o X"${DISTRO}" == X"FREEBSD" ]; then
+    if [ X"${DISTRO}" == X"RHEL" \
+        -o X"${DISTRO}" == X'FREEBSD' \
+        -o X"${DISTRO}" == X'OPENBSD' \
+        ]; then
         perl -pi -e 's#^(SSLCertificateFile)(.*)#${1} $ENV{SSL_CERT_FILE}#' ${HTTPD_SSL_CONF}
         perl -pi -e 's#^(SSLCertificateKeyFile)(.*)#${1} $ENV{SSL_KEY_FILE}#' ${HTTPD_SSL_CONF}
 
 Disallow: /iredadmin
 EOF
 
-    echo "${HTTPD_USER}: root" >> ${POSTFIX_FILE_ALIASES}
-    postalias hash:${POSTFIX_FILE_ALIASES} &>/dev/null
+    if [ X"${DISTRO}" != X'OPENBSD' ]; then
+        echo "${HTTPD_USER}: root" >> ${POSTFIX_FILE_ALIASES}
+        postalias hash:${POSTFIX_FILE_ALIASES} &>/dev/null
+    fi
+
+    if [ X"${DISTRO}" == X'OPENBSD' ]; then
+        echo 'httpd_flags="-DSSL -u"' >> ${RC_CONF_LOCAL}
+    fi
+
     # --------------------------
     # PHP Setting.
     # --------------------------
     backup_file ${PHP_INI}
 
     # FreeBSD: Copy sample file.
-    [ X"${DISTRO}" == X"FREEBSD" ] && cp -f /usr/local/etc/php.ini-production ${PHP_INI}
+    if [ X"${DISTRO}" == X"FREEBSD" ]; then
+        cp -f /usr/local/etc/php.ini-production ${PHP_INI}
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        ln -s /var/www/conf/modules.sample/php-${PHP_VERSION}.conf /var/www/conf/modules/php.conf
+
+        # Enable Apache modules
+        for module in fileinfo bz2 imap ldap mcrypt mysql mysqli pgsql pspell gd; do
+            ln -s /etc/php-${PHP_VERSION}.sample/${module}.ini /etc/php-${PHP_VERSION}/${module}.ini
+        done
+    fi
 
     #ECHO_DEBUG "Setting error_reporting to 'E_ERROR': ${PHP_INI}."
     #perl -pi -e 's#^(error_reporting.*=)#${1} E_ERROR;#' ${PHP_INI}
 
     ECHO_DEBUG "Disable php extension: suhosin. ${PHP_INI}."
     perl -pi -e 's/^(suhosin.session.encrypt.*=)/${1} Off;/' ${PHP_INI}
+    perl -pi -e 's/^;(suhosin.session.encrypt.*=)/${1} Off;/' ${PHP_INI}
 
     # Set date.timezone. Required by PHP-5.3.
     grep '^date.timezone' ${PHP_INI} >/dev/null

iRedMail/functions/clamav.sh

 clamav_config()
 {
     ECHO_INFO "Configure ClamAV (anti-virus toolkit)."
+    backup_file ${CLAMD_CONF} ${FRESHCLAM_CONF}
+
+    if [ X"${DISTRO}" == X'OPENBSD' ]; then
+        perl -pi -e 's/^(Example)/#${1}/' ${CLAMD_CONF} ${FRESHCLAM_CONF}
+        mkdir /var/log/clamav
+        chown ${CLAMAV_USER}:${CLAMAV_GROUP} /var/log/clamav
+    fi
 
     export CLAMD_LOCAL_SOCKET CLAMD_LISTEN_ADDR
     ECHO_DEBUG "Configure ClamAV: ${CLAMD_CONF}."
     perl -pi -e 's/^(TCPSocket.*)/#${1}/' ${CLAMD_CONF}
     perl -pi -e 's#^(TCPAddr).*#${1} $ENV{CLAMD_LISTEN_ADDR}#' ${CLAMD_CONF}
+
+    # Set log file
     perl -pi -e 's#^(LogFile).*#${1} $ENV{CLAMD_LOGFILE}#' ${CLAMD_CONF}
+    perl -pi -e 's/^#(LogFile).*/${1} $ENV{CLAMD_LOGFILE}/' ${CLAMD_CONF}
+
     # Set CLAMD_LOCAL_SOCKET
-    # - for clamav < 0.9.6
-    perl -pi -e 's#^(LocalSocket).*#${1} $ENV{CLAMD_LOCAL_SOCKET}#' ${CLAMD_CONF}
     # - for clamav = 0.9.6
-    perl -pi -e 's-^#(LocalSocket).*-${1} $ENV{CLAMD_LOCAL_SOCKET}-' ${CLAMD_CONF}
+    perl -pi -e 's/^#(LocalSocket).*/${1} $ENV{CLAMD_LOCAL_SOCKET}/' ${CLAMD_CONF}
 
     ECHO_DEBUG "Configure freshclam: ${FRESHCLAM_CONF}."
     perl -pi -e 's-^#(PidFile)(.*)-${1} $ENV{FRESHCLAM_PID_FILE}-' ${FRESHCLAM_CONF}

iRedMail/functions/cleanup.sh

     fi
 
     [ X"${DISTRO}" == X"RHEL" ] && check_status_before_run cleanup_disable_selinux
-    check_status_before_run cleanup_remove_sendmail
+    [ X"${DISTRO}" != X'OPENBSD' ] && check_status_before_run cleanup_remove_sendmail
     check_status_before_run cleanup_remove_mod_python
     [ X"${KERNEL_NAME}" == X"Linux" ] && check_status_before_run cleanup_replace_iptables_rule
     [ X"${DISTRO}" == X"RHEL" ] && check_status_before_run cleanup_replace_mysql_config
     check_status_before_run cleanup_backup_scripts
     [ X"${BACKEND}" == X'PGSQL' ] && check_status_before_run cleanup_pgsql_force_password
-    [ X"${DISTRO}" != X'GENTOO' ] && check_status_before_run cleanup_start_postfix_now
+    [ X"${DISTRO}" != X'GENTOO' -a X"${DISTRO}" != X'OPENBSD' ] && check_status_before_run cleanup_start_postfix_now
 
     # Start Postfix to deliver emails.
     [ X"${DISTRO}" == X'GENTOO' ] && ${DIR_RC_SCRIPTS}/postfix restart >/dev/null
     sendmail -t ${tip_recipient} < /tmp/.links.eml &>/dev/null && rm -f /tmp/.links.eml &>/dev/null
 
     # Don't execute 'cleanup_amavisd_preconfig' before sending emails.
-    [ X"${DISTRO}" == X"FREEBSD" -o X"${DISTRO}" == X'GENTOO' ] && check_status_before_run cleanup_amavisd_preconfig
+    if [ X"${DISTRO}" == X'GENTOO' \
+        -o X"${DISTRO}" == X'FREEBSD' \
+        -o X"${DISTRO}" == X'OPENBSD' \
+        ]; then
+        check_status_before_run cleanup_amavisd_preconfig
+    fi
 
     cat <<EOF
 ********************************************************************

iRedMail/functions/dovecot2.sh

 
     # Base directory.
     perl -pi -e 's#PH_BASE_DIR#$ENV{DOVECOT_BASE_DIR}#' ${DOVECOT_CONF}
+    # base_dir is required on OpenBSD
+    [ X"${DISTRO}" == X'OPENBSD' ] && \
+        perl -pi -e 's/^#(base_dir.*)/${1}/' ${DOVECOT_CONF}
 
     # Provided services.
     export DOVECOT_PROTOCOLS
     backup_file ${DOVECOT_QUOTA_WARNING_SCRIPT}
     rm -f ${DOVECOT_QUOTA_WARNING_SCRIPT} 2>/dev/null
     cp -f ${SAMPLE_DIR}/dovecot/dovecot2-quota-warning.sh ${DOVECOT_QUOTA_WARNING_SCRIPT}
+    if [ X"${DOVECOT_QUOTA_TYPE}" == X'maildir' ]; then
+        perl -pi -e 's#(.*)(-o.*plugin.*)#${1}#' ${DOVECOT_QUOTA_WARNING_SCRIPT}
+    fi
 
     export DOVECOT_DELIVER HOSTNAME
     perl -pi -e 's#PH_DOVECOT_DELIVER#$ENV{DOVECOT_DELIVER}#' ${DOVECOT_QUOTA_WARNING_SCRIPT}

iRedMail/functions/iredadmin.sh

     # Backend related settings.
     if [ X"${BACKEND}" == X"OPENLDAP" ]; then
         # Change backend.
-        sed -i.tmp -e "/\[general\]/,/\[/ s#\(^backend =\).*#\1 ldap#" settings.ini
+        perl -pi -e 's#^(backend.*=).*#${1} ldap#' settings.ini
 
         # Section [ldap].
         ECHO_DEBUG "Configure OpenLDAP backend related settings."
-        sed -i.tmp \
-            -e "/\[ldap\]/,/\[/ s#\(^uri =\).*#\1 ldap://${LDAP_SERVER_HOST}:${LDAP_SERVER_PORT}#" \
-            -e "/\[ldap\]/,/\[/ s#\(^basedn =\).*#\1 ${LDAP_BASEDN}#" \
-            -e "/\[ldap\]/,/\[/ s#\(^domainadmin_dn =\).*#\1 ${LDAP_ADMIN_BASEDN}#" \
-            -e "/\[ldap\]/,/\[/ s#\(^bind_dn =\).*#\1 ${LDAP_ADMIN_DN}#" \
-            -e "/\[ldap\]/,/\[/ s#\(^bind_pw =\).*#\1 ${LDAP_ADMIN_PW}#" \
-            settings.ini
+        perl -pi -e 's#^(uri.*=).*#${1} ldap://$ENV{LDAP_SERVER_HOST}:$ENV{LDAP_SERVER_PORT}#' settings.ini
+        perl -pi -e 's#^(basedn.*=).*#${1} ${LDAP_BASEDN}#' settings.ini
+        perl -pi -e 's#^(domainadmin_dn.*=).*#${1} ${LDAP_ADMIN_BASEDN}#' settings.ini
+        perl -pi -e 's#^(bind_dn.*=).*#${1} ${LDAP_ADMIN_DN}#' settings.ini
+        perl -pi -e 's#^(bind_pw.*=).*#${1} ${LDAP_ADMIN_PW}#' settings.ini
 
     elif [ X"${BACKEND}" == X"MYSQL" -o X"${BACKEND}" == X'PGSQL' ]; then
         ECHO_DEBUG "Configure MySQL related settings."

iRedMail/functions/iredapd.sh

     else
         cp ${IREDAPD_ROOT_DIR}/iredapd/rc_scripts/iredapd.rhel ${DIR_RC_SCRIPTS}/iredapd
     fi
+
+    if [ X"${DISTRO}" == X'OPENBSD' ]; then
+        perl -pi -e 's#(.*)(/usr/bin/env bash)#${1}/usr/local/bin/bash#' ${DIR_RC_SCRIPTS}/iredapd
+        perl -pi -e 's#python#/usr/local/bin/python#' ${DIR_RC_SCRIPTS}/iredapd
+        perl -pi -e 's#(.*echo)(.*Starting.*)#${1} -n " iredapd"#' ${DIR_RC_SCRIPTS}/iredapd
+        perl -pi -e 's#(.*echo)(.*Stopping.*)#${1} -n " iredapd"#' ${DIR_RC_SCRIPTS}/iredapd
+    fi
+
     chmod 0755 ${DIR_RC_SCRIPTS}/iredapd
     chmod +x ${IREDAPD_ROOT_DIR}/iredapd/src/iredapd.py
 

iRedMail/functions/mysql.sh

 
     ECHO_DEBUG "Starting MySQL."
 
-    # Gentoo: Initial MySQL database first
-    [ X"${DISTRO}" == X"GENTOO" ] && \
+    # Gentoo, OpenBSD: Initial MySQL database first
+    if [ X"${DISTRO}" == X"GENTOO" ]; then
         /usr/bin/mysql_install_db &>/dev/null
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        /usr/local/bin/mysql_install_db &>/dev/null
+    fi
 
     # FreeBSD: Start mysql when system start up.
     # Warning: We must have 'mysql_enable=YES' before start/stop mysql daemon.

iRedMail/functions/openldap.sh

     cp -f ${SAMPLE_DIR}/iredmail.schema ${OPENLDAP_SCHEMA_DIR}
 
     # Copy amavisd schema.
+    # - On OpenBSD: package amavisd-new will copy schema file to /etc/openldap/schema
     if [ X"${DISTRO}" == X"RHEL" ]; then
         if [ X"${DISTRO_VERSION}" == X"6" ]; then
             amavisd_schema_file="$( eval ${LIST_FILES_IN_PKG} amavisd-new | grep '/LDAP.schema$')"
 EOF
 
     # Load backend module. Required on Debian/Ubuntu.
-    if [ X"${OPENLDAP_VERSION}" == X"2.4" -a X"${DISTRO}" != X"SUSE" ]; then
+    if [ X"${OPENLDAP_VERSION}" == X"2.4" \
+        -a X"${DISTRO}" != X'SUSE' \
+        -a X"${DISTRO}" != X'OPENBSD' \
+        ]; then
         if [ X"${OPENLDAP_DEFAULT_DBTYPE}" == X"bdb" ]; then
             # bdb, Berkeley DB.
             cat >> ${OPENLDAP_SLAPD_CONF} <<EOF

iRedMail/functions/optional_components.sh

         check_status_before_run phppgadmin_install
 
     # Awstats.
-    [ X"${USE_AWSTATS}" == X"YES" ] && \
-        check_status_before_run awstats_config_basic && \
-        check_status_before_run awstats_config_weblog && \
-        check_status_before_run awstats_config_maillog && \
-        check_status_before_run awstats_config_crontab
+    if [ X"${DISTRO}" != X'OPENBSD' ]; then
+        [ X"${USE_AWSTATS}" == X"YES" ] && \
+            check_status_before_run awstats_config_basic && \
+            check_status_before_run awstats_config_weblog && \
+            check_status_before_run awstats_config_maillog && \
+            check_status_before_run awstats_config_crontab
+    fi
 
     # iRedAdmin.
-    [ X"${USE_IREDADMIN}" == X"YES" ] && \
+    [ X"${USE_IREDADMIN}" == X"YES" -a X"${DISTRO}" != X'OPENBSD' ] && \
         check_status_before_run iredadmin_config
 
     # iRedAPD.
-    [ X"${USE_IREDAPD}" == X"YES" ] && \
+    [ X"${USE_IREDAPD}" == X'YES' ] && \
         check_status_before_run iredapd_config
 
     # Fail2ban.
-    [ X"${USE_FAIL2BAN}" == X"YES" -a X"${DISTRO}" != X"FREEBSD" ] && \
+    [ X"${USE_FAIL2BAN}" == X'YES' \
+        -a X"${DISTRO}" != X'FREEBSD' \
+        -a X"${DISTRO}" != X'OPENBSD' \
+        ] && \
         check_status_before_run fail2ban_config
 
 }

iRedMail/functions/packages.sh

     ALL_PKGS=''
     ENABLED_SERVICES=''
     DISABLED_SERVICES=''
+    PKG_SCRIPTS=''  # OpenBSD only
 
     ###########################
     # Enable syslog or rsyslog.
         elif [ X"${DISTRO}" == X"GENTOO" ]; then
             ALL_PKGS="${ALL_PKGS} openldap mysql"
 
+        elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+            ALL_PKGS="${ALL_PKGS} openldap-server openldap-client mysql-server mysql-client"
+            PKG_SCRIPTS="${PKG_SCRIPTS} ${LDAP_RC_SCRIPT_NAME} ${MYSQL_RC_SCRIPT_NAME}"
+
         fi
     elif [ X"${BACKEND}" == X"MYSQL" ]; then
         # MySQL server & client.
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
             ALL_PKGS="${ALL_PKGS} mysql mod_auth_mysql"
 
+        elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+            ALL_PKGS="${ALL_PKGS} mysql-server mysql-client"
+            PKG_SCRIPTS="${PKG_SCRIPTS} ${MYSQL_RC_SCRIPT_NAME}"
+
         fi
     elif [ X"${BACKEND}" == X"PGSQL" ]; then
         ENABLED_SERVICES="${ENABLED_SERVICES} ${PGSQL_RC_SCRIPT_NAME}"
 
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
             ALL_PKGS="${ALL_PKGS} postgresql-server mod_auth_pgsql"
+
+        elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+            ALL_PKGS="${ALL_PKGS} postgresql-server postgresql-client postgresql-contrib"
+            PKG_SCRIPTS="${PKG_SCRIPTS} ${PGSQL_RC_SCRIPT_NAME}"
         fi
     fi
 
         gentoo_add_make_conf 'APACHE2_MPMS' 'prefork'
 
         gentoo_add_use_flags 'dev-lang/php' 'berkdb bzip2 cli crypt ctype fileinfo filter hash iconv ipv6 json nls phar posix readline session simplexml ssl tokenizer unicode xml zlib apache2 calendar -cdb cgi cjk curl curlwrappers doc flatfile fpm ftp gd gmp imap inifile intl kerberos ldap ldap-sasl mhash mysql mysqli mysqlnd odbc pdo postgres snmp soap sockets spell sqlite sqlite3 suhosin tidy truetype wddx xmlreader xmlrpc xmlwriter xpm xsl zip'
+
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        ALL_PKGS="${ALL_PKGS} php php-bz2 php-imap php-ldap php-mcrypt php-mysql php-mysqli php-pgsql php-gd"
     fi
 
     ###############
         ALL_PKGS="${ALL_PKGS} postfix"
         #gentoo_unmask_package 'mail-mta/ssmtp'
         gentoo_add_use_flags 'mail-mta/postfix' 'ipv6 pam ssl cdb dovecot-sasl hardened ldap ldap-bind mbox mysql postgres sasl'
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        PKG_SCRIPTS="${PKG_SCRIPTS} ${POSTFIX_RC_SCRIPT_NAME}"
+        if [ X"${BACKEND}" == X'OPENLDAP' ]; then
+            ALL_PKGS="${ALL_PKGS} postfix--ldap"
+        elif [ X"${BACKEND}" == X'MYSQL' ]; then
+            ALL_PKGS="${ALL_PKGS} postfix--mysql"
+        elif [ X"${BACKEND}" == X'PGSQL' ]; then
+            ALL_PKGS="${ALL_PKGS} postfix--pgsql"
+        fi
     fi
 
     # Policyd.
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
         ALL_PKGS="${ALL_PKGS} policyd"
         ENABLED_SERVICES="${ENABLED_SERVICES} ${POLICYD_RC_SCRIPT_NAME}"
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        # No port available.
+        :
     fi
 
     # Dovecot.
+    ENABLED_SERVICES="${ENABLED_SERVICES} ${DOVECOT_RC_SCRIPT_NAME}"
     if [ X"${DISTRO}" == X"RHEL" ]; then
         if [ X"${DISTRO_VERSION}" == X"5" ]; then
             ALL_PKGS="${ALL_PKGS} dovecot${PKG_ARCH} dovecot-sieve${PKG_ARCH} dovecot-managesieve${PKG_ARCH}"
         ALL_PKGS="${ALL_PKGS} dovecot"
         DISABLED_SERVICES="${DISABLED_SERVICES} saslauthd"
         gentoo_add_use_flags 'net-mail/dovecot' 'bzip2 ipv6 maildir pam ssl zlib caps doc kerberos ldap managesieve mbox mdbox mysql postgres sdbox sieve sqlite suid'
+
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        ALL_PKGS="${ALL_PKGS} dovecot dovecot-pigeonhole"
+        PKG_SCRIPTS="${PKG_SCRIPTS} ${DOVECOT_RC_SCRIPT_NAME}"
+
+        if [ X"${BACKEND}" == X'OPENLDAP' ]; then
+            ALL_PKGS="${ALL_PKGS} dovecot-ldap dovecot-mysql"
+        elif [ X"${BACKEND}" == X'MYSQL' ]; then
+            ALL_PKGS="${ALL_PKGS} dovecot-mysql"
+        elif [ X"${BACKEND}" == X'OPENLDAP' ]; then
+            ALL_PKGS="${ALL_PKGS} dovecot-postgresql"
+        fi
+
+        DISABLED_SERVICES="${DISABLED_SERVICES} saslauthd"
     fi
 
-    ENABLED_SERVICES="${ENABLED_SERVICES} ${DOVECOT_RC_SCRIPT_NAME}"
-
     # Amavisd-new & ClamAV & Altermime.
     ENABLED_SERVICES="${ENABLED_SERVICES} ${AMAVISD_RC_SCRIPT_NAME} ${CLAMAV_CLAMD_RC_SCRIPT_NAME}"
     if [ X"${DISTRO}" == X"RHEL" ]; then
         gentoo_add_use_flags 'mail-filter/spamassassin' 'berkdb ipv6 ssl doc ldap mysql postgres sqlite'
         gentoo_add_use_flags 'app-antivirus/clamav' 'bzip2 iconv ipv6'
         gentoo_add_use_flags 'net-analyzer/net-snmp' 'bzip2 ipv6 ssl tcpd zlib perl'
+
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        ALL_PKGS="${ALL_PKGS} amavisd-new p5-ldap p5-Mail-SpamAssassin clamav"
+        PKG_SCRIPTS="${PKG_SCRIPTS} ${CLAMAV_CLAMD_RC_SCRIPT_NAME} ${CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME} ${AMAVISD_RC_SCRIPT_NAME}"
     fi
 
     # SPF verification.
 
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
         ALL_PKGS="${ALL_PKGS} Mail-SPF"
+
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        ALL_PKGS="${ALL_PKGS} p5-Mail-SPF"
     fi
 
     # phpPgAdmin
             ALL_PKGS="${ALL_PKGS} phppgadmin"
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
             ALL_PKGS="${ALL_PKGS} phppgadmin"
+        elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+            ALL_PKGS="${ALL_PKGS} phpPgAdmin"
+        fi
+    fi
+
+    # Roundcube
+    if [ X"${USE_RCM}" == X"YES" ]; then
+        if [ X"${DISTRO}" == X'OPENBSD' ]; then
+            ALL_PKGS="${ALL_PKGS} roundcubemail"
+        fi
+    fi
+
+    # phpMyAdmin
+    if [ X"${USE_PHPMYADMIN}" == X"YES" ]; then
+        if [ X"${DISTRO}" == X'OPENBSD' ]; then
+            ALL_PKGS="${ALL_PKGS} phpMyAdmin"
+        fi
+    fi
+
+    # phpLDAPadmin
+    if [ X"${USE_PHPLDAPADMIN}" == X"YES" ]; then
+        if [ X"${DISTRO}" == X'OPENBSD' ]; then
+            ALL_PKGS="${ALL_PKGS} phpldapadmin"
         fi
     fi
 
     # Don't append 'iredapd' to ${ENABLED_SERVICES} since we don't have
     # RC script ready in early stage.
 
-    [ X"${DISTRO}" == X"RHEL" ] && ALL_PKGS="${ALL_PKGS} python-ldap${PKG_ARCH} python-psycopg2${PKG_ARCH}"
-    [ X"${DISTRO}" == X"SUSE" ] && ALL_PKGS="${ALL_PKGS} python-ldap"
-    [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ] && ALL_PKGS="${ALL_PKGS} python-ldap python-psycopg2 python-mysqldb"
-    [ X"${DISTRO}" == X'GENTOO' ] && ALL_PKGS="${ALL_PKGS} python-ldap"
+    if [ X"${DISTRO}" == X"RHEL" ]; then
+        ALL_PKGS="${ALL_PKGS} python-ldap${PKG_ARCH} python-psycopg2${PKG_ARCH}"
+    elif [ X"${DISTRO}" == X"SUSE" ]; then
+        ALL_PKGS="${ALL_PKGS} python-ldap"
+    elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
+        ALL_PKGS="${ALL_PKGS} python-ldap python-psycopg2 python-mysqldb"
+    elif [ X"${DISTRO}" == X'GENTOO' ]; then
+        ALL_PKGS="${ALL_PKGS} python-ldap"
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        ALL_PKGS="${ALL_PKGS} py-ldap py-psycopg2"
+        PKG_SCRIPTS="${PKG_SCRIPTS} iredapd"
+    fi
 
     # iRedAdmin.
     # Force install all dependence to help customers install iRedAdmin-Pro.
         gentoo_add_use_flags 'dev-python/jinja' 'examples i18n vim-syntax'
         # Don't use python-3
         gentoo_mask_package '<=dev-lang/python-3.0'
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        ALL_PKGS="${ALL_PKGS} py-jinja2 py-webpy py-mysql"
     fi
 
     #############
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
             ALL_PKGS="${ALL_PKGS} awstats"
             gentoo_add_use_flags 'www-misc/awstats' 'ipv6 geoip'
+        elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+            # No port available.
+            :
         fi
     fi
 
     #### Fail2ban ####
     if [ X"${USE_FAIL2BAN}" == X"YES" ]; then
-        ALL_PKGS="${ALL_PKGS} fail2ban"
-        ENABLED_SERVICES="${ENABLED_SERVICES} ${FAIL2BAN_RC_SCRIPT_NAME}"
+        if [ X"${DISTRO}" == X'OPENBSD' ]; then
+            # No port available.
+            :
+        else
+            ALL_PKGS="${ALL_PKGS} fail2ban"
+            ENABLED_SERVICES="${ENABLED_SERVICES} ${FAIL2BAN_RC_SCRIPT_NAME}"
 
-        if [ X"${DISTRO}" == X"RHEL" ]; then
-            DISABLED_SERVICES="${DISABLED_SERVICES} shorewall"
+            if [ X"${DISTRO}" == X"RHEL" ]; then
+                DISABLED_SERVICES="${DISABLED_SERVICES} shorewall"
+            fi
         fi
     fi
 
         ENABLED_SERVICES="${ENABLED_SERVICES} cron"
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
         ALL_PKGS="${ALL_PKGS} dos2unix logwatch"
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        ALL_PKGS="${ALL_PKGS} bzip2"
     fi
-    #### End Misc packages & services ####
 
     # Disable Ubuntu firewall rules, we have iptables init script and rule file.
     [ X"${DISTRO}" == X"UBUNTU" ] && export DISABLED_SERVICES="${DISABLED_SERVICES} ufw"
         fi
 
         # Install all packages.
+        if [ X"${DISTRO}" == X'OPENBSD' ]; then
+            ECHO_INFO "PKG_PATH: ${PKG_PATH}"
+            ECHO_INFO "Installing packages:${ALL_PKGS}"
+        fi
         eval ${install_pkg} ${ALL_PKGS}
 
         if [ X"${DISTRO}" == X"SUSE" -a X"${USE_IREDADMIN}" == X"YES" ]; then
         eval ${enable_service} ${ENABLED_SERVICES} >/dev/null
 
         # Disable services.
-        eval ${disable_service} ${DISABLED_SERVICES} >/dev/null
+        if [ X"${DISTRO}" == X'OPENBSD' ]; then
+            echo "pkg_scripts='${PKG_SCRIPTS}'" >> ${RC_CONF_LOCAL}
+            ln -sf /usr/local/bin/python2.7 /usr/local/bin/python
+            ln -sf /usr/local/bin/python2.7-2to3 /usr/local/bin/2to3
+            ln -sf /usr/local/bin/python2.7-config /usr/local/bin/python-config
+            ln -sf /usr/local/bin/pydoc2.7  /usr/local/bin/pydoc
+        else
+            eval ${disable_service} ${DISABLED_SERVICES} >/dev/null
+        fi
 
         if [ X"${DISTRO}" == X"SUSE" ]; then
             eval ${disable_service} SuSEfirewall2_setup SuSEfirewall2_init >/dev/null

iRedMail/functions/phpldapadmin.sh

 EOF
 
     # Make phpldapadmin can be accessed via HTTPS only.
-    perl -pi -e 's#(</VirtualHost>)#Alias /phpldapadmin "$ENV{PLA_HTTPD_ROOT_SYMBOL_LINK}/"\nAlias /ldap "$ENV{PLA_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
+    perl -pi -e 's#^(</VirtualHost>)#Alias /phpldapadmin "$ENV{PLA_HTTPD_ROOT_SYMBOL_LINK}/"\nAlias /ldap "$ENV{PLA_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
 
     cat >> ${TIP_FILE} <<EOF
 phpLDAPadmin:

iRedMail/functions/phpmyadmin.sh

 EOF
 
     # Make phpMyAdmin can be accessed via HTTPS only.
-    perl -pi -e 's#(</VirtualHost>)#Alias /phpmyadmin "$ENV{PHPMYADMIN_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
+    perl -pi -e 's#^(</VirtualHost>)#Alias /phpmyadmin "$ENV{PHPMYADMIN_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
 
     ECHO_DEBUG "Config phpMyAdmin: ${PHPMYADMIN_CONFIG_FILE}."
     cd ${PHPMYADMIN_HTTPD_ROOT} && cp config.sample.inc.php ${PHPMYADMIN_CONFIG_FILE}

iRedMail/functions/phppgadmin.sh

 EOF
 
     # Make phpPgAdmin can be accessed via HTTPS only.
-    perl -pi -e 's#(</VirtualHost>)#Alias /phppgadmin "$ENV{PHPPGADMIN_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
+    perl -pi -e 's#^(</VirtualHost>)#Alias /phppgadmin "$ENV{PHPPGADMIN_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
 
     ECHO_DEBUG "Config phpPgAdmin: ${PHPPGADMIN_CONFIG_FILE}."
     cd ${PHPPGADMIN_HTTPD_ROOT} && cp config.inc.php-dist ${PHPPGADMIN_CONFIG_FILE} &>/dev/null

iRedMail/functions/policy_server.sh

 policy_server_config()
 {
     if [ X"${USE_POLICYD}" == X'YES' ]; then
-        . ${FUNCTIONS_DIR}/policyd.sh
+        if [ X"${DISTRO}" == X'OPENBSD' ]; then
+            :
+        else
+            . ${FUNCTIONS_DIR}/policyd.sh
 
-        ECHO_INFO "Configure Policyd (postfix policy server, version 1.8)."
-        check_status_before_run policyd_user
-        check_status_before_run policyd_config
+            ECHO_INFO "Configure Policyd (postfix policy server, version 1.8)."
+            check_status_before_run policyd_user
+            check_status_before_run policyd_config
+        fi
     fi
 
     if [ X"${USE_CLUEBRINGER}" == X'YES' ]; then

iRedMail/functions/policyd.sh

     perl -pi -e 's#^(SENDER_THROTTLE_SASL=)(.*)#${1}1#' ${POLICYD_THROTTLE_CONF}
     perl -pi -e 's#^(SENDER_THROTTLE_HOST=)(.*)#${1}0#' ${POLICYD_THROTTLE_CONF}
     perl -pi -e 's#^(QUOTA_EXCEEDED_TEMP_REJECT=)(.*)#${1}0#' ${POLICYD_THROTTLE_CONF}
-    perl -pi -e 's#^(SENDERMSGSIZE=)(.*)#${1}$ENV{'MESSAGE_SIZE_LIMIT'}#' ${POLICYD_THROTTLE_CONF}
+    perl -pi -e 's#^(SENDERMSGSIZE=)(.*)#${1}$ENV{MESSAGE_SIZE_LIMIT}#' ${POLICYD_THROTTLE_CONF}
 
     # ---- RCPT ACL ----
     if [ X"${DISTRO}" == X"RHEL" ]; then

iRedMail/functions/postfix.sh

 {
     ECHO_INFO "Configure Postfix."
 
+    # OpenBSD: Replace sendmail with Postfix
+    if [ X"${DISTRO}" == X'OPENBSD' ]; then
+        echo 'sendmail_flags=NO' >> ${RC_CONF_LOCAL}
+        /usr/local/sbin/postfix-enable &>/dev/null
+        perl -pi -e 's/(.*sendmail -L sm-msp-queue.*)/#${1}/' ${CRON_SPOOL_DIR}/root 
+        perl -pi -e 's/^(inet_protocols.*)/#${1}/' ${POSTFIX_FILE_MAIN_CF}
+    fi
+
     backup_file ${POSTFIX_FILE_MAIN_CF} ${POSTFIX_FILE_MASTER_CF}
 
     ECHO_DEBUG "Enable chroot."
     if [ X"${USE_CLUEBRINGER}" == X"YES" ]; then
         postconf -e smtpd_recipient_restrictions="reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unlisted_recipient, ${POSTCONF_IREDAPD} ${POSTCONF_CLUEBRINGER} permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname"
         postconf -e smtpd_end_of_data_restrictions="check_policy_service inet:${CLUEBRINGER_BINDHOST}:${CLUEBRINGER_BINDPORT}"
+    elif [ X"${USE_POLICYD}" == X"YES" ]; then
+        postconf -e smtpd_recipient_restrictions="reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unlisted_recipient, ${POSTCONF_IREDAPD}, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, check_policy_service inet:${POLICYD_BINDHOST}:${POLICYD_BINDPORT}"
     else
-        postconf -e smtpd_recipient_restrictions="reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unlisted_recipient, ${POSTCONF_IREDAPD}, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, check_policy_service inet:${POLICYD_BINDHOST}:${POLICYD_BINDPORT}"
+        postconf -e smtpd_recipient_restrictions="reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unlisted_recipient, ${POSTCONF_IREDAPD}, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname"
     fi
 
     echo 'export status_postfix_config_sasl="DONE"' >> ${STATUS_FILE}

iRedMail/functions/roundcubemail.sh

     ECHO_INFO "Configure Roundcube webmail."
 
     # FreeBSD: install via ports tree.
-    if [ X"${DISTRO}" != X"FREEBSD" ]; then
+    if [ X"${DISTRO}" != X"FREEBSD" -a X"${DISTRO}" != X'OPENBSD' ]; then
         cd ${MISC_DIR}
 
         # Extract source tarball.
 EOF
 
     # Make Roundcube can be accessed via HTTPS.
-    perl -pi -e 's#(</VirtualHost>)#Alias /mail "$ENV{RCM_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
-    perl -pi -e 's#(</VirtualHost>)#Alias /webmail "$ENV{RCM_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
-    perl -pi -e 's#(</VirtualHost>)#Alias /roundcube "$ENV{RCM_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
+    perl -pi -e 's#^(</VirtualHost>)#Alias /mail "$ENV{RCM_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
+    perl -pi -e 's#^(</VirtualHost>)#Alias /webmail "$ENV{RCM_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
+    perl -pi -e 's#^(</VirtualHost>)#Alias /roundcube "$ENV{RCM_HTTPD_ROOT_SYMBOL_LINK}/"\n${1}#' ${HTTPD_SSL_CONF}
 
     # Redirect home page to webmail by default
     backup_file ${HTTPD_DOCUMENTROOT}/index.html

iRedMail/functions/system_accounts.sh

 
 # Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
-# -------------------------------------------------------
-# ---------------- User/Group: vmail --------------------
-# -------------------------------------------------------
+# Add required system accounts
+
 add_user_vmail()
 {
     ECHO_DEBUG "Create HOME folder for vmail user."
     # It will create a group with the same name as vmail user name.
     if [ X"${DISTRO}" == X"FREEBSD" ]; then
         pw useradd -n ${VMAIL_USER_NAME} -s ${SHELL_NOLOGIN} -d ${VMAIL_USER_HOME_DIR} -m 2>/dev/null
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        groupadd ${VMAIL_GROUP_NAME}
+        useradd -d ${VMAIL_USER_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${VMAIL_GROUP_NAME} ${VMAIL_USER_NAME}
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         # Note: package 'postfix-mysql' will create vmail:vmail, with uid/gid=303.
         groupadd ${VMAIL_GROUP_NAME} 2>/dev/null
     # Low privilege user used to run iRedAdmin.
     if [ X"${KERNEL_NAME}" == X"FreeBSD" ]; then
         pw useradd -m -d ${IREDADMIN_HOME_DIR} -s ${SHELL_NOLOGIN} -n ${IREDADMIN_HTTPD_USER}
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        groupadd ${IREDADMIN_HTTPD_GROUP} 2>/dev/null
+        useradd -m -d ${IREDADMIN_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${IREDADMIN_HTTPD_GROUP} ${IREDADMIN_HTTPD_USER} 2>/dev/null
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         groupadd ${IREDADMIN_HTTPD_GROUP}
         useradd -m -d ${IREDADMIN_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${IREDADMIN_HTTPD_GROUP} ${IREDADMIN_HTTPD_USER} 2>/dev/null
     # Low privilege user used to run iRedAPD daemon.
     if [ X"${DISTRO}" == X'FREEBSD' ]; then
         pw useradd -m -d ${IREDAPD_HOME_DIR} -s ${SHELL_NOLOGIN} -c "iRedAPD daemon user" -n ${IREDAPD_DAEMON_USER}
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        groupadd ${IREDAPD_DAEMON_GROUP}
+        useradd -m -d ${IREDAPD_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${IREDAPD_DAEMON_GROUP} ${IREDAPD_DAEMON_USER} 2>/dev/null
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         groupadd ${IREDAPD_DAEMON_GROUP}
         useradd -m -d ${IREDAPD_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${IREDAPD_DAEMON_GROUP} ${IREDAPD_DAEMON_USER} 2>/dev/null

iRedMail/pkgs/MD5.openbsd

+0fc9b5a60e1afbb98cb5b5c948089262  misc/iRedAdmin-0.1.7.tar.bz2
+f3a11bca0e052c37d09931134edb6e63  misc/iRedAPD-1.3.7.tar.bz2

iRedMail/pkgs/get_all.sh

     PKGMISC='MD5.ubuntu.lucid'
 elif [ X"${DISTRO}" == X"SUSE" ]; then
     PKGMISC='MD5.misc MD5.opensuse'
+elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+    PKGMISC='MD5.openbsd'
 else
     PKGMISC='MD5.misc'
 fi
         md5file="/tmp/check_md5_tmp.${RANDOM}$RANDOM}"
         echo -e "${MD5LIST}" > ${md5file}
         cat ${PKGMISC} >> ${md5file}
-        md5sum -c ${md5file} |grep 'FAILED'
-        RETVAL="$?"
+        if [ X"${DISTRO}" == X'OPENBSD' ]; then
+            md5 -c ${md5file} |grep 'FAILED'
+            RETVAL="$?"
+        else
+            md5sum -c ${md5file} |grep 'FAILED'
+            RETVAL="$?"
+        fi
         rm -f ${md5file} 2>/dev/null
 
         if [ X"${RETVAL}" == X"0" ]; then
 fi
 
 check_status_before_run fetch_misc && \
-check_md5 && \
+check_status_before_run check_md5 && \
 check_pkg ${BIN_DIALOG} ${PKG_DIALOG} && \
 echo_end_msg && \
 echo 'export status_get_all="DONE"' >> ${STATUS_FILE}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.