Commits

Zhang Huangbin committed ade4f8e

Improve Gentoo support:
* Store mail log in /var/log/maillog by default
* New runscript for iredapd
* Log password change in Roundcube webmail

Comments (0)

Files changed (10)

iRedMail/conf/clamav

 
 # Freshclam.
 export FRESHCLAM_PID_FILE='/var/run/clamav/freshclam.pid'   # Used to override default setting.
-export FRESHCLAM_DATABASE_MIRROR='db.us.clamav.net'     # db.cn.clamav.net is broken.

iRedMail/conf/core

     cmd="$1"
     pkg="$2"
 
-    ECHO_INFO "Checking required command/package: ${cmd}/${pkg} ..."
+    ECHO_INFO -n "Checking required command/package: ${cmd}/${pkg} ..."
     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 -e '\t[NOT FOUND]'
         eval ${install_pkg} ${pkg}
         if [ X"$?" != X"0" ]; then
             ECHO_ERROR "Please install package ${pkg} first." && exit 255
         fi
+    else
+        echo -e '\t[FOUND]'
     fi
 
     unset HAS_CMD

iRedMail/conf/postfix

     export MAILLOG_WARN='/var/log/mail.warn'
 elif [ X"${DISTRO}" == X"GENTOO" ]; then
     # Gentoo
-    export MAILLOG='/var/log/messages'
+    export MAILLOG='/var/log/maillog'
     export MAILLOG_INFO=''
     export MAILLOG_ERROR=''
     export MAILLOG_WARN=''

iRedMail/functions/amavisd.sh

         [ X"${DISTRO_VERSION}" == X"6" ] && \
             usermod -G ${AMAVISD_SYS_GROUP} ${CLAMAV_USER} >/dev/null
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
-        usermod -G ${CLAMAV_GROUP} ${AMAVISD_SYS_USER} >/dev/null
+        usermod -G ${AMAVISD_SYS_GROUP} ${CLAMAV_USER} >/dev/null
     fi
 
     # Don't check amavisd-milter status.

iRedMail/functions/clamav.sh

     perl -pi -e 's-^#(LocalSocket).*-${1} $ENV{'CLAMD_LOCAL_SOCKET'}-' ${CLAMD_CONF}
 
     ECHO_DEBUG "Configure freshclam: ${FRESHCLAM_CONF}."
-    perl -pi -e 's#^(DatabaseMirror).*#${1} $ENV{'FRESHCLAM_DATABASE_MIRROR'}#' ${CLAMD_CONF}
     perl -pi -e 's-^#(PidFile)(.*)-${1} $ENV{FRESHCLAM_PID_FILE}-' ${FRESHCLAM_CONF}
     perl -pi -e 's#^(UpdateLogFile).*#${1} $ENV{'FRESHCLAM_LOGFILE'}#' ${CLAMD_CONF}
 
+    # Official database only
+    perl -pi -e 's-^#(OfficialDatabaseOnly).*#${1} yes#' ${CLAMD_CONF}
+
     if [ X"${DISTRO}" == X"RHEL" ]; then
         ECHO_DEBUG "Copy freshclam init startup script and enable it."
         cp -f ${FRESHCLAM_INIT_FILE_SAMPLE} /etc/rc.d/init.d/freshclam

iRedMail/functions/cleanup.sh

 
     # Update clamav before start clamav-clamd service.
     ECHO_INFO "Updating ClamAV database (freshclam), please wait ..."
-    freshclam &>/dev/null
+    freshclam
 
     echo 'export status_cleanup_amavisd_preconfig="DONE"' >> ${STATUS_FILE}
 }

iRedMail/functions/iredapd.sh

     ECHO_INFO "Configure iRedAPD (postfix policy daemon)."
 
     # Create a low privilege user as daemon user.
-    if [ X"${KERNEL_NAME}" == X"FreeBSD" ]; then
+    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"SUSE" ]; then
         groupadd ${IREDAPD_DAEMON_GROUP}
         cp ${IREDAPD_ROOT_DIR}/iredapd/rc_scripts/iredapd.debian ${DIR_RC_SCRIPTS}/iredapd
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         cp ${IREDAPD_ROOT_DIR}/iredapd/rc_scripts/iredapd.opensuse ${DIR_RC_SCRIPTS}/iredapd
+    elif [ X"${DISTRO}" == X"GENTOO" ]; then
+        cp ${SAMPLE_DIR}/gentoo.iredapd.runscript ${DIR_RC_SCRIPTS}/iredapd
+        chmod +x ${DIR_RC_SCRIPTS}/iredapd
     elif [ X"${DISTRO}" == X"FREEBSD" ]; then
         cp ${IREDAPD_ROOT_DIR}/iredapd/rc_scripts/iredapd.freebsd ${DIR_RC_SCRIPTS}/iredapd
     else

iRedMail/functions/postfix.sh

 #/(^Received:.*\[).*(\].*Authenticated sender:.*by REPLACED_BY_YOUR_HOSTNAME.*iRedMail.*)/ REPLACE ${1}REPLACED_BY_YOUR_IP_ADDRESS${2}
 EOF
 
+    if [ X"${DISTRO}" == X'GENTOO' ]; then
+        cat >> ${SYSLOG_CONF} <<EOF
+# Maillog
+filter f_maillog {facility(mail); };
+destination maillog {file("${MAILLOG}"); };
+log {source(src); filter(f_maillog); destination(maillog); };
+EOF
+    fi
+
     cat >> ${TIP_FILE} <<EOF
 Postfix (basic):
     * Configuration files:

iRedMail/functions/roundcubemail.sh

 
     # Require the new password to contain a letter and punctuation character
     perl -pi -e 's#(.*password_require_nonalpha.*=).*#${1} true;#' config.inc.php
+    perl -pi -e 's#(.*password_log.*=).*#${1} true;#' config.inc.php
 
     if [ X"${BACKEND}" == X"MYSQL" -o X"${BACKEND}" == X"PGSQL" ]; then
         perl -pi -e 's#(.*password_driver.*=).*#${1} "sql";#' config.inc.php

iRedMail/samples/gentoo.iredapd.runscript

+#!/sbin/runscript
+
+prog='/opt/iredapd/src/iredapd.py'
+progname="iRedAPD"
+
+CONFIG='/opt/iredapd/etc/iredapd.ini'
+PIDFILE='/var/run/iredapd.pid'
+
+depend() {
+	before mta
+    after mysql slapd
+}
+
+start() {
+    ebegin "Starting ${SVCNAME}"
+    start-stop-daemon --start \
+        --exec python ${prog} ${CONFIG}
+
+    eend $?
+}
+
+stop() {
+    ebegin "Stopping ${SVCNAME}"
+    start-stop-daemon --stop --pidfile ${PIDFILE}
+    rm -f ${PIDFILE}
+    eend $?
+}
+
+restart() {
+    ebegin "Restarting ${SVCNAME}"
+    svc_stop
+    sleep 3
+    svc_start
+    eend $?
+}
+