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.

66 lines
1.7 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
  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. [ "$enabled" = 0 ] && return 1
  20. procd_open_instance
  21. procd_set_param command "$PROG" --no-daemon
  22. case "$mode" in
  23. "server"|\
  24. "proxy")
  25. procd_append_param command "--as-${mode}"
  26. [ -n "$smarthost" ] && procd_append_param command "$smarthost"
  27. [ -n "$port" ] && procd_append_param command --port "$port"
  28. [ "$remote_clients" = 1 ] && procd_append_param command --remote-clients
  29. [ -n "$server_tls" ] && procd_append_param command --server-tls "$server_tls"
  30. [ -n "$server_auth" ] && procd_append_param command --server-auth "$server_auth"
  31. [ "$client_tls" = 1 ] && procd_append_param command --client-tls
  32. [ -n "$client_auth" ] && procd_append_param command --client-auth "$client_auth"
  33. ;;
  34. "cmdline")
  35. # empty by intention (just append extra_cmdline)
  36. ;;
  37. *)
  38. echo "no mode specified"
  39. return 1
  40. ;;
  41. esac
  42. [ -n "$extra_cmdline" ] && procd_append_param command $extra_cmdline
  43. procd_set_param respawn
  44. procd_close_instance
  45. }
  46. start_service()
  47. {
  48. [ ! -d /var/spool/emailrelay ] && mkdir -p /var/spool/emailrelay
  49. config_load "${NAME}"
  50. config_foreach emailrelay_instance emailrelay
  51. }