define Package/xmail
SECTION:=mail
CATEGORY:=Mail
- DEPENDS:=+uclibcxx +libopenssl
+ DEPENDS:=+uclibcxx +libopenssl +libpthread
TITLE:=advanced, fast and reliable ESMTP/POP3 mail server
URL:=http://www.xmailserver.org/
endef
multiple domains, virtual users and spam protection.
endef
-define Build/Configure
- $(CP) ./files/SysMachine.h $(PKG_BUILD_DIR)/
-endef
-
define Build/Compile
CFLAGS="$(TARGET_CFLAGS)" \
$(MAKE) -C $(PKG_BUILD_DIR) -f Makefile.lnx \
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(STAGING_DIR)/usr/include/uClibc++ -fno-builtin -fno-rtti -nostdinc++" \
LDFLAGS="$(TARGET_LDFLAGS) -nodefaultlibs -lcrypto -lssl -luClibc++ -ldl -lm -lpthread" \
all
+ tar -cjf $(PKG_BUILD_DIR)/MailRoot.tar.bz2 -C $(PKG_BUILD_DIR)/MailRoot --exclude bin .
endef
define Package/xmail/install
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/* $(1)/usr/bin/
- $(INSTALL_DIR) $(1)/var/MailRoot/
- $(CP) $(PKG_BUILD_DIR)/MailRoot $(1)/var/
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/MailRoot.tar.bz2 $(1)/etc/
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/xmail.config $(1)/etc/config/xmail
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_BIN) ./files/xmail.init $(1)/etc/init.d/xmail
endef
$(eval $(call BuildPackage,xmail))
+++ /dev/null
-#ifndef _MACHDEFS_H
-#define _MACHDEFS_H
-
-
-#undef MACH_BIG_ENDIAN_WORDS
-
-#undef MACH_BIG_ENDIAN_BITFIELD
-
-typedef signed char MachInt8;
-typedef unsigned char MachUInt8;
-#define MACH_TYPE_8BIT char
-
-typedef signed short MachInt16;
-typedef unsigned short MachUInt16;
-#define MACH_TYPE_16BIT short
-
-typedef signed int MachInt32;
-typedef unsigned int MachUInt32;
-#define MACH_TYPE_32BIT int
-
-
-
-#endif
-
--- /dev/null
+# Configuration parameters for xmail
+#
+# To see what xmail command line parameters each parameter corresponds to,
+# please see /etc/init.d/xmail
+#
+# The xmail configuration files are contained in /etc/MailRoot.tar.gz, and need
+# to be installed in the MAIL_ROOT directory, set by default to
+# /var/MailRoot below by:
+# MAIL_ROOT=`grep "option.*mail_root.*'$" /etc/config/xmail | sed -e "s/'$//" -e "s/.*'//"`
+# mkdir -p $MAIL_ROOT; cd $MAIL_ROOT; tar -xjf /etc/MailRoot.tar.bz2
+# NOTE: On OpenWRT /var is a temporary filesystem, so change mail_root below,
+# but it is probably not a good idea to install on a device's internal
+# flash due to the amount of writing of the flash that will ensue.
+#
+# To see what settings are appropriate, please refer to:
+# http://www.xmailserver.org/Readme.html
+# which also documents the configuration files in mail_root
+# ( please note that the values commented out are not real values )
+#
+
+config xmail
+ option mail_root '/var/MailRoot'
+# option debug 1
+# option log_rotate '3600'
+# option split_level 'param-split_level'
+# option rx_buffer 'param-rx_buffer'
+# option tx_buffer 'param-tx_buffer'
+# option maildir_delivery 1
+# option mailbox_delivery 1
+# option dns_cache_dirs 'param-dns_cache_dirs'
+# option ipv4_only 1
+# option ipv6_only 1
+# option ipv4_then_ipv6 1
+# option ipv6_then_ipv4 1
+
+config pop3
+# option disable 1
+# option ipv6 1
+# option server_port 'param-server_port'
+# option session_timeout 'param-session_timeout'
+# option log 1
+# option delay_timeout 'param-delay_timeout'
+# option bad_login_hang 1
+# option local_address 'param-local_address'
+ option num_threads 4
+
+config pop3s
+ option disable 1
+# option ipv6 1
+# option server_port 'param-server_port'
+# option local_address 'param-local_address'
+
+config smtp
+# option disable 1
+# option ipv6 1
+# option server_port 'param-server_port'
+# option session_timeout 'param-session_timeout'
+# option log 1
+# option local_address 'param-local_address'
+ option num_threads 4
+# option max_recipients 'param-max_recipients'
+# option expire_timeout 'param-expire_timeout'
+
+config smtps
+ option disable 1
+# option ipv6 1
+# option server_port 'param-server_port'
+# option local_address 'param-local_address'
+
+config smail
+ option num_threads 8
+# option next_try_timeout 'param-next_try_timeout'
+# option ratio 'param-ratio'
+# option retries 'param-retries'
+# option log 1
+# option filters_timeout 'param-filters_timeout'
+# option filter_log 1
+
+config psync
+ option disable 1
+# option interval 'param-interval'
+# option num_threads 'param-num_threads'
+# option timeout 'param-timeout'
+# option log 1
+
+config finger
+ option disable 1
+# option ipv6 1
+# option server_port 'param-server_port'
+# option log 1
+# option local_address 'param-local_address'
+
+config ctrl
+# option disable 1
+# option ipv6 1
+# option server_port 'param-server_port'
+# option session_timeout 'param-session_timeout'
+# option log 1
+# option local_address 'param-local_address'
+# option num_threads 'param-num_threads'
+
+config ctrls
+ option disable 1
+# option ipv6 1
+# option server_port 'param-server_port'
+# option session_timeout 'param-session_timeout'
+
+config lmail
+ option num_threads 4
+# option sleep_timeout 'param-sleep_timeout'
+# option log 1
--- /dev/null
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008 OpenWrt.org
+
+START=90
+STOP=10
+
+MAIL_ROOT=
+DAEMON=/usr/bin/XMail
+NAME=XMail
+
+append_bool() {
+ local section="$1"
+ local option="$2"
+ local value="$3"
+ local _loctmp
+ config_get_bool _loctmp "$section" "$option"
+ [ "$_loctmp" -le 0 ] && return 0
+ append args "$value"
+}
+
+append_parm() {
+ local section="$1"
+ local option="$2"
+ local switch="$3"
+ local _loctmp
+ config_get _loctmp "$section" "$option"
+ [ -z "$_loctmp" ] && return 0
+ append args "$switch $_loctmp"
+}
+
+xmail() {
+ local cfg="$1"
+
+ append_parm "$cfg" mail_root "-Ms"
+ append_bool "$cfg" debug "-Md"
+ append_parm "$cfg" log_rotate "-Mr"
+ append_parm "$cfg" split_level "-Mx"
+ append_parm "$cfg" rx_buffer "-MR"
+ append_parm "$cfg" tx_buffer "-MS"
+ append_bool "$cfg" maildir_delivery "-MM"
+ append_bool "$cfg" mailbox_delivery "-Mm"
+ append_parm "$cfg" dns_cache_dirs "-MD"
+ append_bool "$cfg" ipv4_only "-M4"
+ append_bool "$cfg" ipv6_only "-M6"
+ append_bool "$cfg" ipv4_then_ipv6 "-M5"
+ append_bool "$cfg" ipv6_then_ipv4 "-M7"
+
+ config_get mail_root $cfg mail_root
+ [ -n "$mail_root" ] || return 0
+ MAIL_ROOT=$mail_root
+}
+
+pop3() {
+ local cfg="$1"
+
+ append_bool "$cfg" disable "-P-"
+ append_bool "$cfg" ipv6 "-P6"
+ append_parm "$cfg" server_port "-Pp"
+ append_parm "$cfg" session_timeout "-Pt"
+ append_bool "$cfg" log "-Pl"
+ append_parm "$cfg" delay_timeout "-Pw"
+ append_bool "$cfg" bad_login_hang "-Ph"
+ append_parm "$cfg" local_address "-PI"
+ append_parm "$cfg" num_threads "-PX"
+}
+
+pop3s() {
+ local cfg="$1"
+
+ append_bool "$cfg" disable "-B-"
+ append_bool "$cfg" ipv6 "-B6"
+ append_parm "$cfg" server_port "-Bp"
+ append_parm "$cfg" local_address "-BI"
+}
+
+smtp() {
+ local cfg="$1"
+
+ append_bool "$cfg" disable "-S-"
+ append_bool "$cfg" ipv6 "-S6"
+ append_parm "$cfg" server_port "-Sp"
+ append_parm "$cfg" session_timeout "-St"
+ append_bool "$cfg" log "-Sl"
+ append_parm "$cfg" local_address "-SI"
+ append_parm "$cfg" num_threads "-SX"
+ append_parm "$cfg" max_recipients "-Sr"
+ append_parm "$cfg" expire_timeout "-Se"
+}
+
+smtps() {
+ local cfg="$1"
+
+ append_bool "$cfg" disable "-X-"
+ append_bool "$cfg" ipv6 "-X6"
+ append_parm "$cfg" server_port "-Xp"
+ append_parm "$cfg" local_address "-XI"
+}
+
+smail() {
+ local cfg="$1"
+
+ append_parm "$cfg" num_threads "-Qn"
+ append_parm "$cfg" next_try_timeout "-Qt"
+ append_parm "$cfg" ratio "-Qi"
+ append_parm "$cfg" retries "-Qr"
+ append_bool "$cfg" log "-Ql"
+ append_parm "$cfg" filters_timeout "-QT"
+ append_bool "$cfg" filter_log "-Qg"
+}
+
+psync() {
+ local cfg="$1"
+
+ append_bool "$cfg" disable "-Y-"
+ append_parm "$cfg" interval "-Yi"
+ append_parm "$cfg" num_threads "-Yt"
+ append_parm "$cfg" timeout "-Yi"
+ append_bool "$cfg" log "-Yl"
+}
+
+finger() {
+ local cfg="$1"
+
+ append_bool "$cfg" disable "-F-"
+ append_bool "$cfg" ipv6 "-F6"
+ append_parm "$cfg" server_port "-Fp"
+ append_bool "$cfg" log "-Fl"
+ append_parm "$cfg" local_address "-FI"
+}
+
+ctrl() {
+ local cfg="$1"
+
+ append_bool "$cfg" disable "-C-"
+ append_bool "$cfg" ipv6 "-C6"
+ append_parm "$cfg" server_port "-Cp"
+ append_parm "$cfg" session_timeout "-Ct"
+ append_bool "$cfg" log "-Cl"
+ append_parm "$cfg" local_address "-CI"
+ append_parm "$cfg" num_threads "-CX"
+}
+
+ctrls() {
+ local cfg="$1"
+
+ append_bool "$cfg" disable "-W-"
+ append_bool "$cfg" ipv6 "-W6"
+ append_parm "$cfg" server_port "-Wp"
+ append_parm "$cfg" session_timeout "-Wt"
+}
+
+lmail() {
+ local cfg="$1"
+
+ append_parm "$cfg" num_threads "-Ln"
+ append_parm "$cfg" sleep_timeout "-Lt"
+ append_bool "$cfg" log "-Ll"
+}
+
+start() {
+ test -f $DAEMON || exit 0
+
+ set -e
+ ulimit -c 10000
+ ulimit -s 128
+
+ config_load xmail
+
+ args=""
+
+ config_foreach xmail xmail
+ config_foreach pop3 pop3
+ config_foreach pop3s pop3s
+ config_foreach smtp smtp
+ config_foreach smtps smtps
+ config_foreach smail smail
+ config_foreach psync psync
+ config_foreach finger finger
+ config_foreach ctrl ctrl
+ config_foreach ctrls ctrls
+ config_foreach lmail lmail
+
+ [ -z "$MAIL_ROOT" ] && exit 0
+ [ -d $MAIL_ROOT ] || exit 0
+
+ export MAIL_ROOT
+
+ rm -f /var/run/$NAME.pid
+
+ $DAEMON $args
+
+ MAX_WAIT=20
+ while [ ! -f /var/run/$NAME.pid -a $MAX_WAIT -gt 0 ]
+ do
+ sleep 1
+ MAX_WAIT=`expr $MAX_WAIT - 1`
+ done
+}
+
+stop() {
+ if [ -f /var/run/$NAME.pid ]
+ then
+ config_load xmail
+ config_foreach xmail xmail
+ [ -z "$MAIL_ROOT" ] || echo `date` > $MAIL_ROOT/.shutdown
+ kill -INT `cat /var/run/$NAME.pid`
+
+ MAX_WAIT=20
+ while [ -f $MAIL_ROOT/.shutdown -a $MAX_WAIT -gt 0 ]
+ do
+ sleep 1
+ MAX_WAIT=`expr $MAX_WAIT - 1`
+ done
+ fi
+}
+
+restart() {
+ stop
+ sleep 1
+ start
+}
--- /dev/null
+diff -urN xmail-1.25.orig/SysMachine.h xmail-1.25/SysMachine.h
+--- xmail-1.25.orig/SysMachine.h 1970-01-01 01:00:00.000000000 +0100
++++ xmail-1.25/SysMachine.h 2008-07-28 10:16:47.000000000 +0200
+@@ -0,0 +1,24 @@
++#ifndef _MACHDEFS_H
++#define _MACHDEFS_H
++
++
++#undef MACH_BIG_ENDIAN_WORDS
++
++#undef MACH_BIG_ENDIAN_BITFIELD
++
++typedef signed char MachInt8;
++typedef unsigned char MachUInt8;
++#define MACH_TYPE_8BIT char
++
++typedef signed short MachInt16;
++typedef unsigned short MachUInt16;
++#define MACH_TYPE_16BIT short
++
++typedef signed int MachInt32;
++typedef unsigned int MachUInt32;
++#define MACH_TYPE_32BIT int
++
++
++
++#endif
++
+++ /dev/null
---- a/xmail
-+++ b/xmail
-@@ -19,7 +19,7 @@
- test -f $DAEMON || exit 0
-
- set -e
--ulimit -c 20000
-+ulimit -c 10000
- ulimit -s 128
-
- start_xmail()