postfix.initd 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/openrc-run
  2. # Copyright 1999-2012 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. extra_started_commands="reload abort flush"
  5. description_reload="Re-read configuration files. Running processes terminate at their earliest convenience."
  6. description_abort="Stop the Postfix mail system abruptly. Running processes are signaled to stop immediately."
  7. description_flush="Force delivery: attempt to deliver every message in the deferred mail queue."
  8. # Please read http://www.postfix.org/MULTI_INSTANCE_README.html for multi instance support
  9. CONF_DIR="/etc/postfix"
  10. CONF_OPT="${SVCNAME##*.}"
  11. if [ -n ${CONF_OPT} -a ${SVCNAME} != "postfix" ]; then
  12. CONF_DIR="${CONF_DIR}.${CONF_OPT}"
  13. fi
  14. if [ "${CONF_DIR}" = "/etc/postfix" ]; then
  15. CONF_PARAM=""
  16. CONF_MESSAGE=""
  17. else
  18. CONF_PARAM="-c ${CONF_DIR}"
  19. CONF_MESSAGE="(${CONF_DIR})"
  20. fi
  21. depend() {
  22. use logger dns ypbind amavisd antivirus postfix_greylist net saslauthd
  23. if [ "${SVCNAME}" = "postfix" ]; then
  24. provide mta
  25. fi
  26. }
  27. start() {
  28. if [ ! -z "${CONF_PARAM}" ]; then
  29. einfo "Please consider updating your config for postmulti support."
  30. fi
  31. ebegin "Starting postfix ${CONF_MESSAGE}"
  32. if [ ! -d ${CONF_DIR} ]; then
  33. eend 1 "${CONF_DIR} does not exist"
  34. return 1
  35. fi
  36. /usr/bin/postfix ${CONF_PARAM} start >/dev/null 2>&1
  37. eend $?
  38. }
  39. stop() {
  40. ebegin "Stopping postfix ${CONF_MESSAGE}"
  41. /usr/bin/postfix ${CONF_PARAM} stop >/dev/null 2>&1
  42. eend
  43. }
  44. status() {
  45. local _retval
  46. einfon ""
  47. /usr/bin/postfix ${CONF_PARAM} status
  48. _retval=$?
  49. if [ x${_retval} = 'x0' ]; then
  50. mark_service_started "${SVCNAME}"
  51. eend 0
  52. else
  53. mark_service_stopped "${SVCNAME}"
  54. eend 3
  55. fi
  56. }
  57. reload() {
  58. ebegin "Reloading postfix ${CONF_MESSAGE}"
  59. /usr/bin/postfix ${CONF_PARAM} reload >/dev/null 2>&1
  60. eend $?
  61. }
  62. abort() {
  63. ebegin "Aborting postfix ${CONF_MESSAGE}"
  64. if service_started "${SVCNAME}"; then
  65. mark_service_stopped "${SVCNAME}"
  66. fi
  67. /usr/bin/postfix ${CONF_PARAM} abort >/dev/null 2>&1
  68. eend $?
  69. }
  70. flush() {
  71. ebegin "Flushing postfix ${CONF_MESSAGE}"
  72. /usr/bin/postfix ${CONF_PARAM} flush >/dev/null 2>&1
  73. eend $?
  74. }