diff options
author | Paul Wassi <p.wassi@gmx.at> | 2017-11-16 11:38:11 +0100 |
---|---|---|
committer | Paul Wassi <p.wassi@gmx.at> | 2017-11-17 12:07:08 +0100 |
commit | 084a9ee0c130d20b720559be03bc527f02a297f4 (patch) | |
tree | 6e173a15aee93efce6f8f020ea20b7cef26e13e7 /mail/emailrelay/files/emailrelay.init | |
parent | e83d0c0d8d117004addd8efc82f355abd512cea3 (diff) |
mail/emailrelay: tune up initscript and config
Previously, configuration of emailrelay was done by fiddling around
with the commandline inside the initscript. Introduce a config file
in /etc/config for basic configuration and at the same time switch
to a procd-style initscript.
Signed-off-by: Paul Wassi <p.wassi@gmx.at>
Diffstat (limited to 'mail/emailrelay/files/emailrelay.init')
-rw-r--r-- | mail/emailrelay/files/emailrelay.init | 65 |
1 files changed, 58 insertions, 7 deletions
diff --git a/mail/emailrelay/files/emailrelay.init b/mail/emailrelay/files/emailrelay.init index 9fc33996e..5b78f2170 100644 --- a/mail/emailrelay/files/emailrelay.init +++ b/mail/emailrelay/files/emailrelay.init @@ -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 } |