ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/mail/emailrelay/files/emailrelay.auth b/external/subpack/mail/emailrelay/files/emailrelay.auth
new file mode 100644
index 0000000..8bc9594
--- /dev/null
+++ b/external/subpack/mail/emailrelay/files/emailrelay.auth
@@ -0,0 +1,16 @@
+#
+# emailrelay secrets file
+#
+#see http://emailrelay.sourceforge.net/reference.html for reference
+
+#Mostly used options:
+#
+#NONE server specifies ip address range allowed to connect to emailrelay SMTP server
+#LOGIN client specifies the credentials to be used when forwarding emails to another SMTP server
+#LOGIN server specifies the credentials to be needed to authenticate with the emailrelay SMTP server
+
+#Examples:
+#
+#NONE server 192.168.1.* keyword
+#LOGIN client smtpuser@smtpserver smtppassword
+#LOGIN server user1 secret
diff --git a/external/subpack/mail/emailrelay/files/emailrelay.config b/external/subpack/mail/emailrelay/files/emailrelay.config
new file mode 100644
index 0000000..7b73de8
--- /dev/null
+++ b/external/subpack/mail/emailrelay/files/emailrelay.config
@@ -0,0 +1,34 @@
+config emailrelay 'server'
+ option enabled '0'
+ option mode 'server'
+ option port '25'
+ option remote_clients '0'
+# option address_verifier '/usr/local/bin/address-verifier.sh'
+# option domain 'my.example.com'
+# option anonymous '1'
+# 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 address_verifier '/usr/local/bin/address-verifier.sh'
+# option domain 'my.example.com'
+# option anonymous '1'
+# 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'
+
diff --git a/external/subpack/mail/emailrelay/files/emailrelay.init b/external/subpack/mail/emailrelay/files/emailrelay.init
new file mode 100644
index 0000000..28f1fdd
--- /dev/null
+++ b/external/subpack/mail/emailrelay/files/emailrelay.init
@@ -0,0 +1,71 @@
+#!/bin/sh /etc/rc.common
+
+START=90
+
+USE_PROCD=1
+PROG=/usr/bin/emailrelay
+NAME=emailrelay
+
+
+emailrelay_instance()
+{
+ local enabled mode port remote_clients server_tls server_auth extra_cmdline smarthost client_tls client_auth address_verifier domain anonymous
+
+ 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
+ config_get address_verifier "$1" address_verifier
+ config_get domain "$1" domain
+ config_get_bool anonymous "$1" anonymous
+
+ [ "$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"
+ [ -n "$address_verifier" ] && procd_append_param command --address-verifier "$address_verifier"
+ [ -n "$domain" ] && procd_append_param command --domain "$domain"
+ [ "$anonymous" = 1 ] && procd_append_param command --anonymous
+ ;;
+ "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
+}
+
+
+start_service()
+{
+ [ ! -d /var/spool/emailrelay ] && mkdir -p /var/spool/emailrelay
+
+ config_load "${NAME}"
+ config_foreach emailrelay_instance emailrelay
+}