Commits

Zhang Huangbin committed 936623f

Improve FreeBSD 10 support:
* Create logrotate config directory on FreeBSD.
* Use 'pkg' instead.

Comments (0)

Files changed (4)

iRedMail/conf/cluebringer

 
 # Default syslog facility is 'LOG_MAIL|LOG_INFO'
 export CLUEBRINGER_SYSLOG_FACILITY='LOG_MAIL|LOG_INFO'
-export CLUEBRINGER_LOGROTATE_FILE='/etc/logrotate.d/policyd'
+export CLUEBRINGER_LOGROTATE_FILE="${LOGROTATE_DIR}/policyd"
 export CLUEBRINGER_LOG_FILE='/var/log/cbpolicyd.log'
 
 if [ X"${DISTRO}" == X"RHEL" ]; then

iRedMail/conf/global

     # Package management.
     export install_pkg='install_pkg_freebsd'
     export remove_pkg='remove_pkg_freebsd'
-    export LIST_ALL_PKGS="pkg_info | awk '{print $1}'"
-    export LIST_FILES_IN_PKG='pkg_info -L'
+    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_WRKDIRPREFIX='/usr/ports'
     # Directory used to store SSL/TLS key/cert file.
     export SSL_FILE_DIR="/etc/ssl"
 
+    # Logrotate directory.
+    export LOGROTATE_DIR="/usr/local/etc/logrotate.d"
+
 elif [ X"${DISTRO}" == X'OPENBSD' ]; then
     export ENABLE_BACKEND_PGSQL='YES'
     export ENABLE_BACKEND_LDAPD='YES'

iRedMail/functions/awstats.sh

     cp -f ${AWSTATS_CONF_MAIL} ${AWSTATS_CONF_DIR}/awstats.conf
 
     if [ X"${DISTRO}" == X"FREEBSD" ]; then
-        export maillogconvert_pl="$( eval ${LIST_FILES_IN_PKG} "/var/db/pkg/awstats-*" | grep 'maillogconvert.pl')"
+        if [ X"${DISTRO_VERSION}" == X'9' ]; then
+            export maillogconvert_pl="$( eval ${LIST_FILES_IN_PKG} "/var/db/pkg/awstats-*" | grep 'maillogconvert.pl')"
+        else
+            export maillogconvert_pl="$( eval ${LIST_FILES_IN_PKG} awstats | grep 'maillogconvert.pl')"
+        fi
     else
         export maillogconvert_pl="$( eval ${LIST_FILES_IN_PKG} awstats | grep 'maillogconvert.pl')"
     fi

iRedMail/functions/packages_freebsd.sh

     ln -sf /usr/local/bin/2to3-2.7 /usr/local/bin/2to3
     ln -sf /usr/local/bin/python2.7-config /usr/local/bin/python-config
 
+    # Create logrotate.d
+    mkdir -p ${LOGROTATE_DIR} 2>/dev/null
+
     # Log and print used time
     all_used_time="$(($(date +%s)-start_time))"
     ECHO_INFO "Total time of ports compiling: ${all_used_time} seconds, ~$((all_used_time/60)) minute(s)"