You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.1 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=90
  3. USE_PROCD=1
  4. PROG=/usr/bin/emailrelay
  5. NAME=emailrelay
  6. emailrelay_instance()
  7. {
  8. local enabled mode port remote_clients server_tls server_auth extra_cmdline smarthost client_tls client_auth address_verifier domain anonymous
  9. config_get_bool enabled "$1" enabled
  10. config_get mode "$1" mode
  11. config_get port "$1" port
  12. config_get_bool remote_clients "$1" remote_clients
  13. config_get server_tls "$1" server_tls
  14. config_get server_auth "$1" server_auth
  15. config_get extra_cmdline "$1" extra_cmdline
  16. config_get smarthost "$1" smarthost
  17. config_get_bool client_tls "$1" client_tls
  18. config_get client_auth "$1" client_auth
  19. config_get address_verifier "$1" address_verifier
  20. config_get domain "$1" domain
  21. config_get_bool anonymous "$1" anonymous
  22. [ "$enabled" = 0 ] && return 1
  23. procd_open_instance
  24. procd_set_param command "$PROG" --no-daemon
  25. case "$mode" in
  26. "server"|\
  27. "proxy")
  28. procd_append_param command "--as-${mode}"
  29. [ -n "$smarthost" ] && procd_append_param command "$smarthost"
  30. [ -n "$port" ] && procd_append_param command --port "$port"
  31. [ "$remote_clients" = 1 ] && procd_append_param command --remote-clients
  32. [ -n "$server_tls" ] && procd_append_param command --server-tls "$server_tls"
  33. [ -n "$server_auth" ] && procd_append_param command --server-auth "$server_auth"
  34. [ "$client_tls" = 1 ] && procd_append_param command --client-tls
  35. [ -n "$client_auth" ] && procd_append_param command --client-auth "$client_auth"
  36. [ -n "$address_verifier" ] && procd_append_param command --address-verifier "$address_verifier"
  37. [ -n "$domain" ] && procd_append_param command --domain "$domain"
  38. [ "$anonymous" = 1 ] && procd_append_param command --anonymous
  39. ;;
  40. "cmdline")
  41. # empty by intention (just append extra_cmdline)
  42. ;;
  43. *)
  44. echo "no mode specified"
  45. return 1
  46. ;;
  47. esac
  48. [ -n "$extra_cmdline" ] && procd_append_param command $extra_cmdline
  49. procd_set_param respawn
  50. procd_close_instance
  51. }
  52. start_service()
  53. {
  54. [ ! -d /var/spool/emailrelay ] && mkdir -p /var/spool/emailrelay
  55. config_load "${NAME}"
  56. config_foreach emailrelay_instance emailrelay
  57. }