Merge pull request #5134 from p-wassi/emailrelay
mail/emailrelay: rework init script and introduce config
This commit is contained in:
commit
a9f30ca5a6
|
@ -9,16 +9,19 @@ include $(TOPDIR)/rules.mk
|
|||
|
||||
PKG_NAME:=emailrelay
|
||||
PKG_VERSION:=1.9
|
||||
PKG_RELEASE:=4
|
||||
PKG_RELEASE:=5
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-src.tar.gz
|
||||
PKG_SOURCE_URL:=@SF/emailrelay/$(PKG_VERSION)
|
||||
PKG_HASH:=869a3e2d053237d7f63784acc25e748af2dbf2d9b9c5c48e4a5269d4e4b5bda0
|
||||
PKG_MAINTAINER:=Federico Di Marco <fededim@gmail.com>
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_CONFIG_DEPENDS:=CONFIG_EMAILRELAY_SUPPORT_VERBOSE_DBG CONFIG_EMAILRELAY_SSL
|
||||
PKG_CONFIG_DEPENDS:=CONFIG_EMAILRELAY_SUPPORT_VERBOSE_DBG CONFIG_EMAILRELAY_SSL
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
#include $(INCLUDE_DIR)/uclibc++.mk # $(CXX_DEPENDS)
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
@ -26,10 +29,9 @@ include $(INCLUDE_DIR)/package.mk
|
|||
define Package/emailrelay
|
||||
SECTION:=mail
|
||||
CATEGORY:=Mail
|
||||
DEPENDS:=+EMAILRELAY_SSL:libopenssl +libstdcpp
|
||||
DEPENDS:=+EMAILRELAY_SSL:libopenssl +libstdcpp
|
||||
TITLE:=A simple SMTP proxy and MTA
|
||||
URL:=http://emailrelay.sourceforge.net/
|
||||
MAINTAINER:=Federico Di Marco <fededim@gmail.com>
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
|
@ -42,7 +44,7 @@ config EMAILRELAY_SUPPORT_VERBOSE_DBG
|
|||
help
|
||||
Enables support for extended logging (must also be explicitely enabled by using command line switch --debug when starting emailrelay)
|
||||
|
||||
config EMAILRELAY_SSL
|
||||
config EMAILRELAY_SSL
|
||||
bool "Enable support for OpenSSL"
|
||||
depends on PACKAGE_emailrelay
|
||||
default y
|
||||
|
@ -54,18 +56,19 @@ endef
|
|||
|
||||
|
||||
define Package/emailrelay/description
|
||||
Emailrelay is a simple SMTP proxy and store-and-forward message transfer agent (MTA).
|
||||
|
||||
When running as a proxy all e-mail messages can be passed through
|
||||
a user-defined program, such as a spam filter, which can drop,
|
||||
re-address or edit messages as they pass through. When running
|
||||
as a store-and-forward MTA incoming messages are stored in a
|
||||
local spool directory, and then forwarded to the next SMTP
|
||||
server on request.
|
||||
Emailrelay is a simple SMTP proxy and store-and-forward message transfer agent (MTA).
|
||||
|
||||
When running as a proxy all e-mail messages can be passed through
|
||||
a user-defined program, such as a spam filter, which can drop,
|
||||
re-address or edit messages as they pass through. When running
|
||||
as a store-and-forward MTA incoming messages are stored in a
|
||||
local spool directory, and then forwarded to the next SMTP
|
||||
server on request.
|
||||
endef
|
||||
|
||||
|
||||
define Package/emailrelay/conffiles
|
||||
/etc/config/emailrelay
|
||||
/etc/emailrelay.auth
|
||||
endef
|
||||
|
||||
|
@ -75,7 +78,7 @@ CONFIGURE_ARGS += \
|
|||
--enable-testing=no
|
||||
|
||||
CONFIGURE_VARS += \
|
||||
CXXFLAGS="$$$$CXXFLAGS -fno-rtti"
|
||||
CXXFLAGS="$$$$CXXFLAGS -fno-rtti"
|
||||
|
||||
|
||||
ifeq ($(CONFIG_EMAILRELAY_SSL),y)
|
||||
|
@ -94,7 +97,7 @@ endif
|
|||
|
||||
ifeq ($(CONFIG_OPENSSL_WITH_SSL3),y)
|
||||
CONFIGURE_VARS += \
|
||||
CXXFLAGS="$$$$CXXFLAGS -DSSL3_SUPPORT"
|
||||
CXXFLAGS="$$$$CXXFLAGS -DSSL3_SUPPORT"
|
||||
endif
|
||||
|
||||
define Package/emailrelay/install
|
||||
|
@ -104,10 +107,10 @@ define Package/emailrelay/install
|
|||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/main/emailrelay-passwd $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/main/emailrelay-poke $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/main/emailrelay-submit $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/tmp/spool
|
||||
$(INSTALL_DIR) $(1)/tmp/spool/emailrelay
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_DATA) files/$(PKG_NAME).auth $(1)/etc/
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) files/$(PKG_NAME).config $(1)/etc/config/$(PKG_NAME)
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) files/$(PKG_NAME).init $(1)/etc/init.d/$(PKG_NAME)
|
||||
endef
|
||||
|
|
|
@ -13,4 +13,4 @@
|
|||
#
|
||||
#NONE server 192.168.1.* keyword
|
||||
#LOGIN client smtpuser@smtpserver smtppassword
|
||||
#LOGIN server user1 secret
|
||||
#LOGIN server user1 secret
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
config emailrelay 'server'
|
||||
option enabled '0'
|
||||
option mode 'server'
|
||||
option port '25'
|
||||
option remote_clients '0'
|
||||
# option server_tls '/etc/path/to/certificate'
|
||||
# option server_auth '/etc/emailrelay.auth'
|
||||
# option extra_cmdline ''
|
||||
|
||||
config emailrelay 'proxy'
|
||||
option enabled '0'
|
||||
option mode 'proxy'
|
||||
option smarthost '192.0.2.1:25'
|
||||
option port '25'
|
||||
option remote_clients '0'
|
||||
# option server_tls '/etc/path/to/certificate'
|
||||
# option server_auth '/etc/emailrelay.auth'
|
||||
# option client_tls '1'
|
||||
# option client_auth '/etc/emailrelay.auth'
|
||||
# option extra_cmdline ''
|
||||
|
||||
config emailrelay 'cmdline'
|
||||
option enabled '0'
|
||||
option mode 'cmdline'
|
||||
# specify all arguments that should be passed to emailrelay here
|
||||
# see http://emailrelay.sourceforge.net/reference.html for command line reference
|
||||
option extra_cmdline '--some-other --cmdline-options'
|
||||
|
|
@ -1,15 +1,66 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
#see http://emailrelay.sourceforge.net/reference.html for command line reference
|
||||
|
||||
START=90
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/bin/emailrelay
|
||||
NAME=emailrelay
|
||||
|
||||
start() {
|
||||
logger -t 'emailrelay' "Starting emailrelay service."
|
||||
service_start /usr/bin/emailrelay --as-server --poll 60 --forward-to smtpserver:smtpport --spool-dir /tmp --client-tls --client-auth /etc/emailrelay.auth --server-auth /etc/emailrelay.auth --log
|
||||
|
||||
emailrelay_instance()
|
||||
{
|
||||
local enabled mode port remote_clients server_tls server_auth extra_cmdline smarthost client_tls client_auth
|
||||
|
||||
config_get_bool enabled "$1" enabled
|
||||
config_get mode "$1" mode
|
||||
config_get port "$1" port
|
||||
config_get_bool remote_clients "$1" remote_clients
|
||||
config_get server_tls "$1" server_tls
|
||||
config_get server_auth "$1" server_auth
|
||||
config_get extra_cmdline "$1" extra_cmdline
|
||||
config_get smarthost "$1" smarthost
|
||||
config_get_bool client_tls "$1" client_tls
|
||||
config_get client_auth "$1" client_auth
|
||||
|
||||
|
||||
[ "$enabled" = 0 ] && return 1
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG" --no-daemon
|
||||
|
||||
case "$mode" in
|
||||
"server"|\
|
||||
"proxy")
|
||||
procd_append_param command "--as-${mode}"
|
||||
[ -n "$smarthost" ] && procd_append_param command "$smarthost"
|
||||
[ -n "$port" ] && procd_append_param command --port "$port"
|
||||
[ "$remote_clients" = 1 ] && procd_append_param command --remote-clients
|
||||
[ -n "$server_tls" ] && procd_append_param command --server-tls "$server_tls"
|
||||
[ -n "$server_auth" ] && procd_append_param command --server-auth "$server_auth"
|
||||
[ "$client_tls" = 1 ] && procd_append_param command --client-tls
|
||||
[ -n "$client_auth" ] && procd_append_param command --client-auth "$client_auth"
|
||||
;;
|
||||
"cmdline")
|
||||
# empty by intention (just append extra_cmdline)
|
||||
;;
|
||||
*)
|
||||
echo "no mode specified"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
[ -n "$extra_cmdline" ] && procd_append_param command $extra_cmdline
|
||||
|
||||
procd_set_param respawn
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop() {
|
||||
logger -t 'emailrelay' "Stopping emailrelay service."
|
||||
service_stop /usr/bin/emailrelay
|
||||
|
||||
start_service()
|
||||
{
|
||||
[ ! -d /var/spool/emailrelay ] && mkdir -p /var/spool/emailrelay
|
||||
|
||||
config_load "${NAME}"
|
||||
config_foreach emailrelay_instance emailrelay
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue