Commits

Zhang Huangbin committed 6d3f06d

Improve Gentoo support:
* Fix incorrect file permission: /etc/ssl/private
* Add OPTS in /etc/conf.d/slapd to start OpenLDAP correctly
* Create MySQL database 'policyd' and grant privileges
* Generate empty file /etc/postfix/aliases if /etc/aliases doesn't exist

Comments (0)

Files changed (5)

iRedMail/conf/apache_php

     export HTTPD_CONF_ROOT="/etc/apache2"
     export HTTPD_CONF="${HTTPD_CONF_ROOT}/httpd.conf"
     export HTTPD_CONF_DIR="${HTTPD_CONF_ROOT}/modules.d"
-    export HTTPD_SSL_CONF="${HTTPD_CONF_DIR}/00_default_ssl_vhost.conf"
+    export HTTPD_SSL_CONF="${HTTPD_CONF_DIR}/vhosts.d/00_default_ssl_vhost.conf"
     export HTTPD_WSGI_CONF="${HTTPD_CONF_DIR}/wsgi.conf"
 
     # Web data.
     export HTTPD_SERVERROOT='/var/www'
-    export HTTPD_DOCUMENTROOT="${HTTPD_SERVERROOT}/html"
+    export HTTPD_DOCUMENTROOT="${HTTPD_SERVERROOT}/localhost/htdocs"
 
     # Daemon user.
     export HTTPD_USER='apache'

iRedMail/conf/core

 
     # Create necessary directories.
     mkdir -p ${SSL_KEY_DIR} ${SSL_CERT_DIR} 2>/dev/null
-    [ X"${DISTRO}" == X"GENTOO" ] && chmod +rw ${SSL_KEY_DIR}
+    [ X"${DISTRO}" == X'GENTOO' ] && chmod o+rx ${SSL_KEY_DIR}
 
     openssl req \
         -x509 -nodes -days 3650 -newkey rsa:${SSL_KEY_SIZE} \

iRedMail/functions/openldap.sh

             # Run slapd with -h "... ldaps:/// ...".
             perl -pi -e 's/#(SLAPD_LDAPS=).*/${1}yes/' ${OPENLDAP_SYSCONFIG_CONF}
         fi
+
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         # Fix strict permission.
         chmod 0755 ${SSL_KEY_DIR}
 
         # Set config backend.
         perl -pi -e 's#^(OPENLDAP_CONFIG_BACKEND=).*#${1}"files"#' ${OPENLDAP_SYSCONFIG_CONF}
+
+    elif [ X"${DISTRO}" == X'GENTOO' ]; then
+        # Comment out default option which uses slapd.d.
+        perl -pi -e 's/^(OPTS=.*)/#${1}/' ${OPENLDAP_SYSCONFIG_CONF}/${LDAP_RC_SCRIPT_NAME}
+
+        # Enable slapd.conf instead of slapd.d.
+        cat >> ${ETC_SYSCONFIG_DIR}/slapd <<EOF
+OPTS="-f ${OPENLDAP_SLAPD_CONF} -h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'"
+EOF
     fi
 
     ###################

iRedMail/functions/policyd.sh

 EOF
         fi
 
+    elif [ X"${DISTRO}" == X'GENTOO' ]; then
+        orig_policyd_sql_file="$(eval ${LIST_FILES_IN_PKG} ${PKG_POLICYD} | grep '/DATABASE.mysql.bz2$')"
+
+        # orig_policyd_sql_file contains SQL command to create database.
+        bunzip2 -c ${orig_policyd_sql_file} > ${tmp_sql}
+
+        cat >> ${tmp_sql} <<EOF
+# Grant privileges.
+GRANT SELECT,INSERT,UPDATE,DELETE ON ${POLICYD_DB_NAME}.* TO "${POLICYD_DB_USER}"@localhost IDENTIFIED BY "${POLICYD_DB_PASSWD}";
+FLUSH PRIVILEGES;
+EOF
+
     elif [ X"${DISTRO}" == X"FREEBSD" ]; then
         # Template file will create database: policyd.
         cat > ${tmp_sql} <<EOF

iRedMail/functions/postfix.sh

     postconf -e allow_min_user='no'
 
     # Postfix aliases file.
-    [ ! -f ${POSTFIX_FILE_ALIASES} ] && cp -f /etc/aliases ${POSTFIX_FILE_ALIASES}
+    if  [ ! -f ${POSTFIX_FILE_ALIASES} ]; then
+        if [ -f /etc/aliases ]; then
+            cp -f /etc/aliases ${POSTFIX_FILE_ALIASES}
+        else
+            touch ${POSTFIX_FILE_ALIASES}
+        fi
+    fi
     [ ! -z ${MAIL_ALIAS_ROOT} ] && echo "root: ${MAIL_ALIAS_ROOT}" >> ${POSTFIX_FILE_ALIASES}
 
     postconf -e alias_maps="hash:${POSTFIX_FILE_ALIASES}"